@defold-typescript/types 0.39.0 → 0.40.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 (87) hide show
  1. package/api-availability.json +117 -0
  2. package/api-signatures.json +262 -237
  3. package/examples/translations.json +81 -81
  4. package/generated/b2d_shape.d.ts +23 -1
  5. package/generated/buffer.d.ts +18 -15
  6. package/generated/camera.d.ts +2 -2
  7. package/generated/collectionfactory.d.ts +12 -10
  8. package/generated/collectionproxy.d.ts +1 -1
  9. package/generated/compute.d.ts +1 -1
  10. package/generated/go.d.ts +9 -5
  11. package/generated/graphics.d.ts +52 -0
  12. package/generated/gui.d.ts +53 -32
  13. package/generated/html5.d.ts +3 -1
  14. package/generated/http.d.ts +4 -2
  15. package/generated/image.d.ts +24 -15
  16. package/generated/kinds/gui-script.d.ts +1 -0
  17. package/generated/kinds/render-script.d.ts +1 -0
  18. package/generated/kinds/script.d.ts +1 -0
  19. package/generated/material.d.ts +1 -1
  20. package/generated/model.d.ts +32 -3
  21. package/generated/physics.d.ts +13 -11
  22. package/generated/profiler.d.ts +1 -1
  23. package/generated/render.d.ts +72 -15
  24. package/generated/resource.d.ts +100 -69
  25. package/generated/socket.d.ts +23 -13
  26. package/generated/sound.d.ts +3 -3
  27. package/generated/sprite.d.ts +9 -1
  28. package/generated/sys.d.ts +34 -23
  29. package/generated/versions/defold-1.12.4/buffer.d.ts +18 -15
  30. package/generated/versions/defold-1.12.4/camera.d.ts +2 -2
  31. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +12 -10
  32. package/generated/versions/defold-1.12.4/go.d.ts +9 -5
  33. package/generated/versions/defold-1.12.4/gui.d.ts +47 -31
  34. package/generated/versions/defold-1.12.4/html5.d.ts +3 -1
  35. package/generated/versions/defold-1.12.4/http.d.ts +4 -2
  36. package/generated/versions/defold-1.12.4/image.d.ts +24 -15
  37. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  38. package/generated/versions/defold-1.12.4/model.d.ts +32 -3
  39. package/generated/versions/defold-1.12.4/physics.d.ts +13 -11
  40. package/generated/versions/defold-1.12.4/profiler.d.ts +1 -1
  41. package/generated/versions/defold-1.12.4/render.d.ts +72 -15
  42. package/generated/versions/defold-1.12.4/resource.d.ts +100 -69
  43. package/generated/versions/defold-1.12.4/socket.d.ts +23 -13
  44. package/generated/versions/defold-1.12.4/sound.d.ts +3 -3
  45. package/generated/versions/defold-1.12.4/sprite.d.ts +9 -1
  46. package/generated/versions/defold-1.12.4/sys.d.ts +34 -23
  47. package/generated/versions/defold-1.12.4/vmath.d.ts +5 -5
  48. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +23 -1
  49. package/generated/versions/defold-1.13.0/buffer.d.ts +18 -15
  50. package/generated/versions/defold-1.13.0/camera.d.ts +2 -2
  51. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +12 -10
  52. package/generated/versions/defold-1.13.0/compute.d.ts +1 -1
  53. package/generated/versions/defold-1.13.0/go.d.ts +9 -5
  54. package/generated/versions/defold-1.13.0/graphics.d.ts +48 -0
  55. package/generated/versions/defold-1.13.0/gui.d.ts +47 -31
  56. package/generated/versions/defold-1.13.0/html5.d.ts +3 -1
  57. package/generated/versions/defold-1.13.0/http.d.ts +4 -2
  58. package/generated/versions/defold-1.13.0/image.d.ts +24 -15
  59. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  60. package/generated/versions/defold-1.13.0/material.d.ts +1 -1
  61. package/generated/versions/defold-1.13.0/model.d.ts +32 -3
  62. package/generated/versions/defold-1.13.0/physics.d.ts +13 -11
  63. package/generated/versions/defold-1.13.0/profiler.d.ts +1 -1
  64. package/generated/versions/defold-1.13.0/render.d.ts +72 -15
  65. package/generated/versions/defold-1.13.0/resource.d.ts +100 -69
  66. package/generated/versions/defold-1.13.0/socket.d.ts +23 -13
  67. package/generated/versions/defold-1.13.0/sound.d.ts +3 -3
  68. package/generated/versions/defold-1.13.0/sprite.d.ts +9 -1
  69. package/generated/versions/defold-1.13.0/sys.d.ts +34 -23
  70. package/generated/versions/defold-1.13.0/vmath.d.ts +5 -5
  71. package/generated/vmath.d.ts +5 -5
  72. package/index.d.ts +1 -0
  73. package/package.json +1 -1
  74. package/scripts/generate-api-signatures.ts +2 -1
  75. package/scripts/prose-constants.ts +96 -0
  76. package/scripts/regen.ts +6 -2
  77. package/src/component-properties.d.ts +33 -0
  78. package/src/core-types.ts +4 -2
  79. package/src/custom-messages.d.ts +4 -3
  80. package/src/doc-comment.ts +35 -12
  81. package/src/emit-dts.ts +457 -47
  82. package/src/engine-globals.d.ts +2 -2
  83. package/src/go-overloads.d.ts +11 -10
  84. package/src/index.ts +4 -0
  85. package/src/param-correction-provenance.ts +67 -0
  86. package/src/render-overloads.d.ts +15 -0
  87. package/src/script-api.ts +3 -1
