@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
@@ -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]>;
@@ -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 &times; 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
  * Resets a shader constant for a sprite component.
58
58
  * The constant must be defined in the material assigned to the sprite.
@@ -79,6 +79,10 @@ declare global {
79
79
  * // How to flip a sprite so it faces the horizontal movement (it is assumed that
80
80
  * // the sprite component has id "sprite" and the original animation faces right):
81
81
  * export default defineScript({
82
+ * init() {
83
+ * return { velocity: vmath.vector3() };
84
+ * },
85
+ *
82
86
  * update(self, dt) {
83
87
  * // calculate self.velocity somehow
84
88
  * sprite.set_hflip("#sprite", self.velocity.x < 0);
@@ -100,6 +104,10 @@ declare global {
100
104
  * // assumed that the sprite component has id "sprite" and the original animation
101
105
  * // is up-right):
102
106
  * export default defineScript({
107
+ * init() {
108
+ * return { up_side_down: false };
109
+ * },
110
+ *
103
111
  * update(self, dt) {
104
112
  * // calculate self.up_side_down somehow, then:
105
113
  * 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