@defold-typescript/types 0.20.0 → 0.20.1
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-signatures.json +100 -100
- package/generated/b2d_chain.d.ts +1 -1
- package/generated/b2d_world.d.ts +1 -1
- package/generated/buffer.d.ts +1 -1
- package/generated/crash.d.ts +2 -2
- package/generated/go.d.ts +2 -2
- package/generated/gui.d.ts +3 -3
- package/generated/image.d.ts +3 -3
- package/generated/physics.d.ts +1 -1
- package/generated/socket.d.ts +35 -35
- package/generated/sys.d.ts +1 -1
- package/generated/timer.d.ts +1 -1
- package/generated/versions/defold-1.12.4/buffer.d.ts +1 -1
- package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
- package/generated/versions/defold-1.12.4/go.d.ts +2 -2
- package/generated/versions/defold-1.12.4/gui.d.ts +3 -3
- package/generated/versions/defold-1.12.4/image.d.ts +3 -3
- package/generated/versions/defold-1.12.4/physics.d.ts +1 -1
- package/generated/versions/defold-1.12.4/socket.d.ts +35 -35
- package/generated/versions/defold-1.12.4/sys.d.ts +1 -1
- package/generated/versions/defold-1.12.4/timer.d.ts +1 -1
- package/package.json +1 -1
- package/scripts/materialize-version.ts +45 -20
- package/src/emit-dts.ts +11 -0
|
@@ -54,7 +54,7 @@ declare global {
|
|
|
54
54
|
*
|
|
55
55
|
* - `"tcp-nodelay"`
|
|
56
56
|
*/
|
|
57
|
-
getoption(option: string): LuaMultiReturn<[unknown, string |
|
|
57
|
+
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
58
58
|
/**
|
|
59
59
|
* Returns information about the remote side of a connected client object.
|
|
60
60
|
* It makes no sense to call this method on server objects.
|
|
@@ -87,7 +87,7 @@ declare global {
|
|
|
87
87
|
* causes the method to read a specified number of bytes from the socket.
|
|
88
88
|
* @param prefix - an optional string to be concatenated to the beginning of any received data before return.
|
|
89
89
|
*/
|
|
90
|
-
receive(pattern?: string | number, prefix?: string): LuaMultiReturn<[string |
|
|
90
|
+
receive(pattern?: string | number, prefix?: string): LuaMultiReturn<[string | undefined, string | undefined, string | undefined]>;
|
|
91
91
|
/**
|
|
92
92
|
* Sends data through client object.
|
|
93
93
|
* The optional arguments i and j work exactly like the standard string.sub Lua function to allow the selection of a substring to be sent.
|
|
@@ -97,7 +97,7 @@ declare global {
|
|
|
97
97
|
* @param i - optional starting index of the string.
|
|
98
98
|
* @param j - optional end index of string.
|
|
99
99
|
*/
|
|
100
|
-
send(data: string, i?: number, j?: number): LuaMultiReturn<[number |
|
|
100
|
+
send(data: string, i?: number, j?: number): LuaMultiReturn<[number | undefined, string | undefined, number | undefined]>;
|
|
101
101
|
/**
|
|
102
102
|
* 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
|
|
103
103
|
*
|
|
@@ -128,7 +128,7 @@ declare global {
|
|
|
128
128
|
* Setting this option to `true` restricts an inet6 socket to sending and receiving only IPv6 packets.
|
|
129
129
|
* @param value - the value to set for the specified option.
|
|
130
130
|
*/
|
|
131
|
-
setoption(option: string, value?: unknown): LuaMultiReturn<[number |
|
|
131
|
+
setoption(option: string, value?: unknown): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
132
132
|
/**
|
|
133
133
|
* Resets accounting information on the socket, useful for throttling of bandwidth.
|
|
134
134
|
*
|
|
@@ -137,7 +137,7 @@ declare global {
|
|
|
137
137
|
* @param age - the new age in seconds.
|
|
138
138
|
* @returns the value `1` in case of success, or `nil` in case of error.
|
|
139
139
|
*/
|
|
140
|
-
setstats(received: number, sent: number, age: number): number |
|
|
140
|
+
setstats(received: number, sent: number, age: number): number | undefined;
|
|
141
141
|
/**
|
|
142
142
|
* 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
143
|
* There are two timeout modes and both can be used together for fine tuning.
|
|
@@ -198,7 +198,7 @@ declare global {
|
|
|
198
198
|
*
|
|
199
199
|
* - `"ip-drop-membership"`
|
|
200
200
|
*/
|
|
201
|
-
getoption(option: string): LuaMultiReturn<[unknown, string |
|
|
201
|
+
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
202
202
|
/**
|
|
203
203
|
* Retrieves information about the peer associated with a connected UDP object.
|
|
204
204
|
* It makes no sense to call this method on unconnected objects.
|
|
@@ -218,14 +218,14 @@ declare global {
|
|
|
218
218
|
*
|
|
219
219
|
* @param size - optional maximum size of the datagram to be retrieved. If there are more than size bytes available in the datagram, the excess bytes are discarded. If there are less then size bytes available in the current datagram, the available bytes are returned. If size is omitted, the maximum datagram size is used (which is currently limited by the implementation to 8192 bytes).
|
|
220
220
|
*/
|
|
221
|
-
receive(size?: number): LuaMultiReturn<[string |
|
|
221
|
+
receive(size?: number): LuaMultiReturn<[string | undefined, string | undefined]>;
|
|
222
222
|
/**
|
|
223
223
|
* Sends a datagram to the UDP peer of a connected object.
|
|
224
224
|
* In UDP, the send method never blocks and the only way it can fail is if the underlying transport layer refuses to send a message to the specified address (i.e. no interface accepts the address).
|
|
225
225
|
*
|
|
226
226
|
* @param datagram - a string with the datagram contents. The maximum datagram size for UDP is 64K minus IP layer overhead. However datagrams larger than the link layer packet size will be fragmented, which may deteriorate performance and/or reliability.
|
|
227
227
|
*/
|
|
228
|
-
send(datagram: string): LuaMultiReturn<[number |
|
|
228
|
+
send(datagram: string): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
229
229
|
/**
|
|
230
230
|
* Sets options for the UDP object. Options are only needed by low-level or time-critical applications. You should only modify an option if you are sure you need it.
|
|
231
231
|
*
|
|
@@ -262,7 +262,7 @@ declare global {
|
|
|
262
262
|
* - string `interface` (IP address)
|
|
263
263
|
* @param value - the value to set for the specified option.
|
|
264
264
|
*/
|
|
265
|
-
setoption(option: string, value?: unknown): LuaMultiReturn<[number |
|
|
265
|
+
setoption(option: string, value?: unknown): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
266
266
|
/**
|
|
267
267
|
* Changes the peer of a UDP object. This method turns an unconnected UDP object into a connected UDP object or vice versa.
|
|
268
268
|
* 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`.
|
|
@@ -270,7 +270,7 @@ declare global {
|
|
|
270
270
|
*
|
|
271
271
|
* @param arg0 - if address is "*" and the object is connected, the peer association is removed and the object becomes an unconnected object again.
|
|
272
272
|
*/
|
|
273
|
-
setpeername(arg0: string): LuaMultiReturn<[number |
|
|
273
|
+
setpeername(arg0: string): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
274
274
|
/**
|
|
275
275
|
* 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
276
|
* 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.
|
|
@@ -286,7 +286,7 @@ declare global {
|
|
|
286
286
|
* @param address - an IP address or a host name. If address is `"*"`, the system binds to all local interfaces using the `INADDR_ANY` constant.
|
|
287
287
|
* @param port - the port to commect to, in the range [0..64K). If port is 0, the system automatically chooses an ephemeral port.
|
|
288
288
|
*/
|
|
289
|
-
bind(address: string, port: number): LuaMultiReturn<[number |
|
|
289
|
+
bind(address: string, port: number): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
290
290
|
/**
|
|
291
291
|
* 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
292
|
* 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.
|
|
@@ -299,7 +299,7 @@ declare global {
|
|
|
299
299
|
* @param address - an IP address or a host name. If address is `"*"`, the system binds to all local interfaces using the `INADDR_ANY` constant.
|
|
300
300
|
* @param port - the port to commect to, in the range [0..64K). If port is 0, the system automatically chooses an ephemeral port.
|
|
301
301
|
*/
|
|
302
|
-
connect(address: string, port: number): LuaMultiReturn<[number |
|
|
302
|
+
connect(address: string, port: number): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
303
303
|
/**
|
|
304
304
|
* Check the read buffer status.
|
|
305
305
|
* This is an internal method, any use is unlikely to be portable.
|
|
@@ -331,7 +331,7 @@ declare global {
|
|
|
331
331
|
*
|
|
332
332
|
* @param backlog - the number of client connections that can be queued waiting for service. If the queue is full and another client attempts connection, the connection is refused.
|
|
333
333
|
*/
|
|
334
|
-
listen(backlog: number): LuaMultiReturn<[number |
|
|
334
|
+
listen(backlog: number): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
335
335
|
/**
|
|
336
336
|
* 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
|
|
337
337
|
*
|
|
@@ -346,7 +346,7 @@ declare global {
|
|
|
346
346
|
* @param age - the new age in seconds.
|
|
347
347
|
* @returns the value `1` in case of success, or `nil` in case of error.
|
|
348
348
|
*/
|
|
349
|
-
setstats(received: number, sent: number, age: number): number |
|
|
349
|
+
setstats(received: number, sent: number, age: number): number | undefined;
|
|
350
350
|
/**
|
|
351
351
|
* 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
352
|
* There are two timeout modes and both can be used together for fine tuning.
|
|
@@ -367,7 +367,7 @@ declare global {
|
|
|
367
367
|
* Waits for a remote connection on the server object and returns a client object representing that connection.
|
|
368
368
|
* Calling `socket.select` with a server object in the `recvt` parameter before a call to accept does not guarantee accept will return immediately. Use the `settimeout` method or accept might block until another client shows up.
|
|
369
369
|
*/
|
|
370
|
-
accept(): LuaMultiReturn<[client |
|
|
370
|
+
accept(): LuaMultiReturn<[client | undefined, string | undefined]>;
|
|
371
371
|
/**
|
|
372
372
|
* 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
373
|
* 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.
|
|
@@ -400,7 +400,7 @@ declare global {
|
|
|
400
400
|
*
|
|
401
401
|
* - `"tcp-nodelay"`
|
|
402
402
|
*/
|
|
403
|
-
getoption(option: string): LuaMultiReturn<[unknown, string |
|
|
403
|
+
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
404
404
|
/**
|
|
405
405
|
* Returns the local address information associated to the object.
|
|
406
406
|
*
|
|
@@ -443,7 +443,7 @@ declare global {
|
|
|
443
443
|
* Setting this option to `true` restricts an inet6 socket to sending and receiving only IPv6 packets.
|
|
444
444
|
* @param value - the value to set for the specified option.
|
|
445
445
|
*/
|
|
446
|
-
setoption(option: string, value?: unknown): LuaMultiReturn<[number |
|
|
446
|
+
setoption(option: string, value?: unknown): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
447
447
|
/**
|
|
448
448
|
* Resets accounting information on the socket, useful for throttling of bandwidth.
|
|
449
449
|
*
|
|
@@ -452,7 +452,7 @@ declare global {
|
|
|
452
452
|
* @param age - the new age in seconds.
|
|
453
453
|
* @returns the value `1` in case of success, or `nil` in case of error.
|
|
454
454
|
*/
|
|
455
|
-
setstats(received: number, sent: number, age: number): number |
|
|
455
|
+
setstats(received: number, sent: number, age: number): number | undefined;
|
|
456
456
|
/**
|
|
457
457
|
* 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
458
|
* There are two timeout modes and both can be used together for fine tuning.
|
|
@@ -499,7 +499,7 @@ declare global {
|
|
|
499
499
|
*
|
|
500
500
|
* - `"ip-drop-membership"`
|
|
501
501
|
*/
|
|
502
|
-
getoption(option: string): LuaMultiReturn<[unknown, string |
|
|
502
|
+
getoption(option: string): LuaMultiReturn<[unknown, string | undefined]>;
|
|
503
503
|
/**
|
|
504
504
|
* Returns the local address information associated to the object.
|
|
505
505
|
* 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).
|
|
@@ -512,13 +512,13 @@ declare global {
|
|
|
512
512
|
*
|
|
513
513
|
* @param size - optional maximum size of the datagram to be retrieved. If there are more than size bytes available in the datagram, the excess bytes are discarded. If there are less then size bytes available in the current datagram, the available bytes are returned. If size is omitted, the maximum datagram size is used (which is currently limited by the implementation to 8192 bytes).
|
|
514
514
|
*/
|
|
515
|
-
receive(size?: number): LuaMultiReturn<[string |
|
|
515
|
+
receive(size?: number): LuaMultiReturn<[string | undefined, string | undefined]>;
|
|
516
516
|
/**
|
|
517
517
|
* Works exactly as the receive method, except it returns the IP address and port as extra return values (and is therefore slightly less efficient).
|
|
518
518
|
*
|
|
519
519
|
* @param size - optional maximum size of the datagram to be retrieved.
|
|
520
520
|
*/
|
|
521
|
-
receivefrom(size?: number): LuaMultiReturn<[string |
|
|
521
|
+
receivefrom(size?: number): LuaMultiReturn<[string | undefined, string, number | undefined]>;
|
|
522
522
|
/**
|
|
523
523
|
* Sends a datagram to the specified IP address and port number.
|
|
524
524
|
* In UDP, the send method never blocks and the only way it can fail is if the underlying transport layer refuses to send a message to the specified address (i.e. no interface accepts the address).
|
|
@@ -527,7 +527,7 @@ declare global {
|
|
|
527
527
|
* @param ip - the IP address of the recipient. Host names are not allowed for performance reasons.
|
|
528
528
|
* @param port - the port number at the recipient.
|
|
529
529
|
*/
|
|
530
|
-
sendto(datagram: string, ip: string, port: number): LuaMultiReturn<[number |
|
|
530
|
+
sendto(datagram: string, ip: string, port: number): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
531
531
|
/**
|
|
532
532
|
* Sets options for the UDP object. Options are only needed by low-level or time-critical applications. You should only modify an option if you are sure you need it.
|
|
533
533
|
*
|
|
@@ -564,7 +564,7 @@ declare global {
|
|
|
564
564
|
* - string `interface` (IP address)
|
|
565
565
|
* @param value - the value to set for the specified option.
|
|
566
566
|
*/
|
|
567
|
-
setoption(option: string, value?: unknown): LuaMultiReturn<[number |
|
|
567
|
+
setoption(option: string, value?: unknown): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
568
568
|
/**
|
|
569
569
|
* Changes the peer of a UDP object. This method turns an unconnected UDP object into a connected UDP object or vice versa.
|
|
570
570
|
* 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`.
|
|
@@ -573,7 +573,7 @@ declare global {
|
|
|
573
573
|
* @param address - an IP address or a host name.
|
|
574
574
|
* @param port - the port number.
|
|
575
575
|
*/
|
|
576
|
-
setpeername(address: string, port: number): LuaMultiReturn<[number |
|
|
576
|
+
setpeername(address: string, port: number): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
577
577
|
/**
|
|
578
578
|
* Binds the UDP object to a local address.
|
|
579
579
|
* This method can only be called before any datagram is sent through the UDP object, and only once. Otherwise, the system automatically binds the object to all local interfaces and chooses an ephemeral port as soon as the first datagram is sent. After the local address is set, either automatically by the system or explicitly by `setsockname`, it cannot be changed.
|
|
@@ -581,7 +581,7 @@ declare global {
|
|
|
581
581
|
* @param address - an IP address or a host name. If address is "*" the system binds to all local interfaces using the constant `INADDR_ANY`.
|
|
582
582
|
* @param port - the port number. If port is 0, the system chooses an ephemeral port.
|
|
583
583
|
*/
|
|
584
|
-
setsockname(address: string, port: number): LuaMultiReturn<[number |
|
|
584
|
+
setsockname(address: string, port: number): LuaMultiReturn<[number | undefined, string | undefined]>;
|
|
585
585
|
/**
|
|
586
586
|
* 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.
|
|
587
587
|
* 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.
|
|
@@ -611,7 +611,7 @@ declare global {
|
|
|
611
611
|
* @param locport - optional local port to bind to.
|
|
612
612
|
* @param family - optional socket family to use, `"inet"` or `"inet6"`.
|
|
613
613
|
*/
|
|
614
|
-
function connect(address: string, port: number, locaddr?: string, locport?: number, family?: string): LuaMultiReturn<[client |
|
|
614
|
+
function connect(address: string, port: number, locaddr?: string, locport?: number, family?: string): LuaMultiReturn<[client | undefined, string | undefined]>;
|
|
615
615
|
/**
|
|
616
616
|
* Returns the time in seconds, relative to the system epoch (Unix epoch time since January 1, 1970 (UTC) or Windows file time since January 1, 1601 (UTC)).
|
|
617
617
|
* You should use the values returned by this function for relative measurements only.
|
|
@@ -681,7 +681,7 @@ declare global {
|
|
|
681
681
|
* @param sendt - array with sockets that are watched to see if it is OK to immediately write on them.
|
|
682
682
|
* @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.
|
|
683
683
|
*/
|
|
684
|
-
function select(recvt: (client | master | unconnected)[], sendt: (client | master | unconnected)[], timeout?: number): LuaMultiReturn<[(client | master | unconnected)[], (client | master | unconnected)[], string |
|
|
684
|
+
function select(recvt: (client | master | unconnected)[], sendt: (client | master | unconnected)[], timeout?: number): LuaMultiReturn<[(client | master | unconnected)[], (client | master | unconnected)[], string | undefined]>;
|
|
685
685
|
/**
|
|
686
686
|
* This function drops a number of arguments and returns the remaining.
|
|
687
687
|
* It is useful to avoid creation of dummy variables:
|
|
@@ -713,21 +713,21 @@ declare global {
|
|
|
713
713
|
/**
|
|
714
714
|
* Creates and returns an IPv4 TCP master object. A master object can be transformed into a server object with the method `listen` (after a call to `bind`) or into a client object with the method `connect`. The only other method supported by a master object is the `close` method.
|
|
715
715
|
*/
|
|
716
|
-
function tcp(): LuaMultiReturn<[master |
|
|
716
|
+
function tcp(): LuaMultiReturn<[master | undefined, string | undefined]>;
|
|
717
717
|
/**
|
|
718
718
|
* Creates and returns an IPv6 TCP master object. A master object can be transformed into a server object with the method `listen` (after a call to `bind`) or into a client object with the method connect. The only other method supported by a master object is the close method.
|
|
719
719
|
* Note: The TCP object returned will have the option "ipv6-v6only" set to true.
|
|
720
720
|
*/
|
|
721
|
-
function tcp6(): LuaMultiReturn<[master |
|
|
721
|
+
function tcp6(): LuaMultiReturn<[master | undefined, string | undefined]>;
|
|
722
722
|
/**
|
|
723
723
|
* Creates and returns an unconnected IPv4 UDP object. Unconnected objects support the `sendto`, `receive`, `receivefrom`, `getoption`, `getsockname`, `setoption`, `settimeout`, `setpeername`, `setsockname`, and `close` methods. The `setpeername` method is used to connect the object.
|
|
724
724
|
*/
|
|
725
|
-
function udp(): LuaMultiReturn<[unconnected |
|
|
725
|
+
function udp(): LuaMultiReturn<[unconnected | undefined, string | undefined]>;
|
|
726
726
|
/**
|
|
727
727
|
* Creates and returns an unconnected IPv6 UDP object. Unconnected objects support the `sendto`, `receive`, `receivefrom`, `getoption`, `getsockname`, `setoption`, `settimeout`, `setpeername`, `setsockname`, and `close` methods. The `setpeername` method is used to connect the object.
|
|
728
728
|
* Note: The UDP object returned will have the option "ipv6-v6only" set to true.
|
|
729
729
|
*/
|
|
730
|
-
function udp6(): LuaMultiReturn<[unconnected |
|
|
730
|
+
function udp6(): LuaMultiReturn<[unconnected | undefined, string | undefined]>;
|
|
731
731
|
namespace dns {
|
|
732
732
|
/**
|
|
733
733
|
* This function converts a host name to IPv4 or IPv6 address.
|
|
@@ -752,7 +752,7 @@ declare global {
|
|
|
752
752
|
*
|
|
753
753
|
* @param address - a hostname or an IPv4 or IPv6 address.
|
|
754
754
|
*/
|
|
755
|
-
function getaddrinfo(address: string): LuaMultiReturn<[Record<string | number, unknown> |
|
|
755
|
+
function getaddrinfo(address: string): LuaMultiReturn<[Record<string | number, unknown> | undefined, string | undefined]>;
|
|
756
756
|
/**
|
|
757
757
|
* Returns the standard host name for the machine as a string.
|
|
758
758
|
*
|
|
@@ -773,21 +773,21 @@ declare global {
|
|
|
773
773
|
*
|
|
774
774
|
* @param address - a hostname or an IPv4 or IPv6 address.
|
|
775
775
|
*/
|
|
776
|
-
function getnameinfo(address: string): LuaMultiReturn<[Record<string | number, unknown> |
|
|
776
|
+
function getnameinfo(address: string): LuaMultiReturn<[Record<string | number, unknown> | undefined, string | undefined]>;
|
|
777
777
|
/**
|
|
778
778
|
* This function converts from an IPv4 address to host name.
|
|
779
779
|
* The address can be an IPv4 address or a host name.
|
|
780
780
|
*
|
|
781
781
|
* @param address - an IPv4 address or host name.
|
|
782
782
|
*/
|
|
783
|
-
function tohostname(address: string): LuaMultiReturn<[string |
|
|
783
|
+
function tohostname(address: string): LuaMultiReturn<[string | undefined, Record<string | number, unknown> | string]>;
|
|
784
784
|
/**
|
|
785
785
|
* This function converts a host name to IPv4 address.
|
|
786
786
|
* The address can be an IP address or a host name.
|
|
787
787
|
*
|
|
788
788
|
* @param address - a hostname or an IP address.
|
|
789
789
|
*/
|
|
790
|
-
function toip(address: string): LuaMultiReturn<[string |
|
|
790
|
+
function toip(address: string): LuaMultiReturn<[string | undefined, Record<string | number, unknown> | string]>;
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
793
|
}
|
|
@@ -498,7 +498,7 @@ declare global {
|
|
|
498
498
|
* }
|
|
499
499
|
* ```
|
|
500
500
|
*/
|
|
501
|
-
function load_resource(filename: string): LuaMultiReturn<[string |
|
|
501
|
+
function load_resource(filename: string): LuaMultiReturn<[string | undefined, string | undefined]>;
|
|
502
502
|
/**
|
|
503
503
|
* Open URL in default application, typically a browser
|
|
504
504
|
*
|
|
@@ -91,7 +91,7 @@ declare global {
|
|
|
91
91
|
* }
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
|
-
function get_info(handle: number): { time_remaining: number; delay: number; repeating: boolean } |
|
|
94
|
+
function get_info(handle: number): { time_remaining: number; delay: number; repeating: boolean } | undefined;
|
|
95
95
|
/**
|
|
96
96
|
* Manual triggering a callback for a timer.
|
|
97
97
|
*
|
package/package.json
CHANGED
|
@@ -31,8 +31,7 @@ export function renderMaterializedKindIndex(opts: RenderMaterializedKindIndexOpt
|
|
|
31
31
|
return `${LUA_STDLIB_REFERENCES}${lines.join("\n")}\n\nexport { ${entry.factory} } from "@defold-typescript/types/lifecycle";\nexport type { ScriptProperties, ScriptProperty } from "@defold-typescript/types/lifecycle";\n`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export interface
|
|
35
|
-
readonly destDir: string;
|
|
34
|
+
export interface BuildVersionedSurfaceOptions {
|
|
36
35
|
readonly resolveOpts?: ResolveTargetOptions;
|
|
37
36
|
// Bare module names (no `.d.ts`) to omit from the surface — both the emitted
|
|
38
37
|
// file and its aggregate-index import. Lets a caller narrow the surface to a
|
|
@@ -40,35 +39,61 @@ export interface MaterializeVersionedSurfaceOptions {
|
|
|
40
39
|
readonly excludeModules?: readonly string[];
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
export interface MaterializeVersionedSurfaceOptions extends BuildVersionedSurfaceOptions {
|
|
43
|
+
readonly destDir: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface VersionedSurfaceFile {
|
|
47
|
+
// Relative to the surface root, so a sink can write it to disk or key it in
|
|
48
|
+
// object storage without rewriting the path.
|
|
49
|
+
readonly path: string;
|
|
50
|
+
readonly contents: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Generate a versioned surface as an in-memory file map: resolve the target's
|
|
54
|
+
// module docs (ref-doc or committed fixture), emit each module declaration, then
|
|
55
|
+
// the aggregate side-effect entrypoint and a minimal package.json. Pure — no
|
|
56
|
+
// `node:fs` — so a Worker with no filesystem can serve a version generated at
|
|
57
|
+
// request time; `materializeVersionedSurface` is the disk sink over the same map.
|
|
58
|
+
export async function buildVersionedSurfaceFiles(
|
|
49
59
|
target: ApiTarget,
|
|
50
|
-
opts:
|
|
51
|
-
): Promise<
|
|
60
|
+
opts: BuildVersionedSurfaceOptions = {},
|
|
61
|
+
): Promise<VersionedSurfaceFile[]> {
|
|
52
62
|
const exclude = new Set(opts.excludeModules ?? []);
|
|
53
63
|
const modules = (await resolveTargetModules(target, opts.resolveOpts ?? {})).filter(
|
|
54
64
|
(entry) => !exclude.has(entry.outFile.replace(/\.d\.ts$/, "")),
|
|
55
65
|
);
|
|
56
|
-
mkdirSync(opts.destDir, { recursive: true });
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
67
|
+
const files: VersionedSurfaceFile[] = modules.map((entry) => ({
|
|
68
|
+
path: entry.outFile,
|
|
69
|
+
contents: generateModuleDeclaration(entry).contents,
|
|
70
|
+
}));
|
|
62
71
|
|
|
63
72
|
const versioned = modules.map((entry) => ({ ...entry, versionId: target.id }));
|
|
64
|
-
|
|
73
|
+
files.push({ path: "index.d.ts", contents: generateVersionIndex(target.id, versioned) });
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`${JSON.stringify(
|
|
75
|
+
files.push({
|
|
76
|
+
path: "package.json",
|
|
77
|
+
contents: `${JSON.stringify(
|
|
69
78
|
{ name: `@defold-typescript/materialized-${target.id}`, types: "index.d.ts" },
|
|
70
79
|
null,
|
|
71
80
|
2,
|
|
72
81
|
)}\n`,
|
|
73
|
-
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return files;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Write the generated surface into a project-local faux `@types` package.
|
|
88
|
+
// ref-doc targets are never pre-baked, so this is the only path that turns a
|
|
89
|
+
// resolved version into a consumable on-disk type surface.
|
|
90
|
+
export async function materializeVersionedSurface(
|
|
91
|
+
target: ApiTarget,
|
|
92
|
+
opts: MaterializeVersionedSurfaceOptions,
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
const files = await buildVersionedSurfaceFiles(target, opts);
|
|
95
|
+
mkdirSync(opts.destDir, { recursive: true });
|
|
96
|
+
for (const file of files) {
|
|
97
|
+
writeFileSync(resolve(opts.destDir, file.path), file.contents);
|
|
98
|
+
}
|
|
74
99
|
}
|
package/src/emit-dts.ts
CHANGED
|
@@ -2057,6 +2057,13 @@ function mapSlotUnion(
|
|
|
2057
2057
|
ts = mapType(token);
|
|
2058
2058
|
}
|
|
2059
2059
|
}
|
|
2060
|
+
} else if (token === "nil" && slotKind === "return") {
|
|
2061
|
+
// A top-level ref-doc `nil` return alternative is the engine's absence
|
|
2062
|
+
// sentinel: project it to `undefined` (TSTL lowers `undefined` to Lua
|
|
2063
|
+
// `nil`) instead of the generic `unknown` fallback that would absorb the
|
|
2064
|
+
// concrete member. Parameters strip `nil` upstream, so this reaches only
|
|
2065
|
+
// return slots.
|
|
2066
|
+
ts = "undefined";
|
|
2060
2067
|
} else {
|
|
2061
2068
|
const curated =
|
|
2062
2069
|
slotKind !== undefined && slotName !== undefined
|
|
@@ -2068,6 +2075,10 @@ function mapSlotUnion(
|
|
|
2068
2075
|
seen.add(ts);
|
|
2069
2076
|
mapped.push(ts);
|
|
2070
2077
|
}
|
|
2078
|
+
// A genuine `unknown` member (an `any` slot, including `any | nil`) absorbs
|
|
2079
|
+
// every other union member, so collapse to exactly `unknown` rather than emit
|
|
2080
|
+
// a redundant `T | unknown` or `unknown | undefined`.
|
|
2081
|
+
if (mapped.includes("unknown")) return "unknown";
|
|
2071
2082
|
return mapped.join(" | ");
|
|
2072
2083
|
}
|
|
2073
2084
|
|