@defold-typescript/types 0.26.0 → 0.27.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 (70) hide show
  1. package/api-availability.json +307 -307
  2. package/api-signatures.json +1311 -0
  3. package/api-targets.json +342 -0
  4. package/examples/translations.json +1984 -0
  5. package/fixtures/messages_doc.json +880 -0
  6. package/generated/versions/defold-1.12.4/gui.d.ts +43 -43
  7. package/generated/versions/defold-1.12.4/liveupdate.d.ts +22 -22
  8. package/generated/versions/defold-1.12.4/physics.d.ts +78 -75
  9. package/generated/versions/defold-1.12.4/render.d.ts +75 -55
  10. package/generated/versions/defold-1.12.4/resource.d.ts +187 -175
  11. package/generated/versions/defold-1.13.0/b2d.d.ts +33 -0
  12. package/generated/versions/defold-1.13.0/b2d_body.d.ts +676 -0
  13. package/generated/versions/defold-1.13.0/b2d_chain.d.ts +106 -0
  14. package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +155 -0
  15. package/generated/versions/defold-1.13.0/b2d_joint.d.ts +823 -0
  16. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +215 -0
  17. package/generated/versions/defold-1.13.0/b2d_world.d.ts +314 -0
  18. package/generated/versions/defold-1.13.0/buffer.d.ts +176 -0
  19. package/generated/versions/defold-1.13.0/camera.d.ts +302 -0
  20. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +146 -0
  21. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +71 -0
  22. package/generated/versions/defold-1.13.0/compute.d.ts +306 -0
  23. package/generated/versions/defold-1.13.0/crash.d.ts +143 -0
  24. package/generated/versions/defold-1.13.0/editor-vm/http.d.ts +56 -0
  25. package/generated/versions/defold-1.13.0/editor-vm/json.d.ts +10 -0
  26. package/generated/versions/defold-1.13.0/editor-vm/localization.d.ts +42 -0
  27. package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +80 -0
  28. package/generated/versions/defold-1.13.0/editor-vm/zip.d.ts +10 -0
  29. package/generated/versions/defold-1.13.0/editor-vm/zlib.d.ts +24 -0
  30. package/generated/versions/defold-1.13.0/editor.d.ts +1092 -0
  31. package/generated/versions/defold-1.13.0/factory.d.ts +123 -0
  32. package/generated/versions/defold-1.13.0/font.d.ts +81 -0
  33. package/generated/versions/defold-1.13.0/go.d.ts +1054 -0
  34. package/generated/versions/defold-1.13.0/graphics.d.ts +321 -0
  35. package/generated/versions/defold-1.13.0/gui.d.ts +2370 -0
  36. package/generated/versions/defold-1.13.0/html5.d.ts +53 -0
  37. package/generated/versions/defold-1.13.0/http.d.ts +84 -0
  38. package/generated/versions/defold-1.13.0/iac.d.ts +18 -0
  39. package/generated/versions/defold-1.13.0/iap.d.ts +60 -0
  40. package/generated/versions/defold-1.13.0/image.d.ts +139 -0
  41. package/generated/versions/defold-1.13.0/index.d.ts +48 -0
  42. package/generated/versions/defold-1.13.0/json.d.ts +76 -0
  43. package/generated/versions/defold-1.13.0/kinds/editor-script.d.ts +13 -0
  44. package/generated/versions/defold-1.13.0/label.d.ts +94 -0
  45. package/generated/versions/defold-1.13.0/liveupdate.d.ts +140 -0
  46. package/generated/versions/defold-1.13.0/material.d.ts +444 -0
  47. package/generated/versions/defold-1.13.0/model.d.ts +246 -0
  48. package/generated/versions/defold-1.13.0/msg.d.ts +10 -0
  49. package/generated/versions/defold-1.13.0/particlefx.d.ts +166 -0
  50. package/generated/versions/defold-1.13.0/physics.d.ts +548 -0
  51. package/generated/versions/defold-1.13.0/profiler.d.ts +233 -0
  52. package/generated/versions/defold-1.13.0/push.d.ts +66 -0
  53. package/generated/versions/defold-1.13.0/render.d.ts +1185 -0
  54. package/generated/versions/defold-1.13.0/resource.d.ts +1530 -0
  55. package/generated/versions/defold-1.13.0/socket.d.ts +795 -0
  56. package/generated/versions/defold-1.13.0/sound.d.ts +291 -0
  57. package/generated/versions/defold-1.13.0/sprite.d.ts +157 -0
  58. package/generated/versions/defold-1.13.0/sys.d.ts +695 -0
  59. package/generated/versions/defold-1.13.0/tilemap.d.ts +195 -0
  60. package/generated/versions/defold-1.13.0/timer.d.ts +114 -0
  61. package/generated/versions/defold-1.13.0/types.d.ts +61 -0
  62. package/generated/versions/defold-1.13.0/vmath.d.ts +806 -0
  63. package/generated/versions/defold-1.13.0/webview.d.ts +68 -0
  64. package/generated/versions/defold-1.13.0/window.d.ts +198 -0
  65. package/generated/versions/defold-1.13.0/zlib.d.ts +40 -0
  66. package/index.d.ts +4 -84
  67. package/package.json +11 -3
  68. package/scripts/import-defold-release.ts +18 -1
  69. package/src/example-store.ts +5 -0
  70. package/scripts/lua-types-signature-index.ts +0 -151
