@defold-typescript/types 0.5.5 → 0.6.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.
Files changed (53) hide show
  1. package/api-targets.json +1 -1
  2. package/generated/b2d.d.ts +3 -0
  3. package/generated/buffer.d.ts +44 -38
  4. package/generated/builtin-messages.d.ts +1 -1
  5. package/generated/camera.d.ts +3 -0
  6. package/generated/collectionfactory.d.ts +47 -40
  7. package/generated/collectionproxy.d.ts +23 -18
  8. package/generated/crash.d.ts +3 -0
  9. package/generated/factory.d.ts +32 -24
  10. package/generated/go.d.ts +123 -124
  11. package/generated/graphics.d.ts +3 -0
  12. package/generated/gui.d.ts +303 -283
  13. package/generated/http.d.ts +26 -16
  14. package/generated/iac.d.ts +3 -0
  15. package/generated/iap.d.ts +6 -3
  16. package/generated/image.d.ts +30 -26
  17. package/generated/json.d.ts +36 -32
  18. package/generated/kinds/gui-script.d.ts +7 -5
  19. package/generated/kinds/render-script.d.ts +7 -5
  20. package/generated/kinds/script.d.ts +7 -5
  21. package/generated/label.d.ts +16 -9
  22. package/generated/liveupdate.d.ts +29 -26
  23. package/generated/model.d.ts +57 -45
  24. package/generated/msg.d.ts +3 -0
  25. package/generated/particlefx.d.ts +50 -34
  26. package/generated/physics.d.ts +153 -133
  27. package/generated/profiler.d.ts +45 -41
  28. package/generated/push.d.ts +5 -2
  29. package/generated/render.d.ts +410 -349
  30. package/generated/resource.d.ts +619 -572
  31. package/generated/socket.d.ts +49 -33
  32. package/generated/sound.d.ts +83 -72
  33. package/generated/sprite.d.ts +3 -0
  34. package/generated/sys.d.ts +198 -189
  35. package/generated/tilemap.d.ts +43 -39
  36. package/generated/timer.d.ts +42 -36
  37. package/generated/vmath.d.ts +22 -0
  38. package/generated/webview.d.ts +3 -0
  39. package/generated/window.d.ts +23 -17
  40. package/generated/zlib.d.ts +15 -12
  41. package/index.d.ts +3 -1
  42. package/package.json +6 -2
  43. package/scripts/fidelity-audit.ts +61 -1
  44. package/scripts/fidelity-baseline.json +10 -10
  45. package/scripts/ref-doc-delta.ts +143 -0
  46. package/scripts/regen.ts +18 -9
  47. package/src/core-types.ts +14 -0
  48. package/src/emit-dts.ts +219 -13
  49. package/src/engine-globals.d.ts +2 -0
  50. package/src/go-overloads.d.ts +43 -0
  51. package/src/index.ts +5 -0
  52. package/src/lifecycle.ts +157 -16
  53. package/src/publish-dts.ts +1 -1
