mirror of
https://github.com/CompeyDev/lune-packaging.git
synced 2025-01-09 12:19:09 +00:00
Refactor typedef files to ensure moonwave picks up functions
This commit is contained in:
parent
8c14c3cda3
commit
623af1c312
7 changed files with 656 additions and 602 deletions
|
@ -14,7 +14,7 @@ export type MetadataPermissions = {
|
||||||
readOnly: boolean,
|
readOnly: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- FIXME: We lose doc comments here because of the union type
|
-- FIXME: We lose doc comments here below in Metadata because of the union type
|
||||||
|
|
||||||
--[=[
|
--[=[
|
||||||
@interface Metadata
|
@interface Metadata
|
||||||
|
@ -87,189 +87,201 @@ export type WriteOptions = {
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
]=]
|
]=]
|
||||||
return {
|
local fs = {}
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Reads a file at `path`.
|
--[=[
|
||||||
|
@within FS
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
Reads a file at `path`.
|
||||||
|
|
||||||
* `path` does not point to an existing file.
|
An error will be thrown in the following situations:
|
||||||
* The current process lacks permissions to read the file.
|
|
||||||
* The contents of the file cannot be read as a UTF-8 string.
|
|
||||||
* Some other I/O error occurred.
|
|
||||||
|
|
||||||
@param path The path to the file to read
|
* `path` does not point to an existing file.
|
||||||
@return The contents of the file
|
* The current process lacks permissions to read the file.
|
||||||
]=]
|
* The contents of the file cannot be read as a UTF-8 string.
|
||||||
readFile = function(path: string): string
|
* Some other I/O error occurred.
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Reads entries in a directory at `path`.
|
@param path The path to the file to read
|
||||||
|
@return The contents of the file
|
||||||
|
]=]
|
||||||
|
function fs.readFile(path: string): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
--[=[
|
||||||
|
@within FS
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
* `path` does not point to an existing directory.
|
Reads entries in a directory at `path`.
|
||||||
* The current process lacks permissions to read the contents of the directory.
|
|
||||||
* Some other I/O error occurred.
|
|
||||||
|
|
||||||
@param path The directory path to search in
|
An error will be thrown in the following situations:
|
||||||
@return A list of files & directories found
|
|
||||||
]=]
|
|
||||||
readDir = function(path: string): { string }
|
|
||||||
return {}
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
|
|
||||||
Writes to a file at `path`.
|
* `path` does not point to an existing directory.
|
||||||
|
* The current process lacks permissions to read the contents of the directory.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
@param path The directory path to search in
|
||||||
|
@return A list of files & directories found
|
||||||
|
]=]
|
||||||
|
function fs.readDir(path: string): { string }
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
* The file's parent directory does not exist.
|
--[=[
|
||||||
* The current process lacks permissions to write to the file.
|
@within FS
|
||||||
* Some other I/O error occurred.
|
|
||||||
|
|
||||||
@param path The path of the file
|
Writes to a file at `path`.
|
||||||
@param contents The contents of the file
|
|
||||||
]=]
|
|
||||||
writeFile = function(path: string, contents: string) end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
|
|
||||||
Creates a directory and its parent directories if they are missing.
|
An error will be thrown in the following situations:
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
* The file's parent directory does not exist.
|
||||||
|
* The current process lacks permissions to write to the file.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
* `path` already points to an existing file or directory.
|
@param path The path of the file
|
||||||
* The current process lacks permissions to create the directory or its missing parents.
|
@param contents The contents of the file
|
||||||
* Some other I/O error occurred.
|
]=]
|
||||||
|
function fs.writeFile(path: string, contents: string) end
|
||||||
|
|
||||||
@param path The directory to create
|
--[=[
|
||||||
]=]
|
@within FS
|
||||||
writeDir = function(path: string) end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
|
|
||||||
Removes a file.
|
Creates a directory and its parent directories if they are missing.
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
An error will be thrown in the following situations:
|
||||||
|
|
||||||
* `path` does not point to an existing file.
|
* `path` already points to an existing file or directory.
|
||||||
* The current process lacks permissions to remove the file.
|
* The current process lacks permissions to create the directory or its missing parents.
|
||||||
* Some other I/O error occurred.
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
@param path The file to remove
|
@param path The directory to create
|
||||||
]=]
|
]=]
|
||||||
removeFile = function(path: string) end,
|
function fs.writeDir(path: string) end
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
|
|
||||||
Removes a directory and all of its contents.
|
--[=[
|
||||||
|
@within FS
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
Removes a file.
|
||||||
|
|
||||||
* `path` is not an existing and empty directory.
|
An error will be thrown in the following situations:
|
||||||
* The current process lacks permissions to remove the directory.
|
|
||||||
* Some other I/O error occurred.
|
|
||||||
|
|
||||||
@param path The directory to remove
|
* `path` does not point to an existing file.
|
||||||
]=]
|
* The current process lacks permissions to remove the file.
|
||||||
removeDir = function(path: string) end,
|
* Some other I/O error occurred.
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Gets metadata for the given path.
|
@param path The file to remove
|
||||||
|
]=]
|
||||||
|
function fs.removeFile(path: string) end
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
--[=[
|
||||||
|
@within FS
|
||||||
|
|
||||||
* The current process lacks permissions to read at `path`.
|
Removes a directory and all of its contents.
|
||||||
* Some other I/O error occurred.
|
|
||||||
|
|
||||||
@param path The path to get metadata for
|
An error will be thrown in the following situations:
|
||||||
@return Metadata for the path
|
|
||||||
]=]
|
|
||||||
metadata = function(path: string): Metadata
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Checks if a given path is a file.
|
* `path` is not an existing and empty directory.
|
||||||
|
* The current process lacks permissions to remove the directory.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
@param path The directory to remove
|
||||||
|
]=]
|
||||||
|
function fs.removeDir(path: string) end
|
||||||
|
|
||||||
* The current process lacks permissions to read at `path`.
|
--[=[
|
||||||
* Some other I/O error occurred.
|
@within FS
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
@param path The file path to check
|
Gets metadata for the given path.
|
||||||
@return If the path is a file or not
|
|
||||||
]=]
|
|
||||||
isFile = function(path: string): boolean
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Checks if a given path is a directory.
|
An error will be thrown in the following situations:
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
* The current process lacks permissions to read at `path`.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
* The current process lacks permissions to read at `path`.
|
@param path The path to get metadata for
|
||||||
* Some other I/O error occurred.
|
@return Metadata for the path
|
||||||
|
]=]
|
||||||
|
function fs.metadata(path: string): Metadata
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param path The directory path to check
|
--[=[
|
||||||
@return If the path is a directory or not
|
@within FS
|
||||||
]=]
|
@tag must_use
|
||||||
isDir = function(path: string): boolean
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
|
|
||||||
Moves a file or directory to a new path.
|
Checks if a given path is a file.
|
||||||
|
|
||||||
Throws an error if a file or directory already exists at the target path.
|
An error will be thrown in the following situations:
|
||||||
This can be bypassed by passing `true` as the third argument, or a dictionary of options.
|
|
||||||
Refer to the documentation for `WriteOptions` for specific option keys and their values.
|
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
* The current process lacks permissions to read at `path`.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
* The current process lacks permissions to read at `from` or write at `to`.
|
@param path The file path to check
|
||||||
* The new path exists on a different mount point.
|
@return If the path is a file or not
|
||||||
* Some other I/O error occurred.
|
]=]
|
||||||
|
function fs.isFile(path: string): boolean
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param from The path to move from
|
--[=[
|
||||||
@param to The path to move to
|
@within FS
|
||||||
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
|
@tag must_use
|
||||||
]=]
|
|
||||||
move = function(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end,
|
|
||||||
--[=[
|
|
||||||
@within FS
|
|
||||||
|
|
||||||
Copies a file or directory recursively to a new path.
|
Checks if a given path is a directory.
|
||||||
|
|
||||||
Throws an error if a file or directory already exists at the target path.
|
An error will be thrown in the following situations:
|
||||||
This can be bypassed by passing `true` as the third argument, or a dictionary of options.
|
|
||||||
Refer to the documentation for `WriteOptions` for specific option keys and their values.
|
|
||||||
|
|
||||||
An error will be thrown in the following situations:
|
* The current process lacks permissions to read at `path`.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
* The current process lacks permissions to read at `from` or write at `to`.
|
@param path The directory path to check
|
||||||
* Some other I/O error occurred.
|
@return If the path is a directory or not
|
||||||
|
]=]
|
||||||
|
function fs.isDir(path: string): boolean
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param from The path to copy from
|
--[=[
|
||||||
@param to The path to copy to
|
@within FS
|
||||||
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
|
|
||||||
]=]
|
Moves a file or directory to a new path.
|
||||||
copy = function(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end,
|
|
||||||
}
|
Throws an error if a file or directory already exists at the target path.
|
||||||
|
This can be bypassed by passing `true` as the third argument, or a dictionary of options.
|
||||||
|
Refer to the documentation for `WriteOptions` for specific option keys and their values.
|
||||||
|
|
||||||
|
An error will be thrown in the following situations:
|
||||||
|
|
||||||
|
* The current process lacks permissions to read at `from` or write at `to`.
|
||||||
|
* The new path exists on a different mount point.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
|
@param from The path to move from
|
||||||
|
@param to The path to move to
|
||||||
|
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
|
||||||
|
]=]
|
||||||
|
function fs.move(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within FS
|
||||||
|
|
||||||
|
Copies a file or directory recursively to a new path.
|
||||||
|
|
||||||
|
Throws an error if a file or directory already exists at the target path.
|
||||||
|
This can be bypassed by passing `true` as the third argument, or a dictionary of options.
|
||||||
|
Refer to the documentation for `WriteOptions` for specific option keys and their values.
|
||||||
|
|
||||||
|
An error will be thrown in the following situations:
|
||||||
|
|
||||||
|
* The current process lacks permissions to read at `from` or write at `to`.
|
||||||
|
* Some other I/O error occurred.
|
||||||
|
|
||||||
|
@param from The path to copy from
|
||||||
|
@param to The path to copy to
|
||||||
|
@param overwriteOrOptions Options for the target path, such as if should be overwritten if it already exists
|
||||||
|
]=]
|
||||||
|
function fs.copy(from: string, to: string, overwriteOrOptions: (boolean | WriteOptions)?) end
|
||||||
|
|
||||||
|
return fs
|
||||||
|
|
|
@ -196,98 +196,106 @@ export type WebSocket = {
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
]=]
|
]=]
|
||||||
return {
|
local net = {}
|
||||||
--[=[
|
|
||||||
@within Net
|
|
||||||
|
|
||||||
Sends an HTTP request using the given url and / or parameters, and returns a dictionary that describes the response received.
|
--[=[
|
||||||
|
@within Net
|
||||||
|
|
||||||
Only throws an error if a miscellaneous network or I/O error occurs, never for unsuccessful status codes.
|
Sends an HTTP request using the given url and / or parameters, and returns a dictionary that describes the response received.
|
||||||
|
|
||||||
@param config The URL or request config to use
|
Only throws an error if a miscellaneous network or I/O error occurs, never for unsuccessful status codes.
|
||||||
@return A dictionary representing the response for the request
|
|
||||||
]=]
|
|
||||||
request = function(config: string | FetchParams): FetchResponse
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Net
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Connects to a web socket at the given URL.
|
@param config The URL or request config to use
|
||||||
|
@return A dictionary representing the response for the request
|
||||||
|
]=]
|
||||||
|
function net.request(config: string | FetchParams): FetchResponse
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
Throws an error if the server at the given URL does not support
|
--[=[
|
||||||
web sockets, or if a miscellaneous network or I/O error occurs.
|
@within Net
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
@param url The URL to connect to
|
Connects to a web socket at the given URL.
|
||||||
@return A web socket handle
|
|
||||||
]=]
|
|
||||||
socket = function(url: string): WebSocket
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Net
|
|
||||||
|
|
||||||
Creates an HTTP server that listens on the given `port`.
|
Throws an error if the server at the given URL does not support
|
||||||
|
web sockets, or if a miscellaneous network or I/O error occurs.
|
||||||
|
|
||||||
This will ***not*** block and will keep listening for requests on the given `port`
|
@param url The URL to connect to
|
||||||
until the `stop` function on the returned `ServeHandle` has been called.
|
@return A web socket handle
|
||||||
|
]=]
|
||||||
|
function net.socket(url: string): WebSocket
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param port The port to use for the server
|
--[=[
|
||||||
@param handlerOrConfig The handler function or config to use for the server
|
@within Net
|
||||||
]=]
|
|
||||||
serve = function(port: number, handlerOrConfig: ServeHttpHandler | ServeConfig): ServeHandle
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Net
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Encodes the given value as JSON.
|
Creates an HTTP server that listens on the given `port`.
|
||||||
|
|
||||||
@param value The value to encode as JSON
|
This will ***not*** block and will keep listening for requests on the given `port`
|
||||||
@param pretty If the encoded JSON string should include newlines and spaces. Defaults to false
|
until the `stop` function on the returned `ServeHandle` has been called.
|
||||||
@return The encoded JSON string
|
|
||||||
]=]
|
|
||||||
jsonEncode = function(value: any, pretty: boolean?): string
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Net
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Decodes the given JSON string into a lua value.
|
@param port The port to use for the server
|
||||||
|
@param handlerOrConfig The handler function or config to use for the server
|
||||||
|
]=]
|
||||||
|
function net.serve(port: number, handlerOrConfig: ServeHttpHandler | ServeConfig): ServeHandle
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param encoded The JSON string to decode
|
--[=[
|
||||||
@return The decoded lua value
|
@within Net
|
||||||
]=]
|
@tag must_use
|
||||||
jsonDecode = function(encoded: string): any
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Net
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Encodes the given string using URL encoding.
|
Encodes the given value as JSON.
|
||||||
|
|
||||||
@param s The string to encode
|
@param value The value to encode as JSON
|
||||||
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
|
@param pretty If the encoded JSON string should include newlines and spaces. Defaults to false
|
||||||
@return The encoded string
|
@return The encoded JSON string
|
||||||
]=]
|
]=]
|
||||||
urlEncode = function(s: string, binary: boolean?): string
|
function net.jsonEncode(value: any, pretty: boolean?): string
|
||||||
return nil :: any
|
return nil :: any
|
||||||
end,
|
end
|
||||||
--[=[
|
|
||||||
@within Net
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Decodes the given string using URL decoding.
|
--[=[
|
||||||
|
@within Net
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
@param s The string to decode
|
Decodes the given JSON string into a lua value.
|
||||||
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
|
|
||||||
@return The decoded string
|
@param encoded The JSON string to decode
|
||||||
]=]
|
@return The decoded lua value
|
||||||
urlDecode = function(s: string, binary: boolean?): string
|
]=]
|
||||||
return nil :: any
|
function net.jsonDecode(encoded: string): any
|
||||||
end,
|
return nil :: any
|
||||||
}
|
end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Net
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
|
Encodes the given string using URL encoding.
|
||||||
|
|
||||||
|
@param s The string to encode
|
||||||
|
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
|
||||||
|
@return The encoded string
|
||||||
|
]=]
|
||||||
|
function net.urlEncode(s: string, binary: boolean?): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Net
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
|
Decodes the given string using URL decoding.
|
||||||
|
|
||||||
|
@param s The string to decode
|
||||||
|
@param binary If the string should be treated as binary data and/or is not valid utf-8. Defaults to false
|
||||||
|
@return The decoded string
|
||||||
|
]=]
|
||||||
|
function net.urlDecode(s: string, binary: boolean?): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
return net
|
||||||
|
|
|
@ -78,83 +78,91 @@ export type SpawnResult = {
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
]=]
|
]=]
|
||||||
return {
|
local process = {}
|
||||||
--[=[
|
|
||||||
@within Process
|
|
||||||
@read_only
|
|
||||||
|
|
||||||
The current operating system being used.
|
--[=[
|
||||||
|
@within Process
|
||||||
|
@tag read_only
|
||||||
|
|
||||||
Possible values:
|
The current operating system being used.
|
||||||
|
|
||||||
* `"linux"`
|
Possible values:
|
||||||
* `"macos"`
|
|
||||||
* `"windows"`
|
|
||||||
]=]
|
|
||||||
os = (nil :: any) :: OS,
|
|
||||||
--[=[
|
|
||||||
@within Process
|
|
||||||
@read_only
|
|
||||||
|
|
||||||
The architecture of the processor currently being used.
|
* `"linux"`
|
||||||
|
* `"macos"`
|
||||||
|
* `"windows"`
|
||||||
|
]=]
|
||||||
|
process.os = (nil :: any) :: OS
|
||||||
|
|
||||||
Possible values:
|
--[=[
|
||||||
|
@within Process
|
||||||
|
@tag read_only
|
||||||
|
|
||||||
* `"x86_64"`
|
The architecture of the processor currently being used.
|
||||||
* `"aarch64"`
|
|
||||||
]=]
|
|
||||||
arch = (nil :: any) :: Arch,
|
|
||||||
--[=[
|
|
||||||
@within Process
|
|
||||||
@read_only
|
|
||||||
|
|
||||||
The arguments given when running the Lune script.
|
Possible values:
|
||||||
]=]
|
|
||||||
args = (nil :: any) :: { string },
|
|
||||||
--[=[
|
|
||||||
@within Process
|
|
||||||
@read_only
|
|
||||||
|
|
||||||
The current working directory in which the Lune script is running.
|
* `"x86_64"`
|
||||||
]=]
|
* `"aarch64"`
|
||||||
cwd = (nil :: any) :: string,
|
]=]
|
||||||
--[=[
|
process.arch = (nil :: any) :: Arch
|
||||||
@within Process
|
|
||||||
@read_write
|
|
||||||
|
|
||||||
Current environment variables for this process.
|
--[=[
|
||||||
|
@within Process
|
||||||
|
@tag read_only
|
||||||
|
|
||||||
Setting a value on this table will set the corresponding environment variable.
|
The arguments given when running the Lune script.
|
||||||
]=]
|
]=]
|
||||||
env = (nil :: any) :: { [string]: string? },
|
process.args = (nil :: any) :: { string }
|
||||||
--[=[
|
|
||||||
@within Process
|
|
||||||
|
|
||||||
Exits the currently running script as soon as possible with the given exit code.
|
--[=[
|
||||||
|
@within Process
|
||||||
|
@tag read_only
|
||||||
|
|
||||||
Exit code 0 is treated as a successful exit, any other value is treated as an error.
|
The current working directory in which the Lune script is running.
|
||||||
|
]=]
|
||||||
|
process.cwd = (nil :: any) :: string
|
||||||
|
|
||||||
Setting the exit code using this function will override any otherwise automatic exit code.
|
--[=[
|
||||||
|
@within Process
|
||||||
|
@read_write
|
||||||
|
|
||||||
@param code The exit code to set
|
Current environment variables for this process.
|
||||||
]=]
|
|
||||||
exit = function(code: number?) end,
|
|
||||||
--[=[
|
|
||||||
@within Process
|
|
||||||
|
|
||||||
Spawns a child process that will run the program `program`, and returns a dictionary that describes the final status and ouput of the child process.
|
Setting a value on this table will set the corresponding environment variable.
|
||||||
|
]=]
|
||||||
|
process.env = (nil :: any) :: { [string]: string? }
|
||||||
|
|
||||||
The second argument, `params`, can be passed as a list of string parameters to give to the program.
|
--[=[
|
||||||
|
@within Process
|
||||||
|
|
||||||
The third argument, `options`, can be passed as a dictionary of options to give to the child process.
|
Exits the currently running script as soon as possible with the given exit code.
|
||||||
Refer to the documentation for `SpawnOptions` for specific option keys and their values.
|
|
||||||
|
|
||||||
@param program The program to spawn as a child process
|
Exit code 0 is treated as a successful exit, any other value is treated as an error.
|
||||||
@param params Additional parameters to pass to the program
|
|
||||||
@param options A dictionary of options for the child process
|
Setting the exit code using this function will override any otherwise automatic exit code.
|
||||||
@return A dictionary representing the result of the child process
|
|
||||||
]=]
|
@param code The exit code to set
|
||||||
spawn = function(program: string, params: { string }?, options: SpawnOptions?): SpawnResult
|
]=]
|
||||||
return nil :: any
|
function process.exit(code: number?) end
|
||||||
end,
|
|
||||||
}
|
--[=[
|
||||||
|
@within Process
|
||||||
|
|
||||||
|
Spawns a child process that will run the program `program`, and returns a dictionary that describes the final status and ouput of the child process.
|
||||||
|
|
||||||
|
The second argument, `params`, can be passed as a list of string parameters to give to the program.
|
||||||
|
|
||||||
|
The third argument, `options`, can be passed as a dictionary of options to give to the child process.
|
||||||
|
Refer to the documentation for `SpawnOptions` for specific option keys and their values.
|
||||||
|
|
||||||
|
@param program The program to spawn as a child process
|
||||||
|
@param params Additional parameters to pass to the program
|
||||||
|
@param options A dictionary of options for the child process
|
||||||
|
@return A dictionary representing the result of the child process
|
||||||
|
]=]
|
||||||
|
function process.spawn(program: string, params: { string }?, options: SpawnOptions?): SpawnResult
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
return process
|
||||||
|
|
|
@ -213,179 +213,187 @@ export type DataModel =
|
||||||
fs.writeFile("myPlaceFile.rbxl", newPlaceFile)
|
fs.writeFile("myPlaceFile.rbxl", newPlaceFile)
|
||||||
```
|
```
|
||||||
]=]
|
]=]
|
||||||
return {
|
local roblox = {}
|
||||||
--[=[
|
|
||||||
@within Roblox
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Deserializes a place into a DataModel instance.
|
--[=[
|
||||||
|
@within Roblox
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
This function accepts a string of contents, *not* a file path.
|
Deserializes a place into a DataModel instance.
|
||||||
If reading a place file from a file path is desired, `fs.readFile`
|
|
||||||
can be used and the resulting string may be passed to this function.
|
|
||||||
|
|
||||||
### Example usage
|
This function accepts a string of contents, *not* a file path.
|
||||||
|
If reading a place file from a file path is desired, `fs.readFile`
|
||||||
|
can be used and the resulting string may be passed to this function.
|
||||||
|
|
||||||
```lua
|
### Example usage
|
||||||
local fs = require("@lune/fs")
|
|
||||||
local roblox = require("@lune/roblox")
|
|
||||||
|
|
||||||
local placeFile = fs.readFile("filePath.rbxl")
|
```lua
|
||||||
local game = roblox.deserializePlace(placeFile)
|
local fs = require("@lune/fs")
|
||||||
```
|
local roblox = require("@lune/roblox")
|
||||||
|
|
||||||
@param contents The contents of the place to read
|
local placeFile = fs.readFile("filePath.rbxl")
|
||||||
]=]
|
local game = roblox.deserializePlace(placeFile)
|
||||||
deserializePlace = function(contents: string): DataModel
|
```
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Roblox
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Deserializes a model into an array of instances.
|
@param contents The contents of the place to read
|
||||||
|
]=]
|
||||||
|
function roblox.deserializePlace(contents: string): DataModel
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
This function accepts a string of contents, *not* a file path.
|
--[=[
|
||||||
If reading a model file from a file path is desired, `fs.readFile`
|
@within Roblox
|
||||||
can be used and the resulting string may be passed to this function.
|
@tag must_use
|
||||||
|
|
||||||
### Example usage
|
Deserializes a model into an array of instances.
|
||||||
|
|
||||||
```lua
|
This function accepts a string of contents, *not* a file path.
|
||||||
local fs = require("@lune/fs")
|
If reading a model file from a file path is desired, `fs.readFile`
|
||||||
local roblox = require("@lune/roblox")
|
can be used and the resulting string may be passed to this function.
|
||||||
|
|
||||||
local modelFile = fs.readFile("filePath.rbxm")
|
### Example usage
|
||||||
local instances = roblox.deserializeModel(modelFile)
|
|
||||||
```
|
|
||||||
|
|
||||||
@param contents The contents of the model to read
|
```lua
|
||||||
]=]
|
local fs = require("@lune/fs")
|
||||||
deserializeModel = function(contents: string): { Instance }
|
local roblox = require("@lune/roblox")
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Roblox
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Serializes a place from a DataModel instance.
|
local modelFile = fs.readFile("filePath.rbxm")
|
||||||
|
local instances = roblox.deserializeModel(modelFile)
|
||||||
|
```
|
||||||
|
|
||||||
This string can then be written to a file, or sent over the network.
|
@param contents The contents of the model to read
|
||||||
|
]=]
|
||||||
|
function roblox.deserializeModel(contents: string): { Instance }
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
### Example usage
|
--[=[
|
||||||
|
@within Roblox
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
```lua
|
Serializes a place from a DataModel instance.
|
||||||
local fs = require("@lune/fs")
|
|
||||||
local roblox = require("@lune/roblox")
|
|
||||||
|
|
||||||
local placeFile = roblox.serializePlace(game)
|
This string can then be written to a file, or sent over the network.
|
||||||
fs.writeFile("filePath.rbxl", placeFile)
|
|
||||||
```
|
|
||||||
|
|
||||||
@param dataModel The DataModel for the place to serialize
|
### Example usage
|
||||||
@param xml If the place should be serialized as xml or not. Defaults to `false`, meaning the place gets serialized using the binary format and not xml.
|
|
||||||
]=]
|
|
||||||
serializePlace = function(dataModel: DataModel, xml: boolean?): string
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Roblox
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Serializes one or more instances as a model.
|
```lua
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
local roblox = require("@lune/roblox")
|
||||||
|
|
||||||
This string can then be written to a file, or sent over the network.
|
local placeFile = roblox.serializePlace(game)
|
||||||
|
fs.writeFile("filePath.rbxl", placeFile)
|
||||||
|
```
|
||||||
|
|
||||||
### Example usage
|
@param dataModel The DataModel for the place to serialize
|
||||||
|
@param xml If the place should be serialized as xml or not. Defaults to `false`, meaning the place gets serialized using the binary format and not xml.
|
||||||
|
]=]
|
||||||
|
function roblox.serializePlace(dataModel: DataModel, xml: boolean?): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
```lua
|
--[=[
|
||||||
local fs = require("@lune/fs")
|
@within Roblox
|
||||||
local roblox = require("@lune/roblox")
|
@tag must_use
|
||||||
|
|
||||||
local modelFile = roblox.serializeModel({ instance1, instance2, ... })
|
Serializes one or more instances as a model.
|
||||||
fs.writeFile("filePath.rbxm", modelFile)
|
|
||||||
```
|
|
||||||
|
|
||||||
@param instances The array of instances to serialize
|
This string can then be written to a file, or sent over the network.
|
||||||
@param xml If the model should be serialized as xml or not. Defaults to `false`, meaning the model gets serialized using the binary format and not xml.
|
|
||||||
]=]
|
|
||||||
serializeModel = function(instances: { Instance }, xml: boolean?): string
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Roblox
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Gets the current auth cookie, for usage with Roblox web APIs.
|
### Example usage
|
||||||
|
|
||||||
Note that this auth cookie is formatted for use as a "Cookie" header,
|
```lua
|
||||||
and that it contains restrictions so that it may only be used for
|
local fs = require("@lune/fs")
|
||||||
official Roblox endpoints. To get the raw cookie value without any
|
local roblox = require("@lune/roblox")
|
||||||
additional formatting, you can pass `true` as the first and only parameter.
|
|
||||||
|
|
||||||
### Example usage
|
local modelFile = roblox.serializeModel({ instance1, instance2, ... })
|
||||||
|
fs.writeFile("filePath.rbxm", modelFile)
|
||||||
|
```
|
||||||
|
|
||||||
```lua
|
@param instances The array of instances to serialize
|
||||||
local roblox = require("@lune/roblox")
|
@param xml If the model should be serialized as xml or not. Defaults to `false`, meaning the model gets serialized using the binary format and not xml.
|
||||||
local net = require("@lune/net")
|
]=]
|
||||||
|
function roblox.serializeModel(instances: { Instance }, xml: boolean?): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
local cookie = roblox.getAuthCookie()
|
--[=[
|
||||||
assert(cookie ~= nil, "Failed to get roblox auth cookie")
|
@within Roblox
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
local myPrivatePlaceId = 1234567890
|
Gets the current auth cookie, for usage with Roblox web APIs.
|
||||||
|
|
||||||
local response = net.request({
|
Note that this auth cookie is formatted for use as a "Cookie" header,
|
||||||
url = "https://assetdelivery.roblox.com/v2/assetId/" .. tostring(myPrivatePlaceId),
|
and that it contains restrictions so that it may only be used for
|
||||||
headers = {
|
official Roblox endpoints. To get the raw cookie value without any
|
||||||
Cookie = cookie,
|
additional formatting, you can pass `true` as the first and only parameter.
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local responseTable = net.jsonDecode(response.body)
|
### Example usage
|
||||||
local responseLocation = responseTable.locations[1].location
|
|
||||||
print("Download link to place: " .. responseLocation)
|
|
||||||
```
|
|
||||||
|
|
||||||
@param raw If the cookie should be returned as a pure value or not. Defaults to false
|
```lua
|
||||||
]=]
|
local roblox = require("@lune/roblox")
|
||||||
getAuthCookie = function(raw: boolean?): string?
|
local net = require("@lune/net")
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Roblox
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Gets the bundled reflection database.
|
local cookie = roblox.getAuthCookie()
|
||||||
|
assert(cookie ~= nil, "Failed to get roblox auth cookie")
|
||||||
|
|
||||||
This database contains information about Roblox enums, classes, and their properties.
|
local myPrivatePlaceId = 1234567890
|
||||||
|
|
||||||
### Example usage
|
local response = net.request({
|
||||||
|
url = "https://assetdelivery.roblox.com/v2/assetId/" .. tostring(myPrivatePlaceId),
|
||||||
|
headers = {
|
||||||
|
Cookie = cookie,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
```lua
|
local responseTable = net.jsonDecode(response.body)
|
||||||
local roblox = require("@lune/roblox")
|
local responseLocation = responseTable.locations[1].location
|
||||||
|
print("Download link to place: " .. responseLocation)
|
||||||
|
```
|
||||||
|
|
||||||
local db = roblox.getReflectionDatabase()
|
@param raw If the cookie should be returned as a pure value or not. Defaults to false
|
||||||
|
]=]
|
||||||
|
function roblox.getAuthCookie(raw: boolean?): string?
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
print("There are", #db:GetClassNames(), "classes in the reflection database")
|
--[=[
|
||||||
|
@within Roblox
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
print("All base instance properties:")
|
Gets the bundled reflection database.
|
||||||
|
|
||||||
local class = db:GetClass("Instance")
|
This database contains information about Roblox enums, classes, and their properties.
|
||||||
for name, prop in class.Properties do
|
|
||||||
print(string.format(
|
### Example usage
|
||||||
"- %s with datatype %s and default value %s",
|
|
||||||
prop.Name,
|
```lua
|
||||||
prop.Datatype,
|
local roblox = require("@lune/roblox")
|
||||||
tostring(class.DefaultProperties[prop.Name])
|
|
||||||
))
|
local db = roblox.getReflectionDatabase()
|
||||||
end
|
|
||||||
```
|
print("There are", #db:GetClassNames(), "classes in the reflection database")
|
||||||
]=]
|
|
||||||
getReflectionDatabase = function(): Database
|
print("All base instance properties:")
|
||||||
return nil :: any
|
|
||||||
end,
|
local class = db:GetClass("Instance")
|
||||||
-- TODO: Make typedefs for all of the datatypes as well...
|
for name, prop in class.Properties do
|
||||||
Instance = (nil :: any) :: {
|
print(string.format(
|
||||||
new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance),
|
"- %s with datatype %s and default value %s",
|
||||||
},
|
prop.Name,
|
||||||
|
prop.Datatype,
|
||||||
|
tostring(class.DefaultProperties[prop.Name])
|
||||||
|
))
|
||||||
|
end
|
||||||
|
```
|
||||||
|
]=]
|
||||||
|
function roblox.getReflectionDatabase(): Database
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: Make typedefs for all of the datatypes as well...
|
||||||
|
roblox.Instance = (nil :: any) :: {
|
||||||
|
new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return roblox
|
||||||
|
|
|
@ -27,92 +27,97 @@ export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib"
|
||||||
fs.writeFile("myFile.yaml", serde.encode("yaml", someYaml))
|
fs.writeFile("myFile.yaml", serde.encode("yaml", someYaml))
|
||||||
```
|
```
|
||||||
]=]
|
]=]
|
||||||
return {
|
local serde = {}
|
||||||
--[=[
|
|
||||||
@within Serde
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Encodes the given value using the given format.
|
--[=[
|
||||||
|
@within Serde
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
Currently supported formats:
|
Encodes the given value using the given format.
|
||||||
|
|
||||||
| Name | Learn More |
|
Currently supported formats:
|
||||||
|:-------|:---------------------|
|
|
||||||
| `json` | https://www.json.org |
|
|
||||||
| `yaml` | https://yaml.org |
|
|
||||||
| `toml` | https://toml.io |
|
|
||||||
|
|
||||||
@param format The format to use
|
| Name | Learn More |
|
||||||
@param value The value to encode
|
|:-------|:---------------------|
|
||||||
@param pretty If the encoded string should be human-readable, including things such as newlines and spaces. Only supported for json and toml formats, and defaults to false
|
| `json` | https://www.json.org |
|
||||||
@return The encoded string
|
| `yaml` | https://yaml.org |
|
||||||
]=]
|
| `toml` | https://toml.io |
|
||||||
encode = function(format: EncodeDecodeFormat, value: any, pretty: boolean?): string
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Serde
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Decodes the given string using the given format into a lua value.
|
@param format The format to use
|
||||||
|
@param value The value to encode
|
||||||
|
@param pretty If the encoded string should be human-readable, including things such as newlines and spaces. Only supported for json and toml formats, and defaults to false
|
||||||
|
@return The encoded string
|
||||||
|
]=]
|
||||||
|
function serde.encode(format: EncodeDecodeFormat, value: any, pretty: boolean?): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
Currently supported formats:
|
--[=[
|
||||||
|
@within Serde
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
| Name | Learn More |
|
Decodes the given string using the given format into a lua value.
|
||||||
|:-------|:---------------------|
|
|
||||||
| `json` | https://www.json.org |
|
|
||||||
| `yaml` | https://yaml.org |
|
|
||||||
| `toml` | https://toml.io |
|
|
||||||
|
|
||||||
@param format The format to use
|
Currently supported formats:
|
||||||
@param encoded The string to decode
|
|
||||||
@return The decoded lua value
|
|
||||||
]=]
|
|
||||||
decode = function(format: EncodeDecodeFormat, encoded: string): any
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Serde
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Compresses the given string using the given format.
|
| Name | Learn More |
|
||||||
|
|:-------|:---------------------|
|
||||||
|
| `json` | https://www.json.org |
|
||||||
|
| `yaml` | https://yaml.org |
|
||||||
|
| `toml` | https://toml.io |
|
||||||
|
|
||||||
Currently supported formats:
|
@param format The format to use
|
||||||
|
@param encoded The string to decode
|
||||||
|
@return The decoded lua value
|
||||||
|
]=]
|
||||||
|
function serde.decode(format: EncodeDecodeFormat, encoded: string): any
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
| Name | Learn More |
|
--[=[
|
||||||
|:---------|:----------------------------------|
|
@within Serde
|
||||||
| `brotli` | https://github.com/google/brotli |
|
@tag must_use
|
||||||
| `gzip` | https://www.gnu.org/software/gzip |
|
|
||||||
| `lz4` | https://github.com/lz4/lz4 |
|
|
||||||
| `zlib` | https://www.zlib.net |
|
|
||||||
|
|
||||||
@param format The format to use
|
Compresses the given string using the given format.
|
||||||
@param encoded The string to compress
|
|
||||||
@return The compressed string
|
|
||||||
]=]
|
|
||||||
compress = function(format: CompressDecompressFormat, s: string): string
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Serde
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Decompresses the given string using the given format.
|
Currently supported formats:
|
||||||
|
|
||||||
Currently supported formats:
|
| Name | Learn More |
|
||||||
|
|:---------|:----------------------------------|
|
||||||
|
| `brotli` | https://github.com/google/brotli |
|
||||||
|
| `gzip` | https://www.gnu.org/software/gzip |
|
||||||
|
| `lz4` | https://github.com/lz4/lz4 |
|
||||||
|
| `zlib` | https://www.zlib.net |
|
||||||
|
|
||||||
| Name | Learn More |
|
@param format The format to use
|
||||||
|:---------|:----------------------------------|
|
@param encoded The string to compress
|
||||||
| `brotli` | https://github.com/google/brotli |
|
@return The compressed string
|
||||||
| `gzip` | https://www.gnu.org/software/gzip |
|
]=]
|
||||||
| `lz4` | https://github.com/lz4/lz4 |
|
function serde.compress(format: CompressDecompressFormat, s: string): string
|
||||||
| `zlib` | https://www.zlib.net |
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param format The format to use
|
--[=[
|
||||||
@param encoded The string to decompress
|
@within Serde
|
||||||
@return The decompressed string
|
@tag must_use
|
||||||
]=]
|
|
||||||
decompress = function(format: CompressDecompressFormat, s: string): string
|
Decompresses the given string using the given format.
|
||||||
return nil :: any
|
|
||||||
end,
|
Currently supported formats:
|
||||||
}
|
|
||||||
|
| Name | Learn More |
|
||||||
|
|:---------|:----------------------------------|
|
||||||
|
| `brotli` | https://github.com/google/brotli |
|
||||||
|
| `gzip` | https://www.gnu.org/software/gzip |
|
||||||
|
| `lz4` | https://github.com/lz4/lz4 |
|
||||||
|
| `zlib` | https://www.zlib.net |
|
||||||
|
|
||||||
|
@param format The format to use
|
||||||
|
@param encoded The string to decompress
|
||||||
|
@return The decompressed string
|
||||||
|
]=]
|
||||||
|
function serde.decompress(format: CompressDecompressFormat, s: string): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
return serde
|
||||||
|
|
|
@ -60,80 +60,87 @@ end
|
||||||
stdio.ewrite("\nAnd some error text, too")
|
stdio.ewrite("\nAnd some error text, too")
|
||||||
```
|
```
|
||||||
]=]
|
]=]
|
||||||
return {
|
local stdio = {}
|
||||||
--[=[
|
|
||||||
@within Stdio
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Return an ANSI string that can be used to modify the persistent output color.
|
stdio.prompt = prompt
|
||||||
|
|
||||||
Pass `"reset"` to get a string that can reset the persistent output color.
|
--[=[
|
||||||
|
@within Stdio
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
### Example usage
|
Return an ANSI string that can be used to modify the persistent output color.
|
||||||
|
|
||||||
```lua
|
Pass `"reset"` to get a string that can reset the persistent output color.
|
||||||
stdio.write(stdio.color("red"))
|
|
||||||
print("This text will be red")
|
|
||||||
stdio.write(stdio.color("reset"))
|
|
||||||
print("This text will be normal")
|
|
||||||
```
|
|
||||||
|
|
||||||
@param color The color to use
|
### Example usage
|
||||||
@return A printable ANSI string
|
|
||||||
]=]
|
|
||||||
color = function(color: Color): string
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Stdio
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Return an ANSI string that can be used to modify the persistent output style.
|
```lua
|
||||||
|
stdio.write(stdio.color("red"))
|
||||||
|
print("This text will be red")
|
||||||
|
stdio.write(stdio.color("reset"))
|
||||||
|
print("This text will be normal")
|
||||||
|
```
|
||||||
|
|
||||||
Pass `"reset"` to get a string that can reset the persistent output style.
|
@param color The color to use
|
||||||
|
@return A printable ANSI string
|
||||||
|
]=]
|
||||||
|
function stdio.color(color: Color): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
### Example usage
|
--[=[
|
||||||
|
@within Stdio
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
```lua
|
Return an ANSI string that can be used to modify the persistent output style.
|
||||||
stdio.write(stdio.style("bold"))
|
|
||||||
print("This text will be bold")
|
|
||||||
stdio.write(stdio.style("reset"))
|
|
||||||
print("This text will be normal")
|
|
||||||
```
|
|
||||||
|
|
||||||
@param style The style to use
|
Pass `"reset"` to get a string that can reset the persistent output style.
|
||||||
@return A printable ANSI string
|
|
||||||
]=]
|
|
||||||
style = function(style: Style): string
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Stdio
|
|
||||||
@tag must_use
|
|
||||||
|
|
||||||
Formats arguments into a human-readable string with syntax highlighting for tables.
|
### Example usage
|
||||||
|
|
||||||
@param ... The values to format
|
```lua
|
||||||
@return The formatted string
|
stdio.write(stdio.style("bold"))
|
||||||
]=]
|
print("This text will be bold")
|
||||||
format = function(...: any): string
|
stdio.write(stdio.style("reset"))
|
||||||
return nil :: any
|
print("This text will be normal")
|
||||||
end,
|
```
|
||||||
--[=[
|
|
||||||
@within Stdio
|
|
||||||
|
|
||||||
Writes a string directly to stdout, without any newline.
|
@param style The style to use
|
||||||
|
@return A printable ANSI string
|
||||||
|
]=]
|
||||||
|
function stdio.style(style: Style): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param s The string to write to stdout
|
--[=[
|
||||||
]=]
|
@within Stdio
|
||||||
write = function(s: string) end,
|
@tag must_use
|
||||||
--[=[
|
|
||||||
@within Stdio
|
|
||||||
|
|
||||||
Writes a string directly to stderr, without any newline.
|
Formats arguments into a human-readable string with syntax highlighting for tables.
|
||||||
|
|
||||||
@param s The string to write to stderr
|
@param ... The values to format
|
||||||
]=]
|
@return The formatted string
|
||||||
ewrite = function(s: string) end,
|
]=]
|
||||||
prompt = prompt,
|
function stdio.format(...: any): string
|
||||||
}
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Stdio
|
||||||
|
|
||||||
|
Writes a string directly to stdout, without any newline.
|
||||||
|
|
||||||
|
@param s The string to write to stdout
|
||||||
|
]=]
|
||||||
|
function stdio.write(s: string) end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Stdio
|
||||||
|
|
||||||
|
Writes a string directly to stderr, without any newline.
|
||||||
|
|
||||||
|
@param s The string to write to stderr
|
||||||
|
]=]
|
||||||
|
function stdio.ewrite(s: string) end
|
||||||
|
|
||||||
|
return stdio
|
||||||
|
|
|
@ -27,69 +27,75 @@
|
||||||
print("Running after task.spawn yields")
|
print("Running after task.spawn yields")
|
||||||
```
|
```
|
||||||
]=]
|
]=]
|
||||||
return {
|
local task = {}
|
||||||
--[=[
|
|
||||||
@within Task
|
|
||||||
|
|
||||||
Stops a currently scheduled thread from resuming.
|
--[=[
|
||||||
|
@within Task
|
||||||
|
|
||||||
@param thread The thread to cancel
|
Stops a currently scheduled thread from resuming.
|
||||||
]=]
|
|
||||||
cancel = function(thread: thread) end,
|
|
||||||
--[=[
|
|
||||||
@within Task
|
|
||||||
|
|
||||||
Defers a thread or function to run at the end of the current task queue.
|
@param thread The thread to cancel
|
||||||
|
]=]
|
||||||
|
function task.cancel(thread: thread) end
|
||||||
|
|
||||||
@param functionOrThread The function or thread to defer
|
--[=[
|
||||||
@return The thread that will be deferred
|
@within Task
|
||||||
]=]
|
|
||||||
defer = function<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Task
|
|
||||||
|
|
||||||
Delays a thread or function to run after `duration` seconds.
|
Defers a thread or function to run at the end of the current task queue.
|
||||||
|
|
||||||
If no `duration` is given, this will wait for the minimum amount of time possible.
|
@param functionOrThread The function or thread to defer
|
||||||
|
@return The thread that will be deferred
|
||||||
|
]=]
|
||||||
|
function task.defer<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
@param functionOrThread The function or thread to delay
|
--[=[
|
||||||
@return The thread that will be delayed
|
@within Task
|
||||||
]=]
|
|
||||||
delay = function<T...>(
|
|
||||||
duration: number?,
|
|
||||||
functionOrThread: thread | (T...) -> ...any,
|
|
||||||
...: T...
|
|
||||||
): thread
|
|
||||||
return nil :: any
|
|
||||||
end,
|
|
||||||
--[=[
|
|
||||||
@within Task
|
|
||||||
|
|
||||||
Instantly runs a thread or function.
|
Delays a thread or function to run after `duration` seconds.
|
||||||
|
|
||||||
If the spawned task yields, the thread that spawned the task
|
If no `duration` is given, this will wait for the minimum amount of time possible.
|
||||||
will resume, letting the spawned task run in the background.
|
|
||||||
|
|
||||||
@param functionOrThread The function or thread to spawn
|
@param functionOrThread The function or thread to delay
|
||||||
@return The thread that was spawned
|
@return The thread that will be delayed
|
||||||
]=]
|
]=]
|
||||||
spawn = function<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
|
function task.delay<T...>(
|
||||||
return nil :: any
|
duration: number?,
|
||||||
end,
|
functionOrThread: thread | (T...) -> ...any,
|
||||||
--[=[
|
...: T...
|
||||||
@within Task
|
): thread
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
Waits for *at least* the given amount of time.
|
--[=[
|
||||||
|
@within Task
|
||||||
|
|
||||||
The minimum wait time possible when using `task.wait` is limited by the underlying OS sleep implementation.
|
Instantly runs a thread or function.
|
||||||
For most systems this means `task.wait` is accurate down to about 5 milliseconds or less.
|
|
||||||
|
|
||||||
@param duration The amount of time to wait
|
If the spawned task yields, the thread that spawned the task
|
||||||
@return The exact amount of time waited
|
will resume, letting the spawned task run in the background.
|
||||||
]=]
|
|
||||||
wait = function(duration: number?): number
|
@param functionOrThread The function or thread to spawn
|
||||||
return nil :: any
|
@return The thread that was spawned
|
||||||
end,
|
]=]
|
||||||
}
|
function task.spawn<T...>(functionOrThread: thread | (T...) -> ...any, ...: T...): thread
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Task
|
||||||
|
|
||||||
|
Waits for *at least* the given amount of time.
|
||||||
|
|
||||||
|
The minimum wait time possible when using `task.wait` is limited by the underlying OS sleep implementation.
|
||||||
|
For most systems this means `task.wait` is accurate down to about 5 milliseconds or less.
|
||||||
|
|
||||||
|
@param duration The amount of time to wait
|
||||||
|
@return The exact amount of time waited
|
||||||
|
]=]
|
||||||
|
function task.wait(duration: number?): number
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
return task
|
||||||
|
|
Loading…
Reference in a new issue