@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
@@ -14,7 +14,7 @@ declare global {
14
14
  * require features not in OpenGL ES 2.0, but those will not work cross platform.
15
15
  */
16
16
  namespace render {
17
- type constant_buffer = Opaque<"constant_buffer">;
17
+ type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
18
18
  type render_target = Opaque<"render_target">;
19
19
  type texture = Opaque<"texture">;
20
20
  type ClearBufferKey = typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT;
@@ -95,7 +95,7 @@ declare global {
95
95
  * });
96
96
  * ```
97
97
  */
98
- function constant_buffer(): Opaque<"constant_buffer">;
98
+ function constant_buffer(): Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
99
99
  /**
100
100
  * Deletes a render target created by a render script.
101
101
  * You cannot delete a render target resource.
@@ -177,6 +177,18 @@ declare global {
177
177
  * @example
178
178
  * ```ts
179
179
  * export default defineRenderScript({
180
+ * init() {
181
+ * const color_params = {
182
+ * format: graphics.TEXTURE_FORMAT_RGBA,
183
+ * width: render.get_window_width(),
184
+ * height: render.get_window_height(),
185
+ * };
186
+ * return {
187
+ * my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
188
+ * my_pred: render.predicate([hash("my_tag")]),
189
+ * };
190
+ * },
191
+ *
180
192
  * update(self, dt) {
181
193
  * render.enable_texture(0, self.my_render_target, graphics.BUFFER_TYPE_COLOR0_BIT);
182
194
  * // draw a predicate with the render target available as texture 0 in the predicate
@@ -188,7 +200,7 @@ declare global {
188
200
  * });
189
201
  * ```
190
202
  */
191
- function disable_texture(binding: Opaque<"texture"> | string | Hash): void;
203
+ function disable_texture(binding: Opaque<"texture"> | string | Hash | number): void;
192
204
  /**
193
205
  * Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes
194
206
  * the 'global working group' of the compute dispatch. Together with the 'local working group' specified in the compute shader
@@ -213,6 +225,7 @@ declare global {
213
225
  * height: render.get_window_height(),
214
226
  * };
215
227
  * return {
228
+ * backing_texture: resource.get_texture_info("/main/backing.texturec").handle,
216
229
  * scene_rt: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
217
230
  * };
218
231
  * },
@@ -232,7 +245,7 @@ declare global {
232
245
  * render.dispatch_compute(32, 32, 32, { constants });
233
246
  * ```
234
247
  */
235
- function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> }): void;
248
+ function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] } }): void;
236
249
  /**
237
250
  * Draws all objects that match a specified predicate. An optional constant buffer can be
238
251
  * provided to override the default constants. If no constants buffer is provided, a default
@@ -259,8 +272,12 @@ declare global {
259
272
  * ```ts
260
273
  * export default defineRenderScript({
261
274
  * init() {
262
- * // define a predicate matching anything with material tag "my_tag"
263
- * return { my_pred: render.predicate([hash("my_tag")]) };
275
+ * return {
276
+ * // define a predicate matching anything with material tag "my_tag"
277
+ * my_pred: render.predicate([hash("my_tag")]),
278
+ * proj: vmath.matrix4_perspective(math.rad(45), render.get_window_width() / render.get_window_height(), 0.1, 1000),
279
+ * view: vmath.matrix4_look_at(vmath.vector3(0, 0, 10), vmath.vector3(0, 0, 0), vmath.vector3(0, 1, 0)),
280
+ * };
264
281
  * },
265
282
  *
266
283
  * update(self, dt) {
@@ -283,7 +300,7 @@ declare global {
283
300
  * });
284
301
  * ```
285
302
  */