@@ -2,6 +2,22 @@
2
2
  import type { Opaque } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * [LuaSocket](https://github.com/diegonehab/luasocket) is a Lua extension library that provides
7
+ * support for the TCP and UDP transport layers. Defold provides the "socket" namespace in
8
+ * runtime, which contain the core C functionality. Additional LuaSocket support modules for
9
+ * SMTP, HTTP, FTP etc are not part of the core included, but can be easily added to a project
10
+ * and used.
11
+ * [icon:html5] On HTML5, the non-network helpers remain available, but TCP, UDP and
12
+ * `socket.select()` are not supported.
13
+ * Note the included helper module "socket.lua" in "builtins/scripts/socket.lua". Require this
14
+ * module to add some additional functions and shortcuts to the namespace:
15
+ * ```lua
16
+ * require "builtins.scripts.socket"
17
+ * ```
18
+ * LuaSocket is Copyright © 2004-2007 Diego Nehab. All rights reserved.
19
+ * LuaSocket is free software, released under the MIT license (same license as the Lua core).
20
+ */
5
21
  namespace socket {
6
22
  type client = Opaque<"client">;
7
23
  type master = Opaque<"master">;
@@ -34,11 +50,11 @@ declare global {
34
50
  *
35
51
  * @returns the number of seconds elapsed.
36
52
  * @example
37
- * ```lua
38
- * How to use the gettime() function to measure running time:
39
- * t = socket.gettime()
40
- * -- do stuff
41
- * print(socket.gettime() - t .. " seconds elapsed")
53
+ * ```ts
54
+ * // How to use the gettime() function to measure running time:
55
+ * const t = socket.gettime();
56
+ * // do stuff
57
+ * print(`${socket.gettime() - t} seconds elapsed`);
42
58
  * ```
43
59
  */
44
60
  function gettime(): number;
@@ -49,16 +65,16 @@ declare global {
49
65
  * @param finalizer - a function that will be called before the try throws the exception.
50
66
  * @returns the customized try function.
51
67
  * @example
52
- * ```lua
53
- * Perform operations on an open socket c:
54
- * -- create a try function that closes 'c' on error
55
- * local try = socket.newtry(function() c:close() end)
56
- * -- do everything reassured c will be closed
57
- * try(c:send("hello there?\r\n"))
58
- * local answer = try(c:receive())
59
- * ...
60
- * try(c:send("good bye\r\n"))
61
- * c:close()
68
+ * ```ts
69
+ * // Perform operations on an open socket c:
70
+ * // create a try function that closes 'c' on error
71
+ * const try_ = socket.newtry(() => c.close());
72
+ * // do everything reassured c will be closed
73
+ * try_(c.send("hello there?\r\n"));
74
+ * const answer = try_(c.receive());
75
+ * // ...
76
+ * try_(c.send("good bye\r\n"));
77
+ * c.close();
62
78
  * ```
63
79
  */
64
80
  function newtry(finalizer: () => void): (...args: unknown[]) => unknown;
@@ -69,17 +85,17 @@ declare global {
69
85
  * @param func - a function that calls a try function (or assert, or error) to throw exceptions.
70
86
  * @returns an equivalent function that instead of throwing exceptions, returns `nil` followed by an error message.
71
87
  * @example
72
- * ```lua
73
- * local dostuff = socket.protect(function()
74
- * local try = socket.newtry()
75
- * local c = try(socket.connect("myserver.com", 80))
76
- * try = socket.newtry(function() c:close() end)
77
- * try(c:send("hello?\r\n"))
78
- * local answer = try(c:receive())
79
- * c:close()
80
- * end)
88
+ * ```ts
89
+ * const dostuff = socket.protect(() => {
90
+ * let try_ = socket.newtry();
91
+ * const c = try_(socket.connect("myserver.com", 80));
92
+ * try_ = socket.newtry(() => c.close());
93
+ * try_(c.send("hello?\r\n"));
94
+ * const answer = try_(c.receive());
95
+ * c.close();
96
+ * });
81
97
  *
82
- * local n, error = dostuff()
98
+ * const [n, error] = dostuff();
83
99
  * ```
84
100
  */
85
101
  function protect(func: (...args: unknown[]) => unknown): (arg0: unknown) => void;
@@ -97,7 +113,7 @@ declare global {
97
113
  * @param sendt - array with sockets that are watched to see if it is OK to immediately write on them.
98
114
  * @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.
99
115
  */
100
- function select(recvt: Record<string | number, unknown>, sendt: Record<string | number, unknown>, timeout?: number): LuaMultiReturn<[Record<string | number, unknown>, Record<string | number, unknown>, string | unknown]>;
116
+ function select(recvt: (Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], sendt: (Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], timeout?: number): LuaMultiReturn<[(Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], (Opaque<"client"> | Opaque<"master"> | Opaque<"unconnected">)[], string | unknown]>;
101
117
  /**
102
118
  * This function drops a number of arguments and returns the remaining.
103
119
  * It is useful to avoid creation of dummy variables:
@@ -109,14 +125,14 @@ declare global {
109
125
  * @param ret2 - argument 2.
110
126
  * @param retN - argument N.
111
127
  * @example
112
- * ```lua
113
- * Instead of doing the following with dummy variables:
114
- * -- get the status code and separator from SMTP server reply
115
- * local dummy1, dummy2, code, sep = string.find(line, "^(%d%d%d)(.?)")
128
+ * ```ts
129
+ * // Instead of doing the following with dummy variables:
130
+ * // get the status code and separator from SMTP server reply
131
+ * const [dummy1, dummy2, code, sep] = string.find(line, "^(%d%d%d)(.?)");
116
132
  *
117
- * You can skip a number of variables:
118
- * -- get the status code and separator from SMTP server reply
119
- * local code, sep = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"))
133
+ * // You can skip a number of variables:
134
+ * // get the status code and separator from SMTP server reply
135
+ * const [code, sep] = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"));
120
136
  * ```
121
137
  */
122
138
  function skip(d: number, ret1?: unknown, ret2?: unknown, retN?: unknown): LuaMultiReturn<[unknown, unknown, unknown]>;
@@ -2,6 +2,10 @@
2
2
  import type { Hash, Url } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions and messages for controlling sound components and
7
+ * mixer groups.
8
+ */
5
9
  namespace sound {
6
10
  /**
7
11
  * Get mixer group gain
@@ -9,10 +13,10 @@ declare global {
9
13
  * @param group - group name
10
14
  * @returns gain in [0 1] range ([-60dB.. 0dB])
11
15
  * @example
12
- * ```lua
13
- * Get the mixer group gain for the "soundfx" and convert to dB:
14
- * local gain = sound.get_group_gain("soundfx")
15
- * local gain_db = 60 * gain
16
+ * ```ts
17
+ * // Get the mixer group gain for the "soundfx" and convert to dB:
18
+ * const gain = sound.get_group_gain("soundfx");
19
+ * const gain_db = 60 * gain;
16
20
  * ```
17
21
  */
18
22
  function get_group_gain(group: string | Hash): number;
@@ -25,13 +29,13 @@ declare global {
25
29
  * @param group - group name
26
30
  * @returns group name
27
31
  * @example
28
- * ```lua
29
- * Get the mixer group string names so we can show them as labels on a dev mixer overlay:
30
- * local groups = sound.get_groups()
31
- * for _,group in ipairs(groups) do
32
- * local name = sound.get_group_name(group)
33
- * msg.post("/mixer_overlay#gui", "set_mixer_label", { group = group, label = name})
34
- * end
32
+ * ```ts
33
+ * // Get the mixer group string names so we can show them as labels on a dev mixer overlay:
34
+ * const groups = sound.get_groups();
35
+ * for (const group of groups) {
36
+ * const name = sound.get_group_name(group);
37
+ * msg.post("/mixer_overlay#gui", "set_mixer_label", { group: group, label: name });
38
+ * }
35
39
  * ```
36
40
  */
37
41
  function get_group_name(group: string | Hash): string;
@@ -40,17 +44,17 @@ declare global {
40
44
  *
41
45
  * @returns table of mixer group names
42
46
  * @example
43
- * ```lua
44
- * Get the mixer groups, set all gains to 0 except for "master" and "soundfx"
45
- * where gain is set to 1:
46
- * local groups = sound.get_groups()
47
- * for _,group in ipairs(groups) do
48
- * if group == hash("master") or group == hash("soundfx") then
49
- * sound.set_group_gain(group, 1)
50
- * else
51
- * sound.set_group_gain(group, 0)
52
- * end
53
- * end
47
+ * ```ts
48
+ * // Get the mixer groups, set all gains to 0 except for "master" and "soundfx"
49
+ * // where gain is set to 1:
50
+ * const groups = sound.get_groups();
51
+ * for (const group of groups) {
52
+ * if (group === hash("master") || group === hash("soundfx")) {
53
+ * sound.set_group_gain(group, 1);
54
+ * } else {
55
+ * sound.set_group_gain(group, 0);
56
+ * }
57
+ * }
54
58
  * ```
55
59
  */
56
60
  function get_groups(): Hash[];
@@ -66,11 +70,11 @@ declare global {
66
70
  * @param group - group name
67
71
  * @param window - window length in seconds
68
72
  * @example
69
- * ```lua
70
- * Get the peak gain from the "master" group and convert to dB for displaying:
71
- * local left_p, right_p = sound.get_peak("master", 0.1)
72
- * left_p_db = 20 * log(left_p)
73
- * right_p_db = 20 * log(right_p)
73
+ * ```ts
74
+ * // Get the peak gain from the "master" group and convert to dB for displaying:
75
+ * const [left_p, right_p] = sound.get_peak("master", 0.1);
76
+ * const left_p_db = 20 * Math.log(left_p);
77
+ * const right_p_db = 20 * Math.log(right_p);
74
78
  * ```
75
79
  */
76
80
  function get_peak(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
@@ -86,10 +90,10 @@ declare global {
86
90
  * @param group - group name
87
91
  * @param window - window length in seconds
88
92
  * @example
89
- * ```lua
90
- * Get the RMS from the "master" group where a mono -1.94 dB sinewave is playing:
91
- * local rms = sound.get_rms("master", 0.1) -- throw away right channel.
92
- * print(rms) --> 0.56555819511414
93
+ * ```ts
94
+ * // Get the RMS from the "master" group where a mono -1.94 dB sinewave is playing:
95
+ * const [rms] = sound.get_rms("master", 0.1); // throw away right channel.
96
+ * print(rms); // => 0.56555819511414
93
97
  * ```
94
98
  */
95
99
  function get_rms(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
@@ -109,12 +113,12 @@ declare global {
109
113
  *
110
114
  * @returns `true` if music is playing, otherwise `false`.
111
115
  * @example
112
- * ```lua
113
- * If music is playing, mute "master":
114
- * if sound.is_music_playing() then
115
- * -- mute "master"
116
- * sound.set_group_gain("master", 0)
117
- * end
116
+ * ```ts
117
+ * // If music is playing, mute "master":
118
+ * if (sound.is_music_playing()) {
119
+ * // mute "master"
120
+ * sound.set_group_gain("master", 0);
121
+ * }
118
122
  * ```
119
123
  */
120
124
  function is_music_playing(): boolean;
@@ -126,11 +130,11 @@ declare global {
126
130
  *
127
131
  * @returns `true` if there is an active phone call, `false` otherwise.
128
132
  * @example
129
- * ```lua
130
- * Test if a phone call is on-going:
131
- * if sound.is_phone_call_active() then
132
- * -- do something sensible.
133
- * end
133
+ * ```ts
134
+ * // Test if a phone call is on-going:
135
+ * if (sound.is_phone_call_active()) {
136
+ * // do something sensible.
137
+ * }
134
138
  * ```
135
139
  */
136
140
  function is_phone_call_active(): boolean;
@@ -140,9 +144,10 @@ declare global {
140
144
  * @param url - the sound that should pause
141
145
  * @param pause - true if the sound should pause
142
146
  * @example
143
- * ```lua
144
- * Assuming the script belongs to an instance with a sound-component with id "sound", this will make the component pause all playing voices:
145
- * sound.pause("#sound", true)
147
+ * ```ts
148
+ * // Assuming the script belongs to an instance with a sound-component with id
149
+ * // "sound", this will make the component pause all playing voices:
150
+ * sound.pause("#sound", true);
146
151
  * ```
147
152
  */
148
153
  function pause(url: string | Hash | Url, pause: boolean): void;
@@ -176,21 +181,24 @@ declare global {
176
181
  * url The invoker of the callback: the sound component.
177
182
  * @returns The identifier for the sound voice
178
183
  * @example
179
- * ```lua
180
- * Assuming the script belongs to an instance with a sound-component with id "sound", this will make the component play its sound after 1 second:
181
- * sound.play("#sound", { delay = 1, gain = 0.9, pan = -1.0 } )
184
+ * ```ts
185
+ * // Assuming the script belongs to an instance with a sound-component with id
186
+ * // "sound", this will make the component play its sound after 1 second:
187
+ * sound.play("#sound", { delay: 1, gain: 0.9, pan: -1.0 });
182
188
  *
183
- * Using the callback argument, you can chain several sounds together:
184
- * local function sound_done(self, message_id, message, sender)
185
- * -- play 'boom' sound fx when the countdown has completed
186
- * if message_id == hash("sound_done") and message.play_id == self.countdown_id then
187
- * sound.play("#boom", nil, sound_done)
188
- * end
189
- * end
189
+ * // Using the callback argument, you can chain several sounds together:
190
+ * function sound_done(self, message_id, message, sender) {
191
+ * // play 'boom' sound fx when the countdown has completed
192
+ * if (message_id === hash("sound_done") && message.play_id === self.countdown_id) {
193
+ * sound.play("#boom", undefined, sound_done);
194
+ * }
195
+ * }
190
196
  *
191
- * function init(self)
192
- * self.countdown_id = sound.play("#countdown", nil, sound_done)
193
- * end
197
+ * export default defineScript({
198
+ * init(self) {
199
+ * self.countdown_id = sound.play("#countdown", undefined, sound_done);
200
+ * },
201
+ * });
194
202
  * ```
195
203
  */
196
204
  function play(url: string | Hash | Url, play_properties?: { delay?: number; gain?: number; pan?: number; speed?: number; start_time?: number; start_frame?: number }, complete_function?: (self: unknown, message_id: unknown, message: unknown, sender: unknown) => void): number;
@@ -200,9 +208,10 @@ declare global {
200
208
  * @param url - the sound to set the gain of
201
209
  * @param gain - sound gain between 0 and 1 [-60dB .. 0dB]. The final gain of the sound will be a combination of this gain, the group gain and the master gain.
202
210
  * @example
203
- * ```lua
204
- * Assuming the script belongs to an instance with a sound-component with id "sound", this will set the gain to 0.9
205
- * sound.set_gain("#sound", 0.9)
211
+ * ```ts
212
+ * // Assuming the script belongs to an instance with a sound-component with id
213
+ * // "sound", this will set the gain to 0.9
214
+ * sound.set_gain("#sound", 0.9);
206
215
  * ```
207
216
  */
208
217
  function set_gain(url: string | Hash | Url, gain?: number): void;
@@ -212,9 +221,9 @@ declare global {
212
221
  * @param group - group name
213
222
  * @param gain - gain in range [0..1] mapped to [0 .. -60dB]
214
223
  * @example
215
- * ```lua
216
- * Set mixer group gain on the "soundfx" group to 50% (-30dB):
217
- * sound.set_group_gain("soundfx", 0.5)
224
+ * ```ts
225
+ * // Set mixer group gain on the "soundfx" group to 50% (-30dB):
226
+ * sound.set_group_gain("soundfx", 0.5);
218
227
  * ```
219
228
  */
220
229
  function set_group_gain(group: string | Hash, gain: number): void;
@@ -225,9 +234,10 @@ declare global {
225
234
  * @param url - the sound to set the panning value to
226
235
  * @param pan - sound panning between -1.0 and 1.0
227
236
  * @example
228
- * ```lua
229
- * Assuming the script belongs to an instance with a sound-component with id "sound", this will set the gain to 0.5
230
- * sound.set_pan("#sound", 0.5) -- pan to the right
237
+ * ```ts
238
+ * // Assuming the script belongs to an instance with a sound-component with id
239
+ * // "sound", this will set the gain to 0.5
240
+ * sound.set_pan("#sound", 0.5); // pan to the right
231
241
  * ```
232
242
  */
233
243
  function set_pan(url: string | Hash | Url, pan?: number): void;
@@ -239,11 +249,12 @@ declare global {
239
249
  * `play_id`
240
250
  * number the sequential play identifier that should be stopped (was given by the sound.play() function)
241
251
  * @example
242
- * ```lua
243
- * Assuming the script belongs to an instance with a sound-component with id "sound", this will make the component stop all playing voices:
244
- * sound.stop("#sound")
245
- * local id = sound.play("#sound")
246
- * sound.stop("#sound", {play_id = id})
252
+ * ```ts
253
+ * // Assuming the script belongs to an instance with a sound-component with id
254
+ * // "sound", this will make the component stop all playing voices:
255
+ * sound.stop("#sound");
256
+ * const id = sound.play("#sound");
257
+ * sound.stop("#sound", { play_id: id });
247
258
  * ```
248
259
  */
249
260
  function stop(url: string | Hash | Url, stop_properties?: { play_id?: number }): void;
@@ -2,6 +2,9 @@
2
2
  import type { Hash, Url, Vector3, Vector4 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions, messages and properties used to manipulate sprite components.
7
+ */
5
8
  namespace sprite {
6
9
  /**
7
10
  * Play an animation on a sprite component from its tile set