@ts-defold/types 1.1.16 → 1.2.3

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.
Files changed (2) hide show
  1. package/index.d.ts +132 -7
  2. package/package.json +8 -4
package/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /** @noSelfInFile */
2
2
  /// <reference types="lua-types/5.1" />
3
+ /// <reference types="typescript-to-lua/language-extensions" />
3
4
 
4
- // DEFOLD. stable version 1.2.186 (1f748d5b0a84e8b5c58bf747e4c48d153ef77a52)
5
+ // DEFOLD. stable version 1.2.187 (581c6439ae93755a8a6bcf58732c39c724fa193c)
5
6
  // =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
6
7
 
7
8
 
@@ -97,6 +98,130 @@ declare function pprint(v: any): void
97
98
  // =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
98
99
 
99
100
 
101
+ declare namespace socket {
102
+
103
+ /**
104
+ * max numbers of sockets the select function can handle
105
+ */
106
+ export let _SETSIZE: any
107
+
108
+ /**
109
+ * the current LuaSocket version
110
+ */
111
+ export let _VERSION: any
112
+
113
+ /**
114
+ * This function is a shortcut that creates and returns a TCP client object connected to a remote
115
+ * address at a given port. Optionally, the user can also specify the local address and port to
116
+ * bind (`locaddr` and `locport`), or restrict the socket family to `"inet"` or `"inet6"`.
117
+ * Without specifying family to connect, whether a tcp or tcp6 connection is created depends on
118
+ * your system configuration.
119
+ * @param address the address to connect to.
120
+ * @param port the port to connect to.
121
+ * @param locaddr optional local address to bind to.
122
+ * @param locport optional local port to bind to.
123
+ * @param family optional socket family to use, `"inet"` or `"inet6"`.
124
+ * @return tcp_client a new IPv6 TCP client object, or `nil` in case of error.
125
+ * @return error the error message, or `nil` if no error occurred.
126
+ */
127
+ export function connect(address: string, port: number, locaddr?: string, locport?: number, family?: string): LuaMultiReturn<[any, string]>
128
+
129
+ /**
130
+ * 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)).
131
+ * You should use the values returned by this function for relative measurements only.
132
+ * @return seconds the number of seconds elapsed.
133
+ */
134
+ export function gettime(): number
135
+
136
+ /**
137
+ * This function creates and returns a clean try function that allows for cleanup before the exception is raised.
138
+ * The `finalizer` function will be called in protected mode (see protect).
139
+ * @param finalizer a function that will be called before the try throws the exception.
140
+ * @return try the customized try function.
141
+ */
142
+ export function newtry(finalizer: any): any
143
+
144
+ /**
145
+ * 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.
146
+ * ⚠ 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.
147
+ * @param func a function that calls a try function (or assert, or error) to throw exceptions.
148
+ * @return safe_func an equivalent function that instead of throwing exceptions, returns `nil` followed by an error message.
149
+ */
150
+ export function protect(func: any): any
151
+
152
+ /**
153
+ * 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.
154
+ * `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.
155
+ * 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.
156
+ * ⚠ This function can monitor a limited number of sockets, as defined by the constant socket._SETSIZE. This number may be as high as 1024 or as low as 64 by default, depending on the system. It is usually possible to change this at compile time. Invoking select with a larger number of sockets will raise an error.
157
+ * ⚠ A known bug in WinSock causes select to fail on non-blocking TCP sockets. The function may return a socket as writable even though the socket is not ready for sending.
158
+ * ⚠ Calling select with a server socket in the receive parameter before a call to accept does not guarantee accept will return immediately. Use the settimeout method or accept might block forever.
159
+ * ⚠ If you close a socket and pass it to select, it will be ignored.
160
+ * (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.)
161
+ * @param recvt array with the sockets to test for characters available for reading.
162
+ * @param sendt array with sockets that are watched to see if it is OK to immediately write on them.
163
+ * @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.
164
+ * @return sockets_r a list with the sockets ready for reading.
165
+ * @return sockets_w a list with the sockets ready for writing.
166
+ * @return error an error message. "timeout" if a timeout condition was met, otherwise `nil`.
167
+ */
168
+ export function select(recvt: any, sendt: any, timeout?: number): LuaMultiReturn<[any, any, string]>
169
+
170
+ /**
171
+ * This function drops a number of arguments and returns the remaining.
172
+ * It is useful to avoid creation of dummy variables:
173
+ * `D` is the number of arguments to drop. `Ret1` to `retN` are the arguments.
174
+ * The function returns `retD+1` to `retN`.
175
+ * @param d the number of arguments to drop.
176
+ * @param ret1 argument 1.
177
+ * @param ret2 argument 2.
178
+ * @param retN argument N.
179
+ * @return retD_1 argument D+1.
180
+ * @return retD_2 argument D+2.
181
+ * @return retN argument N.
182
+ */
183
+ export function skip(d: number, ret1?: any, ret2?: any, retN?: any): LuaMultiReturn<[any, any, any]> | undefined
184
+
185
+ /**
186
+ * Freezes the program execution during a given amount of time.
187
+ * @param time the number of seconds to sleep for.
188
+ */
189
+ export function sleep(time: number): void
190
+
191
+ /**
192
+ * 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.
193
+ * @return tcp_master a new IPv4 TCP master object, or `nil` in case of error.
194
+ * @return error the error message, or `nil` if no error occurred.
195
+ */
196
+ export function tcp(): LuaMultiReturn<[any, string]>
197
+
198
+ /**
199
+ * 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.
200
+ * Note: The TCP object returned will have the option "ipv6-v6only" set to true.
201
+ * @return tcp_master a new IPv6 TCP master object, or `nil` in case of error.
202
+ * @return error the error message, or `nil` if no error occurred.
203
+ */
204
+ export function tcp6(): LuaMultiReturn<[any, string]>
205
+
206
+ /**
207
+ * 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.
208
+ * @return udp_unconnected a new unconnected IPv4 UDP object, or `nil` in case of error.
209
+ * @return error the error message, or `nil` if no error occurred.
210
+ */
211
+ export function udp(): LuaMultiReturn<[any, string]>
212
+
213
+ /**
214
+ * 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.
215
+ * Note: The UDP object returned will have the option "ipv6-v6only" set to true.
216
+ * @return udp_unconnected a new unconnected IPv6 UDP object, or `nil` in case of error.
217
+ * @return error the error message, or `nil` if no error occurred.
218
+ */
219
+ export function udp6(): LuaMultiReturn<[any, string]>
220
+
221
+ }
222
+ // =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
223
+
224
+
100
225
  declare namespace crash {
101
226
 
102
227
  /**
@@ -1923,7 +2048,7 @@ with a custom curve. See the animation guide for more information.
1923
2048
  * @return success texture creation was successful
1924
2049
  * @return code one of the gui.RESULT_* codes if unsuccessful
1925
2050
  */
1926
- export function new_texture(texture: string | hash, width: number, height: number, type: any, buffer: string, flip: boolean): boolean
2051
+ export function new_texture(texture: string | hash, width: number, height: number, type: any, buffer: string, flip: boolean): LuaMultiReturn<[boolean, number]>
1927
2052
 
1928
2053
  /**
1929
2054
  * Tests whether a coordinate is within the bounding box of a
@@ -4215,7 +4340,7 @@ The HTTP user agent, i.e. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) Apple
4215
4340
  * @return data loaded data, or `nil` if the resource could not be loaded
4216
4341
  * @return error the error message, or `nil` if no error occurred
4217
4342
  */
4218
- export function load_resource(filename: string): string
4343
+ export function load_resource(filename: string): LuaMultiReturn<[string, string]>
4219
4344
 
4220
4345
  /**
4221
4346
  * Open URL in default application, typically a browser
@@ -4394,7 +4519,7 @@ declare namespace window {
4394
4519
  * @return width The window width
4395
4520
  * @return height The window height
4396
4521
  */
4397
- export function get_size(): number
4522
+ export function get_size(): LuaMultiReturn<[number, number]>
4398
4523
 
4399
4524
  /**
4400
4525
  * 🤖 Sets the dimming mode on a mobile device.
@@ -5867,7 +5992,7 @@ declare namespace sound {
5867
5992
  * @return peak_l peak value for left channel
5868
5993
  * @return peak_r peak value for right channel
5869
5994
  */
5870
- export function get_peak(group: string | hash, window: number): number
5995
+ export function get_peak(group: string | hash, window: number): LuaMultiReturn<[number, number]>
5871
5996
 
5872
5997
  /**
5873
5998
  * Get RMS (Root Mean Square) value from mixer group. This value is the
@@ -5882,7 +6007,7 @@ declare namespace sound {
5882
6007
  * @return rms_l RMS value for left channel
5883
6008
  * @return rms_r RMS value for right channel
5884
6009
  */
5885
- export function get_rms(group: string | hash, window: number): number
6010
+ export function get_rms(group: string | hash, window: number): LuaMultiReturn<[number, number]>
5886
6011
 
5887
6012
  /**
5888
6013
  * Checks if background music is playing, e.g. from iTunes.
@@ -6311,7 +6436,7 @@ declare namespace tilemap {
6311
6436
  * @return w number of columns (width) in the tile map
6312
6437
  * @return h number of rows (height) in the tile map
6313
6438
  */
6314
- export function get_bounds(url: string | hash | url): number
6439
+ export function get_bounds(url: string | hash | url): LuaMultiReturn<[number, number, number, number]>
6315
6440
 
6316
6441
  /**
6317
6442
  * Get the tile set at the specified position in the tilemap.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-defold/types",
3
- "version": "1.1.16",
3
+ "version": "1.2.3",
4
4
  "description": "TypeScript definitions for Defold",
5
5
  "repository": "github:ts-defold/types",
6
6
  "keywords": [
@@ -24,10 +24,14 @@
24
24
  "version": "latest"
25
25
  },
26
26
  "dependencies": {
27
- "lua-types": "2.8.0"
27
+ "lua-types": "^2.10.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@ts-defold/type-gen": "^0.2.10",
31
- "typescript": "^4.3.5"
30
+ "@ts-defold/type-gen": "^0.5.0",
31
+ "typescript": "4.3.4",
32
+ "typescript-to-lua": "^1.0.1"
33
+ },
34
+ "peerDependencies": {
35
+ "typescript-to-lua": "^1.0.1"
32
36
  }
33
37
  }