286
- function draw(predicate: number, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer">; sort_order?: number }): void;
303
+ function draw(predicate: number, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] }; sort_order?: number }): void;
287
304
  /**
288
305
  * Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
289
306
  *
@@ -403,6 +420,18 @@ declare global {
403
420
  * @example
404
421
  * ```ts
405
422
  * export default defineRenderScript({
423
+ * init() {
424
+ * const color_params = {
425
+ * format: graphics.TEXTURE_FORMAT_RGBA,
426
+ * width: render.get_window_width(),
427
+ * height: render.get_window_height(),
428
+ * };
429
+ * return {
430
+ * my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
431
+ * my_pred: render.predicate([hash("my_tag")]),
432
+ * };
433
+ * },
434
+ *
406
435
  * update(self, dt) {
407
436
  * // enable target so all drawing is done to it
408
437
  * render.set_render_target(self.my_render_target);
@@ -424,6 +453,10 @@ declare global {
424
453
  * ```ts
425
454
  * // Or enable a render target by resource id:
426
455
  * export default defineRenderScript({
456
+ * init() {
457
+ * return { my_pred: render.predicate([hash("my_tag")]) };
458
+ * },
459
+ *
427
460
  * update(self, dt) {
428
461
  * render.set_render_target("my_rt_resource");
429
462
  * render.draw(self.my_pred);
@@ -440,6 +473,10 @@ declare global {
440
473
  * ```ts
441
474
  * // Or bind a texture handle directly:
442
475
  * export default defineRenderScript({
476
+ * init() {
477
+ * return { my_texture_handle: resource.get_texture_info("/main/my_texture.texturec").handle };
478
+ * },
479
+ *
443
480
  * update(self, dt) {
444
481
  * // bind a texture to the texture unit 0
445
482
  * render.enable_texture(0, self.my_texture_handle);
@@ -449,7 +486,7 @@ declare global {
449
486
  * });
450
487
  * ```
451
488
  */
452
- function enable_texture(binding: number | string | Hash, handle_or_name: Opaque<"texture"> | string | Hash, buffer_type?: graphics.BufferType): void;
489
+ function enable_texture(binding: number | string | Hash, handle_or_name: Opaque<"texture"> | string | Hash | Opaque<"render_target"> | number, buffer_type?: graphics.BufferType): void;
453
490
  /**
454
491
  * Returns the logical window height that is set in the "game.project" settings.
455
492
  * Note that the actual window pixel size can change, either by device constraints
@@ -505,7 +542,7 @@ declare global {
505
542
  * });
506
543
  * ```
507
544
  */
508
- function get_render_target_height(render_target: Opaque<"render_target">, buffer_type: graphics.BufferType): number;
545
+ function get_render_target_height(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BufferType): number;
509
546
  /**
510
547
  * Returns the specified buffer width from a render target.
511
548
  *
@@ -550,7 +587,7 @@ declare global {
550
587
  * });
551
588
  * ```
552
589
  */
553
- function get_render_target_width(render_target: Opaque<"render_target">, buffer_type: graphics.BufferType): number;
590
+ function get_render_target_width(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BufferType): number;
554
591
  /**
555
592
  * Returns the logical window width that is set in the "game.project" settings.
556
593
  * Note that the actual window pixel size can change, either by device constraints
@@ -731,7 +768,7 @@ declare global {
731
768
  * });
732
769
  * ```
733
770
  */
734
- function set_camera(camera?: Url | number, options?: { use_frustum?: boolean }): void;
771
+ function set_camera(camera?: Url | number | string, options?: { use_frustum?: boolean }): void;
735
772
  /**
736
773
  * Specifies whether the individual color components in the frame buffer is enabled for writing (`true`) or disabled (`false`). For example, if `blue` is `false`, nothing is written to the blue component of any pixel in any of the color buffers, regardless of the drawing operation attempted. Note that writing are either enabled or disabled for entire color components, not the individual bits of a component.
737
774
  * The component masks are all initially `true`.
@@ -881,7 +918,7 @@ declare global {
881
918
  * offset for each polygon. The initial value is `0`.
882
919
  * `units` is multiplied by an implementation-specific value to create a
883
920
  * constant depth offset. The initial value is `0`.
884
- * The value of the offset is computed as `factor` &times; `DZ` + `r` &times; `units`
921
+ * The value of the offset is computed as `factor` × `DZ` + `r` × `units`
885
922
  * `DZ` is a measurement of the depth slope of the polygon which is the change in z (depth)
886
923
  * values divided by the change in either x or y coordinates, as you traverse a polygon.
887
924
  * The depth values are in window coordinates, clamped to the range [0, 1].
@@ -936,6 +973,18 @@ declare global {
936
973
  * // How to set a render target and draw to it and then switch back to the default render target
937
974
  * // The render target defines the depth/stencil buffers as transient, when set_render_target is called the next time the buffers may be invalidated and allow for optimisations depending on driver support
938
975
  * export default defineRenderScript({
976
+ * init() {
977
+ * const color_params = {
978
+ * format: graphics.TEXTURE_FORMAT_RGBA,
979
+ * width: render.get_window_width(),
980
+ * height: render.get_window_height(),
981
+ * };
982
+ * return {
983
+ * my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
984
+ * my_pred: render.predicate([hash("my_tag")]),
985
+ * };
986
+ * },
987
+ *
939
988
  * update(self, dt) {
940
989
  * // set render target so all drawing is done to it
941
990
  * render.set_render_target(self.my_render_target, {
@@ -955,6 +1004,10 @@ declare global {
955
1004
  * ```ts
956
1005
  * // Or set the render target by a render target resource identifier:
957
1006
  * export default defineRenderScript({
1007
+ * init() {
1008
+ * return { my_pred: render.predicate([hash("my_tag")]) };
1009
+ * },
1010
+ *
958
1011
  * update(self, dt) {
959
1012
  * render.set_render_target("my_rt_resource");
960
1013
  *
@@ -967,7 +1020,7 @@ declare global {
967
1020
  * });
968
1021
  * ```
969
1022
  */
