@defold-typescript/types 0.5.5 → 0.6.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 (53) hide show
  1. package/api-targets.json +1 -1
  2. package/generated/b2d.d.ts +3 -0
  3. package/generated/buffer.d.ts +44 -38
  4. package/generated/builtin-messages.d.ts +1 -1
  5. package/generated/camera.d.ts +3 -0
  6. package/generated/collectionfactory.d.ts +47 -40
  7. package/generated/collectionproxy.d.ts +23 -18
  8. package/generated/crash.d.ts +3 -0
  9. package/generated/factory.d.ts +32 -24
  10. package/generated/go.d.ts +123 -124
  11. package/generated/graphics.d.ts +3 -0
  12. package/generated/gui.d.ts +303 -283
  13. package/generated/http.d.ts +26 -16
  14. package/generated/iac.d.ts +3 -0
  15. package/generated/iap.d.ts +6 -3
  16. package/generated/image.d.ts +30 -26
  17. package/generated/json.d.ts +36 -32
  18. package/generated/kinds/gui-script.d.ts +7 -5
  19. package/generated/kinds/render-script.d.ts +7 -5
  20. package/generated/kinds/script.d.ts +7 -5
  21. package/generated/label.d.ts +16 -9
  22. package/generated/liveupdate.d.ts +29 -26
  23. package/generated/model.d.ts +57 -45
  24. package/generated/msg.d.ts +3 -0
  25. package/generated/particlefx.d.ts +50 -34
  26. package/generated/physics.d.ts +153 -133
  27. package/generated/profiler.d.ts +45 -41
  28. package/generated/push.d.ts +5 -2
  29. package/generated/render.d.ts +410 -349
  30. package/generated/resource.d.ts +619 -572
  31. package/generated/socket.d.ts +49 -33
  32. package/generated/sound.d.ts +83 -72
  33. package/generated/sprite.d.ts +3 -0
  34. package/generated/sys.d.ts +198 -189
  35. package/generated/tilemap.d.ts +43 -39
  36. package/generated/timer.d.ts +42 -36
  37. package/generated/vmath.d.ts +22 -0
  38. package/generated/webview.d.ts +3 -0
  39. package/generated/window.d.ts +23 -17
  40. package/generated/zlib.d.ts +15 -12
  41. package/index.d.ts +3 -1
  42. package/package.json +6 -2
  43. package/scripts/fidelity-audit.ts +61 -1
  44. package/scripts/fidelity-baseline.json +10 -10
  45. package/scripts/ref-doc-delta.ts +143 -0
  46. package/scripts/regen.ts +18 -9
  47. package/src/core-types.ts +14 -0
  48. package/src/emit-dts.ts +219 -13
  49. package/src/engine-globals.d.ts +2 -0
  50. package/src/go-overloads.d.ts +43 -0
  51. package/src/index.ts +5 -0
  52. package/src/lifecycle.ts +157 -16
  53. package/src/publish-dts.ts +1 -1