@@ -83,7 +83,7 @@ declare global {
83
83
  * square root of the mean (average) value of the squared function of
84
84
  * the instantaneous values.
85
85
  * For instance: for a sinewave signal with a peak gain of -1.94 dB (0.8 linear),
86
- * the RMS is `0.8 × 1/sqrt(2)` which is about 0.566.
86
+ * the RMS is `0.8 × 1/sqrt(2)` which is about 0.566.
87
87
  * Note the returned value might be an approximation and in particular
88
88
  * the effective window might be larger than specified.
89
89
  *
@@ -202,8 +202,8 @@ declare global {
202
202
  * }
203
203
  *
204
204
  * export default defineScript({
205
- * init(self) {
206
- * self.countdown_id = sound.play("#countdown", undefined, sound_done);
205
+ * init() {
206
+ * return { countdown_id: sound.play("#countdown", undefined, sound_done) };
207
207
  * },
208
208
  * });
209
209
  * ```
@@ -52,7 +52,7 @@ declare global {
52
52
  * });
53
53
  * ```
54
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;
55
+ function play_flipbook(url: string | Hash | Url, id: string | Hash, complete_function?: (self: unknown, message_id: Hash, message: { current_tile: number; id: Hash }, sender: Url) => void, play_properties?: { offset?: number; playback_rate?: number }): void;
56
56
  /**
57
57
  * Sets horizontal flipping of the provided sprite's animations.
58
58
  * The sprite is identified by its URL.
@@ -65,6 +65,10 @@ declare global {
65
65
  * // How to flip a sprite so it faces the horizontal movement (it is assumed that
66
66
  * // the sprite component has id "sprite" and the original animation faces right):
67
67
  * export default defineScript({
68
+ * init() {
69
+ * return { velocity: vmath.vector3() };
70
+ * },
71
+ *
68
72
  * update(self, dt) {
69
73
  * // calculate self.velocity somehow
70
74
  * sprite.set_hflip("#sprite", self.velocity.x < 0);
@@ -86,6 +90,10 @@ declare global {
86
90
  * // assumed that the sprite component has id "sprite" and the original animation
87
91
  * // is up-right):
88
92
  * export default defineScript({
93
+ * init() {
94
+ * return { up_side_down: false };
95
+ * },
96
+ *
89
97
  * update(self, dt) {
90
98
  * // calculate self.up_side_down somehow, then:
91
99
  * sprite.set_vflip("#sprite", self.up_side_down);
@@ -55,11 +55,12 @@ declare global {
55
55
  * @example
56
56
  * ```ts
57
57
  * // Load data but return nil if path didn't exist
58
- * const path = "/save/game.dat";
59
- * if (!sys.exists(path)) {
60
- * return undefined;
58
+ * function load_data(path: string) {
59
+ * if (!sys.exists(path)) {
60
+ * return undefined;
61
+ * }
62
+ * return sys.load(path); // returns {} if it failed
61
63
  * }
62
- * return sys.load(path); // returns {} if it failed
63
64
  * ```
64
65
  */
65
66
  function exists(path: string): boolean;
@@ -97,7 +98,7 @@ declare global {
97
98
  * ```ts
98
99
  * // Check if twitter is installed:
99
100
  * const sysinfo = sys.get_sys_info();
100
- * let twitter = {};
101
+ * let twitter: { installed?: boolean } = {};
101
102
  *
102
103
  * if (sysinfo.system_name === "Android") {
103
104
  * twitter = sys.get_application_info("com.twitter.android");
@@ -262,13 +263,17 @@ declare global {
262
263
  * @example
263
264
  * ```ts
264
265
  * // Save data on the host
265
- * const mytable = { score: 100, level: 3 };
266
- * const host_path = sys.get_host_path("logs/test.txt");
267
- * sys.save(host_path, mytable);
266
+ * {
267
+ * const mytable = { score: 100, level: 3 };
268
+ * const host_path = sys.get_host_path("logs/test.txt");
269
+ * sys.save(host_path, mytable);
270
+ * }
268
271
  *
269
272
  * // Load data from the host
270
- * const host_path = sys.get_host_path("logs/test.txt");
271
- * const table = sys.load(host_path);
273
+ * {
274
+ * const host_path = sys.get_host_path("logs/test.txt");
275
+ * const table = sys.load(host_path);
276
+ * }
272
277
  * ```
273
278
  */
274
279
  function get_host_path(filename: string): string;
@@ -447,14 +452,16 @@ declare global {
447
452
  * @example
448
453
  * ```ts
449
454
  * // Load binary data from a custom project resource and update a texture resource:
450
- * function my_callback(self: unknown, request_id: unknown, result: unknown) {
451
- * const { status, buf } = result as { status: number; buf: Opaque<"buffer"> };
452
- * if (status === resource.REQUEST_STATUS_FINISHED) {
453
- * resource.set_texture("/my_texture", {}, buf); // texture args
455
+ * {
456
+ * function my_callback(self: unknown, request_id: unknown, result: unknown) {
457
+ * const { status, buf } = result as { status: number; buf: Opaque<"buffer"> };
458
+ * if (status === sys.REQUEST_STATUS_FINISHED) {
459
+ * resource.set_texture("/my_texture", {}, buf); // texture args
460
+ * }
454
461
  * }
455
- * }
456
462
  *
457
- * const my_request = sys.load_buffer_async("/assets/my_level_data.bin", my_callback);
463
+ * const my_request = sys.load_buffer_async("/assets/my_level_data.bin", my_callback);
464
+ * }
458
465
  *
459
466
  * // Load binary data from non-custom resource files on disk:
460
467
  * function my_callback(self: unknown, request_id: unknown, result: unknown) {
@@ -469,11 +476,15 @@ declare global {
469
476
  * }
470
477
  *
471
478
  * export default defineScript({
472
- * init(self) {
473
- * self.first_asset = hash("folder_next_to_binary/my_level_asset.bin");
474
- * self.second_asset = hash("/some_absolute_path/my_level.bin");
475
- * self.first_request = sys.load_buffer_async(self.first_asset, my_callback);
476
- * self.second_request = sys.load_buffer_async(self.second_asset, my_callback);
479
+ * init() {
480
+ * const first_path = "folder_next_to_binary/my_level_asset.bin";
481
+ * const second_path = "/some_absolute_path/my_level.bin";
482
+ * return {
483
+ * first_asset: hash(first_path),
484
+ * second_asset: hash(second_path),
485
+ * first_request: sys.load_buffer_async(first_path, my_callback),
486
+ * second_request: sys.load_buffer_async(second_path, my_callback),
487
+ * };
477
488
  * },
478
489
  * });
479
490
  * ```
@@ -572,7 +583,7 @@ declare global {
572
583
  * sys.save(my_file_path, my_table);
573
584
  * ```
574
585
  */
575
- function save(filename: string, table: Record<string | number, unknown>): void;
586
+ function save(filename: string, table: Record<string | number, unknown> | readonly unknown[]): void;
576
587
  /**
577
588
  * The buffer can later deserialized by `sys.deserialize`.
578
589
  * This function has all the same limitations as `sys.save`.
@@ -588,7 +599,7 @@ declare global {
588
599
  * const buffer = sys.serialize(my_table);
589
600
  * ```
590
601
  */
591
- function serialize(table: Record<string | number, unknown>): string;
602
+ function serialize(table: Record<string | number, unknown> | readonly unknown[]): string;
592
603
  /**
593
604
  * Sets the host that is used to check for network connectivity against.
594
605
  *
@@ -49,7 +49,7 @@ declare global {
49
49
  function conj(q1: Quaternion): Quaternion;
50
50
  /**
51
51
  * Given two linearly independent vectors P and Q, the cross product,
52
- * P &#x00D7; Q, is a vector that is perpendicular to both P and Q and
52
+ * P × Q, is a vector that is perpendicular to both P and Q and
53
53
  * therefore normal to the plane containing them.
54
54
  * If the two vectors have the same direction (or have the exact
55
55
  * opposite direction from one another, i.e. are not linearly independent)
@@ -70,8 +70,8 @@ declare global {
70
70
  function cross(v1: Vector3, v2: Vector3): Vector3;
71
71
  /**
72
72
  * The returned value is a scalar defined as:
73
- * `P &#x22C5; Q = |P| |Q| cos &#x03B8;`
74
- * where &#x03B8; is the angle between the vectors P and Q.
73
+ * `P ⋅ Q = |P| |Q| cos θ`
74
+ * where θ is the angle between the vectors P and Q.
75
75
  *
76
76
  * - If the dot product is positive then the angle between the vectors is below 90 degrees.
77
77
  *
@@ -437,8 +437,8 @@ declare global {
437
437
  /**
438
438
  * Calculates the extent the projection of the first vector onto the second.
439
439
  * The returned value is a scalar p defined as:
440
- * `p = |P| cos &#x03B8; / |Q|`
441
- * where &#x03B8; is the angle between the vectors P and Q.
440
+ * `p = |P| cos θ / |Q|`
441
+ * where θ is the angle between the vectors P and Q.
442
442
  *
443
443
  * @param v1 - vector to be projected on the second
444
444
  * @param v2 - vector onto which the first will be projected, must not have zero length
@@ -47,6 +47,7 @@ declare global {
47
47
  * @returns true if contact events are enabled
48
48
  */
49
49
  function are_contact_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
50
+ function are_contact_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
50
51
  /**
51
52
  * Check if hit events are enabled for a shape.
52
53
  *
@@ -54,6 +55,7 @@ declare global {
54
55
  * @returns true if hit events are enabled
55
56
  */
56
57
  function are_hit_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
58
+ function are_hit_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
57
59
  /**
58
60
  * Check if pre-solve events are enabled for a shape.
59
61
  *
@@ -61,6 +63,7 @@ declare global {
61
63
  * @returns true if pre-solve events are enabled
62
64
  */
63
65
  function are_pre_solve_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
66
+ function are_pre_solve_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
64
67
  /**
65
68
  * Check if sensor events are enabled for a shape.
66
69
  *
@@ -68,6 +71,7 @@ declare global {
68
71
  * @returns true if sensor events are enabled
69
72
  */
70
73
  function are_sensor_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
74
+ function are_sensor_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
71
75
  /**
72
76
  * Enable or disable contact events for a shape.
73
77
  *
@@ -75,6 +79,7 @@ declare global {
75
79
  * @param enable - true to enable contact events
76
80
  */
77
81
  function enable_contact_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
82
+ function enable_contact_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
78
83
  /**
79
84
  * Enable or disable hit events for a shape.
80
85
  *
@@ -82,6 +87,7 @@ declare global {
82
87
  * @param enable - true to enable hit events
83
88
  */
84
89
  function enable_hit_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
90
+ function enable_hit_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
85
91
  /**
86
92
  * Enable or disable pre-solve events for a shape.
87
93
  *
@@ -89,6 +95,7 @@ declare global {
89
95
  * @param enable - true to enable pre-solve events
90
96
  */
91
97
  function enable_pre_solve_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
98
+ function enable_pre_solve_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
92
99
  /**
93
100
  * Enable or disable sensor events for a shape.
94
101
  *
@@ -96,6 +103,7 @@ declare global {
96
103
  * @param enable - true to enable sensor events
97
104
  */
98
105
  function enable_sensor_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
106
+ function enable_sensor_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
99
107
  /**
100
108
  * Get the body owning a shape.
101
109
  *
@@ -103,6 +111,7 @@ declare global {
103
111
  * @returns owning body
104
112
  */
105
113
  function get_body(shape_id: Opaque<"b2Shape">): Opaque<"b2Body">;
114
+ function get_body(body: Opaque<"b2Body">, shape_index: number): Opaque<"b2Body">;
106
115
  /**
107
116
  * Get the closest point on a shape.
108
117
  *
@@ -111,6 +120,7 @@ declare global {
111
120
  * @returns closest world point on the shape
112
121
  */
113
122
  function get_closest_point(shape_id: Opaque<"b2Shape">, target: Vector3): Vector3;
123
+ function get_closest_point(body: Opaque<"b2Body">, shape_index: number, target: Vector3): Vector3;
114
124
  /**
115
125
  * Get shape contact capacity.
116
126
  *
@@ -118,6 +128,7 @@ declare global {
118
128
  * @returns maximum contact data count
119
129
  */
120
130
  function get_contact_capacity(shape_id: Opaque<"b2Shape">): number;
131
+ function get_contact_capacity(body: Opaque<"b2Body">, shape_index: number): number;
121
132
  /**
122
133
  * Get touching contact data for a shape.
123
134
  *
@@ -125,6 +136,7 @@ declare global {
125
136
  * @returns array of contact tables
126
137
  */
127
138
  function get_contact_data(shape_id: Opaque<"b2Shape">): Record<string | number, unknown>;
139
+ function get_contact_data(body: Opaque<"b2Body">, shape_index: number): Record<string | number, unknown>;
128
140
  /**
129
141
  * Get mass data for a shape.
130
142
  *
@@ -132,6 +144,7 @@ declare global {
132
144
  * @returns table with `mass`, `center`, and `inertia`
133
145
  */
134
146
  function get_mass_data(shape_id: Opaque<"b2Shape">): { mass: number; center: Vector3; inertia: number };
147
+ function get_mass_data(body: Opaque<"b2Body">, shape_index: number): { mass: number; center: Vector3; inertia: number };
135
148
  /**
136
149
  * Get shape material id.
137
150
  *
@@ -139,6 +152,7 @@ declare global {
139
152
  * @returns shape material id
140
153
  */
141
154
  function get_material(shape_id: Opaque<"b2Shape">): number;
155
+ function get_material(body: Opaque<"b2Body">, shape_index: number): number;
142
156
  /**
143
157
  * Get sensor overlap capacity.
144
158
  *
@@ -146,6 +160,7 @@ declare global {
146
160
  * @returns maximum sensor overlap count
147
161
  */
148
162
  function get_sensor_capacity(shape_id: Opaque<"b2Shape">): number;
163
+ function get_sensor_capacity(body: Opaque<"b2Body">, shape_index: number): number;
149
164
  /**
150
165
  * Get sensor overlaps.
151
166
  *
@@ -153,6 +168,7 @@ declare global {
153
168
  * @returns array of shape info tables
154
169
  */
155
170
  function get_sensor_overlaps(shape_id: Opaque<"b2Shape">): { shape_id: number }[];
171
+ function get_sensor_overlaps(body: Opaque<"b2Body">, shape_index: number): { shape_id: number }[];
156
172
  /**
157
173
  * Get a shape's geometry.
158
174
  *
@@ -160,6 +176,7 @@ declare global {
160
176
  * @returns shape table with numeric `type` from `b2d.shape.SHAPE_TYPE_*`
161
177
  */
162
178
  function get_shape(shape_id: Opaque<"b2Shape">): { type: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 };
179
+ function get_shape(body: Opaque<"b2Body">, shape_index: number): { type: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 };
163
180
  /**
164
181
  * Get the world owning a shape.
165
182
  *
@@ -167,6 +184,7 @@ declare global {
167
184
  * @returns owning world
168
185
  */
169
186
  function get_world(shape_id: Opaque<"b2Shape">): Opaque<"b2World">;
187
+ function get_world(body: Opaque<"b2Body">, shape_index: number): Opaque<"b2World">;
170
188
  /**
171
189
  * Validate a shape handle.
172
190
  *
@@ -174,6 +192,7 @@ declare global {
174
192
  * @returns true if the shape handle still refers to a live Box2D shape
175
193
  */
176
194
  function is_valid(shape_id: Opaque<"b2Shape">): boolean;
195
+ function is_valid(body: Opaque<"b2Body">, shape_index: number): boolean;
177
196
  /**
178
197
  * Ray cast a shape directly.
179
198
  *
@@ -184,6 +203,7 @@ declare global {
184
203
  * @returns hit table with `point`, `normal`, `fraction`, and `iterations`, or nil
185
204
  */
186
205
  function ray_cast(shape_id: Opaque<"b2Shape">, origin: Vector3, translation: Vector3, max_fraction?: number): { point: Vector3; normal: Vector3; fraction: number; iterations: number };
206
+ function ray_cast(body: Opaque<"b2Body">, shape_index: number, origin: Vector3, translation: Vector3, max_fraction?: number): { point: Vector3; normal: Vector3; fraction: number; iterations: number };
187
207
  /**
188
208
  * Set shape material id.
189
209
  *
@@ -191,6 +211,7 @@ declare global {
191
211
  * @param material - shape material id
192
212
  */
193
213
  function set_material(shape_id: Opaque<"b2Shape">, material: number): void;
214
+ function set_material(body: Opaque<"b2Body">, shape_index: number, material: number): void;
194
215
  /**
195
216
  * This updates the shape geometry using the same table format as
196
217
  * `b2d.body.create_shape` and `b2d.shape.get_shape`. The body mass is not
@@ -210,7 +231,8 @@ declare global {
210
231
  * }
211
232
  * ```
212
233
  */
213
- function set_shape(shape_id: Opaque<"b2Shape">, definition: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, update_mass: boolean): void;
234
+ function set_shape(shape_id: Opaque<"b2Shape">, definition: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, update_mass?: boolean): void;
235
+ function set_shape(body: Opaque<"b2Body">, shape_index: number, definition: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, update_mass?: boolean): void;
214
236
  }
215
237
  }
216
238
 
@@ -88,10 +88,10 @@ declare global {
88
88
  * // copy entire stream
89
89
  * const srcstream = buffer.get_stream(srcbuffer, hash("xyz"));
90
90
  * const dststream = buffer.get_stream(dstbuffer, hash("xyz"));
91
- * buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length);
91
+ * buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length());
92
92
  * ```
93
93
  */
94
- function copy_stream(dst: Opaque<"bufferstream"> & { [index: number]: number }, dstoffset: number, src: Opaque<"bufferstream"> & { [index: number]: number }, srcoffset: number, count: number): void;
94
+ function copy_stream(dst: Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> }, dstoffset: number, src: Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> }, srcoffset: number, count: number): void;
95
95
  /**
96
96
  * Create a new data buffer containing a specified set of streams. A data buffer
97
97
  * can contain one or more streams with typed data. This is useful for managing
@@ -111,24 +111,27 @@ declare global {
111
111
  * ```ts
112
112
  * // How to create and initialize a buffer
113
113
  * export default defineScript({
114
- * init(self) {
114
+ * init() {
115
115
  * const size = 128;
116
- * self.image = buffer.create(size * size, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
117
- * self.imagestream = buffer.get_stream(self.image, hash("rgb"));
118
- *
119
- * for (let y = 0; y < self.height; y++) {
120
- * for (let x = 0; x < self.width; x++) {
121
- * const index = y * self.width * 3 + x * 3;
122
- * self.imagestream[index + 0] = self.r;
123
- * self.imagestream[index + 1] = self.g;
124
- * self.imagestream[index + 2] = self.b;
116
+ * const [width, height] = [size, size];
117
+ * const [r, g, b] = [0xff, 0x80, 0x10];
118
+ * const image = buffer.create(size * size, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
119
+ * const imagestream = buffer.get_stream(image, hash("rgb"));
120
+ *
121
+ * for (let y = 0; y < height; y++) {
122
+ * for (let x = 0; x < width; x++) {
123
+ * const index = y * width * 3 + x * 3;
124
+ * imagestream[index + 0] = r;
125
+ * imagestream[index + 1] = g;
126
+ * imagestream[index + 2] = b;
125
127
  * }
126
128
  * }
129
+ * return { image, imagestream };
127
130
  * },
128
131
  * });
129
132
  * ```
130
133
  */
131
- function create(element_count: number, declaration: { name?: Hash | string; type?: Opaque<"constant">; count?: number }): Opaque<"buffer">;
134
+ function create(element_count: number, declaration: { name?: Hash | string; type?: buffer.ValueType; count?: number }[]): Opaque<"buffer">;
132
135
  /**
133
136
  * Get a copy of all the bytes from a specified stream as a Lua string.
134
137
  *
@@ -136,7 +139,7 @@ declare global {
136
139
  * @param stream_name - the name of the stream
137
140
  * @returns the buffer data as a Lua string
138
141
  */
139
- function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash): string;
142
+ function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash | string): string;
140
143
  /**
141
144
  * Get a named metadata entry from a buffer along with its type.
142
145
  *
@@ -160,7 +163,7 @@ declare global {
160
163
  * @param stream_name - the stream name
161
164
  * @returns the data stream
162
165
  */
163
- function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number };
166
+ function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
164
167
  /**
165
168
  * Creates or updates a metadata array entry on a buffer.
166
169
  * The value type and count given when updating the entry should match those used when first creating it.
@@ -137,7 +137,7 @@ declare global {
137
137
  * export default defineScript({
138
138
  * on_input(self, action_id, action) {
139
139
  * if (action_id === hash("touch")) {
140
- * if (action.pressed) {
140
+ * if (action.pressed && action.screen_x !== undefined && action.screen_y !== undefined) {
141
141
  * const perspective_camera = msg.url("#perspective_camera");
142
142
  * const random_z = math.random(
143
143
  * camera.get_near_z(perspective_camera) + 0.01,
@@ -169,7 +169,7 @@ declare global {
169
169
  * export default defineScript({
170
170
  * on_input(self, action_id, action) {
171
171
  * if (action_id === hash("touch")) {
172
- * if (action.pressed) {
172
+ * if (action.pressed && action.screen_x !== undefined && action.screen_y !== undefined) {
173
173
  * const world_position = camera.screen_xy_to_world(action.screen_x, action.screen_y);
174
174
  * go.set_position(world_position, "/go1");
175
175
  * }
@@ -46,18 +46,17 @@ declare global {
46
46
  * ```ts
47
47
  * // How to spawn a collection of game objects:
48
48
  * export default defineScript({
49
- * init(self) {
49
+ * init() {
50
50
  * // Spawn a small group of enemies.
51
51
  * const pos = vmath.vector3(100, 12.5, 0);
52
52
  * const rot = vmath.quat_rotation_z(Math.PI / 2);
53
53
  * const scale = 0.5;
54
- * const props = {
55
- * [hash("/enemy_leader")]: { health: 1000.0 },
56
- * [hash("/enemy_1")]: { health: 200.0 },
57
- * [hash("/enemy_2")]: { health: 400.0, color: hash("green") },
58
- * };
54
+ * const props = new LuaMap<Hash, Record<string, unknown>>();
55
+ * props.set(hash("/enemy_leader"), { health: 1000.0 });
56
+ * props.set(hash("/enemy_1"), { health: 200.0 });
57
+ * props.set(hash("/enemy_2"), { health: 400.0, color: hash("green") });
59
58
  *
60
- * self.enemy_ids = collectionfactory.create("#enemyfactory", pos, rot, props, scale);
59
+ * const enemy_ids = collectionfactory.create("#enemyfactory", pos, rot, props, scale);
61
60
  * // enemy_ids now map to the spawned instance ids:
62
61
  * //
63
62
  * // pprint(self.enemy_ids)
@@ -70,8 +69,11 @@ declare global {
70
69
  * // }
71
70
  *
72
71
  * // Send "attack" message to the leader. First look up its instance id.
73
- * const leader_id = self.enemy_ids[hash("/enemy_leader")];
74
- * msg.post(leader_id, "attack");
72
+ * const leader_id = enemy_ids.get(hash("/enemy_leader"));
73
+ * if (leader_id !== undefined) {
74
+ * msg.post(leader_id, "attack");
75
+ * }
76
+ * return { enemy_ids };
75
77
  * },
76
78
  * });
77
79
  *
@@ -81,7 +83,7 @@ declare global {
81
83
  * }
82
84
  * ```
83
85
  */
84
- function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): LuaMap<Hash, Hash>;
86
+ function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: LuaMap<Hash, Record<string | number, unknown>> | Record<string, Record<string | number, unknown>>, scale?: number | Vector3): LuaMap<Hash, Hash>;
85
87
  /**
86
88
  * This returns status of the collection factory.
87
89
  * Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED.
@@ -299,7 +299,7 @@ declare global {
299
299
  * compute.set_textures("/my_compute.computec", { my_texture: resource.texture() });
300
300
  * ```
301
301
  */
302
- function set_textures(path: Hash | string, textures: LuaMap<string, Hash>): void;
302
+ function set_textures(path: Hash | string, textures: LuaMap<string, Hash> | Record<string, Hash>): void;
303
303
  }
304
304
  }
305
305
 
@@ -321,7 +321,7 @@ declare global {
321
321
  * go.delete(ids, true);
322
322
  * ```
323
323
  */
324
- function _delete(id?: SceneGameObjectAddress | Hash | Url | (SceneGameObjectAddress | Hash | Url)[], recursive?: boolean): void;
324
+ function _delete(id?: SceneGameObjectAddress | Hash | Url | (SceneGameObjectAddress | Hash | Url)[] | boolean, recursive?: boolean): void;
325
325
  /**
326
326
  * This function can check for game objects in any collection by specifying
327
327
  * the collection name in the URL.
@@ -349,6 +349,10 @@ declare global {
349
349
  * @example
350
350
  * ```ts
351
351
  * export default defineScript({
352
+ * init() {
353
+ * return { some_value: 0 };
354
+ * },
355
+ *
352
356
  * final(self) {
353
357
  * // report finalization
354
358
  * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
@@ -791,7 +795,7 @@ declare global {
791
795
  * self.velocity = vmath.vector3();
792
796
  * } else {
793
797
  * // update velocity
794
- * self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0);
798
+ * self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);
795
799
  * }
796
800
  * }
797
801
  * },
@@ -833,12 +837,12 @@ declare global {
833
837
  * init() {
834
838
  * // store the url of instance "a" for later use, by specifying undefined as socket we
835
839
  * // automatically use our own socket
836
- * return { a_url: msg.url(undefined, go.get_id("a"), "script") };
840
+ * return { a_url: msg.url(undefined, go.get_id("a"), "script"), important_value: 0 };
837
841
  * },
838
842
  *
839
843
  * on_message(self, message_id, message, sender) {
840
844
  * // check message and sender
841
- * if (message_id === hash("my_data") && sender === self.a_url) {
845
+ * if (message_id === hash("my_data") && sender === self.a_url && typeof message.important_value === "number") {
842
846
  * // use the data in some way
843
847
  * self.important_value = message.important_value;
844
848
  * }
@@ -880,7 +884,7 @@ declare global {
880
884
  * self.velocity = vmath.vector3();
881
885
  * } else {
882
886
  * // update velocity
883
- * self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0);
887
+ * self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);
884
888
  * }
885
889
  * }
886
890
  * },
@@ -95,6 +95,54 @@ declare global {
95
95
  const FACE_TYPE_BACK: number & { readonly __brand: "graphics.FACE_TYPE_BACK" };
96
96
  const FACE_TYPE_FRONT: number & { readonly __brand: "graphics.FACE_TYPE_FRONT" };
97
97
  const FACE_TYPE_FRONT_AND_BACK: number & { readonly __brand: "graphics.FACE_TYPE_FRONT_AND_BACK" };
98
+ /**
99
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
100
+ */
101
+ const SEMANTIC_TYPE_BONE_INDICES: number & { readonly __brand: "graphics.SEMANTIC_TYPE_BONE_INDICES" };
102
+ /**
103
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
104
+ */
105
+ const SEMANTIC_TYPE_BONE_WEIGHTS: number & { readonly __brand: "graphics.SEMANTIC_TYPE_BONE_WEIGHTS" };
106
+ /**
107
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
108
+ */
109
+ const SEMANTIC_TYPE_COLOR: number & { readonly __brand: "graphics.SEMANTIC_TYPE_COLOR" };
110
+ /**
111
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
112
+ */
113
+ const SEMANTIC_TYPE_NONE: number & { readonly __brand: "graphics.SEMANTIC_TYPE_NONE" };
114
+ /**
115
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
116
+ */
117
+ const SEMANTIC_TYPE_NORMAL: number & { readonly __brand: "graphics.SEMANTIC_TYPE_NORMAL" };
118
+ /**
119
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
120
+ */
121
+ const SEMANTIC_TYPE_NORMAL_MATRIX: number & { readonly __brand: "graphics.SEMANTIC_TYPE_NORMAL_MATRIX" };
122
+ /**
123
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
124
+ */
125
+ const SEMANTIC_TYPE_PAGE_INDEX: number & { readonly __brand: "graphics.SEMANTIC_TYPE_PAGE_INDEX" };
126
+ /**
127
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
128
+ */
129
+ const SEMANTIC_TYPE_POSITION: number & { readonly __brand: "graphics.SEMANTIC_TYPE_POSITION" };
130
+ /**
131
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
132
+ */
133
+ const SEMANTIC_TYPE_TANGENT: number & { readonly __brand: "graphics.SEMANTIC_TYPE_TANGENT" };
134
+ /**
135
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
136
+ */
137
+ const SEMANTIC_TYPE_TEXCOORD: number & { readonly __brand: "graphics.SEMANTIC_TYPE_TEXCOORD" };
138
+ /**
139
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
140
+ */
141
+ const SEMANTIC_TYPE_TEXTURE_TRANSFORM_2D: number & { readonly __brand: "graphics.SEMANTIC_TYPE_TEXTURE_TRANSFORM_2D" };
142
+ /**
143
+ * Vertex attribute semantic type, for `material.set_vertex_attributes`.
144
+ */
145
+ const SEMANTIC_TYPE_WORLD_MATRIX: number & { readonly __brand: "graphics.SEMANTIC_TYPE_WORLD_MATRIX" };
98
146
  const STATE_ALPHA_TEST: number & { readonly __brand: "graphics.STATE_ALPHA_TEST" };
99
147
  const STATE_ALPHA_TEST_SUPPORTED: number & { readonly __brand: "graphics.STATE_ALPHA_TEST_SUPPORTED" };
100
148
  const STATE_BLEND: number & { readonly __brand: "graphics.STATE_BLEND" };