970
- function set_render_target(render_target: Opaque<"render_target">, options?: { transient?: Record<string | number, unknown> }): void;
1023
+ function set_render_target(render_target: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT, options?: { transient?: graphics.BufferType[] }): void;
971
1024
  /**
972
1025
  * Sets the render target size for a render target created from
973
1026
  * either a render script, or from a render target resource.
@@ -990,7 +1043,7 @@ declare global {
990
1043
  * });
991
1044
  * ```
992
1045
  */
993
- function set_render_target_size(render_target: Opaque<"render_target">, width: number, height: number): void;
1046
+ function set_render_target_size(render_target: Opaque<"render_target"> | string | Hash, width: number, height: number): void;
994
1047
  /**
995
1048
  * Stenciling is similar to depth-buffering as it enables and disables drawing on a
996
1049
  * per-pixel basis. First, GL drawing primitives are drawn into the stencil planes.
@@ -1116,7 +1169,11 @@ declare global {
1116
1169
  * },
1117
1170
  *
1118
1171
  * on_message(self, message_id, message) {
1119
- * if (message_id === hash("set_view_projection")) {
1172
+ * if (
1173
+ * message_id === hash("set_view_projection") &&
1174
+ * types.is_matrix4(message.view) &&
1175
+ * types.is_matrix4(message.projection)
1176
+ * ) {
1120
1177
  * // camera view and projection arrives here.
1121
1178
  * self.view = message.view;
1122
1179
  * self.projection = message.projection;
@@ -21,9 +21,11 @@ declare global {
21
21
  * Load an atlas and set it to a sprite:
22
22
  * ```ts
23
23
  * // Load an atlas and set it to a sprite:
24
- * go.property("my_atlas", resource.atlas("/atlas.atlas"));
25
- *
26
24
  * export default defineScript({
25
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
26
+ * // registration from this field, and only this field types the property onto `self`.
27
+ * properties: { my_atlas: resource.atlas("/atlas.atlas") },
28
+ *
27
29
  * init(self) {
28
30
  * go.set("#sprite", "image", self.my_atlas);
29
31
  * },
@@ -33,9 +35,11 @@ declare global {
33
35
  * Load an atlas and set it to a gui:
34
36
  * ```ts
35
37
  * // Load an atlas and set it to a gui:
36
- * go.property("my_atlas", resource.atlas("/atlas.atlas"));
37
- *
38
38
  * export default defineScript({
39
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
40
+ * // registration from this field, and only this field types the property onto `self`.
41
+ * properties: { my_atlas: resource.atlas("/atlas.atlas") },
42
+ *
39
43
  * init(self) {
40
44
  * go.set("#gui", "textures", self.my_atlas, { key: "my_atlas" });
41
45
  * },
@@ -57,9 +61,11 @@ declare global {
57
61
  * @example
58
62
  * ```ts
59
63
  * // Set a unique buffer it to a sprite:
60
- * go.property("my_buffer", resource.buffer("/cube.buffer"));
61
- *
62
64
  * export default defineScript({
65
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
66
+ * // registration from this field, and only this field types the property onto `self`.
67
+ * properties: { my_buffer: resource.buffer("/cube.buffer") },
68
+ *
63
69
  * init(self) {
64
70
  * go.set("#mesh", "vertices", self.my_buffer);
65
71
  * },
@@ -195,7 +201,7 @@ declare global {
195
201
  * });
196
202
  * ```
197
203
  */
