@defold-typescript/types 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-availability.json +4024 -716
- package/api-migrations.json +27 -0
- package/api-signatures.json +18118 -10264
- package/api-targets.json +448 -11
- package/examples/translations.json +619 -148
- package/fixtures/messages_doc.json +96 -0
- package/generated/b2d.d.ts +680 -4
- package/generated/b2d_body.d.ts +29 -103
- package/generated/b2d_chain.d.ts +5 -6
- package/generated/b2d_fixture.d.ts +34 -38
- package/generated/b2d_joint.d.ts +503 -25
- package/generated/b2d_shape.d.ts +199 -14
- package/generated/b2d_world.d.ts +57 -63
- package/generated/buffer.d.ts +33 -29
- package/generated/builtin-messages.d.ts +7 -1
- package/generated/bullet3d.d.ts +91 -0
- package/generated/bullet3d_collision_object.d.ts +433 -0
- package/generated/bullet3d_constraint.d.ts +818 -0
- package/generated/bullet3d_rigid_body.d.ts +429 -0
- package/generated/bullet3d_shape.d.ts +123 -0
- package/generated/bullet3d_world.d.ts +492 -0
- package/generated/camera.d.ts +31 -34
- package/generated/collectionfactory.d.ts +26 -27
- package/generated/collectionproxy.d.ts +22 -6
- package/generated/compute.d.ts +12 -238
- package/generated/crash.d.ts +24 -10
- package/generated/editor-vm/http.d.ts +90 -7
- package/generated/editor-vm/image.d.ts +7 -7
- package/generated/editor-vm/json.d.ts +11 -0
- package/generated/editor-vm/localization.d.ts +7 -7
- package/generated/editor-vm/tilemap_tiles.d.ts +56 -10
- package/generated/editor-vm/zip.d.ts +28 -0
- package/generated/editor.d.ts +1496 -430
- package/generated/factory.d.ts +21 -25
- package/generated/font.d.ts +64 -22
- package/generated/go.d.ts +243 -186
- package/generated/graphics.d.ts +374 -84
- package/generated/gui.d.ts +282 -492
- package/generated/html5.d.ts +5 -3
- package/generated/http.d.ts +31 -36
- package/generated/image.d.ts +127 -85
- package/generated/json.d.ts +34 -16
- package/generated/kinds/gui-script.d.ts +8 -0
- package/generated/kinds/render-script.d.ts +8 -0
- package/generated/kinds/script.d.ts +8 -0
- package/generated/label.d.ts +77 -7
- package/generated/liveupdate.d.ts +13 -10
- package/generated/material.d.ts +312 -360
- package/generated/model.d.ts +72 -42
- package/generated/particlefx.d.ts +19 -28
- package/generated/physics.d.ts +378 -144
- package/generated/profiler.d.ts +14 -24
- package/generated/render.d.ts +294 -297
- package/generated/resource.d.ts +753 -641
- package/generated/socket.d.ts +131 -134
- package/generated/sound.d.ts +65 -34
- package/generated/sprite.d.ts +39 -17
- package/generated/sys.d.ts +237 -182
- package/generated/tilemap.d.ts +21 -16
- package/generated/timer.d.ts +34 -21
- package/generated/versions/defold-1.12.4/b2d_body.d.ts +0 -7
- package/generated/versions/defold-1.12.4/buffer.d.ts +18 -17
- package/generated/versions/defold-1.12.4/camera.d.ts +23 -23
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +21 -19
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
- package/generated/versions/defold-1.12.4/factory.d.ts +15 -16
- package/generated/versions/defold-1.12.4/go.d.ts +15 -17
- package/generated/versions/defold-1.12.4/gui.d.ts +111 -193
- package/generated/versions/defold-1.12.4/html5.d.ts +4 -2
- package/generated/versions/defold-1.12.4/http.d.ts +4 -15
- package/generated/versions/defold-1.12.4/image.d.ts +38 -46
- package/generated/versions/defold-1.12.4/index.d.ts +2 -0
- package/generated/versions/defold-1.12.4/json.d.ts +10 -6
- package/generated/versions/defold-1.12.4/label.d.ts +2 -3
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +5 -3
- package/generated/versions/defold-1.12.4/model.d.ts +34 -13
- package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.12.4/physics.d.ts +82 -78
- package/generated/versions/defold-1.12.4/profiler.d.ts +3 -6
- package/generated/versions/defold-1.12.4/render.d.ts +160 -132
- package/generated/versions/defold-1.12.4/resource.d.ts +212 -209
- package/generated/versions/defold-1.12.4/socket.d.ts +45 -61
- package/generated/versions/defold-1.12.4/sound.d.ts +11 -11
- package/generated/versions/defold-1.12.4/sprite.d.ts +24 -6
- package/generated/versions/defold-1.12.4/sys.d.ts +45 -68
- package/generated/versions/defold-1.12.4/tilemap.d.ts +18 -11
- package/generated/versions/defold-1.12.4/timer.d.ts +5 -3
- package/generated/versions/defold-1.12.4/vmath.d.ts +5 -26
- package/generated/versions/defold-1.12.4/window.d.ts +1 -16
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +10 -55
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +25 -25
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +188 -5
- package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
- package/generated/versions/defold-1.13.0/buffer.d.ts +18 -17
- package/generated/versions/defold-1.13.0/camera.d.ts +27 -27
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +21 -19
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.13.0/compute.d.ts +1 -70
- package/generated/versions/defold-1.13.0/crash.d.ts +2 -2
- package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +3 -3
- package/generated/versions/defold-1.13.0/editor.d.ts +34 -24
- package/generated/versions/defold-1.13.0/factory.d.ts +15 -16
- package/generated/versions/defold-1.13.0/go.d.ts +15 -17
- package/generated/versions/defold-1.13.0/graphics.d.ts +121 -37
- package/generated/versions/defold-1.13.0/gui.d.ts +111 -193
- package/generated/versions/defold-1.13.0/html5.d.ts +4 -2
- package/generated/versions/defold-1.13.0/http.d.ts +4 -15
- package/generated/versions/defold-1.13.0/image.d.ts +38 -46
- package/generated/versions/defold-1.13.0/index.d.ts +2 -0
- package/generated/versions/defold-1.13.0/json.d.ts +10 -6
- package/generated/versions/defold-1.13.0/label.d.ts +2 -3
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +7 -5
- package/generated/versions/defold-1.13.0/material.d.ts +69 -107
- package/generated/versions/defold-1.13.0/model.d.ts +34 -13
- package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.13.0/physics.d.ts +82 -78
- package/generated/versions/defold-1.13.0/profiler.d.ts +3 -6
- package/generated/versions/defold-1.13.0/render.d.ts +160 -132
- package/generated/versions/defold-1.13.0/resource.d.ts +217 -210
- package/generated/versions/defold-1.13.0/socket.d.ts +45 -61
- package/generated/versions/defold-1.13.0/sound.d.ts +11 -11
- package/generated/versions/defold-1.13.0/sprite.d.ts +24 -6
- package/generated/versions/defold-1.13.0/sys.d.ts +45 -68
- package/generated/versions/defold-1.13.0/tilemap.d.ts +18 -11
- package/generated/versions/defold-1.13.0/timer.d.ts +5 -3
- package/generated/versions/defold-1.13.0/vmath.d.ts +5 -26
- package/generated/versions/defold-1.13.0/window.d.ts +1 -16
- package/generated/versions/defold-1.13.1/b2d.d.ts +33 -0
- package/generated/versions/defold-1.13.1/b2d_body.d.ts +636 -0
- package/generated/versions/defold-1.13.1/b2d_chain.d.ts +106 -0
- package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +157 -0
- package/generated/versions/defold-1.13.1/b2d_joint.d.ts +823 -0
- package/generated/versions/defold-1.13.1/b2d_shape.d.ts +400 -0
- package/generated/versions/defold-1.13.1/b2d_world.d.ts +320 -0
- package/generated/versions/defold-1.13.1/buffer.d.ts +189 -0
- package/generated/versions/defold-1.13.1/camera.d.ts +303 -0
- package/generated/versions/defold-1.13.1/collectionfactory.d.ts +151 -0
- package/generated/versions/defold-1.13.1/collectionproxy.d.ts +93 -0
- package/generated/versions/defold-1.13.1/compute.d.ts +237 -0
- package/generated/versions/defold-1.13.1/crash.d.ts +143 -0
- package/generated/versions/defold-1.13.1/editor-vm/http.d.ts +56 -0
- package/generated/versions/defold-1.13.1/editor-vm/image.d.ts +48 -0
- package/generated/versions/defold-1.13.1/editor-vm/json.d.ts +10 -0
- package/generated/versions/defold-1.13.1/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.1/editor-vm/tilemap_tiles.d.ts +80 -0
- package/generated/versions/defold-1.13.1/editor-vm/zip.d.ts +10 -0
- package/generated/versions/defold-1.13.1/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.1/editor.d.ts +1121 -0
- package/generated/versions/defold-1.13.1/factory.d.ts +124 -0
- package/generated/versions/defold-1.13.1/font.d.ts +81 -0
- package/generated/versions/defold-1.13.1/go.d.ts +1107 -0
- package/generated/versions/defold-1.13.1/graphics.d.ts +411 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +2353 -0
- package/generated/versions/defold-1.13.1/html5.d.ts +55 -0
- package/generated/versions/defold-1.13.1/http.d.ts +77 -0
- package/generated/versions/defold-1.13.1/image.d.ts +131 -0
- package/generated/versions/defold-1.13.1/index.d.ts +57 -0
- package/generated/versions/defold-1.13.1/json.d.ts +80 -0
- package/generated/versions/defold-1.13.1/kinds/editor-script.d.ts +14 -0
- package/generated/versions/defold-1.13.1/label.d.ts +93 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +142 -0
- package/generated/versions/defold-1.13.1/material.d.ts +408 -0
- package/generated/versions/defold-1.13.1/model.d.ts +272 -0
- package/generated/versions/defold-1.13.1/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.1/particlefx.d.ts +163 -0
- package/generated/versions/defold-1.13.1/physics.d.ts +559 -0
- package/generated/versions/defold-1.13.1/profiler.d.ts +235 -0
- package/generated/versions/defold-1.13.1/render.d.ts +1190 -0
- package/generated/versions/defold-1.13.1/resource.d.ts +1523 -0
- package/generated/versions/defold-1.13.1/socket.d.ts +784 -0
- package/generated/versions/defold-1.13.1/sound.d.ts +292 -0
- package/generated/versions/defold-1.13.1/sprite.d.ts +175 -0
- package/generated/versions/defold-1.13.1/sys.d.ts +678 -0
- package/generated/versions/defold-1.13.1/tilemap.d.ts +208 -0
- package/generated/versions/defold-1.13.1/timer.d.ts +125 -0
- package/generated/versions/defold-1.13.1/types.d.ts +61 -0
- package/generated/versions/defold-1.13.1/vmath.d.ts +774 -0
- package/generated/versions/defold-1.13.1/window.d.ts +183 -0
- package/generated/versions/defold-1.13.1/zlib.d.ts +41 -0
- package/generated/vmath.d.ts +6 -26
- package/generated/window.d.ts +71 -71
- package/identity-vocabulary.json +561 -0
- package/index.d.ts +8 -0
- package/package.json +13 -2
- package/scripts/example-store-io.ts +12 -1
- package/scripts/extension-goldens.ts +1 -0
- package/scripts/fidelity-baseline.json +146 -46
- package/scripts/generate-api-availability.ts +90 -12
- package/scripts/generate-api-signatures.ts +14 -3
- package/scripts/import-defold-release.ts +85 -24
- package/scripts/prose-constants.ts +157 -0
- package/scripts/regen.ts +396 -78
- package/scripts/shared-handle-methods.ts +53 -0
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/sync-api-docs.ts +16 -5
- package/src/api-availability.ts +0 -0
- package/src/api-doc.ts +201 -3
- package/src/api-identity.ts +252 -0
- package/src/component-properties.d.ts +33 -0
- package/src/core-types.ts +28 -3
- package/src/correction-pins.ts +49 -0
- package/src/custom-messages.d.ts +4 -3
- package/src/doc-comment.ts +139 -23
- package/src/doc-corrections.ts +108 -0
- package/src/editor-vm-globals.d.ts +5 -2
- package/src/emit-dts.ts +2474 -281
- package/src/emit-messages.ts +52 -0
- package/src/engine-globals.d.ts +2 -2
- package/src/example-store.ts +125 -14
- package/src/field-correction-coverage.ts +204 -0
- package/src/fnv1a.ts +16 -0
- package/src/go-overloads.d.ts +33 -13
- package/src/index-base-table.ts +145 -0
- package/src/index-slot-classifications.ts +588 -0
- package/src/index.ts +39 -2
- package/src/library-index-slot-classifications.ts +332 -0
- package/src/lifecycle.ts +61 -199
- package/src/luals-type-expr.ts +354 -0
- package/src/msg-overloads.d.ts +0 -1
- package/src/param-correction-provenance.ts +64 -0
- package/src/return-correction-provenance.ts +58 -16
- package/src/script-api.ts +3 -1
- package/src/sys-overloads.d.ts +48 -0
- package/src/vmath-overloads.d.ts +27 -1
- package/src/window-event-guard.d.ts +6 -9
- package/url-parameters.json +1 -2
package/generated/socket.d.ts
CHANGED
|
@@ -17,16 +17,24 @@ declare global {
|
|
|
17
17
|
* require "builtins.scripts.socket"
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
|
-
* LuaSocket is Copyright
|
|
20
|
+
* LuaSocket is Copyright © 2004-2007 Diego Nehab. All rights reserved.
|
|
21
21
|
* LuaSocket is free software, released under the MIT license (same license as the Lua core).
|
|
22
22
|
*/
|
|
23
23
|
namespace socket {
|
|
24
|
+
type socket_client = client;
|
|
25
|
+
type socket_connected = connected;
|
|
26
|
+
type socket_master = master;
|
|
27
|
+
type socket_selectable = master | client | server | connected | unconnected | { getfd: (self: unknown) => number; dirty: (self: unknown) => boolean };
|
|
28
|
+
type socket_server = server;
|
|
29
|
+
type socket_unconnected = unconnected;
|
|
24
30
|
interface client {
|
|
25
31
|
/**
|
|
26
32
|
* Closes the TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket.
|
|
27
33
|
* It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though.
|
|
34
|
+
*
|
|
35
|
+
* @returns the value `1`.
|
|
28
36
|
*/
|
|
29
|
-
close():
|
|
37
|
+
close(): number;
|
|
30
38
|
/**
|
|
31
39
|
* Check the read buffer status.
|
|
32
40
|
* This is an internal method, any use is unlikely to be portable.
|
|
@@ -47,33 +55,24 @@ declare global {
|
|
|
47
55
|
* @param option - the name of the option to get:
|
|
48
56
|
*
|
|
49
57
|
* - `"keepalive"`
|
|
50
|
-
*
|
|
51
58
|
* - `"linger"`
|
|
52
|
-
*
|
|
53
59
|
* - `"reuseaddr"`
|
|
54
|
-
*
|
|
55
60
|
* - `"tcp-nodelay"`
|
|
56
61
|
*/
|
|
57
62
|
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
58
63
|
/**
|
|
59
64
|
* Returns information about the remote side of a connected client object.
|
|
60
65
|
* It makes no sense to call this method on server objects.
|
|
61
|
-
*
|
|
62
|
-
* @returns a string with the IP address of the peer, the port number that peer is using for the connection, and the family ("inet" or "inet6"). In case of error, the method returns `nil`.
|
|
63
66
|
*/
|
|
64
|
-
getpeername(): string
|
|
67
|
+
getpeername(): LuaMultiReturn<[string | undefined, number | string, string | undefined]>;
|
|
65
68
|
/**
|
|
66
69
|
* Returns the local address information associated to the object.
|
|
67
|
-
*
|
|
68
|
-
* @returns a string with local IP address, the local port number, and the family ("inet" or "inet6"). In case of error, the method returns `nil`.
|
|
69
70
|
*/
|
|
70
|
-
getsockname(): string
|
|
71
|
+
getsockname(): LuaMultiReturn<[string | undefined, string, string | undefined]>;
|
|
71
72
|
/**
|
|
72
73
|
* Returns accounting information on the socket, useful for throttling of bandwidth.
|
|
73
|
-
*
|
|
74
|
-
* @returns a string with the number of bytes received, the number of bytes sent, and the age of the socket object in seconds.
|
|
75
74
|
*/
|
|
76
|
-
getstats():
|
|
75
|
+
getstats(): LuaMultiReturn<[number, number, number]>;
|
|
77
76
|
/**
|
|
78
77
|
* Reads data from a client object, according to the specified `read pattern`. Patterns follow the Lua file I/O format, and the difference in performance between patterns is negligible.
|
|
79
78
|
*
|
|
@@ -94,8 +93,12 @@ declare global {
|
|
|
94
93
|
* Output is not buffered. For small strings, it is always better to concatenate them in Lua (with the `..` operator) and send the result in one call instead of calling the method several times.
|
|
95
94
|
*
|
|
96
95
|
* @param data - the string to be sent.
|
|
97
|
-
* @param i - optional starting index of the string.
|
|
98
|
-
* @param j - optional end index of string.
|
|
96
|
+
* @param i - optional starting index of the string. **⚠️ 1-based; passed to Defold unchanged.**
|
|
97
|
+
* @param j - optional end index of string. **⚠️ 1-based; passed to Defold unchanged.**
|
|
98
|
+
* @returns `[index, error, lastindex]`:
|
|
99
|
+
* - `index` — the index of the last byte within [i, j] that has been sent, or `nil` in case of error. Notice that, if `i` is 1 or absent, this is effectively the total number of bytes sent. **⚠️ 1-based; passed to Defold unchanged.**
|
|
100
|
+
* - `error` — the error message, or `nil` if no error occurred. The error message can be `"closed"` in case the connection was closed before the transmission was completed or the string `"timeout"` in case there was a timeout during the operation.
|
|
101
|
+
* - `lastindex` — in case of error, the index of the last byte within [i, j] that has been sent. You might want to try again from the byte following that. `nil` if no error occurred. **⚠️ 1-based; passed to Defold unchanged.**
|
|
99
102
|
*/
|
|
100
103
|
send(data: string, i?: number, j?: number): LuaMultiReturn<[number | undefined, string | undefined, number | undefined]>;
|
|
101
104
|
/**
|
|
@@ -115,7 +118,6 @@ declare global {
|
|
|
115
118
|
* Controls the action taken when unsent data are queued on a socket and a close is performed. The value is a table with the following keys:
|
|
116
119
|
*
|
|
117
120
|
* - boolean `on`
|
|
118
|
-
*
|
|
119
121
|
* - number `timeout` (seconds)
|
|
120
122
|
*
|
|
121
123
|
* If the 'on' field is set to true, the system will block the process on the close attempt until it is able to transmit the data or until `timeout` has passed. If 'on' is false and a close is issued, the system will process the close in a manner that allows the process to continue as quickly as possible. It is not advised to set this to anything other than zero;
|
|
@@ -132,12 +134,12 @@ declare global {
|
|
|
132
134
|
/**
|
|
133
135
|
* Resets accounting information on the socket, useful for throttling of bandwidth.
|
|
134
136
|
*
|
|
135
|
-
* @param received - the new number of bytes received.
|
|
136
|
-
* @param sent - the new number of bytes sent.
|
|
137
|
-
* @param age - the new age in seconds.
|
|
138
|
-
* @returns the value `1
|
|
137
|
+
* @param received - the new number of bytes received, or `nil` to preserve it.
|
|
138
|
+
* @param sent - the new number of bytes sent, or `nil` to preserve it.
|
|
139
|
+
* @param age - the new age in seconds, or `nil` to preserve it.
|
|
140
|
+
* @returns the value `1`.
|
|
139
141
|
*/
|
|
140
|
-
setstats(received
|
|
142
|
+
setstats(received?: number, sent?: number, age?: number): number;
|
|
141
143
|
/**
|
|
142
144
|
* Changes the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods `send`, `receive`, and `accept` will block indefinitely, until the operation completes. The `settimeout` method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code.
|
|
143
145
|
* There are two timeout modes and both can be used together for fine tuning.
|
|
@@ -150,8 +152,9 @@ declare global {
|
|
|
150
152
|
* block timeout. Specifies the upper limit on the amount of time LuaSocket can be blocked by the operating system while waiting for completion of any single I/O operation. This is the default mode;
|
|
151
153
|
* `"t"`
|
|
152
154
|
* total timeout. Specifies the upper limit on the amount of time LuaSocket can block a Lua script before returning from a call.
|
|
155
|
+
* @returns the value `1`.
|
|
153
156
|
*/
|
|
154
|
-
settimeout(value
|
|
157
|
+
settimeout(value?: number, mode?: string): number;
|
|
155
158
|
/**
|
|
156
159
|
* Shuts down part of a full-duplex connection.
|
|
157
160
|
*
|
|
@@ -171,48 +174,37 @@ declare global {
|
|
|
171
174
|
/**
|
|
172
175
|
* Closes a UDP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket.
|
|
173
176
|
* It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though.
|
|
177
|
+
*
|
|
178
|
+
* @returns the value `1`.
|
|
174
179
|
*/
|
|
175
|
-
close():
|
|
180
|
+
close(): number;
|
|
176
181
|
/**
|
|
177
182
|
* Gets an option value from the UDP object. See connected:setoption for description of the option names and values.
|
|
178
183
|
*
|
|
179
184
|
* @param option - the name of the option to get:
|
|
180
185
|
*
|
|
181
186
|
* - `"dontroute"`
|
|
182
|
-
*
|
|
183
187
|
* - `"broadcast"`
|
|
184
|
-
*
|
|
185
188
|
* - `"reuseaddr"`
|
|
186
|
-
*
|
|
187
189
|
* - `"reuseport"`
|
|
188
|
-
*
|
|
189
190
|
* - `"ip-multicast-loop"`
|
|
190
|
-
*
|
|
191
191
|
* - `"ipv6-v6only"`
|
|
192
|
-
*
|
|
193
192
|
* - `"ip-multicast-if"`
|
|
194
|
-
*
|
|
195
193
|
* - `"ip-multicast-ttl"`
|
|
196
|
-
*
|
|
197
194
|
* - `"ip-add-membership"`
|
|
198
|
-
*
|
|
199
195
|
* - `"ip-drop-membership"`
|
|
200
196
|
*/
|
|
201
197
|
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
202
198
|
/**
|
|
203
199
|
* Retrieves information about the peer associated with a connected UDP object.
|
|
204
200
|
* It makes no sense to call this method on unconnected objects.
|
|
205
|
-
*
|
|
206
|
-
* @returns a string with the IP address of the peer, the port number that peer is using for the connection, and the family ("inet" or "inet6"). In case of error, the method returns `nil`.
|
|
207
201
|
*/
|
|
208
|
-
getpeername(): string
|
|
202
|
+
getpeername(): LuaMultiReturn<[string | undefined, number | string, string | undefined]>;
|
|
209
203
|
/**
|
|
210
204
|
* Returns the local address information associated to the object.
|
|
211
205
|
* UDP sockets are not bound to any address until the `setsockname` or the `sendto` method is called for the first time (in which case it is bound to an ephemeral port and the wild-card address).
|
|
212
|
-
*
|
|
213
|
-
* @returns a string with local IP address, a number with the local port, and the family ("inet" or "inet6"). In case of error, the method returns `nil`.
|
|
214
206
|
*/
|
|
215
|
-
getsockname(): string
|
|
207
|
+
getsockname(): LuaMultiReturn<[string | undefined, string, string | undefined]>;
|
|
216
208
|
/**
|
|
217
209
|
* Receives a datagram from the UDP object. If the UDP object is connected, only datagrams coming from the peer are accepted. Otherwise, the returned datagram can come from any host.
|
|
218
210
|
*
|
|
@@ -251,14 +243,12 @@ declare global {
|
|
|
251
243
|
* `"ip-add-membership"`: Joins the multicast group specified. Receives a table with fields:
|
|
252
244
|
*
|
|
253
245
|
* - string `multiaddr` (IP address)
|
|
254
|
-
*
|
|
255
246
|
* - string `interface` (IP address)
|
|
256
247
|
*
|
|
257
248
|
* "'ip-drop-membership"`
|
|
258
249
|
* Leaves the multicast group specified. Receives a table with fields:
|
|
259
250
|
*
|
|
260
251
|
* - string `multiaddr` (IP address)
|
|
261
|
-
*
|
|
262
252
|
* - string `interface` (IP address)
|
|
263
253
|
* @param value - the value to set for the specified option.
|
|
264
254
|
*/
|
|
@@ -268,16 +258,17 @@ declare global {
|
|
|
268
258
|
* For connected objects, outgoing datagrams will be sent to the specified peer, and datagrams received from other peers will be discarded by the OS. Connected UDP objects must use the `send` and `receive` methods instead of `sendto` and `receivefrom`.
|
|
269
259
|
* Since the address of the peer does not have to be passed to and from the OS, the use of connected UDP objects is recommended when the same peer is used for several transmissions and can result in up to 30% performance gains.
|
|
270
260
|
*
|
|
271
|
-
* @param
|
|
261
|
+
* @param address - must be `"*"`. The peer association is removed and the object becomes an unconnected object again.
|
|
272
262
|
*/
|
|
273
|
-
setpeername(
|
|
263
|
+
setpeername(address: string): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
274
264
|
/**
|
|
275
265
|
* Changes the timeout values for the object. By default, the `receive` and `receivefrom` operations are blocking. That is, any call to the methods will block indefinitely, until data arrives. The `settimeout` function defines a limit on the amount of time the functions can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code.
|
|
276
266
|
* In UDP, the `send` and `sendto` methods never block (the datagram is just passed to the OS and the call returns immediately). Therefore, the `settimeout` method has no effect on them.
|
|
277
267
|
*
|
|
278
268
|
* @param value - the amount of time to wait, in seconds. The `nil` timeout value allows operations to block indefinitely. Negative timeout values have the same effect.
|
|
269
|
+
* @returns the value `1`.
|
|
279
270
|
*/
|
|
280
|
-
settimeout(value
|
|
271
|
+
settimeout(value?: number): number;
|
|
281
272
|
}
|
|
282
273
|
interface master {
|
|
283
274
|
/**
|
|
@@ -290,8 +281,10 @@ declare global {
|
|
|
290
281
|
/**
|
|
291
282
|
* Closes the TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket.
|
|
292
283
|
* It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though.
|
|
284
|
+
*
|
|
285
|
+
* @returns the value `1`.
|
|
293
286
|
*/
|
|
294
|
-
close():
|
|
287
|
+
close(): number;
|
|
295
288
|
/**
|
|
296
289
|
* Attempts to connect a master object to a remote host, transforming it into a client object. Client objects support methods send, receive, getsockname, getpeername, settimeout, and close.
|
|
297
290
|
* Note that the function `socket.connect` is available and is a shortcut for the creation of client sockets.
|
|
@@ -316,16 +309,12 @@ declare global {
|
|
|
316
309
|
getfd(): number;
|
|
317
310
|
/**
|
|
318
311
|
* Returns the local address information associated to the object.
|
|
319
|
-
*
|
|
320
|
-
* @returns a string with local IP address, the local port number, and the family ("inet" or "inet6"). In case of error, the method returns `nil`.
|
|
321
312
|
*/
|
|
322
|
-
getsockname(): string
|
|
313
|
+
getsockname(): LuaMultiReturn<[string | undefined, string, string | undefined]>;
|
|
323
314
|
/**
|
|
324
315
|
* Returns accounting information on the socket, useful for throttling of bandwidth.
|
|
325
|
-
*
|
|
326
|
-
* @returns a string with the number of bytes received, the number of bytes sent, and the age of the socket object in seconds.
|
|
327
316
|
*/
|
|
328
|
-
getstats():
|
|
317
|
+
getstats(): LuaMultiReturn<[number, number, number]>;
|
|
329
318
|
/**
|
|
330
319
|
* Specifies the socket is willing to receive connections, transforming the object into a server object. Server objects support the `accept`, `getsockname`, `setoption`, `settimeout`, and `close` methods.
|
|
331
320
|
*
|
|
@@ -341,12 +330,12 @@ declare global {
|
|
|
341
330
|
/**
|
|
342
331
|
* Resets accounting information on the socket, useful for throttling of bandwidth.
|
|
343
332
|
*
|
|
344
|
-
* @param received - the new number of bytes received.
|
|
345
|
-
* @param sent - the new number of bytes sent.
|
|
346
|
-
* @param age - the new age in seconds.
|
|
347
|
-
* @returns the value `1
|
|
333
|
+
* @param received - the new number of bytes received, or `nil` to preserve it.
|
|
334
|
+
* @param sent - the new number of bytes sent, or `nil` to preserve it.
|
|
335
|
+
* @param age - the new age in seconds, or `nil` to preserve it.
|
|
336
|
+
* @returns the value `1`.
|
|
348
337
|
*/
|
|
349
|
-
setstats(received
|
|
338
|
+
setstats(received?: number, sent?: number, age?: number): number;
|
|
350
339
|
/**
|
|
351
340
|
* Changes the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods `send`, `receive`, and `accept` will block indefinitely, until the operation completes. The `settimeout` method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code.
|
|
352
341
|
* There are two timeout modes and both can be used together for fine tuning.
|
|
@@ -359,8 +348,9 @@ declare global {
|
|
|
359
348
|
* block timeout. Specifies the upper limit on the amount of time LuaSocket can be blocked by the operating system while waiting for completion of any single I/O operation. This is the default mode;
|
|
360
349
|
* `"t"`
|
|
361
350
|
* total timeout. Specifies the upper limit on the amount of time LuaSocket can block a Lua script before returning from a call.
|
|
351
|
+
* @returns the value `1`.
|
|
362
352
|
*/
|
|
363
|
-
settimeout(value
|
|
353
|
+
settimeout(value?: number, mode?: string): number;
|
|
364
354
|
}
|
|
365
355
|
interface server {
|
|
366
356
|
/**
|
|
@@ -371,8 +361,10 @@ declare global {
|
|
|
371
361
|
/**
|
|
372
362
|
* Closes the TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket.
|
|
373
363
|
* It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though.
|
|
364
|
+
*
|
|
365
|
+
* @returns the value `1`.
|
|
374
366
|
*/
|
|
375
|
-
close():
|
|
367
|
+
close(): number;
|
|
376
368
|
/**
|
|
377
369
|
* Check the read buffer status.
|
|
378
370
|
* This is an internal method, any use is unlikely to be portable.
|
|
@@ -393,26 +385,19 @@ declare global {
|
|
|
393
385
|
* @param option - the name of the option to get:
|
|
394
386
|
*
|
|
395
387
|
* - `"keepalive"`
|
|
396
|
-
*
|
|
397
388
|
* - `"linger"`
|
|
398
|
-
*
|
|
399
389
|
* - `"reuseaddr"`
|
|
400
|
-
*
|
|
401
390
|
* - `"tcp-nodelay"`
|
|
402
391
|
*/
|
|
403
392
|
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
404
393
|
/**
|
|
405
394
|
* Returns the local address information associated to the object.
|
|
406
|
-
*
|
|
407
|
-
* @returns a string with local IP address, the local port number, and the family ("inet" or "inet6"). In case of error, the method returns `nil`.
|
|
408
395
|
*/
|
|
409
|
-
getsockname(): string
|
|
396
|
+
getsockname(): LuaMultiReturn<[string | undefined, string, string | undefined]>;
|
|
410
397
|
/**
|
|
411
398
|
* Returns accounting information on the socket, useful for throttling of bandwidth.
|
|
412
|
-
*
|
|
413
|
-
* @returns a string with the number of bytes received, the number of bytes sent, and the age of the socket object in seconds.
|
|
414
399
|
*/
|
|
415
|
-
getstats():
|
|
400
|
+
getstats(): LuaMultiReturn<[number, number, number]>;
|
|
416
401
|
/**
|
|
417
402
|
* Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made
|
|
418
403
|
*
|
|
@@ -430,7 +415,6 @@ declare global {
|
|
|
430
415
|
* Controls the action taken when unsent data are queued on a socket and a close is performed. The value is a table with the following keys:
|
|
431
416
|
*
|
|
432
417
|
* - boolean `on`
|
|
433
|
-
*
|
|
434
418
|
* - number `timeout` (seconds)
|
|
435
419
|
*
|
|
436
420
|
* If the 'on' field is set to true, the system will block the process on the close attempt until it is able to transmit the data or until `timeout` has passed. If 'on' is false and a close is issued, the system will process the close in a manner that allows the process to continue as quickly as possible. It is not advised to set this to anything other than zero;
|
|
@@ -447,12 +431,12 @@ declare global {
|
|
|
447
431
|
/**
|
|
448
432
|
* Resets accounting information on the socket, useful for throttling of bandwidth.
|
|
449
433
|
*
|
|
450
|
-
* @param received - the new number of bytes received.
|
|
451
|
-
* @param sent - the new number of bytes sent.
|
|
452
|
-
* @param age - the new age in seconds.
|
|
453
|
-
* @returns the value `1
|
|
434
|
+
* @param received - the new number of bytes received, or `nil` to preserve it.
|
|
435
|
+
* @param sent - the new number of bytes sent, or `nil` to preserve it.
|
|
436
|
+
* @param age - the new age in seconds, or `nil` to preserve it.
|
|
437
|
+
* @returns the value `1`.
|
|
454
438
|
*/
|
|
455
|
-
setstats(received
|
|
439
|
+
setstats(received?: number, sent?: number, age?: number): number;
|
|
456
440
|
/**
|
|
457
441
|
* Changes the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods `send`, `receive`, and `accept` will block indefinitely, until the operation completes. The `settimeout` method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code.
|
|
458
442
|
* There are two timeout modes and both can be used together for fine tuning.
|
|
@@ -465,48 +449,40 @@ declare global {
|
|
|
465
449
|
* block timeout. Specifies the upper limit on the amount of time LuaSocket can be blocked by the operating system while waiting for completion of any single I/O operation. This is the default mode;
|
|
466
450
|
* `"t"`
|
|
467
451
|
* total timeout. Specifies the upper limit on the amount of time LuaSocket can block a Lua script before returning from a call.
|
|
452
|
+
* @returns the value `1`.
|
|
468
453
|
*/
|
|
469
|
-
settimeout(value
|
|
454
|
+
settimeout(value?: number, mode?: string): number;
|
|
470
455
|
}
|
|
471
456
|
interface unconnected {
|
|
472
457
|
/**
|
|
473
458
|
* Closes a UDP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket.
|
|
474
459
|
* It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though.
|
|
460
|
+
*
|
|
461
|
+
* @returns the value `1`.
|
|
475
462
|
*/
|
|
476
|
-
close():
|
|
463
|
+
close(): number;
|
|
477
464
|
/**
|
|
478
465
|
* Gets an option value from the UDP object. See unconnected:setoption for description of the option names and values.
|
|
479
466
|
*
|
|
480
467
|
* @param option - the name of the option to get:
|
|
481
468
|
*
|
|
482
469
|
* - `"dontroute"`
|
|
483
|
-
*
|
|
484
470
|
* - `"broadcast"`
|
|
485
|
-
*
|
|
486
471
|
* - `"reuseaddr"`
|
|
487
|
-
*
|
|
488
472
|
* - `"reuseport"`
|
|
489
|
-
*
|
|
490
473
|
* - `"ip-multicast-loop"`
|
|
491
|
-
*
|
|
492
474
|
* - `"ipv6-v6only"`
|
|
493
|
-
*
|
|
494
475
|
* - `"ip-multicast-if"`
|
|
495
|
-
*
|
|
496
476
|
* - `"ip-multicast-ttl"`
|
|
497
|
-
*
|
|
498
477
|
* - `"ip-add-membership"`
|
|
499
|
-
*
|
|
500
478
|
* - `"ip-drop-membership"`
|
|
501
479
|
*/
|
|
502
480
|
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
503
481
|
/**
|
|
504
482
|
* Returns the local address information associated to the object.
|
|
505
483
|
* UDP sockets are not bound to any address until the `setsockname` or the `sendto` method is called for the first time (in which case it is bound to an ephemeral port and the wild-card address).
|
|
506
|
-
*
|
|
507
|
-
* @returns a string with local IP address, a number with the local port, and the family ("inet" or "inet6"). In case of error, the method returns `nil`.
|
|
508
484
|
*/
|
|
509
|
-
getsockname(): string
|
|
485
|
+
getsockname(): LuaMultiReturn<[string | undefined, string, string | undefined]>;
|
|
510
486
|
/**
|
|
511
487
|
* Receives a datagram from the UDP object. If the UDP object is connected, only datagrams coming from the peer are accepted. Otherwise, the returned datagram can come from any host.
|
|
512
488
|
*
|
|
@@ -553,14 +529,12 @@ declare global {
|
|
|
553
529
|
* `"ip-add-membership"`: Joins the multicast group specified. Receives a table with fields:
|
|
554
530
|
*
|
|
555
531
|
* - string `multiaddr` (IP address)
|
|
556
|
-
*
|
|
557
532
|
* - string `interface` (IP address)
|
|
558
533
|
*
|
|
559
534
|
* "'ip-drop-membership"`
|
|
560
535
|
* Leaves the multicast group specified. Receives a table with fields:
|
|
561
536
|
*
|
|
562
537
|
* - string `multiaddr` (IP address)
|
|
563
|
-
*
|
|
564
538
|
* - string `interface` (IP address)
|
|
565
539
|
* @param value - the value to set for the specified option.
|
|
566
540
|
*/
|
|
@@ -587,8 +561,9 @@ declare global {
|
|
|
587
561
|
* In UDP, the `send` and `sendto` methods never block (the datagram is just passed to the OS and the call returns immediately). Therefore, the `settimeout` method has no effect on them.
|
|
588
562
|
*
|
|
589
563
|
* @param value - the amount of time to wait, in seconds. The `nil` timeout value allows operations to block indefinitely. Negative timeout values have the same effect.
|
|
564
|
+
* @returns the value `1`.
|
|
590
565
|
*/
|
|
591
|
-
settimeout(value
|
|
566
|
+
settimeout(value?: number): number;
|
|
592
567
|
}
|
|
593
568
|
/**
|
|
594
569
|
* This constant contains the maximum number of sockets that the select function can handle.
|
|
@@ -640,15 +615,18 @@ declare global {
|
|
|
640
615
|
* // create a try function that closes 'c' on error
|
|
641
616
|
* const try_ = socket.newtry(() => c.close());
|
|
642
617
|
* // do everything reassured c will be closed
|
|
643
|
-
*
|
|
644
|
-
*
|
|
618
|
+
* const [sent, sendError, lastByte] = c.send("hello there?\r\n");
|
|
619
|
+
* try_(sent, sendError, lastByte);
|
|
620
|
+
* const [line, receiveError, partial] = c.receive();
|
|
621
|
+
* const answer = try_(line, receiveError, partial);
|
|
645
622
|
* // ...
|
|
646
|
-
*
|
|
623
|
+
* const [byeSent, byeError, byeLastByte] = c.send("good bye\r\n");
|
|
624
|
+
* try_(byeSent, byeError, byeLastByte);
|
|
647
625
|
* c.close();
|
|
648
626
|
* }
|
|
649
627
|
* ```
|
|
650
628
|
*/
|
|
651
|
-
function newtry(finalizer
|
|
629
|
+
function newtry(finalizer?: () => void): <T>(value: T | undefined, ...rest: T extends { readonly __tstlMultiReturn: unknown } ? [boxedMultiReturn: never] : unknown[]) => T;
|
|
652
630
|
/**
|
|
653
631
|
* Converts a function that throws exceptions into a safe function. This function only catches exceptions thrown by try functions. It does not catch normal Lua errors.
|
|
654
632
|
* Beware that if your function performs some illegal operation that raises an error, the protected function will catch the error and return it as a string. This is because try functions uses errors as the mechanism to throw exceptions.
|
|
@@ -659,17 +637,20 @@ declare global {
|
|
|
659
637
|
* ```ts
|
|
660
638
|
* const dostuff = socket.protect(() => {
|
|
661
639
|
* let try_ = socket.newtry();
|
|
662
|
-
* const
|
|
640
|
+
* const [conn, connectError] = socket.connect("myserver.com", 80);
|
|
641
|
+
* const c = try_(conn, connectError);
|
|
663
642
|
* try_ = socket.newtry(() => c.close());
|
|
664
|
-
*
|
|
665
|
-
*
|
|
643
|
+
* const [sent, sendError, lastByte] = c.send("hello?\r\n");
|
|
644
|
+
* try_(sent, sendError, lastByte);
|
|
645
|
+
* const [line, receiveError, partial] = c.receive();
|
|
646
|
+
* const answer = try_(line, receiveError, partial);
|
|
666
647
|
* c.close();
|
|
667
648
|
* });
|
|
668
649
|
*
|
|
669
650
|
* const [n, error] = dostuff();
|
|
670
651
|
* ```
|
|
671
652
|
*/
|
|
672
|
-
function protect(func: (...args: unknown[]) => unknown): (
|
|
653
|
+
function protect(func: (...args: unknown[]) => unknown): (...args: unknown[]) => LuaMultiReturn<[unknown, string | undefined]>;
|
|
673
654
|
/**
|
|
674
655
|
* The function returns a list with the sockets ready for reading, a list with the sockets ready for writing and an error message. The error message is "timeout" if a timeout condition was met and nil otherwise. The returned tables are doubly keyed both by integers and also by the sockets themselves, to simplify the test if a specific socket has changed status.
|
|
675
656
|
* `Recvt` and `sendt` parameters can be empty tables or `nil`. Non-socket values (or values with non-numeric indices) in these arrays will be silently ignored.
|
|
@@ -680,11 +661,11 @@ declare global {
|
|
|
680
661
|
* If you close a socket and pass it to select, it will be ignored.
|
|
681
662
|
* (Using select with non-socket objects: Any object that implements `getfd` and `dirty` can be used with select, allowing objects from other libraries to be used within a socket.select driven loop.)
|
|
682
663
|
*
|
|
683
|
-
* @param recvt - array with the sockets to test for characters available for reading.
|
|
684
|
-
* @param sendt - array with sockets that are watched to see if it is OK to immediately write on them.
|
|
664
|
+
* @param recvt - array with the sockets or compatible objects to test for characters available for reading.
|
|
665
|
+
* @param sendt - array with sockets or compatible objects that are watched to see if it is OK to immediately write on them.
|
|
685
666
|
* @param timeout - the maximum amount of time (in seconds) to wait for a change in status. Nil, negative or omitted timeout value allows the function to block indefinitely.
|
|
686
667
|
*/
|
|
687
|
-
function select(recvt:
|
|
668
|
+
function select(recvt: socket.socket_selectable[], sendt: socket.socket_selectable[], timeout?: number): LuaMultiReturn<[(client | master | unconnected)[], (client | master | unconnected)[], string | undefined]>;
|
|
688
669
|
/**
|
|
689
670
|
* This function drops a number of arguments and returns the remaining.
|
|
690
671
|
* It is useful to avoid creation of dummy variables:
|
|
@@ -692,23 +673,24 @@ declare global {
|
|
|
692
673
|
* The function returns `retD+1` to `retN`.
|
|
693
674
|
*
|
|
694
675
|
* @param d - the number of arguments to drop.
|
|
695
|
-
* @param
|
|
696
|
-
* @
|
|
697
|
-
* @param retN - argument N.
|
|
676
|
+
* @param args - the values from which to drop arguments.
|
|
677
|
+
* @returns the remaining values after the first `d` values are dropped.
|
|
698
678
|
* @example
|
|
679
|
+
* Instead of doing the following with dummy variables:
|
|
699
680
|
* ```ts
|
|
700
681
|
* const line = "250 OK";
|
|
701
|
-
*
|
|
702
|
-
* // Instead of doing the following with dummy variables:
|
|
703
682
|
* // get the status code and separator from SMTP server reply
|
|
704
683
|
* const [dummy1, dummy2, code, sep] = string.find(line, "^(%d%d%d)(.?)");
|
|
705
|
-
*
|
|
706
|
-
*
|
|
684
|
+
* ```
|
|
685
|
+
* @example
|
|
686
|
+
* You can skip a number of variables:
|
|
687
|
+
* ```ts
|
|
688
|
+
* const line = "250 OK";
|
|
707
689
|
* // get the status code and separator from SMTP server reply
|
|
708
690
|
* const [code, sep] = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"));
|
|
709
691
|
* ```
|
|
710
692
|
*/
|
|
711
|
-
function skip(d: number,
|
|
693
|
+
function skip(d: number, ...args: unknown[]): LuaMultiReturn<unknown[]>;
|
|
712
694
|
/**
|
|
713
695
|
* Freezes the program execution during a given amount of time.
|
|
714
696
|
*
|
|
@@ -734,30 +716,44 @@ declare global {
|
|
|
734
716
|
*/
|
|
735
717
|
function udp6(): LuaMultiReturn<[unconnected | undefined, string | undefined]>;
|
|
736
718
|
namespace dns {
|
|
719
|
+
/**
|
|
720
|
+
* DNS address information
|
|
721
|
+
*/
|
|
722
|
+
interface address_info {
|
|
723
|
+
/**
|
|
724
|
+
* `"inet"` for IPv4 or `"inet6"` for IPv6
|
|
725
|
+
*/
|
|
726
|
+
family: string;
|
|
727
|
+
/**
|
|
728
|
+
* resolved IP address
|
|
729
|
+
*/
|
|
730
|
+
addr: string;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* DNS host information
|
|
734
|
+
*/
|
|
735
|
+
interface host_info {
|
|
736
|
+
/**
|
|
737
|
+
* canonical host name
|
|
738
|
+
*/
|
|
739
|
+
name: string;
|
|
740
|
+
/**
|
|
741
|
+
* host aliases
|
|
742
|
+
*/
|
|
743
|
+
alias: string[];
|
|
744
|
+
/**
|
|
745
|
+
* resolved IPv4 addresses
|
|
746
|
+
*/
|
|
747
|
+
ip: string[];
|
|
748
|
+
}
|
|
737
749
|
/**
|
|
738
750
|
* This function converts a host name to IPv4 or IPv6 address.
|
|
739
751
|
* The supplied address can be an IPv4 or IPv6 address or host name.
|
|
740
|
-
* The function returns a table with all information returned by the resolver:
|
|
741
|
-
*
|
|
742
|
-
* `{
|
|
743
|
-
* [1] = {
|
|
744
|
-
* family = family-name-1,
|
|
745
|
-
* addr = address-1
|
|
746
|
-
* },
|
|
747
|
-
* ...
|
|
748
|
-
* [n] = {
|
|
749
|
-
* family = family-name-n,
|
|
750
|
-
* addr = address-n
|
|
751
|
-
* }
|
|
752
|
-
* }
|
|
753
|
-
* `
|
|
754
|
-
*
|
|
755
|
-
* Here, family contains the string `"inet"` for IPv4 addresses, and `"inet6"` for IPv6 addresses.
|
|
756
752
|
* In case of error, the function returns nil followed by an error message.
|
|
757
753
|
*
|
|
758
754
|
* @param address - a hostname or an IPv4 or IPv6 address.
|
|
759
755
|
*/
|
|
760
|
-
function getaddrinfo(address: string): LuaMultiReturn<[
|
|
756
|
+
function getaddrinfo(address: string): LuaMultiReturn<[socket.dns.address_info[] | undefined, string | undefined]>;
|
|
761
757
|
/**
|
|
762
758
|
* Returns the standard host name for the machine as a string.
|
|
763
759
|
*
|
|
@@ -769,30 +765,31 @@ declare global {
|
|
|
769
765
|
* The supplied address can be an IPv4 or IPv6 address or host name.
|
|
770
766
|
* The function returns a table with all information returned by the resolver:
|
|
771
767
|
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
768
|
+
* ```lua
|
|
769
|
+
* {
|
|
770
|
+
* [1] = host-name-1,
|
|
771
|
+
* ...
|
|
772
|
+
* [n] = host-name-n,
|
|
776
773
|
* }
|
|
777
|
-
*
|
|
774
|
+
* ```
|
|
778
775
|
*
|
|
779
776
|
* @param address - a hostname or an IPv4 or IPv6 address.
|
|
780
777
|
*/
|
|
781
|
-
function getnameinfo(address: string): LuaMultiReturn<[
|
|
778
|
+
function getnameinfo(address: string): LuaMultiReturn<[string[] | undefined, string | undefined]>;
|
|
782
779
|
/**
|
|
783
780
|
* This function converts from an IPv4 address to host name.
|
|
784
781
|
* The address can be an IPv4 address or a host name.
|
|
785
782
|
*
|
|
786
783
|
* @param address - an IPv4 address or host name.
|
|
787
784
|
*/
|
|
788
|
-
function tohostname(address: string): LuaMultiReturn<[string | undefined,
|
|
785
|
+
function tohostname(address: string): LuaMultiReturn<[string | undefined, socket.dns.host_info | string]>;
|
|
789
786
|
/**
|
|
790
787
|
* This function converts a host name to IPv4 address.
|
|
791
788
|
* The address can be an IP address or a host name.
|
|
792
789
|
*
|
|
793
790
|
* @param address - a hostname or an IP address.
|
|
794
791
|
*/
|
|
795
|
-
function toip(address: string): LuaMultiReturn<[string | undefined,
|
|
792
|
+
function toip(address: string): LuaMultiReturn<[string | undefined, socket.dns.host_info | string]>;
|
|
796
793
|
}
|
|
797
794
|
}
|
|
798
795
|
}
|