@defold-typescript/types 0.8.3 → 0.9.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 (47) hide show
  1. package/README.md +1 -1
  2. package/api-targets.json +18 -0
  3. package/generated/b2d_body.d.ts +348 -0
  4. package/generated/buffer.d.ts +3 -0
  5. package/generated/camera.d.ts +236 -1
  6. package/generated/collectionfactory.d.ts +4 -0
  7. package/generated/factory.d.ts +4 -0
  8. package/generated/font.d.ts +81 -0
  9. package/generated/go.d.ts +53 -0
  10. package/generated/gui.d.ts +264 -49
  11. package/generated/html5.d.ts +17 -13
  12. package/generated/http.d.ts +16 -0
  13. package/generated/image.d.ts +24 -0
  14. package/generated/json.d.ts +2 -0
  15. package/generated/kinds/gui-script.d.ts +3 -0
  16. package/generated/kinds/render-script.d.ts +3 -0
  17. package/generated/kinds/script.d.ts +3 -0
  18. package/generated/model.d.ts +14 -0
  19. package/generated/msg.d.ts +17 -11
  20. package/generated/particlefx.d.ts +6 -0
  21. package/generated/physics.d.ts +32 -0
  22. package/generated/profiler.d.ts +14 -0
  23. package/generated/render.d.ts +109 -0
  24. package/generated/resource.d.ts +223 -0
  25. package/generated/socket.d.ts +4 -0
  26. package/generated/sound.d.ts +6 -0
  27. package/generated/sprite.d.ts +5 -0
  28. package/generated/sys.d.ts +136 -0
  29. package/generated/tilemap.d.ts +2 -0
  30. package/generated/timer.d.ts +3 -0
  31. package/generated/vmath.d.ts +109 -93
  32. package/generated/window.d.ts +24 -1
  33. package/index.d.ts +8 -0
  34. package/package.json +1 -1
  35. package/scripts/fidelity-baseline.json +18 -2
  36. package/scripts/regen.ts +5 -0
  37. package/scripts/signature-store-io.ts +18 -0
  38. package/scripts/sync-api-docs.ts +208 -12
  39. package/src/core-types.ts +4 -2
  40. package/src/doc-comment.ts +42 -5
  41. package/src/emit-dts.ts +20 -1
  42. package/src/engine-globals.d.ts +2 -0
  43. package/src/example-store.ts +11 -7
  44. package/src/index.ts +18 -1
  45. package/src/msg-overloads.d.ts +3 -0
  46. package/src/signature-store.ts +20 -0
  47. package/src/window-event-guard.d.ts +52 -0