198
- function create_atlas(path: string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?: Opaque<"constant">; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean }[]; geometries?: { id?: string; width?: number; height?: number; pivot_x?: number; pivot_y?: number; rotated?: boolean }[]; vertices?: number[]; uvs?: number[]; indices?: number[] }): Hash;
204
+ function create_atlas(path: string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean }[]; geometries?: { id?: string; width?: number; height?: number; pivot_x?: number; pivot_y?: number; rotated?: boolean }[]; vertices?: number[]; uvs?: number[]; indices?: number[] }): Hash;
199
205
  /**
200
206
  * This function creates a new buffer resource that can be used in the same way as any buffer created during build time.
201
207
  * The function requires a valid buffer created from either buffer.create or another pre-existing buffer resource.
@@ -244,9 +250,9 @@ declare global {
244
250
  * const stream = buffer.get_stream(buffer_handle, hash("position"));
245
251
  *
246
252
  * // transfer vertex data to buffer
247
- * for (let k = 0; k < positions.length; k++) {
248
- * stream[k] = positions[k];
249
- * }
253
+ * positions.forEach((value, k) => {
254
+ * stream[k] = value;
255
+ * });
250
256
  *
251
257
  * const my_buffer = resource.create_buffer("/my_buffer.bufferc", { buffer: buffer_handle });
252
258
  * go.set("/go#mesh", "vertices", my_buffer);
@@ -288,6 +294,11 @@ declare global {
288
294
  * export default defineScript({
289
295
  * init() {
290
296
  * // create a new sound resource, given the initial chunk of the file
297
+ * const [data] = sys.load_resource("/sounds/music_header.oggc");
298
+ * if (data === undefined) {
299
+ * return;
300
+ * }
301
+ * const filesize = 1048576;
291
302
  * const relative_path = "/a/unique/resource/name.oggc";
292
303
  * const hash = resource.create_sound_data(relative_path, { data, filesize, partial: true });
293
304
  * go.set("#music", "sound", hash); // override the previous sound resource
@@ -477,8 +488,8 @@ declare global {
477
488
  * width: 32,
478
489
  * height: 32,
479
490
  * depth: 32,
480
- * format: resource.TEXTURE_FORMAT_RGBA32F,
481
- * flags: resource.TEXTURE_USAGE_FLAG_STORAGE + resource.TEXTURE_USAGE_FLAG_SAMPLE,
491
+ * format: graphics.TEXTURE_FORMAT_RGBA32F,
492
+ * flags: graphics.TEXTURE_USAGE_FLAG_STORAGE + graphics.TEXTURE_USAGE_FLAG_SAMPLE,
482
493
  * });
483
494
  *
484
495
  * // pass the backing texture to the render script
@@ -708,9 +719,11 @@ declare global {
708
719
  * Load a font and set it to a label:
709
720
  * ```ts
710
721
  * // Load a font and set it to a label:
711
- * go.property("my_font", resource.font("/font.font"));
712
- *
713
722
  * export default defineScript({
723
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
724
+ * // registration from this field, and only this field types the property onto `self`.
725
+ * properties: { my_font: resource.font("/font.font") },
726
+ *
714
727
  * init(self) {
715
728
  * go.set("#label", "font", self.my_font);
716
729
  * },
@@ -720,9 +733,11 @@ declare global {
720
733
  * Load a font and set it to a gui:
721
734
  * ```ts
722
735
  * // Load a font and set it to a gui:
723
- * go.property("my_font", resource.font("/font.font"));
724
- *
725
736
  * export default defineScript({
737
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
738
+ * // registration from this field, and only this field types the property onto `self`.
739
+ * properties: { my_font: resource.font("/font.font") },
740
+ *
726
741
  * init(self) {
727
742
  * go.set("#gui", "fonts", self.my_font, { key: "my_font" });
728
743
  * },
@@ -746,7 +761,7 @@ declare global {
746
761
  * `geometries`, preserving the frame-to-geometry mapping used by the atlas.
747
762
  * See resource.set_atlas for a detailed description of each field
748
763
  */
