@defold-typescript/types 0.19.4 → 0.20.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 (86) hide show
  1. package/api-availability.json +2755 -0
  2. package/api-migrations.json +31 -0
  3. package/api-signatures.json +2324 -0
  4. package/api-targets.json +493 -45
  5. package/generated/b2d.d.ts +6 -0
  6. package/generated/b2d_body.d.ts +329 -1
  7. package/generated/b2d_chain.d.ts +106 -0
  8. package/generated/b2d_fixture.d.ts +155 -0
  9. package/generated/b2d_joint.d.ts +823 -0
  10. package/generated/b2d_shape.d.ts +215 -0
  11. package/generated/b2d_world.d.ts +314 -0
  12. package/generated/builtin-messages.d.ts +18 -0
  13. package/generated/camera.d.ts +62 -5
  14. package/generated/compute.d.ts +306 -0
  15. package/generated/go.d.ts +29 -4
  16. package/generated/graphics.d.ts +95 -0
  17. package/generated/gui.d.ts +1 -3
  18. package/generated/json.d.ts +2 -2
  19. package/generated/kinds/gui-script.d.ts +7 -0
  20. package/generated/kinds/render-script.d.ts +7 -0
  21. package/generated/kinds/script.d.ts +7 -0
  22. package/generated/label.d.ts +1 -1
  23. package/generated/liveupdate.d.ts +22 -4
  24. package/generated/material.d.ts +444 -0
  25. package/generated/model.d.ts +46 -5
  26. package/generated/physics.d.ts +1 -3
  27. package/generated/profiler.d.ts +2 -3
  28. package/generated/render.d.ts +25 -9
  29. package/generated/resource.d.ts +2 -2
  30. package/generated/sprite.d.ts +15 -1
  31. package/generated/tilemap.d.ts +14 -0
  32. package/generated/versions/defold-1.12.4/b2d.d.ts +27 -0
  33. package/generated/versions/defold-1.12.4/b2d_body.d.ts +348 -0
  34. package/generated/versions/defold-1.12.4/buffer.d.ts +176 -0
  35. package/generated/versions/defold-1.12.4/camera.d.ts +245 -0
  36. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +146 -0
  37. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +71 -0
  38. package/generated/versions/defold-1.12.4/crash.d.ts +143 -0
  39. package/generated/versions/defold-1.12.4/factory.d.ts +123 -0
  40. package/generated/versions/defold-1.12.4/font.d.ts +81 -0
  41. package/generated/versions/defold-1.12.4/go.d.ts +1029 -0
  42. package/generated/versions/defold-1.12.4/graphics.d.ts +226 -0
  43. package/generated/versions/defold-1.12.4/gui.d.ts +2372 -0
  44. package/generated/versions/defold-1.12.4/html5.d.ts +53 -0
  45. package/generated/versions/defold-1.12.4/http.d.ts +84 -0
  46. package/generated/versions/defold-1.12.4/iac.d.ts +18 -0
  47. package/generated/versions/defold-1.12.4/iap.d.ts +60 -0
  48. package/generated/versions/defold-1.12.4/image.d.ts +139 -0
  49. package/generated/versions/defold-1.12.4/index.d.ts +41 -0
  50. package/generated/versions/defold-1.12.4/json.d.ts +76 -0
  51. package/generated/versions/defold-1.12.4/label.d.ts +94 -0
  52. package/generated/versions/defold-1.12.4/liveupdate.d.ts +122 -0
  53. package/generated/versions/defold-1.12.4/model.d.ts +205 -0
  54. package/generated/versions/defold-1.12.4/msg.d.ts +10 -0
  55. package/generated/versions/defold-1.12.4/particlefx.d.ts +166 -0
  56. package/generated/versions/defold-1.12.4/physics.d.ts +547 -0
  57. package/generated/versions/defold-1.12.4/profiler.d.ts +234 -0
  58. package/generated/versions/defold-1.12.4/push.d.ts +66 -0
  59. package/generated/versions/defold-1.12.4/render.d.ts +1149 -0
  60. package/generated/versions/defold-1.12.4/resource.d.ts +1518 -0
  61. package/generated/versions/defold-1.12.4/socket.d.ts +795 -0
  62. package/generated/versions/defold-1.12.4/sound.d.ts +291 -0
  63. package/generated/versions/defold-1.12.4/sprite.d.ts +143 -0
  64. package/generated/versions/defold-1.12.4/sys.d.ts +695 -0
  65. package/generated/versions/defold-1.12.4/tilemap.d.ts +181 -0
  66. package/generated/versions/defold-1.12.4/timer.d.ts +114 -0
  67. package/generated/versions/defold-1.12.4/types.d.ts +61 -0
  68. package/generated/versions/defold-1.12.4/vmath.d.ts +806 -0
  69. package/generated/versions/defold-1.12.4/webview.d.ts +68 -0
  70. package/generated/versions/defold-1.12.4/window.d.ts +198 -0
  71. package/generated/versions/defold-1.12.4/zlib.d.ts +40 -0
  72. package/index.d.ts +22 -0
  73. package/package.json +8 -1
  74. package/scripts/fidelity-audit.ts +69 -12
  75. package/scripts/fidelity-baseline.json +56 -0
  76. package/scripts/generate-api-availability.ts +139 -0
  77. package/scripts/generate-api-signatures.ts +66 -0
  78. package/scripts/import-defold-release.ts +480 -0
  79. package/scripts/regen.ts +53 -6
  80. package/scripts/sync-api-docs.ts +89 -41
  81. package/src/api-availability.ts +0 -0
  82. package/src/core-types.ts +9 -0
  83. package/src/emit-dts.ts +674 -17
  84. package/src/emit-messages.ts +72 -2
  85. package/src/index.ts +26 -1
  86. package/src/lifecycle.ts +43 -2