@@ -15,17 +15,22 @@ declare global {
15
15
  * @param url - the sprite that should play the animation
16
16
  * @param id - hashed id of the animation to play
17
17
  * @param complete_function - function to call when the animation has completed.
18
+ *
18
19
  * `self`
19
20
  * object The current object.
20
21
  * `message_id`
21
22
  * hash The name of the completion message, `"animation_done"`.
22
23
  * `message`
23
24
  * table Information about the completion:
25
+ *
24
26
  * - number `current_tile` - the current tile of the sprite.
27
+ *
25
28
  * - hash `id` - id of the animation that was completed.
29
+ *
26
30
  * `sender`
27
31
  * url The invoker of the callback: the sprite component.
28
32
  * @param play_properties - optional table with properties:
33
+ *
29
34
  * `offset`
30
35
  * number the normalized initial value of the animation cursor when the animation starts playing.
31
36
  * `playback_rate`
@@ -19,6 +19,18 @@ declare global {
19
19
  * no network connection found
20
20
  */
21
21
  const NETWORK_DISCONNECTED: number & { readonly __brand: "sys.NETWORK_DISCONNECTED" };
22
+ /**
23
+ * an asyncronous request is unable to read the resource
24
+ */
25
+ const REQUEST_STATUS_ERROR_IO_ERROR: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_IO_ERROR" };
26
+ /**
27
+ * an asyncronous request is unable to locate the resource
28
+ */
29
+ const REQUEST_STATUS_ERROR_NOT_FOUND: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_NOT_FOUND" };
30
+ /**
31
+ * an asyncronous request has finished successfully
32
+ */
33
+ const REQUEST_STATUS_FINISHED: number & { readonly __brand: "sys.REQUEST_STATUS_FINISHED" };
22
34
  /**
23
35
  * This function will raise a Lua error if an error occurs while deserializing the buffer.
24
36
  *
@@ -75,6 +87,7 @@ declare global {
75
87
  *
76
88
  * @param app_string - platform specific string with application package or query, see above for details.
77
89
  * @returns table with application information in the following fields:
90
+ *
78
91
  * `installed`
79
92
  * boolean `true` if the application is installed, `false` otherwise.
80
93
  * @example
@@ -201,8 +214,11 @@ declare global {
201
214
  * On desktop, this function always return `sys.NETWORK_CONNECTED`.
202
215
  *
203
216
  * @returns network connectivity status:
217
+ *
204
218
  * - `sys.NETWORK_DISCONNECTED` (no network connection is found)
219
+ *
205
220
  * - `sys.NETWORK_CONNECTED_CELLULAR` (connected through mobile cellular)
221
+ *
206
222
  * - `sys.NETWORK_CONNECTED` (otherwise, Wifi)
207
223
  * @example
208
224
  * ```ts
@@ -217,6 +233,7 @@ declare global {
217
233
  * Returns a table with engine information.
218
234
  *
219
235
  * @returns table with engine information in the following fields:
236
+ *
220
237
  * `version`
221
238
  * string The current Defold engine version, i.e. "1.2.96"
222
239
  * `version_sha1`
@@ -255,6 +272,7 @@ declare global {
255
272
  * Returns an array of tables with information on network interfaces.
256
273
  *
257
274
  * @returns an array of tables. Each table entry contain the following fields:
275
+ *
258
276
  * `name`
259
277
  * string Interface name
260
278
  * `address`
@@ -315,6 +333,7 @@ declare global {
315
333
  * @param options - optional options table
316
334
  * - ignore_secure boolean this flag ignores values might be secured by OS e.g. `device_ident`
317
335
  * @returns table with system information in the following fields:
336
+ *
318
337
  * `device_model`
319
338
  * string Only available on iOS and Android.
320
339
  * `manufacturer`
@@ -364,6 +383,96 @@ declare global {
364
383
  * ```
365
384
  */
366
385
  function load(filename: string): Record<string | number, unknown>;
386
+ /**
387
+ * The sys.load_buffer function will first try to load the resource
388
+ * from any of the mounted resource locations and return the data if
389
+ * any matching entries found. If not, the path will be tried
390
+ * as is from the primary disk on the device.
391
+ * In order for the engine to include custom resources in the build process, you need
392
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
393
+ * You can specify single resource files or directories. If a directory is included
394
+ * in the resource list, all files and directories in that directory is recursively
395
+ * included:
396
+ * For example "main/data/,assets/level_data.json".
397
+ *
398
+ * @param path - the path to load the buffer from
399
+ * @returns the buffer with data
400
+ * @example
401
+ * ```ts
402
+ * // Load binary data from a custom project resource:
403
+ * const my_buffer = sys.load_buffer("/assets/my_level_data.bin");
404
+ * const data_str = buffer.get_bytes(my_buffer, "data");
405
+ * const has_my_header = data_str.slice(0, 6) === "D3F0LD";
406
+ *
407
+ * // Load binary data from non-custom resource files on disk:
408
+ * const asset_1 = sys.load_buffer("folder_next_to_binary/my_level_asset.txt");
409
+ * const asset_2 = sys.load_buffer("/my/absolute/path");
410
+ * ```
411
+ */
412
+ function load_buffer(path: string): Opaque<"buffer">;
413
+ /**
414
+ * The sys.load_buffer function will first try to load the resource
415
+ * from any of the mounted resource locations and return the data if
416
+ * any matching entries found. If not, the path will be tried
417
+ * as is from the primary disk on the device.
418
+ * In order for the engine to include custom resources in the build process, you need
419
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
420
+ * You can specify single resource files or directories. If a directory is included
421
+ * in the resource list, all files and directories in that directory is recursively
422
+ * included:
423
+ * For example "main/data/,assets/level_data.json".
424
+ * Note that issuing multiple requests of the same resource will yield
425
+ * individual buffers per request. There is no implic caching of the buffers
426
+ * based on request path.
427
+ *
428
+ * @param path - the path to load the buffer from
429
+ * @param status_callback - A status callback that will be invoked when a request has been handled, or an error occured. The result is a table containing:
430
+ *
431
+ * `status`
432
+ * number The status of the request, supported values are:
433
+ *
434
+ * - `resource.REQUEST_STATUS_FINISHED`
435
+ *
436
+ * - `resource.REQUEST_STATUS_ERROR_IO_ERROR`
437
+ *
438
+ * - `resource.REQUEST_STATUS_ERROR_NOT_FOUND`
439
+ *
440
+ * `buffer`
441
+ * buffer If the request was successfull, this will contain the request payload in a buffer object, and nil otherwise. Make sure to check the status before doing anything with the buffer value!
442
+ * @returns a handle to the request
443
+ * @example
444
+ * ```ts
445
+ * // Load binary data from a custom project resource and update a texture resource:
446
+ * function my_callback(self, request_id, result) {
447
+ * if (result.status === resource.REQUEST_STATUS_FINISHED) {
448
+ * resource.set_texture("/my_texture", {}, result.buf); // texture args
449
+ * }
450
+ * }
451
+ *
452
+ * const my_request = sys.load_buffer_async("/assets/my_level_data.bin", my_callback);
453
+ *
454
+ * // Load binary data from non-custom resource files on disk:
455
+ * function my_callback(self, request_id, result) {
456
+ * if (result.status !== sys.REQUEST_STATUS_FINISHED) {
457
+ * // uh oh! File could not be found, do something graceful
458
+ * } else if (request_id === self.first_asset) {
459
+ * // result.buffer contains data from my_level_asset.bin
460
+ * } else if (request_id === self.second_asset) {
461
+ * // result.buffer contains data from 'my_level.bin'
462
+ * }
463
+ * }
464
+ *
465
+ * export default defineScript({
466
+ * init(self) {
467
+ * self.first_asset = hash("folder_next_to_binary/my_level_asset.bin");
468
+ * self.second_asset = hash("/some_absolute_path/my_level.bin");
469
+ * self.first_request = sys.load_buffer_async(self.first_asset, my_callback);
470
+ * self.second_request = sys.load_buffer_async(self.second_asset, my_callback);
471
+ * },
472
+ * });
473
+ * ```
474
+ */
475
+ function load_buffer_async(path: string, status_callback: (self: unknown, request_id: unknown, result: unknown) => void): number;
367
476
  /**
368
477
  * Loads a custom resource. Specify the full filename of the resource that you want
369
478
  * to load. When loaded, the file data is returned as a string.
@@ -484,11 +593,27 @@ declare global {
484
593
  * ```
485
594
  */
486
595
  function set_connectivity_host(host: string): void;
596
+ /**
597
+ * Enables engine throttling.
598
+ *
599
+ * @param enable - true if throttling should be enabled
600
+ * @param cooldown - the time period to do update + render for (seconds)
601
+ * @example
602
+ * ```ts
603
+ * // Disable throttling
604
+ * sys.set_engine_throttle(false);
605
+ *
606
+ * // Enable throttling
607
+ * sys.set_engine_throttle(true, 1.5);
608
+ * ```
609
+ */
610
+ function set_engine_throttle(enable: boolean, cooldown: number): void;
487
611
  /**
488
612
  * Set the Lua error handler function.
489
613
  * The error handler is a function which is called whenever a lua runtime error occurs.
490
614
  *
491
615
  * @param error_handler - the function to be called on error
616
+ *
492
617
  * `source`
493
618
  * string The runtime context of the error. Currently, this is always `"lua"`.
494
619
  * `message`
@@ -519,6 +644,17 @@ declare global {
519
644
  * ```
520
645
  */
521
646
  function set_error_handler(error_handler: (source: unknown, message: unknown, traceback: unknown) => void): void;
647
+ /**
648
+ * Disables rendering
649
+ *
650
+ * @param enable - true if throttling should be enabled
651
+ * @example
652
+ * ```ts
653
+ * // Disable rendering
654
+ * sys.set_render_enable(false);
655
+ * ```
656
+ */
657
+ function set_render_enable(enable: boolean): void;
522
658
  /**
523
659
  * Set game update-frequency (frame cap). This option is equivalent to `display.update_frequency` in
524
660
  * the "game.project" settings but set in run-time. If `Vsync` checked in "game.project", the rate will
@@ -115,6 +115,7 @@ declare global {
115
115
  * The coordinates of the tiles are indexed so that the "first" tile just
116
116
  * above and to the right of origin has coordinates 1,1.
117
117
  * Tiles to the left of and below origin are indexed 0, -1, -2 and so forth.
118
+ *
118
119
  * +-------+-------+------+------+
119
120
  * | 0,3 | 1,3 | 2,3 | 3,3 |
120
121
  * +-------+-------+------+------+
@@ -124,6 +125,7 @@ declare global {
124
125
  * +-------O-------+------+------+
125
126
  * | 0,0 | 1,0 | 2,0 | 3,0 |
126
127
  * +-------+-------+------+------+
128
+ *
127
129
  * The coordinates must be within the bounds of the tile map as it were created.
128
130
  * That is, it is not possible to extend the size of a tile map by setting tiles outside the edges.
129
131
  * To clear a tile, set the tile to number 0. Which tile map and layer to manipulate is identified by the URL and the layer name parameters.
@@ -2,6 +2,7 @@
2
2
  declare global {
3
3
  /**
4
4
  * Timers allow you to set a delay and a callback to be called when the timer completes.
5
+ *
5
6
  * The timers created with this API are updated with the collection timer where they
6
7
  * are created. If you pause or speed up the collection (using `set_time_step`) it will
7
8
  * also affect the new timer.
@@ -39,6 +40,7 @@ declare global {
39
40
  * @param delay - time interval in seconds
40
41
  * @param repeating - true = repeat timer until cancel, false = one-shot timer
41
42
  * @param callback - timer callback function
43
+ *
42
44
  * `self`
43
45
  * object The current object
44
46
  * `handle`
@@ -70,6 +72,7 @@ declare global {
70
72
  *
71
73
  * @param handle - the timer handle returned by timer.delay()
72
74
  * @returns table or `nil` if timer is cancelled/completed. table with data in the following fields:
75
+ *
73
76
  * `time_remaining`
74
77
  * number Time remaining until the next time a timer.delay() fires.
75
78
  * `delay`
@@ -4,23 +4,30 @@ import type { Matrix4, Quaternion, Vector, Vector3, Vector4 } from "../src/core-
4
4
  declare global {
5
5
  /**
6
6
  * Functions for mathematical operations on vectors, matrices and quaternions.
7
+ *
7
8
  * - The vector types (`vmath.vector3` and `vmath.vector4`) supports addition and subtraction
8
9
  * with vectors of the same type. Vectors can be negated and multiplied (scaled) or divided by numbers.
9
10
  * - The quaternion type (`vmath.quat`) supports multiplication with other quaternions.
10
11
  * - The matrix type (`vmath.matrix4`) can be multiplied with numbers, other matrices
11
12
  * and `vmath.vector4` values.
12
13
  * - All types performs equality comparison by each component value.
14
+ *
13
15
  * The following components are available for the various types:
16
+ *
14
17
  * vector3
15
18
  * : `x`, `y` and `z`. Example: `v.y`
19
+ *
16
20
  * vector4
17
21
  * : `x`, `y`, `z`, and `w`. Example: `v.w`
22
+ *
18
23
  * quaternion
19
24
  * : `x`, `y`, `z`, and `w`. Example: `q.w`
25
+ *
20
26
  * matrix4
21
27
  * : `m00` to `m33` where the first number is the row (starting from 0) and the second
22
28
  * number is the column. Columns can be accessed with `c0` to `c3`, returning a `vector4`.
23
29
  * Example: `m.m21` which is equal to `m.c1.z`
30
+ *
24
31
  * vector
25
32
  * : indexed by number 1 to the vector length. Example: `v[3]`
26
33
  */
@@ -88,8 +95,11 @@ declare global {
88
95
  * The returned value is a scalar defined as:
89
96
  * `P &#x22C5; Q = |P| |Q| cos &#x03B8;`
90
97
  * where &#x03B8; is the angle between the vectors P and Q.
98
+ *
91
99
  * - If the dot product is positive then the angle between the vectors is below 90 degrees.
100
+ *
92
101
  * - If the dot product is zero the vectors are perpendicular (at right-angles to each other).
102
+ *
93
103
  * - If the dot product is negative then the angle between the vectors is more than 90 degrees.
94
104
  *
95
105
  * @param v1 - first vector
@@ -218,20 +228,22 @@ declare global {
218
228
  * @param q2 - quaternion to lerp to
219
229
  * @returns the lerped quaternion
220
230
  * @example
221
- * ```lua
222
- * function init(self)
223
- * self.t = 0
224
- * end
231
+ * ```ts
232
+ * export default defineScript({
233
+ * init(self) {
234
+ * self.t = 0;
235
+ * },
225
236
  *
226
- * function update(self, dt)
227
- * self.t = self.t + dt
228
- * if self.t <= 1 then
229
- * local startrot = vmath.quat_rotation_z(0)
230
- * local endrot = vmath.quat_rotation_z(3.141592653)
231
- * local rot = vmath.lerp(self.t, startrot, endrot)
232
- * go.set_rotation(rot, "go")
233
- * end
234
- * end
237
+ * update(self, dt) {
238
+ * self.t = self.t + dt;
239
+ * if (self.t <= 1) {
240
+ * const startrot = vmath.quat_rotation_z(0);
241
+ * const endrot = vmath.quat_rotation_z(3.141592653);
242
+ * const rot = vmath.lerp(self.t, startrot, endrot);
243
+ * go.set_rotation(rot, "go");
244
+ * }
245
+ * },
246
+ * });
235
247
  * ```
236
248
  */
237
249
  function lerp(t: number, q1: Quaternion, q2: Quaternion): Quaternion;
@@ -245,20 +257,22 @@ declare global {
245
257
  * @param n2 - number to lerp to
246
258
  * @returns the lerped number
247
259
  * @example
248
- * ```lua
249
- * function init(self)
250
- * self.t = 0
251
- * end
260
+ * ```ts
261
+ * export default defineScript({
262
+ * init(self) {
263
+ * self.t = 0;
264
+ * },
252
265
  *
253
- * function update(self, dt)
254
- * self.t = self.t + dt
255
- * if self.t <= 1 then
256
- * local startx = 0
257
- * local endx = 600
258
- * local x = vmath.lerp(self.t, startx, endx)
259
- * go.set_position(vmath.vector3(x, 100, 0), "go")
260
- * end
261
- * end
266
+ * update(self, dt) {
267
+ * self.t = self.t + dt;
268
+ * if (self.t <= 1) {
269
+ * const startx = 0;
270
+ * const endx = 600;
271
+ * const x = vmath.lerp(self.t, startx, endx);
272
+ * go.set_position(vmath.vector3(x, 100, 0), "go");
273
+ * }
274
+ * },
275
+ * });
262
276
  * ```
263
277
  */
264
278
  function lerp(t: number, n1: number, n2: number): number;
@@ -286,13 +300,13 @@ declare global {
286
300
  * @param m1 - existing matrix
287
301
  * @returns matrix which is a copy of the specified matrix
288
302
  * @example
289
- * ```lua
290
- * local mat1 = vmath.matrix4_rotation_x(3.141592653)
291
- * local mat2 = vmath.matrix4(mat1)
292
- * if mat1 == mat2 then
293
- * -- yes, they are equal
294
- * print(mat2) --> vmath.matrix4(1, 0, 0, 0, 0, -1, 8.7422776573476e-08, 0, 0, -8.7422776573476e-08, -1, 0, 0, 0, 0, 1)
295
- * end
303
+ * ```ts
304
+ * const mat1 = vmath.matrix4_rotation_x(3.141592653);
305
+ * const mat2 = vmath.matrix4(mat1);
306
+ * if (mat1 === mat2) {
307
+ * // yes, they are equal
308
+ * print(mat2); // => vmath.matrix4(1, 0, 0, 0, 0, -1, 8.7422776573476e-08, 0, 0, -8.7422776573476e-08, -1, 0, 0, 0, 0, 1)
309
+ * }
296
310
  * ```
297
311
  */
298
312
  function matrix4(m1: Matrix4): Matrix4;
@@ -492,9 +506,9 @@ declare global {
492
506
  * @param scale - scale
493
507
  * @returns new matrix4
494
508
  * @example
495
- * ```lua
496
- * local result = vmath.matrix4_scale(0.5)
497
- * print(result) --> vmath.matrix4(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1)
509
+ * ```ts
510
+ * const result = vmath.matrix4_scale(0.5);
511
+ * print(result); // => vmath.matrix4(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1)
498
512
  * ```
499
513
  */
500
514
  function matrix4_scale(scale: number): Matrix4;
@@ -506,9 +520,9 @@ declare global {
506
520
  * @param scale_z - scale along Z asis
507
521
  * @returns new matrix4
508
522
  * @example
509
- * ```lua
510
- * local result = vmath.matrix4_scale(1, 0.5, 0.5)
511
- * print(result) --> vmath.matrix4(1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1)
523
+ * ```ts
524
+ * const result = vmath.matrix4_scale(1, 0.5, 0.5);
525
+ * print(result); // => vmath.matrix4(1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1)
512
526
  * ```
513
527
  */
514
528
  function matrix4_scale(scale_x: number, scale_y: number, scale_z: number): Matrix4;
@@ -600,10 +614,10 @@ declare global {
600
614
  *
601
615
  * @returns new identity quaternion
602
616
  * @example
603
- * ```lua
604
- * local quat = vmath.quat()
605
- * print(quat) --> vmath.quat(0, 0, 0, 1)
606
- * print(quat.w) --> 1
617
+ * ```ts
618
+ * const quat = vmath.quat();
619
+ * print(quat); // => vmath.quat(0, 0, 0, 1)
620
+ * print(quat.w); // => 1
607
621
  * ```
608
622
  */
609
623
  function quat(): Quaternion;
@@ -615,13 +629,13 @@ declare global {
615
629
  * @param q1 - existing quaternion
616
630
  * @returns new quaternion
617
631
  * @example
618
- * ```lua
619
- * local quat1 = vmath.quat(1, 2, 3, 4)
620
- * local quat2 = vmath.quat(quat1)
621
- * if quat1 == quat2 then
622
- * -- yes, they are equal
623
- * print(quat2) --> vmath.quat(1, 2, 3, 4)
624
- * end
632
+ * ```ts
633
+ * const quat1 = vmath.quat(1, 2, 3, 4);
634
+ * const quat2 = vmath.quat(quat1);
635
+ * if (quat1 === quat2) {
636
+ * // yes, they are equal
637
+ * print(quat2); // => vmath.quat(1, 2, 3, 4)
638
+ * }
625
639
  * ```
626
640
  */
627
641
  function quat(q1: Quaternion): Quaternion;
@@ -833,20 +847,22 @@ declare global {
833
847
  * @param q2 - quaternion to slerp to
834
848
  * @returns the slerped quaternion
835
849
  * @example
836
- * ```lua
837
- * function init(self)
838
- * self.t = 0
839
- * end
850
+ * ```ts
851
+ * export default defineScript({
852
+ * init(self) {
853
+ * self.t = 0;
854
+ * },
840
855
  *
841
- * function update(self, dt)
842
- * self.t = self.t + dt
843
- * if self.t <= 1 then
844
- * local startrot = vmath.quat_rotation_z(0)
845
- * local endrot = vmath.quat_rotation_z(3.141592653)
846
- * local rot = vmath.slerp(self.t, startrot, endrot)
847
- * go.set_rotation(rot, "go")
848
- * end
849
- * end
856
+ * update(self, dt) {
857
+ * self.t = self.t + dt;
858
+ * if (self.t <= 1) {
859
+ * const startrot = vmath.quat_rotation_z(0);
860
+ * const endrot = vmath.quat_rotation_z(3.141592653);
861
+ * const rot = vmath.slerp(self.t, startrot, endrot);
862
+ * go.set_rotation(rot, "go");
863
+ * }
864
+ * },
865
+ * });
850
866
  * ```
851
867
  */
852
868
  function slerp(t: number, q1: Quaternion, q2: Quaternion): Quaternion;
@@ -874,10 +890,10 @@ declare global {
874
890
  *
875
891
  * @returns new zero vector
876
892
  * @example
877
- * ```lua
878
- * local vec = vmath.vector3()
879
- * pprint(vec) --> vmath.vector3(0, 0, 0)
880
- * print(vec.x) --> 0
893
+ * ```ts
894
+ * const vec = vmath.vector3();
895
+ * pprint(vec); // => vmath.vector3(0, 0, 0)
896
+ * print(vec.x); // => 0
881
897
  * ```
882
898
  */
883
899
  function vector3(): Vector3;
@@ -888,10 +904,10 @@ declare global {
888
904
  * @param n - scalar value to splat
889
905
  * @returns new vector
890
906
  * @example
891
- * ```lua
892
- * local vec = vmath.vector3(1.0)
893
- * print(vec) --> vmath.vector3(1, 1, 1)
894
- * print(vec.x) --> 1
907
+ * ```ts
908
+ * const vec = vmath.vector3(1.0);
909
+ * print(vec); // => vmath.vector3(1, 1, 1)
910
+ * print(vec.x); // => 1
895
911
  * ```
896
912
  */
897
913
  function vector3(n: number): Vector3;
@@ -903,13 +919,13 @@ declare global {
903
919
  * @param v1 - existing vector
904
920
  * @returns new vector
905
921
  * @example
906
- * ```lua
907
- * local vec1 = vmath.vector3(1.0)
908
- * local vec2 = vmath.vector3(vec1)
909
- * if vec1 == vec2 then
910
- * -- yes, they are equal
911
- * print(vec2) --> vmath.vector3(1, 1, 1)
912
- * end
922
+ * ```ts
923
+ * const vec1 = vmath.vector3(1.0);
924
+ * const vec2 = vmath.vector3(vec1);
925
+ * if (vec1 === vec2) {
926
+ * // yes, they are equal
927
+ * print(vec2); // => vmath.vector3(1, 1, 1)
928
+ * }
913
929
  * ```
914
930
  */
915
931
  function vector3(v1: Vector3): Vector3;
@@ -937,10 +953,10 @@ declare global {
937
953
  *
938
954
  * @returns new zero vector
939
955
  * @example
940
- * ```lua
941
- * local vec = vmath.vector4()
942
- * print(vec) --> vmath.vector4(0, 0, 0, 0)
943
- * print(vec.w) --> 0
956
+ * ```ts
957
+ * const vec = vmath.vector4();
958
+ * print(vec); // => vmath.vector4(0, 0, 0, 0)
959
+ * print(vec.w); // => 0
944
960
  * ```
945
961
  */
946
962
  function vector4(): Vector4;
@@ -951,10 +967,10 @@ declare global {
951
967
  * @param n - scalar value to splat
952
968
  * @returns new vector
953
969
  * @example
954
- * ```lua
955
- * local vec = vmath.vector4(1.0)
956
- * print(vec) --> vmath.vector4(1, 1, 1, 1)
957
- * print(vec.w) --> 1
970
+ * ```ts
971
+ * const vec = vmath.vector4(1.0);
972
+ * print(vec); // => vmath.vector4(1, 1, 1, 1)
973
+ * print(vec.w); // => 1
958
974
  * ```
959
975
  */
960
976
  function vector4(n: number): Vector4;
@@ -966,13 +982,13 @@ declare global {
966
982
  * @param v1 - existing vector
967
983
  * @returns new vector
968
984
  * @example
969
- * ```lua
970
- * local vect1 = vmath.vector4(1.0)
971
- * local vect2 = vmath.vector4(vec1)
972
- * if vec1 == vec2 then
973
- * -- yes, they are equal
974
- * print(vec2) --> vmath.vector4(1, 1, 1, 1)
975
- * end
985
+ * ```ts
986
+ * const vec1 = vmath.vector4(1.0);
987
+ * const vec2 = vmath.vector4(vec1);
988
+ * if (vec1 === vec2) {
989
+ * // yes, they are equal
990
+ * print(vec2); // => vmath.vector4(1, 1, 1, 1)
991
+ * }
976
992
  * ```
977
993
  */
978
994
  function vector4(v1: Vector4): Vector4;
@@ -51,8 +51,11 @@ declare global {
51
51
  * On platforms that does not support dimming, `window.DIMMING_UNKNOWN` is always returned.
52
52
  *
53
53
  * @returns The mode for screen dimming
54
+ *
54
55
  * - `window.DIMMING_UNKNOWN`
56
+ *
55
57
  * - `window.DIMMING_ON`
58
+ *
56
59
  * - `window.DIMMING_OFF`
57
60
  */
58
61
  function get_dim_mode(): Opaque<"constant">;
@@ -74,15 +77,24 @@ declare global {
74
77
  * this returns the full window size and zero insets.
75
78
  *
76
79
  * @returns safe area data
80
+ *
77
81
  * `safe_area`
78
82
  * table table containing these keys:
83
+ *
79
84
  * - number `x`
85
+ *
80
86
  * - number `y`
87
+ *
81
88
  * - number `width`
89
+ *
82
90
  * - number `height`
91
+ *
83
92
  * - number `inset_left`
93
+ *
84
94
  * - number `inset_top`
95
+ *
85
96
  * - number `inset_right`
97
+ *
86
98
  * - number `inset_bottom`
87
99
  */
88
100
  function get_safe_area(): { safe_area: { x: number; y: number; width: number; height: number; inset_left: number; inset_top: number; inset_right: number; inset_bottom: number } };
@@ -96,7 +108,9 @@ declare global {
96
108
  * This function has no effect on platforms that does not support dimming.
97
109
  *
98
110
  * @param mode - The mode for screen dimming
111
+ *
99
112
  * - `window.DIMMING_ON`
113
+ *
100
114
  * - `window.DIMMING_OFF`
101
115
  */
102
116
  function set_dim_mode(mode: Opaque<"constant">): void;
@@ -104,18 +118,27 @@ declare global {
104
118
  * Sets a window event listener. Only one window event listener can be set at a time.
105
119
  *
106
120
  * @param callback - A callback which receives info about window events. Pass an empty function or `nil` if you no longer wish to receive callbacks.
121
+ *
107
122
  * `self`
108
123
  * object The calling script
109
124
  * `event`
110
125
  * constant The type of event. Can be one of these:
126
+ *
111
127
  * - `window.WINDOW_EVENT_FOCUS_LOST`
128
+ *
112
129
  * - `window.WINDOW_EVENT_FOCUS_GAINED`
130
+ *
113
131
  * - `window.WINDOW_EVENT_RESIZED`
132
+ *
114
133
  * - `window.WINDOW_EVENT_ICONIFIED`
134
+ *
115
135
  * - `window.WINDOW_EVENT_DEICONIFIED`
136
+ *
116
137
  * `data`
117
138
  * table The callback value `data` is a table which currently holds these values
139
+ *
118
140
  * - number `width`: The width of a resize event. nil otherwise.
141
+ *
119
142
  * - number `height`: The height of a resize event. nil otherwise.
120
143
  * @example
121
144
  * ```ts
@@ -140,7 +163,7 @@ declare global {
140
163
  * });
141
164
  * ```
142
165
  */
143
- function set_listener(callback?: (self: unknown, event: unknown, data: unknown) => void): void;
166
+ function set_listener(callback?: (self: unknown, event: typeof WINDOW_EVENT_FOCUS_LOST | typeof WINDOW_EVENT_FOCUS_GAINED | typeof WINDOW_EVENT_RESIZED | typeof WINDOW_EVENT_ICONFIED | typeof WINDOW_EVENT_DEICONIFIED, data: Record<string | number, unknown>) => void): void;
144
167
  /**
145
168
  * Set the locking state for current mouse cursor on a PC platform.
146
169
  * This function locks or unlocks the mouse cursor to the center point of the window. While the cursor is locked,