749
- function get_atlas(path: Hash | string): { texture: string | Hash; animations: { id: string; width: number; height: number; frame_start: number; frame_end: number; playback: Opaque<"constant">; fps: number; flip_vertical: boolean; flip_horizontal: boolean }[]; geometries: { vertices: number[]; uvs: number[]; indices: number[] }[] };
764
+ function get_atlas(path: Hash | string): { texture: string | Hash; animations: { id: string; width: number; height: number; frame_start: number; frame_end: number; playback: go.Playback; fps: number; flip_vertical: boolean; flip_horizontal: boolean }[]; geometries: { vertices: number[]; uvs: number[]; indices: number[] }[] };
750
765
  /**
751
766
  * gets the buffer from a resource
752
767
  *
@@ -757,11 +772,11 @@ declare global {
757
772
  * // How to get the data from a buffer
758
773
  * export default defineScript({
759
774
  * init() {
760
- * const res_path = go.get("#mesh", "vertices");
775
+ * const res_path = go.get<mesh.properties>()("#mesh", "vertices");
761
776
  * const buf = resource.get_buffer(res_path);
762
777
  * const stream_positions = buffer.get_stream(buf, "position");
763
778
  *
764
- * for (let i = 0; i < stream_positions.length; i++) {
779
+ * for (let i = 0; i < stream_positions.length(); i++) {
765
780
  * print(i, stream_positions[i]);
766
781
  * }
767
782
  * },
@@ -871,7 +886,7 @@ declare global {
871
886
  * ```ts
872
887
  * export default defineScript({
873
888
  * init() {
874
- * const font = go.get("#label", "font");
889
+ * const font = go.get<label.properties>()("#label", "font");
875
890
  * const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
876
891
  * pprint(metrics);
877
892
  * },
@@ -993,9 +1008,11 @@ declare global {
993
1008
  * Load a material and set it to a sprite:
994
1009
  * ```ts
995
1010
  * // Load a material and set it to a sprite:
996
- * go.property("my_material", resource.material("/material.material"));
997
- *
998
1011
  * export default defineScript({
1012
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1013
+ * // registration from this field, and only this field types the property onto `self`.
1014
+ * properties: { my_material: resource.material("/material.material") },
1015
+ *
999
1016
  * init(self) {
1000
1017
  * go.set("#sprite", "material", self.my_material);
1001
1018
  * },
@@ -1005,9 +1022,11 @@ declare global {
1005
1022
  * Load a material resource and update a named material with the resource:
1006
1023
  * ```ts
1007
1024
  * // Load a material resource and update a named material with the resource:
1008
- * go.property("my_material", resource.material("/material.material"));
1009
- *
1010
1025
  * export default defineScript({
1026
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1027
+ * // registration from this field, and only this field types the property onto `self`.
1028
+ * properties: { my_material: resource.material("/material.material") },
1029
+ *
1011
1030
  * init(self) {
1012
1031
  * go.set("#gui", "materials", self.my_material, { key: "my_material" });
1013
1032
  * },
@@ -1036,9 +1055,11 @@ declare global {
1036
1055
  * @example
1037
1056
  * ```ts
1038
1057
  * // Set a render target color attachment as a model texture:
1039
- * go.property("my_render_target", resource.render_target("/rt.render_target"));
1040
- *
1041
1058
  * export default defineScript({
1059
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1060
+ * // registration from this field, and only this field types the property onto `self`.
1061
+ * properties: { my_render_target: resource.render_target("/rt.render_target") },
1062
+ *
1042
1063
  * init(self) {
1043
1064
  * const rt_info = resource.get_render_target_info(self.my_render_target);
1044
1065
  * go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
@@ -1057,7 +1078,7 @@ declare global {
1057
1078
  * // Assuming the folder "/res" is added to the project custom resources:
1058
1079
  * // load a texture resource and set it on a sprite
1059
1080
  * const buffer = resource.load("/res/new.texturec");
1060
- * resource.set(go.get("#sprite", "texture0"), buffer);
1081
+ * resource.set(go.get<sprite.properties>()("#sprite", "texture0"), buffer);
1061
1082
  * ```
1062
1083
  */
1063
1084
  function set(path: string | Hash, buffer: Opaque<"buffer">): void;