@@ -0,0 +1,291 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Url } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and messages for controlling sound components and
7
+ * mixer groups.
8
+ */
9
+ namespace sound {
10
+ /**
11
+ * Get mixer group gain
12
+ *
13
+ * @param group - group name
14
+ * @returns gain in [0 1] range ([-60dB.. 0dB])
15
+ * @example
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;
20
+ * ```
21
+ */
22
+ function get_group_gain(group: string | Hash): number;
23
+ /**
24
+ * Get a mixer group name as a string.
25
+ * This function is to be used for debugging and
26
+ * development tooling only. The function does a reverse hash lookup, which does not
27
+ * return a proper string value when the game is built in release mode.
28
+ *
29
+ * @param group - group name
30
+ * @returns group name
31
+ * @example
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
+ * }
39
+ * ```
40
+ */
41
+ function get_group_name(group: string | Hash): string;
42
+ /**
43
+ * Get a table of all mixer group names (hashes).
44
+ *
45
+ * @returns table of mixer group names
46
+ * @example
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
+ * }
58
+ * ```
59
+ */
60
+ function get_groups(): Hash[];
61
+ /**
62
+ * Get peak value from mixer group.
63
+ * Note that gain is in linear scale, between 0 and 1.
64
+ * To get the dB value from the gain, use the formula `20 * log(gain)`.
65
+ * Inversely, to find the linear value from a dB value, use the formula
66
+ * `10db/20`.
67
+ * Also note that the returned value might be an approximation and in particular
68
+ * the effective window might be larger than specified.
69
+ *
70
+ * @param group - group name
71
+ * @param window - window length in seconds
72
+ * @example
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);
78
+ * ```
79
+ */
80
+ function get_peak(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
81
+ /**
82
+ * Get RMS (Root Mean Square) value from mixer group. This value is the
83
+ * square root of the mean (average) value of the squared function of
84
+ * the instantaneous values.
85
+ * For instance: for a sinewave signal with a peak gain of -1.94 dB (0.8 linear),
86
+ * the RMS is `0.8 &times; 1/sqrt(2)` which is about 0.566.
87
+ * Note the returned value might be an approximation and in particular
88
+ * the effective window might be larger than specified.
89
+ *
90
+ * @param group - group name
91
+ * @param window - window length in seconds
92
+ * @example
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
97
+ * ```
98
+ */
99
+ function get_rms(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
100
+ /**
101
+ * Checks if background music is playing, e.g. from iTunes.
102
+ * On non mobile platforms,
103
+ * this function always return `false`.
104
+ * On Android you can only get a correct reading
105
+ * of this state if your game is not playing any sounds itself. This is a limitation
106
+ * in the Android SDK. If your game is playing any sounds, *even with a gain of zero*, this
107
+ * function will return `false`.
108
+ * The best time to call this function is:
109
+ *
110
+ * - In the `init` function of your main collection script before any sounds are triggered
111
+ *
112
+ * - In a window listener callback when the window.WINDOW_EVENT_FOCUS_GAINED event is received
113
+ *
114
+ * Both those times will give you a correct reading of the state even when your application is
115
+ * swapped out and in while playing sounds and it works equally well on Android and iOS.
116
+ *
117
+ * @returns `true` if music is playing, otherwise `false`.
118
+ * @example
119
+ * ```ts
120
+ * // If music is playing, mute "master":
121
+ * if (sound.is_music_playing()) {
122
+ * // mute "master"
123
+ * sound.set_group_gain("master", 0);
124
+ * }
125
+ * ```
126
+ */
127
+ function is_music_playing(): boolean;
128
+ /**
129
+ * Checks if a phone call is active. If there is an active phone call all
130
+ * other sounds will be muted until the phone call is finished.
131
+ * On non mobile platforms,
132
+ * this function always return `false`.
133
+ *
134
+ * @returns `true` if there is an active phone call, `false` otherwise.
135
+ * @example
136
+ * ```ts
137
+ * // Test if a phone call is on-going:
138
+ * if (sound.is_phone_call_active()) {
139
+ * // do something sensible.
140
+ * }
141
+ * ```
142
+ */
143
+ function is_phone_call_active(): boolean;
144
+ /**
145
+ * Pause all active voices
146
+ *
147
+ * @param url - the sound that should pause
148
+ * @param pause - true if the sound should pause
149
+ * @example
150
+ * ```ts
151
+ * // Assuming the script belongs to an instance with a sound-component with id
152
+ * // "sound", this will make the component pause all playing voices:
153
+ * sound.pause("#sound", true);
154
+ * ```
155
+ */
156
+ function pause(url: string | Hash | Url, pause: boolean): void;
157
+ /**
158
+ * Make the sound component play its sound. Multiple voices are supported. The limit is set to 32 voices per sound component.
159
+ * A sound will continue to play even if the game object the sound component belonged to is deleted. You can call `sound.stop()` to stop the sound.
160
+ *
161
+ * @param url - the sound that should play
162
+ * @param play_properties - optional table with properties:
163
+ * `delay`
164
+ * number delay in seconds before the sound starts playing, default is 0.
165
+ * `gain`
166
+ * number sound gain between 0 and 1, default is 1. The final gain of the sound will be a combination of this gain, the group gain and the master gain.
167
+ * `pan`
168
+ * number sound pan between -1 and 1, default is 0. The final pan of the sound will be an addition of this pan and the sound pan.
169
+ * `speed`
170
+ * number sound speed where 1.0 is normal speed, 0.5 is half speed and 2.0 is double speed. Valid range is 0.0 to 50.0. The final speed of the sound will be a multiplication of this speed and the sound speed.
171
+ * `start_time`
172
+ * number start playback offset (seconds). Optional, mutually exclusive with `start_frame`.
173
+ * `start_frame`
174
+ * number start playback offset (frames/samples). Optional, mutually exclusive with `start_time`. If both are provided, `start_frame` is used.
175
+ * @param complete_function - function to call when the sound has finished playing or stopped manually via sound.stop.
176
+ *
177
+ * `self`
178
+ * object The current object.
179
+ * `message_id`
180
+ * hash The name of the completion message, which can be either `"sound_done"` if the sound has finished playing, or `"sound_stopped"` if it was stopped manually.
181
+ * `message`
182
+ * table Information about the completion:
183
+ *
184
+ * - number `play_id` - the sequential play identifier that was given by the sound.play function.
185
+ *
186
+ * `sender`
187
+ * url The invoker of the callback: the sound component.
188
+ * @returns The identifier for the sound voice
189
+ * @example
190
+ * ```ts
191
+ * // Assuming the script belongs to an instance with a sound-component with id
192
+ * // "sound", this will make the component play its sound after 1 second:
193
+ * sound.play("#sound", { delay: 1, gain: 0.9, pan: -1.0 });
194
+ *
195
+ * // Using the callback argument, you can chain several sounds together:
196
+ * function sound_done(self, message_id, message, sender) {
197
+ * // play 'boom' sound fx when the countdown has completed
198
+ * if (message_id === hash("sound_done") && message.play_id === self.countdown_id) {
199
+ * sound.play("#boom", undefined, sound_done);
200
+ * }
201
+ * }
202
+ *
203
+ * export default defineScript({
204
+ * init(self) {
205
+ * self.countdown_id = sound.play("#countdown", undefined, sound_done);
206
+ * },
207
+ * });
208
+ * ```
209
+ */
210
+ 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;
211
+ /**
212
+ * Set gain on all active playing voices of a sound.
213
+ *
214
+ * @param url - the sound to set the gain of
215
+ * @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.
216
+ * @example
217
+ * ```ts
218
+ * // Assuming the script belongs to an instance with a sound-component with id
219
+ * // "sound", this will set the gain to 0.9
220
+ * sound.set_gain("#sound", 0.9);
221
+ * ```
222
+ */
223
+ function set_gain(url: string | Hash | Url, gain?: number): void;
224
+ /**
225
+ * Set mixer group gain
226
+ *
227
+ * @param group - group name
228
+ * @param gain - gain in range [0..1] mapped to [0 .. -60dB]
229
+ * @example
230
+ * ```ts
231
+ * // Set mixer group gain on the "soundfx" group to 50% (-30dB):
232
+ * sound.set_group_gain("soundfx", 0.5);
233
+ * ```
234
+ */
235
+ function set_group_gain(group: string | Hash, gain: number): void;
236
+ /**
237
+ * Set panning on all active playing voices of a sound.
238
+ * The valid range is from -1.0 to 1.0, representing -45 degrees left, to +45 degrees right.
239
+ *
240
+ * @param url - the sound to set the panning value to
241
+ * @param pan - sound panning between -1.0 and 1.0
242
+ * @example
243
+ * ```ts
244
+ * // Assuming the script belongs to an instance with a sound-component with id
245
+ * // "sound", this will set the gain to 0.5
246
+ * sound.set_pan("#sound", 0.5); // pan to the right
247
+ * ```
248
+ */
249
+ function set_pan(url: string | Hash | Url, pan?: number): void;
250
+ /**
251
+ * Stop playing all active voices or just one voice if `play_id` provided
252
+ *
253
+ * @param url - the sound component that should stop
254
+ * @param stop_properties - optional table with properties:
255
+ * `play_id`
256
+ * number the sequential play identifier that should be stopped (was given by the sound.play() function)
257
+ * @example
258
+ * ```ts
259
+ * // Assuming the script belongs to an instance with a sound-component with id
260
+ * // "sound", this will make the component stop all playing voices:
261
+ * sound.stop("#sound");
262
+ * const id = sound.play("#sound");
263
+ * sound.stop("#sound", { play_id: id });
264
+ * ```
265
+ */
266
+ function stop(url: string | Hash | Url, stop_properties?: { play_id?: number }): void;
267
+ interface properties {
268
+ /**
269
+ * The gain on the sound-component. Note that gain is in linear scale,
270
+ * between 0 and 1.
271
+ */
272
+ gain: number;
273
+ /**
274
+ * The pan on the sound-component. The valid range is from -1.0 to 1.0,
275
+ * representing -45 degrees left, to +45 degrees right.
276
+ */
277
+ pan: number;
278
+ /**
279
+ * The sound data used when playing the sound. The type of the property is hash.
280
+ */
281
+ sound: Hash;
282
+ /**
283
+ * The speed on the sound-component where 1.0 is normal speed, 0.5 is half
284
+ * speed and 2.0 is double speed. Valid range is 0.0 to 50.0.
285
+ */
286
+ speed: number;
287
+ }
288
+ }
289
+ }
290
+
291
+ export {};
@@ -0,0 +1,157 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Url, Vector3, Vector4 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Sprite API documentation
7
+ */
8
+ namespace sprite {
9
+ /**
10
+ * Play an animation on a sprite component from its tile set
11
+ * An optional completion callback function can be provided that will be called when
12
+ * the animation has completed playing. If no function is provided,
13
+ * a animation_done message is sent to the script that started the animation.
14
+ *
15
+ * @param url - the sprite that should play the animation
16
+ * @param id - hashed id of the animation to play
17
+ * @param complete_function - function to call when the animation has completed.
18
+ *
19
+ * `self`
20
+ * object The current object.
21
+ * `message_id`
22
+ * hash The name of the completion message, `"animation_done"`.
23
+ * `message`
24
+ * table Information about the completion:
25
+ *
26
+ * - number `current_tile` - the current tile of the sprite.
27
+ *
28
+ * - hash `id` - id of the animation that was completed.
29
+ *
30
+ * `sender`
31
+ * url The invoker of the callback: the sprite component.
32
+ * @param play_properties - optional table with properties:
33
+ *
34
+ * `offset`
35
+ * number the normalized initial value of the animation cursor when the animation starts playing.
36
+ * `playback_rate`
37
+ * number the rate with which the animation will be played. Must be positive.
38
+ * @example
39
+ * ```ts
40
+ * // Assuming the sprite has id "sprite": play the "jump" animation followed by the
41
+ * // "run" animation:
42
+ * export default defineScript({
43
+ * init() {
44
+ * const url = msg.url("#sprite");
45
+ * sprite.play_flipbook(url, "jump", (self, message_id, message) => {
46
+ * if (message_id === hash("animation_done") && message.id === hash("jump")) {
47
+ * // jump animation done, chain with "run"
48
+ * sprite.play_flipbook(url, "run");
49
+ * }
50
+ * });
51
+ * },
52
+ * });
53
+ * ```
54
+ */
55
+ function play_flipbook(url: string | Hash | Url, id: string | Hash, complete_function?: (self: unknown, message_id: unknown, message: unknown, sender: unknown) => void, play_properties?: { offset?: number; playback_rate?: number }): void;
56
+ /**
57
+ * Resets a shader constant for a sprite component.
58
+ * The constant must be defined in the material assigned to the sprite.
59
+ * Resetting a constant through this function implies that the value defined in the material will be used.
60
+ * Which sprite to reset a constant for is identified by the URL.
61
+ *
62
+ * @param url - the sprite that should have a constant reset
63
+ * @param constant - name of the constant
64
+ * @example
65
+ * ```ts
66
+ * sprite.reset_constant("#sprite", "tint");
67
+ * ```
68
+ */
69
+ function reset_constant(url: string | Hash | Url, constant: string | Hash): void;
70
+ /**
71
+ * Sets horizontal flipping of the provided sprite's animations.
72
+ * The sprite is identified by its URL.
73
+ * If the currently playing animation is flipped by default, flipping it again will make it appear like the original texture.
74
+ *
75
+ * @param url - the sprite that should flip its animations
76
+ * @param flip - `true` if the sprite should flip its animations, `false` if not
77
+ * @example
78
+ * ```ts
79
+ * // How to flip a sprite so it faces the horizontal movement (it is assumed that
80
+ * // the sprite component has id "sprite" and the original animation faces right):
81
+ * export default defineScript({
82
+ * update(self, dt) {
83
+ * // calculate self.velocity somehow
84
+ * sprite.set_hflip("#sprite", self.velocity.x < 0);
85
+ * },
86
+ * });
87
+ * ```
88
+ */
89
+ function set_hflip(url: string | Hash | Url, flip: boolean): void;
90
+ /**
91
+ * Sets vertical flipping of the provided sprite's animations.
92
+ * The sprite is identified by its URL.
93
+ * If the currently playing animation is flipped by default, flipping it again will make it appear like the original texture.
94
+ *
95
+ * @param url - the sprite that should flip its animations
96
+ * @param flip - `true` if the sprite should flip its animations, `false` if not
97
+ * @example
98
+ * ```ts
99
+ * // How to flip a sprite in a game which negates gravity as a game mechanic (it is
100
+ * // assumed that the sprite component has id "sprite" and the original animation
101
+ * // is up-right):
102
+ * export default defineScript({
103
+ * update(self, dt) {
104
+ * // calculate self.up_side_down somehow, then:
105
+ * sprite.set_vflip("#sprite", self.up_side_down);
106
+ * },
107
+ * });
108
+ * ```
109
+ */
110
+ function set_vflip(url: string | Hash | Url, flip: boolean): void;
111
+ interface properties {
112
+ /**
113
+ * READ ONLY The current animation id. An animation that plays currently for the sprite. The type of the property is hash.
114
+ */
115
+ animation: Hash;
116
+ /**
117
+ * The normalized animation cursor. The type of the property is number.
118
+ */
119
+ cursor: number;
120
+ /**
121
+ * READ ONLY The frame count of the currently playing animation.
122
+ */
123
+ frame_count: Hash;
124
+ /**
125
+ * The image used when rendering the sprite. The type of the property is hash.
126
+ */
127
+ image: Hash;
128
+ /**
129
+ * The material used when rendering the sprite. The type of the property is hash.
130
+ */
131
+ material: Hash;
132
+ /**
133
+ * The animation playback rate. A multiplier to the animation playback rate. The type of the property is number.
134
+ * The playback_rate is a non-negative number, a negative value will be clamped to 0.
135
+ */
136
+ playback_rate: number;
137
+ /**
138
+ * The non-uniform scale of the sprite. The type of the property is vector3.
139
+ */
140
+ scale: Vector3;
141
+ /**
142
+ * The size of the sprite, not allowing for any additional scaling that may be applied.
143
+ * The type of the property is vector3. It is not possible to set the size if the size mode
144
+ * of the sprite is set to auto.
145
+ */
146
+ size: Vector3;
147
+ /**
148
+ * The slice values of the sprite. The type of the property is a vector4 that corresponds to
149
+ * the left, top, right, bottom values of the sprite in the editor.
150
+ * It is not possible to set the slice property if the size mode of the sprite is set to auto.
151
+ */
152
+ slice: Vector4;
153
+ }
154
+ }
155
+ }
156
+
157
+ export {};