@@ -2,6 +2,10 @@
2
2
  import type { Hash, Url, Vector4 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions and properties for controlling particle effect component playback and
7
+ * shader constants.
8
+ */
5
9
  namespace particlefx {
6
10
  /**
7
11
  * The emitter is not spawning any particles, but has particles that are still alive.
@@ -40,19 +44,21 @@ declare global {
40
44
  * - `particlefx.EMITTER_STATE_SPAWNING`
41
45
  * - `particlefx.EMITTER_STATE_POSTSPAWN`
42
46
  * @example
43
- * ```lua
44
- * How to play a particle fx when a game object is created.
45
- * The callback receives the hash of the path to the particlefx, the hash of the id
46
- * of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
47
- * local function emitter_state_change(self, id, emitter, state)
48
- * if emitter == hash("exhaust") and state == particlefx.EMITTER_STATE_POSTSPAWN then
49
- * -- exhaust is done spawning particles...
50
- * end
51
- * end
47
+ * ```ts
48
+ * // How to play a particle fx when a game object is created.
49
+ * // The callback receives the hash of the path to the particlefx, the hash of the id
50
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
51
+ * function emitter_state_change(self, id, emitter, state) {
52
+ * if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
53
+ * // exhaust is done spawning particles...
54
+ * }
55
+ * }
52
56
  *
53
- * function init(self)
54
- * particlefx.play("#particlefx", emitter_state_change)
55
- * end
57
+ * export default defineScript({
58
+ * init(self) {
59
+ * particlefx.play("#particlefx", emitter_state_change);
60
+ * },
61
+ * });
56
62
  * ```
57
63
  */
58
64
  function play(url: string | Hash | Url, emitter_state_function?: (self: unknown, id: unknown, emitter: unknown, state: unknown) => void): void;
@@ -66,14 +72,18 @@ declare global {
66
72
  * @param emitter - the id of the emitter
67
73
  * @param constant - the name of the constant
68
74
  * @example
69
- * ```lua
70
- * The following examples assumes that the particle FX has id "particlefx", it
71
- * contains an emitter with the id "emitter" and that the default-material in builtins is used, which defines the constant "tint".
72
- * If you assign a custom material to the sprite, you can reset the constants defined there in the same manner.
73
- * How to reset the tinting of particles from an emitter:
74
- * function init(self)
75
- * particlefx.reset_constant("#particlefx", "emitter", "tint")
76
- * end
75
+ * ```ts
76
+ * // The following examples assume that the particle FX has id "particlefx", it
77
+ * // contains an emitter with the id "emitter" and that the default-material in
78
+ * // builtins is used, which defines the constant "tint".
79
+ * // If you assign a custom material to the sprite, you can reset the constants
80
+ * // defined there in the same manner.
81
+ * // How to reset the tinting of particles from an emitter:
82
+ * export default defineScript({
83
+ * init(self) {
84
+ * particlefx.reset_constant("#particlefx", "emitter", "tint");
85
+ * },
86
+ * });
77
87
  * ```
78
88
  */
79
89
  function reset_constant(url: string | Hash | Url, emitter: string | Hash, constant: string | Hash): void;
@@ -89,14 +99,18 @@ declare global {
89
99
  * @param constant - the name of the constant
90
100
  * @param value - the value of the constant
91
101
  * @example
92
- * ```lua
93
- * The following examples assumes that the particle FX has id "particlefx", it
94
- * contains an emitter with the id "emitter" and that the default-material in builtins is used, which defines the constant "tint".
95
- * If you assign a custom material to the sprite, you can reset the constants defined there in the same manner.
96
- * How to tint particles from an emitter red:
97
- * function init(self)
98
- * particlefx.set_constant("#particlefx", "emitter", "tint", vmath.vector4(1, 0, 0, 1))
99
- * end
102
+ * ```ts
103
+ * // The following examples assume that the particle FX has id "particlefx", it
104
+ * // contains an emitter with the id "emitter" and that the default-material in
105
+ * // builtins is used, which defines the constant "tint".
106
+ * // If you assign a custom material to the sprite, you can reset the constants
107
+ * // defined there in the same manner.
108
+ * // How to tint particles from an emitter red:
109
+ * export default defineScript({
110
+ * init(self) {
111
+ * particlefx.set_constant("#particlefx", "emitter", "tint", vmath.vector4(1, 0, 0, 1));
112
+ * },
113
+ * });
100
114
  * ```
101
115
  */
102
116
  function set_constant(url: string | Hash | Url, emitter: string | Hash, constant: string | Hash, value: Vector4): void;
@@ -109,12 +123,14 @@ declare global {
109
123
  * @param options - Options when stopping the particle fx. Supported options:
110
124
  * - boolean `clear`: instantly clear spawned particles
111
125
  * @example
112
- * ```lua
113
- * How to stop a particle fx when a game object is deleted and immediately also clear
114
- * any spawned particles:
115
- * function final(self)
116
- * particlefx.stop("#particlefx", { clear = true })
117
- * end
126
+ * ```ts
127
+ * // How to stop a particle fx when a game object is deleted and immediately also
128
+ * // clear any spawned particles:
129
+ * export default defineScript({
130
+ * final(self) {
131
+ * particlefx.stop("#particlefx", { clear: true });
132
+ * },
133
+ * });
118
134
  * ```
119
135
  */
120
136
  function stop(url: string | Hash | Url, options?: { clear?: boolean }): void;
@@ -2,6 +2,11 @@
2
2
  import type { Hash, Url, Vector3 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions and messages for collision object physics interaction
7
+ * with other objects (collisions and ray-casting) and control of
8
+ * physical behaviors.
9
+ */
5
10
  namespace physics {
6
11
  /**
7
12
  * The following properties are available when connecting a joint of `JOINT_TYPE_FIXED` type:
@@ -62,13 +67,15 @@ declare global {
62
67
  *
63
68
  * @returns gravity vector of collection
64
69
  * @example
65
- * ```lua
66
- * function init(self)
67
- * local gravity = physics.get_gravity()
68
- * -- Inverse gravity!
69
- * gravity = -gravity
70
- * physics.set_gravity(gravity)
71
- * end
70
+ * ```ts
71
+ * export default defineScript({
72
+ * init(self) {
73
+ * let gravity = physics.get_gravity();
74
+ * // Inverse gravity!
75
+ * gravity = -gravity;
76
+ * physics.set_gravity(gravity);
77
+ * },
78
+ * });
72
79
  * ```
73
80
  */
74
81
  function get_gravity(): Vector3;
@@ -178,25 +185,27 @@ declare global {
178
185
  * boolean Set to `true` to return all ray cast hits. If `false`, it will only return the closest hit.
179
186
  * @returns It returns a list. If missed it returns `nil`. See ray_cast_response for details on the returned values.
180
187
  * @example
181
- * ```lua
182
- * How to perform a ray cast synchronously:
183
- * function init(self)
184
- * self.groups = {hash("world"), hash("enemy")}
185
- * end
188
+ * ```ts
189
+ * // How to perform a ray cast synchronously:
190
+ * export default defineScript({
191
+ * init(self) {
192
+ * self.groups = [hash("world"), hash("enemy")];
193
+ * },
186
194
  *
187
- * function update(self, dt)
188
- * -- request ray cast
189
- * local result = physics.raycast(from, to, self.groups, {all=true})
190
- * if result ~= nil then
191
- * -- act on the hit (see 'ray_cast_response')
192
- * for _,result in ipairs(results) do
193
- * handle_result(result)
194
- * end
195
- * end
196
- * end
195
+ * update(self, dt) {
196
+ * // request ray cast
197
+ * const result = physics.raycast(from, to, self.groups, { all: true });
198
+ * if (result !== undefined) {
199
+ * // act on the hit (see 'ray_cast_response')
200
+ * for (const result of results) {
201
+ * handle_result(result);
202
+ * }
203
+ * }
204
+ * },
205
+ * });
197
206
  * ```
198
207
  */
199
- function raycast(from: Vector3, to: Vector3, groups: Record<string | number, unknown>, options?: { all?: boolean }): Record<string | number, unknown> | unknown;
208
+ function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: { all?: boolean }): Record<string | number, unknown> | unknown;
200
209
  /**
201
210
  * Ray casts are used to test for intersections against collision objects in the physics world.
202
211
  * Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
@@ -213,28 +222,30 @@ declare global {
213
222
  * @param groups - a lua table containing the hashed groups for which to test collisions against
214
223
  * @param request_id - a number in range [0,255]. It will be sent back in the response for identification, 0 by default
215
224
  * @example
216
- * ```lua
217
- * How to perform a ray cast asynchronously:
218
- * function init(self)
219
- * self.my_groups = {hash("my_group1"), hash("my_group2")}
220
- * end
225
+ * ```ts
226
+ * // How to perform a ray cast asynchronously:
227
+ * export default defineScript({
228
+ * init(self) {
229
+ * self.my_groups = [hash("my_group1"), hash("my_group2")];
230
+ * },
221
231
  *
222
- * function update(self, dt)
223
- * -- request ray cast
224
- * physics.raycast_async(my_start, my_end, self.my_groups)
225
- * end
232
+ * update(self, dt) {
233
+ * // request ray cast
234
+ * physics.raycast_async(my_start, my_end, self.my_groups);
235
+ * },
226
236
  *
227
- * function on_message(self, message_id, message, sender)
228
- * -- check for the response
229
- * if message_id == hash("ray_cast_response") then
230
- * -- act on the hit
231
- * elseif message_id == hash("ray_cast_missed") then
232
- * -- act on the miss
233
- * end
234
- * end
237
+ * on_message(self, message_id, message, sender) {
238
+ * // check for the response
239
+ * if (message_id === hash("ray_cast_response")) {
240
+ * // act on the hit
241
+ * } else if (message_id === hash("ray_cast_missed")) {
242
+ * // act on the miss
243
+ * }
244
+ * },
245
+ * });
235
246
  * ```
236
247
  */
237
- function raycast_async(from: Vector3, to: Vector3, groups: Record<string | number, unknown>, request_id?: number): void;
248
+ function raycast_async(from: Vector3, to: Vector3, groups: Hash[], request_id?: number): void;
238
249
  /**
239
250
  * Only one physics world event listener can be set at a time.
240
251
  *
@@ -251,82 +262,85 @@ declare global {
251
262
  * `data`
252
263
  * table The callback value data is a table that contains event-related data. See the documentation for details on the messages.
253
264
  * @example
254
- * ```lua
255
- * local function physics_world_listener(self, events)
256
- * for _,event in ipairs(events):
257
- * local event_type = event['type']
258
- * if event_type == hash("contact_point_event") then
259
- * pprint(event)
260
- * -- {
261
- * -- distance = 2.1490633487701,
262
- * -- applied_impulse = 0
263
- * -- a = { --[[0x113f7c6c0]]
264
- * -- group = hash: [box],
265
- * -- id = hash: [/box]
266
- * -- mass = 0,
267
- * -- normal = vmath.vector3(0.379, 0.925, -0),
268
- * -- position = vmath.vector3(517.337, 235.068, 0),
269
- * -- instance_position = vmath.vector3(480, 144, 0),
270
- * -- relative_velocity = vmath.vector3(-0, -0, -0),
271
- * -- },
272
- * -- b = { --[[0x113f7c840]]
273
- * -- group = hash: [circle],
274
- * -- id = hash: [/circle]
275
- * -- mass = 0,
276
- * -- normal = vmath.vector3(-0.379, -0.925, 0),
277
- * -- position = vmath.vector3(517.337, 235.068, 0),
278
- * -- instance_position = vmath.vector3(-0.0021, 0, -0.0022),
279
- * -- relative_velocity = vmath.vector3(0, 0, 0),
280
- * -- },
281
- * -- }
282
- * elseif event == hash("collision_event") then
283
- * pprint(event)
284
- * -- {
285
- * -- a = {
286
- * -- group = hash: [default],
287
- * -- position = vmath.vector3(183, 666, 0),
288
- * -- id = hash: [/go1]
289
- * -- },
290
- * -- b = {
291
- * -- group = hash: [default],
292
- * -- position = vmath.vector3(185, 704.05865478516, 0),
293
- * -- id = hash: [/go2]
294
- * -- }
295
- * -- }
296
- * elseif event == hash("trigger_event") then
297
- * pprint(event)
298
- * -- {
299
- * -- enter = true,
300
- * -- b = {
301
- * -- group = hash: [default],
302
- * -- id = hash: [/go2]
303
- * -- },
304
- * -- a = {
305
- * -- group = hash: [default],
306
- * -- id = hash: [/go1]
307
- * -- }
308
- * -- },
309
- * elseif event == hash("ray_cast_response") then
310
- * pprint(event)
311
- * --{
312
- * -- group = hash: [default],
313
- * -- request_id = 0,
314
- * -- position = vmath.vector3(249.92222595215, 249.92222595215, 0),
315
- * -- fraction = 0.68759721517563,
316
- * -- normal = vmath.vector3(0, 1, 0),
317
- * -- id = hash: [/go]
318
- * -- }
319
- * elseif event == hash("ray_cast_missed") then
320
- * pprint(event)
321
- * -- {
322
- * -- request_id = 0
323
- * --},
324
- * end
325
- * end
265
+ * ```ts
266
+ * function physics_world_listener(self, events) {
267
+ * for (const event of events) {
268
+ * const event_type = event["type"];
269
+ * if (event_type === hash("contact_point_event")) {
270
+ * pprint(event);
271
+ * // {
272
+ * // distance = 2.1490633487701,
273
+ * // applied_impulse = 0
274
+ * // a = { --[[0x113f7c6c0]]
275
+ * // group = hash: [box],
276
+ * // id = hash: [/box]
277
+ * // mass = 0,
278
+ * // normal = vmath.vector3(0.379, 0.925, -0),
279
+ * // position = vmath.vector3(517.337, 235.068, 0),
280
+ * // instance_position = vmath.vector3(480, 144, 0),
281
+ * // relative_velocity = vmath.vector3(-0, -0, -0),
282
+ * // },
283
+ * // b = { --[[0x113f7c840]]
284
+ * // group = hash: [circle],
285
+ * // id = hash: [/circle]
286
+ * // mass = 0,
287
+ * // normal = vmath.vector3(-0.379, -0.925, 0),
288
+ * // position = vmath.vector3(517.337, 235.068, 0),
289
+ * // instance_position = vmath.vector3(-0.0021, 0, -0.0022),
290
+ * // relative_velocity = vmath.vector3(0, 0, 0),
291
+ * // },
292
+ * // }
293
+ * } else if (event === hash("collision_event")) {
294
+ * pprint(event);
295
+ * // {
296
+ * // a = {
297
+ * // group = hash: [default],
298
+ * // position = vmath.vector3(183, 666, 0),
299
+ * // id = hash: [/go1]
300
+ * // },
301
+ * // b = {
302
+ * // group = hash: [default],
303
+ * // position = vmath.vector3(185, 704.05865478516, 0),
304
+ * // id = hash: [/go2]
305
+ * // }
306
+ * // }
307
+ * } else if (event === hash("trigger_event")) {
308
+ * pprint(event);
309
+ * // {
310
+ * // enter = true,
311
+ * // b = {
312
+ * // group = hash: [default],
313
+ * // id = hash: [/go2]
314
+ * // },
315
+ * // a = {
316
+ * // group = hash: [default],
317
+ * // id = hash: [/go1]
318
+ * // }
319
+ * // },
320
+ * } else if (event === hash("ray_cast_response")) {
321
+ * pprint(event);
322
+ * // {
323
+ * // group = hash: [default],
324
+ * // request_id = 0,
325
+ * // position = vmath.vector3(249.92222595215, 249.92222595215, 0),
326
+ * // fraction = 0.68759721517563,
327
+ * // normal = vmath.vector3(0, 1, 0),
328
+ * // id = hash: [/go]
329
+ * // }
330
+ * } else if (event === hash("ray_cast_missed")) {
331
+ * pprint(event);
332
+ * // {
333
+ * // request_id = 0
334
+ * // },
335
+ * }
336
+ * }
337
+ * }
326
338
  *
327
- * function init(self)
328
- * physics.set_event_listener(physics_world_listener)
329
- * end
339
+ * export default defineScript({
340
+ * init(self) {
341
+ * physics.set_event_listener(physics_world_listener);
342
+ * },
343
+ * });
330
344
  * ```
331
345
  */
332
346
  function set_event_listener(callback?: (self: unknown, events: unknown) => void): void;
@@ -337,11 +351,13 @@ declare global {
337
351
  *
338
352
  * @param gravity - the new gravity vector
339
353
  * @example
340
- * ```lua
341
- * function init(self)
342
- * -- Set "upside down" gravity for this collection.
343
- * physics.set_gravity(vmath.vector3(0, 10.0, 0))
344
- * end
354
+ * ```ts
355
+ * export default defineScript({
356
+ * init(self) {
357
+ * // Set "upside down" gravity for this collection.
358
+ * physics.set_gravity(vmath.vector3(0, 10.0, 0));
359
+ * },
360
+ * });
345
361
  * ```
346
362
  */
347
363
  function set_gravity(gravity: Vector3): void;
@@ -364,11 +380,13 @@ declare global {
364
380
  * @param url - the collision object that should flip its shapes
365
381
  * @param flip - `true` if the collision object should flip its shapes, `false` if not
366
382
  * @example
367
- * ```lua
368
- * function init(self)
369
- * self.fliph = true -- set on some condition
370
- * physics.set_hflip("#collisionobject", self.fliph)
371
- * end
383
+ * ```ts
384
+ * export default defineScript({
385
+ * init(self) {
386
+ * self.fliph = true; // set on some condition
387
+ * physics.set_hflip("#collisionobject", self.fliph);
388
+ * },
389
+ * });
372
390
  * ```
373
391
  */
374
392
  function set_hflip(url: string | Hash | Url, flip: boolean): void;
@@ -432,11 +450,13 @@ declare global {
432
450
  * @param url - the collision object that should flip its shapes
433
451
  * @param flip - `true` if the collision object should flip its shapes, `false` if not
434
452
  * @example
435
- * ```lua
436
- * function init(self)
437
- * self.flipv = true -- set on some condition
438
- * physics.set_vflip("#collisionobject", self.flipv)
439
- * end
453
+ * ```ts
454
+ * export default defineScript({
455
+ * init(self) {
456
+ * self.flipv = true; // set on some condition
457
+ * physics.set_vflip("#collisionobject", self.flipv);
458
+ * },
459
+ * });
440
460
  * ```
441
461
  */
442
462
  function set_vflip(url: string | Hash | Url, flip: boolean): void;
@@ -447,8 +467,8 @@ declare global {
447
467
  * @param collisionobject - the collision object whose mass needs to be updated.
448
468
  * @param mass - the new mass value to set for the collision object.
449
469
  * @example
450
- * ```lua
451
- * physics.update_mass("#collisionobject", 14)
470
+ * ```ts
471
+ * physics.update_mass("#collisionobject", 14);
452
472
  * ```
453
473
  */
454
474
  function update_mass(collisionobject: string | Hash | Url, mass: number): void;
@@ -2,6 +2,10 @@
2
2
  import type { Opaque } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions for getting profiling data in runtime.
7
+ * More detailed [profiling](https://www.defold.com/manuals/profiling/) and [debugging](http://www.defold.com/manuals/debugging/) information available in the manuals.
8
+ */
5
9
  namespace profiler {
6
10
  /**
7
11
  * pause on current frame
@@ -31,8 +35,8 @@ declare global {
31
35
  * logs the current frame to the console
32
36
  *
33
37
  * @example
34
- * ```lua
35
- * profiler.dump_frame()
38
+ * ```ts
39
+ * profiler.dump_frame();
36
40
  * ```
37
41
  */
38
42
  function dump_frame(): void;
@@ -43,9 +47,9 @@ declare global {
43
47
  *
44
48
  * @param enabled - true to enable, false to disable
45
49
  * @example
46
- * ```lua
47
- * -- Show the profiler UI
48
- * profiler.enable(true)
50
+ * ```ts
51
+ * // Show the profiler UI
52
+ * profiler.enable(true);
49
53
  * ```
50
54
  */
51
55
  function enable(enabled: boolean): void;
@@ -57,9 +61,9 @@ declare global {
57
61
  *
58
62
  * @param enabled - true to enable, false to disable
59
63
  * @example
60
- * ```lua
61
- * -- Show the profiler UI
62
- * profiler.enable_ui(true)
64
+ * ```ts
65
+ * // Show the profiler UI
66
+ * profiler.enable_ui(true);
63
67
  * ```
64
68
  */
65
69
  function enable_ui(enabled: boolean): void;
@@ -92,12 +96,12 @@ declare global {
92
96
  *
93
97
  * @returns used by the application
94
98
  * @example
95
- * ```lua
96
- * Get memory usage before and after loading a collection:
97
- * print(profiler.get_memory_usage())
98
- * msg.post("#collectionproxy", "load")
99
- * ...
100
- * print(profiler.get_memory_usage()) -- will report a higher number than the initial call
99
+ * ```ts
100
+ * // Get memory usage before and after loading a collection:
101
+ * print(profiler.get_memory_usage());
102
+ * msg.post("#collectionproxy", "load");
103
+ * // ...
104
+ * print(profiler.get_memory_usage()); // will report a higher number than the initial call
101
105
  * ```
102
106
  */
103
107
  function get_memory_usage(): number;
@@ -106,8 +110,8 @@ declare global {
106
110
  *
107
111
  * @param text - the string to send to the connected profiler
108
112
  * @example
109
- * ```lua
110
- * profiler.log_text("Event: " .. name)
113
+ * ```ts
114
+ * profiler.log_text(`Event: ${name}`);
111
115
  * ```
112
116
  */
113
117
  function log_text(text: string): void;
@@ -116,10 +120,10 @@ declare global {
116
120
  *
117
121
  * @returns the number of recorded frames, zero if on-screen profiler is disabled
118
122
  * @example
119
- * ```lua
120
- * -- Show the last recorded frame
121
- * local recorded_frame_count = profiler.recorded_frame_count()
122
- * profiler.view_recorded_frame(recorded_frame_count)
123
+ * ```ts
124
+ * // Show the last recorded frame
125
+ * const recorded_frame_count = profiler.recorded_frame_count();
126
+ * profiler.view_recorded_frame(recorded_frame_count);
123
127
  * ```
124
128
  */
125
129
  function recorded_frame_count(): number;
@@ -128,11 +132,11 @@ declare global {
128
132
  *
129
133
  * @param name - The name of the scope
130
134
  * @example
131
- * ```lua
132
- * -- Go back one frame
133
- * profiler.scope_begin("test_function")
134
- * test_function()
135
- * profiler.scope_end()
135
+ * ```ts
136
+ * // Go back one frame
137
+ * profiler.scope_begin("test_function");
138
+ * test_function();
139
+ * profiler.scope_end();
136
140
  * ```
137
141
  */
138
142
  function scope_begin(name: string): void;
@@ -152,14 +156,14 @@ declare global {
152
156
  * You can also use the `view_recorded_frame` function to display a recorded frame. Doing so stops the recording as well.
153
157
  * Every time you switch to recording mode the recording buffer is cleared.
154
158
  * @example
155
- * ```lua
156
- * function start_recording()
157
- * profiler.set_ui_mode(profiler.MODE_RECORD)
158
- * end
159
+ * ```ts
160
+ * function start_recording() {
161
+ * profiler.set_ui_mode(profiler.MODE_RECORD);
162
+ * }
159
163
  *
160
- * function stop_recording()
161
- * profiler.set_ui_mode(profiler.MODE_PAUSE)
162
- * end
164
+ * function stop_recording() {
165
+ * profiler.set_ui_mode(profiler.MODE_PAUSE);
166
+ * }
163
167
  * ```
164
168
  */
165
169
  function set_ui_mode(mode: Opaque<"constant">): void;
@@ -170,9 +174,9 @@ declare global {
170
174
  * - `profiler.VIEW_MODE_FULL` The default mode which displays all the ui profiler details
171
175
  * - `profiler.VIEW_MODE_MINIMIZED` Minimized mode which only shows the top header (fps counters and ui profiler mode)
172
176
  * @example
173
- * ```lua
174
- * -- Minimize the profiler view
175
- * profiler.set_ui_view_mode(profiler.VIEW_MODE_MINIMIZED)
177
+ * ```ts
178
+ * // Minimize the profiler view
179
+ * profiler.set_ui_view_mode(profiler.VIEW_MODE_MINIMIZED);
176
180
  * ```
177
181
  */
178
182
  function set_ui_view_mode(mode: Opaque<"constant">): void;
@@ -190,9 +194,9 @@ declare global {
190
194
  *
191
195
  * @param visible - true to include it in the display, false to hide it.
192
196
  * @example
193
- * ```lua
194
- * -- Exclude frame wait time form the profiler ui
195
- * profiler.set_ui_vsync_wait_visible(false)
197
+ * ```ts
198
+ * // Exclude frame wait time from the profiler ui
199
+ * profiler.set_ui_vsync_wait_visible(false);
196
200
  * ```
197
201
  */
198
202
  function set_ui_vsync_wait_visible(visible: boolean): void;
@@ -204,9 +208,9 @@ declare global {
204
208
  * - `distance` The offset from the currently displayed frame (this is truncated between zero and the number of recorded frames)
205
209
  * - `frame` The frame index in the recording buffer (1 is first recorded frame)
206
210
  * @example
207
- * ```lua
208
- * -- Go back one frame
209
- * profiler.view_recorded_frame({distance = -1})
211
+ * ```ts
212
+ * // Go back one frame
213
+ * profiler.view_recorded_frame({ distance: -1 });
210
214
  * ```
211
215
  */
212
216
  function view_recorded_frame(frame_index: Record<string | number, unknown>): void;