@@ -1136,6 +1157,8 @@ declare global {
1136
1157
  * frame_end: 6,
1137
1158
  * playback: go.PLAYBACK_LOOP_PINGPONG,
1138
1159
  * fps: 8,
1160
+ * flip_vertical: false,
1161
+ * flip_horizontal: false,
1139
1162
  * };
1140
1163
  * data.animations.push(my_animation);
1141
1164
  * resource.set_atlas("/main/my_atlas.a.texturesetc", data);
@@ -1171,7 +1194,7 @@ declare global {
1171
1194
  * });
1172
1195
  * ```
1173
1196
  */
1174
- function set_atlas(path: Hash | string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?: Opaque<"constant">; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean }[]; geometries?: { vertices?: number[]; uvs?: number[]; indices?: number[] }[]; vertices?: number[]; uvs?: number[]; indices?: number[] }): void;
1197
+ function set_atlas(path: Hash | string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean }[]; geometries?: { vertices?: number[]; uvs?: number[]; indices?: number[] }[]; vertices?: number[]; uvs?: number[]; indices?: number[] }): void;
1175
1198
  /**
1176
1199
  * Sets the buffer of a resource. By default, setting the resource buffer will either copy the data from the incoming buffer object
1177
1200
  * to the buffer stored in the destination resource, or make a new buffer object if the sizes between the source buffer and the destination buffer
@@ -1198,7 +1221,7 @@ declare global {
1198
1221
  *
1199
1222
  * export default defineScript({
1200
1223
  * init() {
1201
- * const res_path = go.get("#mesh", "vertices");
1224
+ * const res_path = go.get<mesh.properties>()("#mesh", "vertices");
1202
1225
  *
1203
1226
  * const positions = [
1204
1227
  * 1, -1, 0,
@@ -1318,24 +1341,25 @@ declare global {
1318
1341
  * ```ts
1319
1342
  * // How to set all pixels of an atlas