@@ -0,0 +1,205 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Opaque, Url, Vector3 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and messages for interacting with model components.
7
+ */
8
+ namespace model {
9
+ /**
10
+ * Cancels all animation on a model component.
11
+ *
12
+ * @param url - the model for which to cancel the animation
13
+ */
14
+ function cancel(url: string | Hash | Url): void;
15
+ /**
16
+ * Get AABB of the whole model in local coordinate space.
17
+ * AABB information return as a table with `min` and `max` fields, where `min` and `max` has type `vmath.vector3`.
18
+ *
19
+ * @param url - the model
20
+ * @returns A table containing AABB of the model. If model has no meshes - return vmath.vector3(0,0,0) for min and max fields.
21
+ * @example
22
+ * ```ts
23
+ * model.get_aabb("#model"); // => { min = vmath.vector3(-2.5, -3.0, 0), max = vmath.vector3(1.5, 5.5, 0) }
24
+ * model.get_aabb("#empty"); // => { min = vmath.vector3(0, 0, 0), max = vmath.vector3(0, 0, 0) }
25
+ * ```
26
+ */
27
+ function get_aabb(url: string | Hash | Url): { min: Vector3; max: Vector3 };
28
+ /**
29
+ * Gets the id of the game object that corresponds to a model skeleton bone.
30
+ * The returned game object can be used for parenting and transform queries.
31
+ * This function has complexity `O(n)`, where `n` is the number of bones in the model skeleton.
32
+ * Game objects corresponding to a model skeleton bone can not be individually deleted.
33
+ *
34
+ * @param url - the model to query
35
+ * @param bone_id - id of the corresponding bone
36
+ * @returns id of the game object
37
+ * @example
38
+ * ```ts
39
+ * // The following examples assume that the model component has id "model".
40
+ * // How to parent the game object of the calling script to the "right_hand" bone
41
+ * // of the model in a player game object:
42
+ * export default defineScript({
43
+ * init(self) {
44
+ * const parent = model.get_go("player#model", "right_hand");
45
+ * msg.post(".", "set_parent", { parent_id: parent });
46
+ * },
47
+ * });
48
+ * ```
49
+ */
50
+ function get_go(url: string | Hash | Url, bone_id: string | Hash): Hash;
51
+ /**
52
+ * Get AABB of all meshes.
53
+ * AABB information return as a table with `min` and `max` fields, where `min` and `max` has type `vmath.vector3`.
54
+ *
55
+ * @param url - the model
56
+ * @returns A table containing info about all AABB in the format
57
+ * @example
58
+ * ```ts
59
+ * model.get_mesh_aabb("#model"); // => { hash("Sword") = { min = vmath.vector3(-0.5, -0.5, 0), max = vmath.vector3(0.5, 0.5, 0) }, hash("Shield") = { min = vmath.vector3(-0.5, -0.5, -0.5), max = vmath.vector3(0.5, 0.5, 0.5) } }
60
+ * ```
61
+ */
62
+ function get_mesh_aabb(url: string | Hash | Url): LuaMap<Hash, { min: Vector3; max: Vector3 }>;
63
+ /**
64
+ * Get the enabled state of a mesh
65
+ *
66
+ * @param url - the model
67
+ * @param mesh_id - the id of the mesh
68
+ * @returns true if the mesh is visible, false otherwise
69
+ * @example
70
+ * ```ts
71
+ * export default defineScript({
72
+ * init(self) {
73
+ * if (model.get_mesh_enabled("#model", "Sword")) {
74
+ * // set properties specific for the sword
75
+ * self.weapon_properties = game.data.weapons["Sword"];
76
+ * }
77
+ * },
78
+ * });
79
+ * ```
80
+ */
81
+ function get_mesh_enabled(url: string | Hash | Url, mesh_id: string | Hash | Url): boolean;
82
+ /**
83
+ * Plays an animation on a model component with specified playback
84
+ * mode and parameters.
85
+ * An optional completion callback function can be provided that will be called when
86
+ * the animation has completed playing. If no function is provided,
87
+ * a model_animation_done message is sent to the script that started the animation.
88
+ * The callback is not called (or message sent) if the animation is
89
+ * cancelled with model.cancel. The callback is called (or message sent) only for
90
+ * animations that play with the following playback modes:
91
+ *
92
+ * - `go.PLAYBACK_ONCE_FORWARD`
93
+ *
94
+ * - `go.PLAYBACK_ONCE_BACKWARD`
95
+ *
96
+ * - `go.PLAYBACK_ONCE_PINGPONG`
97
+ *
98
+ * @param url - the model for which to play the animation
99
+ * @param anim_id - id of the animation to play
100
+ * @param playback - playback mode of the animation
101
+ *
102
+ * - `go.PLAYBACK_ONCE_FORWARD`
103
+ *
104
+ * - `go.PLAYBACK_ONCE_BACKWARD`
105
+ *
106
+ * - `go.PLAYBACK_ONCE_PINGPONG`
107
+ *
108
+ * - `go.PLAYBACK_LOOP_FORWARD`
109
+ *
110
+ * - `go.PLAYBACK_LOOP_BACKWARD`
111
+ *
112
+ * - `go.PLAYBACK_LOOP_PINGPONG`
113
+ * @param play_properties - optional table with properties
114
+ * Play properties table:
115
+ *
116
+ * `blend_duration`
117
+ * number Duration of a linear blend between the current and new animation.
118
+ * `offset`
119
+ * number The normalized initial value of the animation cursor when the animation starts playing.
120
+ * `playback_rate`
121
+ * number The rate with which the animation will be played. Must be positive.
122
+ * @param complete_function - function to call when the animation has completed.
123
+ *
124
+ * `self`
125
+ * object The current object.
126
+ * `message_id`
127
+ * hash The name of the completion message, `"model_animation_done"`.
128
+ * `message`
129
+ * table Information about the completion:
130
+ *
131
+ * - hash `animation_id` - the animation that was completed.
132
+ *
133
+ * - constant `playback` - the playback mode for the animation.
134
+ *
135
+ * `sender`
136
+ * url The invoker of the callback: the model component.
137
+ * @example
138
+ * ```ts
139
+ * // The following examples assume that the model has id "model".
140
+ * // How to play the "jump" animation followed by the "run" animation:
141
+ * function anim_done(self, message_id, message, sender) {
142
+ * if (message_id === hash("model_animation_done")) {
143
+ * if (message.animation_id === hash("jump")) {
144
+ * // open animation done, chain with "run"
145
+ * const properties = { blend_duration: 0.2 };
146
+ * model.play_anim(url, "run", go.PLAYBACK_LOOP_FORWARD, properties, anim_done);
147
+ * }
148
+ * }
149
+ * }
150
+ *
151
+ * export default defineScript({
152
+ * init(self) {
153
+ * const url = msg.url("#model");
154
+ * const play_properties = { blend_duration: 0.1 };
155
+ * // first blend during 0.1 sec into the jump, then during 0.2 s into the run animation
156
+ * model.play_anim(url, "jump", go.PLAYBACK_ONCE_FORWARD, play_properties, anim_done);
157
+ * },
158
+ * });
159
+ * ```
160
+ */
161
+ function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: Opaque<"constant">, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id: unknown, message: unknown, sender: unknown) => void): void;
162
+ /**
163
+ * Enable or disable visibility of a mesh
164
+ *
165
+ * @param url - the model
166
+ * @param mesh_id - the id of the mesh
167
+ * @param enabled - true if the mesh should be visible, false if it should be hideen
168
+ * @example
169
+ * ```ts
170
+ * export default defineScript({
171
+ * init(self) {
172
+ * model.set_mesh_enabled("#model", "Sword", false); // hide the sword
173
+ * model.set_mesh_enabled("#model", "Axe", true); // show the axe
174
+ * },
175
+ * });
176
+ * ```
177
+ */
178
+ function set_mesh_enabled(url: string | Hash | Url, mesh_id: string | Hash | Url, enabled: boolean): void;
179
+ interface properties {
180
+ /**
181
+ * The current animation set on the component. The type of the property is hash.
182
+ */
183
+ animation: Hash;
184
+ /**
185
+ * The normalized animation cursor. The type of the property is number.
186
+ * Please note that model events may not fire as expected when the cursor is manipulated directly.
187
+ */
188
+ cursor: number;
189
+ /**
190
+ * The material used when rendering the model. The type of the property is hash.
191
+ */
192
+ material: Hash;
193
+ /**
194
+ * The animation playback rate. A multiplier to the animation playback rate. The type of the property is number.
195
+ */
196
+ playback_rate: number;
197
+ /**
198
+ * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
199
+ */
200
+ textureN: Hash;
201
+ }
202
+ }
203
+ }
204
+
205
+ export {};
@@ -0,0 +1,10 @@
1
+ /** @noSelfInFile */
2
+ declare global {
3
+ /**
4
+ * Functions for passing messages and constructing URL objects.
5
+ */
6
+ namespace msg {
7
+ }
8
+ }
9
+
10
+ export {};
@@ -0,0 +1,166 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Url, Vector4 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and properties for controlling particle effect component playback and
7
+ * shader constants.
8
+ */
9
+ namespace particlefx {
10
+ /**
11
+ * The emitter is not spawning any particles, but has particles that are still alive.
12
+ */
13
+ const EMITTER_STATE_POSTSPAWN: number & { readonly __brand: "particlefx.EMITTER_STATE_POSTSPAWN" };
14
+ /**
15
+ * The emitter will be in this state when it has been started but before spawning any particles. Normally the emitter is in this state for a short time, depending on if a start delay has been set for this emitter or not.
16
+ */
17
+ const EMITTER_STATE_PRESPAWN: number & { readonly __brand: "particlefx.EMITTER_STATE_PRESPAWN" };
18
+ /**
19
+ * The emitter does not have any living particles and will not spawn any particles in this state.
20
+ */
21
+ const EMITTER_STATE_SLEEPING: number & { readonly __brand: "particlefx.EMITTER_STATE_SLEEPING" };
22
+ /**
23
+ * The emitter is spawning particles.
24
+ */
25
+ const EMITTER_STATE_SPAWNING: number & { readonly __brand: "particlefx.EMITTER_STATE_SPAWNING" };
26
+ /**
27
+ * Starts playing a particle FX component.
28
+ * Particle FX started this way need to be manually stopped through `particlefx.stop()`.
29
+ * Which particle FX to play is identified by the URL.
30
+ * A particle FX will continue to emit particles even if the game object the particle FX component belonged to is deleted. You can call `particlefx.stop()` to stop it from emitting more particles.
31
+ *
32
+ * @param url - the particle fx that should start playing.
33
+ * @param emitter_state_function - optional callback function that will be called when an emitter attached to this particlefx changes state.
34
+ *
35
+ * `self`
36
+ * object The current object
37
+ * `id`
38
+ * hash The id of the particle fx component
39
+ * `emitter`
40
+ * hash The id of the emitter
41
+ * `state`
42
+ * constant the new state of the emitter:
43
+ *
44
+ * - `particlefx.EMITTER_STATE_SLEEPING`
45
+ *
46
+ * - `particlefx.EMITTER_STATE_PRESPAWN`
47
+ *
48
+ * - `particlefx.EMITTER_STATE_SPAWNING`
49
+ *
50
+ * - `particlefx.EMITTER_STATE_POSTSPAWN`
51
+ * @example
52
+ * ```ts
53
+ * // How to play a particle fx when a game object is created.
54
+ * // The callback receives the hash of the path to the particlefx, the hash of the id
55
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
56
+ * function emitter_state_change(self, id, emitter, state) {
57
+ * if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
58
+ * // exhaust is done spawning particles...
59
+ * }
60
+ * }
61
+ *
62
+ * export default defineScript({
63
+ * init(self) {
64
+ * particlefx.play("#particlefx", emitter_state_change);
65
+ * },
66
+ * });
67
+ * ```
68
+ */
69
+ function play(url: string | Hash | Url, emitter_state_function?: (self: unknown, id: unknown, emitter: unknown, state: unknown) => void): void;
70
+ /**
71
+ * Resets a shader constant for a particle FX component emitter.
72
+ * The constant must be defined in the material assigned to the emitter.
73
+ * Resetting a constant through this function implies that the value defined in the material will be used.
74
+ * Which particle FX to reset a constant for is identified by the URL.
75
+ *
76
+ * @param url - the particle FX that should have a constant reset
77
+ * @param emitter - the id of the emitter
78
+ * @param constant - the name of the constant
79
+ * @example
80
+ * ```ts
81
+ * // The following examples assume that the particle FX has id "particlefx", it
82
+ * // contains an emitter with the id "emitter" and that the default-material in
83
+ * // builtins is used, which defines the constant "tint".
84
+ * // If you assign a custom material to the sprite, you can reset the constants
85
+ * // defined there in the same manner.
86
+ * // How to reset the tinting of particles from an emitter:
87
+ * export default defineScript({
88
+ * init(self) {
89
+ * particlefx.reset_constant("#particlefx", "emitter", "tint");
90
+ * },
91
+ * });
92
+ * ```
93
+ */
94
+ function reset_constant(url: string | Hash | Url, emitter: string | Hash, constant: string | Hash): void;
95
+ /**
96
+ * Sets a shader constant for a particle FX component emitter.
97
+ * The constant must be defined in the material assigned to the emitter.
98
+ * Setting a constant through this function will override the value set for that constant in the material.
99
+ * The value will be overridden until particlefx.reset_constant is called.
100
+ * Which particle FX to set a constant for is identified by the URL.
101
+ *
102
+ * @param url - the particle FX that should have a constant set
103
+ * @param emitter - the id of the emitter
104
+ * @param constant - the name of the constant
105
+ * @param value - the value of the constant
106
+ * @example
107
+ * ```ts
108
+ * // The following examples assume that the particle FX has id "particlefx", it
109
+ * // contains an emitter with the id "emitter" and that the default-material in
110
+ * // builtins is used, which defines the constant "tint".
111
+ * // If you assign a custom material to the sprite, you can reset the constants
112
+ * // defined there in the same manner.
113
+ * // How to tint particles from an emitter red:
114
+ * export default defineScript({
115
+ * init(self) {
116
+ * particlefx.set_constant("#particlefx", "emitter", "tint", vmath.vector4(1, 0, 0, 1));
117
+ * },
118
+ * });
119
+ * ```
120
+ */
121
+ function set_constant(url: string | Hash | Url, emitter: string | Hash, constant: string | Hash, value: Vector4): void;
122
+ /**
123
+ * Stops a particle FX component from playing.
124
+ * Stopping a particle FX does not remove already spawned particles.
125
+ * Which particle FX to stop is identified by the URL.
126
+ *
127
+ * @param url - the particle fx that should stop playing
128
+ * @param options - Options when stopping the particle fx. Supported options:
129
+ *
130
+ * - boolean `clear`: instantly clear spawned particles
131
+ * @example
132
+ * ```ts
133
+ * // How to stop a particle fx when a game object is deleted and immediately also
134
+ * // clear any spawned particles:
135
+ * export default defineScript({
136
+ * final(self) {
137
+ * particlefx.stop("#particlefx", { clear: true });
138
+ * },
139
+ * });
140
+ * ```
141
+ */
142
+ function stop(url: string | Hash | Url, options?: { clear?: boolean }): void;
143
+ interface properties {
144
+ /**
145
+ * The animation used during rendering by an emitter in a particle FX component.
146
+ * The property type is a hash and refers to a valid animation in an atlas or a tile source resource.
147
+ * If the animation isn't found, and error will be thrown.
148
+ */
149
+ animation: Hash;
150
+ /**
151
+ * The image used during rendering by an emitter in a particle FX component.
152
+ * The property type is a hash and refers to an image resource (atlas or tile source).
153
+ * Note: When setting the image, if the currently playing animation of the emitter
154
+ * isn't found in the new image, the animation will be set to the first animation found.
155
+ */
156
+ image: Hash;
157
+ /**
158
+ * The material used during rendering by an emitter in a particle FX component.
159
+ * The property type is a hash and refers to a material resource.
160
+ */
161
+ material: Hash;
162
+ }
163
+ }
164
+ }
165
+
166
+ export {};