1320
1343
  * export default defineScript({
1321
- * init(self) {
1322
- * self.height = 128;
1323
- * self.width = 128;
1324
- * self.buffer = buffer.create(self.width * self.height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
1325
- * self.stream = buffer.get_stream(self.buffer, hash("rgb"));
1326
- *
1327
- * for (let y = 0; y < self.height; y++) {
1328
- * for (let x = 0; x < self.width; x++) {
1329
- * const index = y * self.width * 3 + x * 3;
1330
- * self.stream[index + 0] = 0xff;
1331
- * self.stream[index + 1] = 0x80;
1332
- * self.stream[index + 2] = 0x10;
1344
+ * init() {
1345
+ * const height = 128;
1346
+ * const width = 128;
1347
+ * const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
1348
+ * const stream = buffer.get_stream(buf, hash("rgb"));
1349
+ *
1350
+ * for (let y = 0; y < height; y++) {
1351
+ * for (let x = 0; x < width; x++) {
1352
+ * const index = y * width * 3 + x * 3;
1353
+ * stream[index + 0] = 0xff;
1354
+ * stream[index + 1] = 0x80;
1355
+ * stream[index + 2] = 0x10;
1333
1356
  * }
1334
1357
  * }
1335
1358
  *
1336
- * const resource_path = go.get("#model", "texture0");
1337
- * const args = { width: self.width, height: self.height, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };
1338
- * resource.set_texture(resource_path, args, self.buffer);
1359
+ * const resource_path = go.get<model.properties>()("#model", "texture0");
1360
+ * const args = { width, height, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };
1361
+ * resource.set_texture(resource_path, args, buf);
1362
+ * return { buffer: buf, stream };
1339
1363
  * },
1340
1364
  * });
1341
1365
  * ```
@@ -1344,26 +1368,27 @@ declare global {
1344
1368
  * ```ts
1345
1369
  * // How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.
1346
1370
  * export default defineScript({
1347
- * init(self) {
1348
- * self.x = 16;
1349
- * self.y = 16;
1350
- * self.height = 128 - self.x * 2;
1351
- * self.width = 128 - self.y * 2;
1352
- * self.buffer = buffer.create(self.width * self.height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
1353
- * self.stream = buffer.get_stream(self.buffer, hash("rgb"));
1354
- *
1355
- * for (let y = 0; y < self.height; y++) {
1356
- * for (let x = 0; x < self.width; x++) {
1357
- * const index = y * self.width * 3 + x * 3;
1358
- * self.stream[index + 0] = 0xff;
1359
- * self.stream[index + 1] = 0x80;
1360
- * self.stream[index + 2] = 0x10;
1371
+ * init() {
1372
+ * const x = 16;
1373
+ * const y = 16;
1374
+ * const height = 128 - x * 2;
1375
+ * const width = 128 - y * 2;
1376
+ * const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
1377
+ * const stream = buffer.get_stream(buf, hash("rgb"));
1378
+ *
1379
+ * for (let row = 0; row < height; row++) {
1380
+ * for (let col = 0; col < width; col++) {
1381
+ * const index = row * width * 3 + col * 3;
1382
+ * stream[index + 0] = 0xff;
1383
+ * stream[index + 1] = 0x80;
1384
+ * stream[index + 2] = 0x10;
1361
1385
  * }
1362
1386
  * }
1363
1387
  *
1364
- * const resource_path = go.get("#model", "texture0");
1365
- * const args = { width: self.width, height: self.height, x: self.x, y: self.y, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };
1366
- * resource.set_texture(resource_path, args, self.buffer);
1388
+ * const resource_path = go.get<model.properties>()("#model", "texture0");
1389
+ * const args = { width, height, x, y, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };
1390
+ * resource.set_texture(resource_path, args, buf);
1391
+ * return { buffer: buf, stream };
1367
1392
  * },
1368
1393
  * });
1369
1394
  * ```
@@ -1371,11 +1396,13 @@ declare global {
1371
1396
  * Update a texture from a buffer resource
1372
1397
  * ```ts
1373
1398
  * // Update a texture from a buffer resource
1374
- * go.property("my_buffer", resource.buffer("/my_default_buffer.buffer"));
1375
- *
1376
1399
  * export default defineScript({
1400
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1401
+ * // registration from this field, and only this field types the property onto `self`.
1402
+ * properties: { my_buffer: resource.buffer("/my_default_buffer.buffer") },
1403
+ *
1377
1404
  * init(self) {
1378
- * const resource_path = go.get("#model", "texture0");
1405
+ * const resource_path = go.get<model.properties>()("#model", "texture0");
1379
1406
  * // the "my_buffer" resource is expected to hold 128 * 128 * 3 bytes!
1380
1407
  * const args = {
1381
1408
  * width: 128,
@@ -1419,7 +1446,7 @@ declare global {
1419
1446
  * width: 8,
1420
1447
  * height: 8,
1421
1448
  * depth: 8,
1422
- * format: resource.TEXTURE_FORMAT_RGBA32F,
1449
+ * format: graphics.TEXTURE_FORMAT_RGBA32F,
1423
1450
  * };
1424
1451
  *
1425
1452
  * // This expects that the texture resource "/my_3d_texture.texturec" already exists
@@ -1476,9 +1503,11 @@ declare global {
1476
1503
  * @example
1477
1504
  * ```ts
1478
1505
  * // Load a texture and set it to a model:
1479
- * go.property("my_texture", resource.texture("/texture.png"));
1480
- *
1481
1506
  * export default defineScript({
1507
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1508
+ * // registration from this field, and only this field types the property onto `self`.
1509
+ * properties: { my_texture: resource.texture("/texture.png") },
1510
+ *
1482
1511
  * init(self) {
1483
1512
  * go.set("#model", "texture0", self.my_texture);
1484
1513
  * },
@@ -1500,9 +1529,11 @@ declare global {
1500
1529
  * @example
1501
1530
  * ```ts
1502
1531
  * // Load tile source and set it to a tile map:
1503
- * go.property("my_tile_source", resource.tile_source("/tilesource.tilesource"));
1504
- *
1505
1532
  * export default defineScript({
1533
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1534
+ * // registration from this field, and only this field types the property onto `self`.
1535
+ * properties: { my_tile_source: resource.tile_source("/tilesource.tilesource") },
1536
+ *
1506
1537
  * init(self) {
1507
1538
  * go.set("#tilemap", "tile_source", self.my_tile_source);
1508
1539
  * },
@@ -17,7 +17,7 @@ declare global {
17
17
  * require "builtins.scripts.socket"
18
18
  * ```
19
19
  *
20
- * LuaSocket is Copyright &copy; 2004-2007 Diego Nehab. All rights reserved.
20
+ * LuaSocket is Copyright © 2004-2007 Diego Nehab. All rights reserved.
21
21
  * LuaSocket is free software, released under the MIT license (same license as the Lua core).
22
22
  */
23
23
  namespace socket {
@@ -640,15 +640,18 @@ declare global {
640
640
  * // create a try function that closes 'c' on error
641
641
  * const try_ = socket.newtry(() => c.close());
642
642
  * // do everything reassured c will be closed
643
- * try_(c.send("hello there?\r\n"));
644
- * const answer = try_(c.receive());
643
+ * const [sent, sendError, lastByte] = c.send("hello there?\r\n");
644
+ * try_(sent, sendError, lastByte);
645
+ * const [line, receiveError, partial] = c.receive();
646
+ * const answer = try_(line, receiveError, partial);
645
647
  * // ...
646
- * try_(c.send("good bye\r\n"));
648
+ * const [byeSent, byeError, byeLastByte] = c.send("good bye\r\n");
649
+ * try_(byeSent, byeError, byeLastByte);
647
650
  * c.close();
648
651
  * }
649
652
  * ```
650
653
  */
651
- function newtry(finalizer: () => void): (...args: unknown[]) => unknown;
654
+ function newtry(finalizer?: () => void): <T>(value: T | undefined, ...rest: T extends { readonly __tstlMultiReturn: unknown } ? [boxedMultiReturn: never] : unknown[]) => T;
652
655
  /**
653
656
  * Converts a function that throws exceptions into a safe function. This function only catches exceptions thrown by try functions. It does not catch normal Lua errors.
654
657
  * Beware that if your function performs some illegal operation that raises an error, the protected function will catch the error and return it as a string. This is because try functions uses errors as the mechanism to throw exceptions.
@@ -659,17 +662,20 @@ declare global {
659
662
  * ```ts
660
663
  * const dostuff = socket.protect(() => {
661
664
  * let try_ = socket.newtry();
662
- * const c = try_(socket.connect("myserver.com", 80));
665
+ * const [conn, connectError] = socket.connect("myserver.com", 80);
666
+ * const c = try_(conn, connectError);
663
667
  * try_ = socket.newtry(() => c.close());
664
- * try_(c.send("hello?\r\n"));
665
- * const answer = try_(c.receive());
668
+ * const [sent, sendError, lastByte] = c.send("hello?\r\n");
669
+ * try_(sent, sendError, lastByte);
670
+ * const [line, receiveError, partial] = c.receive();
671
+ * const answer = try_(line, receiveError, partial);
666
672
  * c.close();
667
673
  * });
668
674
  *
669
675
  * const [n, error] = dostuff();
670
676
  * ```
671
677
  */
672
- function protect(func: (...args: unknown[]) => unknown): (arg0: unknown) => void;
678
+ function protect(func: (...args: unknown[]) => unknown): (...args: unknown[]) => LuaMultiReturn<[unknown, string | undefined]>;
673
679
  /**
674
680
  * The function returns a list with the sockets ready for reading, a list with the sockets ready for writing and an error message. The error message is "timeout" if a timeout condition was met and nil otherwise. The returned tables are doubly keyed both by integers and also by the sockets themselves, to simplify the test if a specific socket has changed status.
675
681
  * `Recvt` and `sendt` parameters can be empty tables or `nil`. Non-socket values (or values with non-numeric indices) in these arrays will be silently ignored.
@@ -700,12 +706,16 @@ declare global {
700
706
  * const line = "250 OK";
701
707
  *
702
708
  * // Instead of doing the following with dummy variables:
703
- * // get the status code and separator from SMTP server reply
704
- * const [dummy1, dummy2, code, sep] = string.find(line, "^(%d%d%d)(.?)");
709
+ * {
710
+ * // get the status code and separator from SMTP server reply
711
+ * const [dummy1, dummy2, code, sep] = string.find(line, "^(%d%d%d)(.?)");
712
+ * }
705
713
  *
706
714
  * // You can skip a number of variables:
707
- * // get the status code and separator from SMTP server reply
708
- * const [code, sep] = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"));
715
+ * {
716
+ * // get the status code and separator from SMTP server reply
717
+ * const [code, sep] = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"));
718
+ * }
709
719
  * ```
710
720
  */
711
721
  function skip(d: number, ret1?: unknown, ret2?: unknown, retN?: unknown): LuaMultiReturn<[unknown, unknown, unknown]>;