@defold-typescript/types 0.50.1 → 0.52.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.
- package/api-availability.json +4 -58
- package/api-signatures.json +1128 -1552
- package/api-targets.json +15 -5
- package/examples/translations.json +19 -71
- package/fixtures/messages_doc.json +20 -39
- package/generated/b2d_world.d.ts +10 -10
- package/generated/buffer.d.ts +9 -9
- package/generated/builtin-messages.d.ts +16 -14
- package/generated/bullet3d_collision_object.d.ts +1 -1
- package/generated/bullet3d_constraint.d.ts +109 -7
- package/generated/bullet3d_shape.d.ts +2 -2
- package/generated/collectionfactory.d.ts +1 -1
- package/generated/collectionproxy.d.ts +2 -2
- package/generated/factory.d.ts +4 -2
- package/generated/go.d.ts +114 -220
- package/generated/graphics.d.ts +5 -0
- package/generated/gui.d.ts +148 -371
- package/generated/http.d.ts +4 -2
- package/generated/image.d.ts +56 -4
- package/generated/kinds/gui-script.d.ts +3 -0
- package/generated/kinds/render-script.d.ts +15 -15
- package/generated/kinds/script.d.ts +1 -0
- package/generated/liveupdate.d.ts +5 -1
- package/generated/material.d.ts +3 -3
- package/generated/model.d.ts +4 -5
- package/generated/particlefx.d.ts +20 -1
- package/generated/physics.d.ts +48 -4
- package/generated/render-script-modules/b2d.d.ts +711 -0
- package/generated/render-script-modules/bullet3d.d.ts +73 -0
- package/generated/render-script-modules/collectionfactory.d.ts +25 -0
- package/generated/render-script-modules/collectionproxy.d.ts +39 -0
- package/generated/render-script-modules/factory.d.ts +25 -0
- package/generated/render-script-modules/go.d.ts +436 -0
- package/generated/render-script-modules/label.d.ts +105 -0
- package/generated/render-script-modules/model.d.ts +89 -0
- package/generated/render-script-modules/particlefx.d.ts +59 -0
- package/generated/render-script-modules/physics.d.ts +333 -0
- package/generated/render-script-modules/resource.d.ts +1233 -0
- package/generated/render-script-modules/sound.d.ts +227 -0
- package/generated/render-script-modules/sprite.d.ts +68 -0
- package/generated/render-script-modules/tilemap.d.ts +43 -0
- package/generated/render.d.ts +175 -21
- package/generated/resource.d.ts +31 -10
- package/generated/sprite.d.ts +49 -1
- package/generated/sys.d.ts +78 -10
- package/generated/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.12.4/factory.d.ts +4 -2
- package/generated/versions/defold-1.12.4/go.d.ts +115 -343
- package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
- package/generated/versions/defold-1.12.4/http.d.ts +4 -2
- package/generated/versions/defold-1.12.4/image.d.ts +83 -3
- package/generated/versions/defold-1.12.4/index.d.ts +2 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.12.4/model.d.ts +4 -5
- package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +47 -3
- package/generated/versions/defold-1.12.4/render.d.ts +119 -15
- package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
- package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
- package/generated/versions/defold-1.12.4/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.0/factory.d.ts +4 -2
- package/generated/versions/defold-1.13.0/go.d.ts +115 -370
- package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
- package/generated/versions/defold-1.13.0/http.d.ts +4 -2
- package/generated/versions/defold-1.13.0/image.d.ts +83 -3
- package/generated/versions/defold-1.13.0/index.d.ts +2 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.0/material.d.ts +3 -1
- package/generated/versions/defold-1.13.0/model.d.ts +4 -5
- package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +47 -3
- package/generated/versions/defold-1.13.0/render.d.ts +182 -16
- package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.0/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.1/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.1/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.1/factory.d.ts +4 -2
- package/generated/versions/defold-1.13.1/go.d.ts +115 -370
- package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
- package/generated/versions/defold-1.13.1/http.d.ts +4 -2
- package/generated/versions/defold-1.13.1/image.d.ts +83 -3
- package/generated/versions/defold-1.13.1/index.d.ts +3 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.1/material.d.ts +3 -1
- package/generated/versions/defold-1.13.1/model.d.ts +4 -5
- package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.1/physics.d.ts +47 -3
- package/generated/versions/defold-1.13.1/render.d.ts +182 -16
- package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.1/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
- package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
- package/generated/versions/defold-1.13.2/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.2/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.13.2/factory.d.ts +4 -2
- package/generated/versions/defold-1.13.2/go.d.ts +114 -220
- package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
- package/generated/versions/defold-1.13.2/http.d.ts +4 -2
- package/generated/versions/defold-1.13.2/image.d.ts +56 -4
- package/generated/versions/defold-1.13.2/index.d.ts +3 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
- package/generated/versions/defold-1.13.2/material.d.ts +3 -3
- package/generated/versions/defold-1.13.2/model.d.ts +4 -5
- package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
- package/generated/versions/defold-1.13.2/physics.d.ts +48 -4
- package/generated/versions/defold-1.13.2/render.d.ts +164 -20
- package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
- package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
- package/generated/versions/defold-1.13.2/sys.d.ts +78 -10
- package/generated/versions/defold-1.13.2/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/window.d.ts +1 -1
- package/generated/vmath.d.ts +0 -24
- package/generated/window.d.ts +1 -1
- package/identity-vocabulary.json +98 -7
- package/index.d.ts +3 -0
- package/package.json +3 -1
- package/scripts/generate-api-availability.ts +6 -22
- package/scripts/generate-api-signatures.ts +87 -21
- package/scripts/materialize-version.ts +53 -6
- package/scripts/regen.ts +256 -44
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/target-version.ts +26 -0
- package/src/api-doc.ts +26 -0
- package/src/component-properties.d.ts +226 -6
- package/src/core-types.ts +82 -20
- package/src/doc-corrections.ts +53 -5
- package/src/emit-dts.ts +1300 -269
- package/src/emit-messages.ts +289 -0
- package/src/engine-globals.d.ts +8 -2
- package/src/go-overloads.d.ts +80 -15
- package/src/gui-overloads.d.ts +489 -0
- package/src/gui-texture-removal.d.ts +41 -0
- package/src/index.ts +2 -0
- package/src/lifecycle.ts +46 -37
- package/src/luals-type-expr.ts +6 -1
- package/src/msg-overloads.d.ts +25 -13
- package/src/physics-event-guard.d.ts +39 -0
- package/src/render-overloads.d.ts +2 -2
- package/src/return-correction-provenance.ts +36 -6
- package/src/signature-store.ts +50 -0
- package/src/timers.d.ts +2 -1
- package/src/vmath-overloads.d.ts +26 -0
- package/src/window-event-guard.d.ts +5 -3
package/src/lifecycle.ts
CHANGED
|
@@ -7,51 +7,51 @@ export interface InputTouch {
|
|
|
7
7
|
/**
|
|
8
8
|
* Identifier for the touch during its lifetime.
|
|
9
9
|
*/
|
|
10
|
-
id
|
|
10
|
+
id: number;
|
|
11
11
|
/**
|
|
12
12
|
* Whether the finger was pressed this frame.
|
|
13
13
|
*/
|
|
14
|
-
pressed
|
|
14
|
+
pressed: boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Whether the finger was released this frame.
|
|
17
17
|
*/
|
|
18
|
-
released
|
|
18
|
+
released: boolean;
|
|
19
19
|
/**
|
|
20
20
|
* Number of taps, such as one for a single tap and two for a double tap.
|
|
21
21
|
*/
|
|
22
|
-
tap_count
|
|
22
|
+
tap_count: number;
|
|
23
23
|
/**
|
|
24
24
|
* Touch x-coordinate.
|
|
25
25
|
*/
|
|
26
|
-
x
|
|
26
|
+
x: number;
|
|
27
27
|
/**
|
|
28
28
|
* Touch y-coordinate.
|
|
29
29
|
*/
|
|
30
|
-
y
|
|
30
|
+
y: number;
|
|
31
31
|
/**
|
|
32
32
|
* Change in the touch x-coordinate.
|
|
33
33
|
*/
|
|
34
|
-
dx
|
|
34
|
+
dx: number;
|
|
35
35
|
/**
|
|
36
36
|
* Change in the touch y-coordinate.
|
|
37
37
|
*/
|
|
38
|
-
dy
|
|
38
|
+
dy: number;
|
|
39
39
|
/**
|
|
40
40
|
* Touch x-coordinate in screen space.
|
|
41
41
|
*/
|
|
42
|
-
screen_x
|
|
42
|
+
screen_x: number;
|
|
43
43
|
/**
|
|
44
44
|
* Touch y-coordinate in screen space.
|
|
45
45
|
*/
|
|
46
|
-
screen_y
|
|
46
|
+
screen_y: number;
|
|
47
47
|
/**
|
|
48
48
|
* Change in the touch x-coordinate in screen space.
|
|
49
49
|
*/
|
|
50
|
-
screen_dx
|
|
50
|
+
screen_dx: number;
|
|
51
51
|
/**
|
|
52
52
|
* Change in the touch y-coordinate in screen space.
|
|
53
53
|
*/
|
|
54
|
-
screen_dy
|
|
54
|
+
screen_dy: number;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Fields and docs follow the go ref-doc's `on_input.action` STRUCT, whose keys are
|
|
@@ -363,14 +363,17 @@ export type GuiScriptHooks<TSelf, TInitState = TSelf> = Omit<
|
|
|
363
363
|
|
|
364
364
|
export type RenderScriptHooks<TSelf, TInitState = TSelf> = Omit<
|
|
365
365
|
ScriptHooks<TSelf, TInitState>,
|
|
366
|
-
"on_input"
|
|
366
|
+
"on_input" | "final" | "fixed_update" | "late_update"
|
|
367
367
|
>;
|
|
368
368
|
|
|
369
369
|
// The factory hook table plus the value-keyed `properties` field. `TProps` is
|
|
370
370
|
// the property channel (raw default values), `TSelf` the merged `self` the
|
|
371
371
|
// callbacks see (`NoInfer`-wrapped inside the hook set), and `TInitState` what
|
|
372
372
|
// `init` returns. `ScriptHooks` itself stays callback-only so the
|
|
373
|
-
// `SCRIPT_HOOK_NAMES` drift pin remains valid.
|
|
373
|
+
// `SCRIPT_HOOK_NAMES` drift pin remains valid. Only `defineScript` takes
|
|
374
|
+
// `properties`: the GUI and render variants keep the same three type parameters
|
|
375
|
+
// but type the field `undefined`, because Defold builds `go.property` only in
|
|
376
|
+
// `.script` files.
|
|
374
377
|
//
|
|
375
378
|
// `init` is overridden to receive `self: NoInfer<TProps>` — Defold applies the
|
|
376
379
|
// declared property values to `self` before `init` runs, so init-time setup can
|
|
@@ -402,17 +405,20 @@ export type GuiScriptHooksWithProperties<TProps, TSelf, TInitState> = Omit<
|
|
|
402
405
|
"init"
|
|
403
406
|
> & {
|
|
404
407
|
/**
|
|
405
|
-
* Receives `self`
|
|
406
|
-
*
|
|
407
|
-
* returned object
|
|
408
|
+
* Receives `self` typed by the first type argument, which stays empty unless
|
|
409
|
+
* given explicitly, since a GUI script declares no properties. The
|
|
410
|
+
* returned object seeds the inferred script state.
|
|
408
411
|
*/
|
|
409
412
|
init?(self: NoInfer<TProps>): TInitState;
|
|
410
413
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
+
* Not available: Defold builds `go.property` only in `.script` files, so a
|
|
415
|
+
* GUI script cannot declare properties. Declare the property on a game
|
|
416
|
+
* object's {@link defineScript} and `msg.post` its value to the GUI
|
|
417
|
+
* script from that script's `init`; `go.get` does not work for this from a
|
|
418
|
+
* GUI script, since the engine's `go.get` accepts only a game-object
|
|
419
|
+
* script instance.
|
|
414
420
|
*/
|
|
415
|
-
properties?:
|
|
421
|
+
properties?: undefined;
|
|
416
422
|
};
|
|
417
423
|
|
|
418
424
|
export type RenderScriptHooksWithProperties<TProps, TSelf, TInitState> = Omit<
|
|
@@ -420,17 +426,20 @@ export type RenderScriptHooksWithProperties<TProps, TSelf, TInitState> = Omit<
|
|
|
420
426
|
"init"
|
|
421
427
|
> & {
|
|
422
428
|
/**
|
|
423
|
-
* Receives `self`
|
|
424
|
-
*
|
|
425
|
-
* returned object
|
|
429
|
+
* Receives `self` typed by the first type argument, which stays empty unless
|
|
430
|
+
* given explicitly, since a render script declares no properties. The
|
|
431
|
+
* returned object seeds the inferred script state.
|
|
426
432
|
*/
|
|
427
433
|
init?(self: NoInfer<TProps>): TInitState;
|
|
428
434
|
/**
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
435
|
+
* Not available: Defold builds `go.property` only in `.script` files, so a
|
|
436
|
+
* render script cannot declare properties. Declare the property on a game
|
|
437
|
+
* object's {@link defineScript} and `msg.post` its value to the render
|
|
438
|
+
* script from that script's `init`; `go.get` does not work for this from a
|
|
439
|
+
* render script, since the engine's `go.get` accepts only a game-object
|
|
440
|
+
* script instance.
|
|
432
441
|
*/
|
|
433
|
-
properties?:
|
|
442
|
+
properties?: undefined;
|
|
434
443
|
};
|
|
435
444
|
|
|
436
445
|
// The script-local message map an `onMessage` dispatcher carries, lifted onto
|
|
@@ -502,9 +511,9 @@ export function defineScript<
|
|
|
502
511
|
/**
|
|
503
512
|
* Type a `.gui_script` component's hook table. Like {@link defineScript} it is
|
|
504
513
|
* an identity function at runtime, infers `TSelf` from `init`'s return by
|
|
505
|
-
* default,
|
|
506
|
-
*
|
|
507
|
-
*
|
|
514
|
+
* default, and is erased by the transpiler's `lifecycle-erasure` pass into the
|
|
515
|
+
* flat Defold chunk shape. The `properties` field is {@link defineScript}-only:
|
|
516
|
+
* Defold builds `go.property` only in `.script` files.
|
|
508
517
|
*
|
|
509
518
|
* `GuiScriptHooks` is `Omit<ScriptHooks, "fixed_update" | "late_update">` — gui
|
|
510
519
|
* scripts are not driven by the fixed-timestep or late-update passes. It accepts
|
|
@@ -543,13 +552,13 @@ export function defineGuiScript<
|
|
|
543
552
|
/**
|
|
544
553
|
* Type a `.render_script` component's hook table. Like {@link defineScript} it
|
|
545
554
|
* is an identity function at runtime, infers `TSelf` from `init`'s return by
|
|
546
|
-
* default,
|
|
547
|
-
*
|
|
548
|
-
*
|
|
555
|
+
* default, and is erased by the transpiler's `lifecycle-erasure` pass into the
|
|
556
|
+
* flat Defold chunk shape. The `properties` field is {@link defineScript}-only:
|
|
557
|
+
* Defold builds `go.property` only in `.script` files.
|
|
549
558
|
*
|
|
550
|
-
* `RenderScriptHooks` is `Omit<ScriptHooks, "on_input"
|
|
551
|
-
*
|
|
552
|
-
*
|
|
559
|
+
* `RenderScriptHooks` is `Omit<ScriptHooks, "on_input" | "final" |
|
|
560
|
+
* "fixed_update" | "late_update">` — the engine calls only four render-script
|
|
561
|
+
* hooks, all optional: `init`, `update`, `on_message`, `on_reload`.
|
|
553
562
|
*
|
|
554
563
|
* Scaffold it with the `def-ts-defineRenderScript-inferred-self` / `def-ts-defineRenderScript-typed-self` VSCode snippets
|
|
555
564
|
* from `defold-typescript init`.
|
package/src/luals-type-expr.ts
CHANGED
|
@@ -334,6 +334,11 @@ export function mapLualsExpression(
|
|
|
334
334
|
return { ts: mapToken(token, walk), unknowns: walk.unknowns };
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
/** Whether a raw token is a typed LuaLS `fun(...)` expression rather than a bare `function(...)`. */
|
|
338
|
+
export function isLualsFunctionToken(token: string): boolean {
|
|
339
|
+
return /^fun\s*\(/.test(token.trim());
|
|
340
|
+
}
|
|
341
|
+
|
|
337
342
|
/**
|
|
338
343
|
* Map a `fun(...)` expression to a TypeScript **call signature** — the colon-return
|
|
339
344
|
* form `(params): ret` an interface uses to become callable, not the `=>` arrow a
|
|
@@ -345,7 +350,7 @@ export function mapLualsCallSignatureExpression(
|
|
|
345
350
|
position: LualsPosition = "output",
|
|
346
351
|
): LualsMapResult {
|
|
347
352
|
const trimmed = token.trim();
|
|
348
|
-
if (
|
|
353
|
+
if (!isLualsFunctionToken(trimmed)) {
|
|
349
354
|
throw new Error(`mapLualsCallSignature: expected a "fun(...)" token, got "${token}".`);
|
|
350
355
|
}
|
|
351
356
|
const walk: Walk = { resolveLeaf, unknowns: [], position };
|
package/src/msg-overloads.d.ts
CHANGED
|
@@ -100,17 +100,24 @@ declare global {
|
|
|
100
100
|
* Only the following arities are supported at runtime:
|
|
101
101
|
*
|
|
102
102
|
* - `msg.url()` — no-arg.
|
|
103
|
-
* - `msg.url("[socket:][path][#fragment]"
|
|
104
|
-
*
|
|
103
|
+
* - `msg.url(urlstring)` — one argument: a `"[socket:][path][#fragment]"`
|
|
104
|
+
* string, a `Hash`, or a `Url`.
|
|
105
|
+
* - `msg.url(socket, path, fragment)` — three positions, each of which may
|
|
106
|
+
* be `undefined` (Lua `nil`).
|
|
105
107
|
*
|
|
106
108
|
* The two-arg form `msg.url(socket, path)` is a runtime error.
|
|
107
109
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
+
* In the one-argument form, a `Hash` is a path in the current world with no
|
|
111
|
+
* fragment, and a `Url` is copied. `undefined` is equivalent to `msg.url()`
|
|
112
|
+
* — the URL of the current script.
|
|
110
113
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* current
|
|
114
|
+
* In the three-argument form, an `undefined` `socket` addresses the current
|
|
115
|
+
* game world, exactly as the runtime's own examples do. An `undefined`
|
|
116
|
+
* `path` with an `undefined` socket is the current path. An `undefined`
|
|
117
|
+
* `fragment` is no fragment, unless `socket` and `path` are both
|
|
118
|
+
* `undefined`, which keeps the current fragment. A `socket` and `fragment`
|
|
119
|
+
* with an `undefined` `path` raise "Can't resolve id with specified socket
|
|
120
|
+
* and fragment."
|
|
114
121
|
*
|
|
115
122
|
* In the same world, address a sibling **relatively** — by bare id
|
|
116
123
|
* (`msg.url("camera")`), absolute path (`msg.url("/camera")`), or
|
|
@@ -139,6 +146,9 @@ declare global {
|
|
|
139
146
|
* // A component on a sibling.
|
|
140
147
|
* const comp: Url = msg.url("camera#script");
|
|
141
148
|
*
|
|
149
|
+
* // A hashed path in the current world.
|
|
150
|
+
* const door: Url = msg.url(hash("/door"));
|
|
151
|
+
*
|
|
142
152
|
* // Crossing into a proxy-loaded world — `socket` is the world name.
|
|
143
153
|
* const proxied: Url = msg.url(hash("level1"), hash("/door"), hash("script"));
|
|
144
154
|
*
|
|
@@ -147,18 +157,20 @@ declare global {
|
|
|
147
157
|
* ```
|
|
148
158
|
*/
|
|
149
159
|
function url(): Url;
|
|
150
|
-
function url(urlstring: SceneAddress | undefined): Url;
|
|
160
|
+
function url(urlstring: SceneAddress | Hash | Url | undefined): Url;
|
|
151
161
|
function url(
|
|
152
162
|
socket: string | Hash | undefined,
|
|
153
|
-
path: string | Hash,
|
|
154
|
-
fragment: string | Hash,
|
|
163
|
+
path: string | Hash | undefined,
|
|
164
|
+
fragment: string | Hash | undefined,
|
|
155
165
|
): Url;
|
|
156
166
|
function url<M extends object>(): ReceiverUrl<M>;
|
|
157
|
-
function url<M extends object>(
|
|
167
|
+
function url<M extends object>(
|
|
168
|
+
urlstring: SceneAddress | Hash | Url | undefined,
|
|
169
|
+
): ReceiverUrl<M>;
|
|
158
170
|
function url<M extends object>(
|
|
159
171
|
socket: string | Hash | undefined,
|
|
160
|
-
path: string | Hash,
|
|
161
|
-
fragment: string | Hash,
|
|
172
|
+
path: string | Hash | undefined,
|
|
173
|
+
fragment: string | Hash | undefined,
|
|
162
174
|
): ReceiverUrl<M>;
|
|
163
175
|
}
|
|
164
176
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Hash } from "./core-types";
|
|
3
|
+
|
|
4
|
+
// `physics.set_event_listener` sets `type` on every event to its message-name
|
|
5
|
+
// hash (script_physics.cpp), but a `Hash` is an object type, not a unit type, so
|
|
6
|
+
// an `event.type == hash("…")` check cannot narrow the event union. This guard
|
|
7
|
+
// re-introduces the literal at the use site. The transpiler lowers the call to
|
|
8
|
+
// `event.type == hash("…")` (physics-event-guard-lowering.ts), so this package
|
|
9
|
+
// emits no runtime Lua. It names no `physics` type, so it compiles on a surface
|
|
10
|
+
// whose reference declares no event union.
|
|
11
|
+
type PhysicsEventName<E> = E extends { type: Hash<infer N> } ? N : never;
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
/**
|
|
15
|
+
* Type guard for a `physics.set_event_listener` callback: narrows one event
|
|
16
|
+
* to the member of the event union whose `type` is the hash of `name`. The
|
|
17
|
+
* engine sets `type` on every event, but a `Hash` cannot act as a union
|
|
18
|
+
* discriminant, so an `event.type == hash("collision_event")` check leaves the
|
|
19
|
+
* event unnarrowed — this guard re-introduces the literal.
|
|
20
|
+
*
|
|
21
|
+
* @param event - one entry of the `events` array the listener received.
|
|
22
|
+
* @param name - the event's message name (e.g. `"collision_event"`).
|
|
23
|
+
* @returns `true` when `event.type` is `hash(name)`, narrowing `event` to that event.
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* physics.set_event_listener((self, events) => {
|
|
27
|
+
* for (const event of events) {
|
|
28
|
+
* if (isPhysicsEvent(event, "collision_event")) {
|
|
29
|
+
* print(event.a.id, event.b.id);
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function isPhysicsEvent<E extends { type: Hash }, K extends PhysicsEventName<E>>(
|
|
36
|
+
event: E,
|
|
37
|
+
name: K,
|
|
38
|
+
): event is Extract<E, { type: Hash<K> }>;
|
|
39
|
+
}
|
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
* @param parameters - table of buffer parameters, see the description for available keys and values
|
|
13
13
|
* @returns new render target
|
|
14
14
|
*/
|
|
15
|
-
function render_target(parameters:
|
|
15
|
+
function render_target(parameters: render.RenderTargetParams): Opaque<"render_target">;
|
|
16
16
|
/**
|
|
17
17
|
* Creates a new named render target according to the supplied specification
|
|
18
18
|
* table. The name is used by the profiler and by render target lookups.
|
|
@@ -23,7 +23,7 @@ declare global {
|
|
|
23
23
|
*/
|
|
24
24
|
function render_target(
|
|
25
25
|
name: string,
|
|
26
|
-
parameters:
|
|
26
|
+
parameters: render.RenderTargetParams,
|
|
27
27
|
): Opaque<"render_target">;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -248,6 +248,10 @@ export interface ReturnTypeProvenance {
|
|
|
248
248
|
readonly sightedIn: readonly string[];
|
|
249
249
|
readonly neededBy: readonly string[];
|
|
250
250
|
readonly resolvedIn: readonly string[];
|
|
251
|
+
// Targets whose vendored binding does not show a binding-pinned entry's pin,
|
|
252
|
+
// so the emitter leaves the entry off there. Never a resolution: upstream
|
|
253
|
+
// documented nothing, the engine source changed.
|
|
254
|
+
readonly unboundIn: readonly string[];
|
|
251
255
|
readonly driftedIn: readonly string[];
|
|
252
256
|
readonly typeDrift: readonly string[];
|
|
253
257
|
}
|
|
@@ -255,14 +259,26 @@ export interface ReturnTypeProvenance {
|
|
|
255
259
|
// Same ranking argument as `FIELD_VERDICT_RANK`: `emitReturn` applies the
|
|
256
260
|
// correction to every declaration of the FQN in a target, so one drifted
|
|
257
261
|
// declaration makes that target's emit wrong whatever its siblings say.
|
|
258
|
-
|
|
262
|
+
// Binding evidence is per target, so for a binding-pinned entry `unbound` never
|
|
263
|
+
// meets another verdict in the same target.
|
|
264
|
+
type ReturnVerdict = "drift" | "needed" | "unbound" | "resolved";
|
|
259
265
|
|
|
260
266
|
const RETURN_VERDICT_RANK: Record<ReturnVerdict, number> = {
|
|
261
|
-
drift:
|
|
262
|
-
needed:
|
|
267
|
+
drift: 3,
|
|
268
|
+
needed: 2,
|
|
269
|
+
unbound: 1,
|
|
263
270
|
resolved: 0,
|
|
264
271
|
};
|
|
265
272
|
|
|
273
|
+
// Whether the declared tokens already say what the correction does. Tokens can
|
|
274
|
+
// state only the nil: a binding-pinned `ts` entry corrects what the binding sets
|
|
275
|
+
// (a field it never pushes), so upstream fixing that shows as a retype, which is
|
|
276
|
+
// drift, never as a resolution.
|
|
277
|
+
function declaresCorrection(tokens: readonly string[], correction: ReturnTypeCorrection): boolean {
|
|
278
|
+
if (correction.nullable === undefined && correction.binding !== undefined) return false;
|
|
279
|
+
return correction.nullable === false ? !tokens.includes("nil") : tokens.includes("nil");
|
|
280
|
+
}
|
|
281
|
+
|
|
266
282
|
// The return-type class has the same two-sided evidence: the declared tokens
|
|
267
283
|
// still say what the correction contradicts, and the slot prose still states the
|
|
268
284
|
// contradiction. A target that fixes either half no longer needs the entry.
|
|
@@ -273,9 +289,16 @@ const RETURN_VERDICT_RANK: Record<ReturnVerdict, number> = {
|
|
|
273
289
|
// return correction replaces the whole emitted type, so a base upstream no longer
|
|
274
290
|
// declares means the correction now overwrites a type nobody verified — a
|
|
275
291
|
// decision for a human, not a deletion and not a silent bank.
|
|
292
|
+
//
|
|
293
|
+
// A binding-pinned entry rests on the engine source rather than the prose, so
|
|
294
|
+
// its prose is never searched. `bindingEvidence` maps each vendored target to
|
|
295
|
+
// the keys whose pin holds there; a target absent from it shows no evidence.
|
|
296
|
+
// A target without the entry's evidence is `unbound` before its tokens are
|
|
297
|
+
// read, because the emitter leaves the entry off there.
|
|
276
298
|
export function returnCorrectionProvenance(
|
|
277
299
|
entries: readonly [string, ReturnTypeCorrection][],
|
|
278
300
|
surfaces: readonly ProvenanceSurface[],
|
|
301
|
+
bindingEvidence: ReadonlyMap<string, ReadonlySet<string>> = new Map(),
|
|
279
302
|
): ReturnTypeProvenance[] {
|
|
280
303
|
return entries.map(([key, correction]) => {
|
|
281
304
|
const namespace = namespaceOf(key);
|
|
@@ -291,7 +314,12 @@ export function returnCorrectionProvenance(
|
|
|
291
314
|
const tokens = slot.types ?? [];
|
|
292
315
|
|
|
293
316
|
let verdict: ReturnVerdict;
|
|
294
|
-
if (
|
|
317
|
+
if (
|
|
318
|
+
correction.binding !== undefined &&
|
|
319
|
+
bindingEvidence.get(surface.target)?.has(key) !== true
|
|
320
|
+
) {
|
|
321
|
+
verdict = "unbound";
|
|
322
|
+
} else if (!pinMatches(tokens, pins)) {
|
|
295
323
|
verdict = "drift";
|
|
296
324
|
const messages = drift.get(surface.target) ?? new Set<string>();
|
|
297
325
|
drift.set(surface.target, messages);
|
|
@@ -299,8 +327,9 @@ export function returnCorrectionProvenance(
|
|
|
299
327
|
`${surface.target}: pinned ${pins.map((pin) => pin.join("|")).join(" or ")}, found ${tokens.join("|")}`,
|
|
300
328
|
);
|
|
301
329
|
} else if (
|
|
302
|
-
tokens
|
|
303
|
-
|
|
330
|
+
declaresCorrection(tokens, correction) ||
|
|
331
|
+
(correction.binding === undefined &&
|
|
332
|
+
!decodeSlotProse(slot.doc ?? "").includes(correction.reason))
|
|
304
333
|
) {
|
|
305
334
|
verdict = "resolved";
|
|
306
335
|
} else {
|
|
@@ -323,6 +352,7 @@ export function returnCorrectionProvenance(
|
|
|
323
352
|
sightedIn,
|
|
324
353
|
neededBy: inBucket("needed"),
|
|
325
354
|
resolvedIn: inBucket("resolved"),
|
|
355
|
+
unboundIn: inBucket("unbound"),
|
|
326
356
|
driftedIn,
|
|
327
357
|
typeDrift: driftedIn.flatMap((target) => [...(drift.get(target) ?? [])]).sort(),
|
|
328
358
|
};
|
package/src/signature-store.ts
CHANGED
|
@@ -9,6 +9,10 @@ export interface SignatureOverride {
|
|
|
9
9
|
// than `signatures` keeps the ref-doc fixture description for those rows. Every
|
|
10
10
|
// existing override omits `docs` and renders exactly as before.
|
|
11
11
|
docs?: (string | null)[];
|
|
12
|
+
// Optional per-overload first release, parallel to `signatures`: entry `i` is
|
|
13
|
+
// the bare semver from which row `i` exists, or `null` for a row every target
|
|
14
|
+
// declares. An absent array means every row is ungated.
|
|
15
|
+
since?: (string | null)[];
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
// An FQN (`io.open`, `file:read`, …) maps to one override. An element with
|
|
@@ -23,3 +27,49 @@ export type SignatureStore = Record<string, SignatureOverride>;
|
|
|
23
27
|
export function lookupSignature(store: SignatureStore, fqn: string): SignatureOverride | null {
|
|
24
28
|
return store[fqn] ?? null;
|
|
25
29
|
}
|
|
30
|
+
|
|
31
|
+
function versionParts(version: string): number[] {
|
|
32
|
+
return version.split(".").map((part) => Number.parseInt(part, 10));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function versionAtLeast(version: string, since: string): boolean {
|
|
36
|
+
const [have, need] = [versionParts(version), versionParts(since)];
|
|
37
|
+
for (let index = 0; index < Math.max(have.length, need.length); index += 1) {
|
|
38
|
+
const diff = (have[index] ?? 0) - (need[index] ?? 0);
|
|
39
|
+
if (diff !== 0) return diff > 0;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The override as a target at `version` declares it: only the rows whose `since`
|
|
45
|
+
// is absent, `null`, or at most `version`, with `docs` and `since` kept parallel.
|
|
46
|
+
export function signatureArmsFor(override: SignatureOverride, version: string): SignatureOverride {
|
|
47
|
+
const since = override.since;
|
|
48
|
+
if (since === undefined) return override;
|
|
49
|
+
const kept = override.signatures
|
|
50
|
+
.map((_, index) => index)
|
|
51
|
+
.filter((index) => {
|
|
52
|
+
const first = since[index];
|
|
53
|
+
return first == null || versionAtLeast(version, first);
|
|
54
|
+
});
|
|
55
|
+
if (kept.length === override.signatures.length) return override;
|
|
56
|
+
const docs = override.docs;
|
|
57
|
+
return {
|
|
58
|
+
signatures: kept.map((index) => override.signatures[index] as string),
|
|
59
|
+
...(docs === undefined
|
|
60
|
+
? {}
|
|
61
|
+
: { docs: kept.filter((index) => index < docs.length).map((index) => docs[index] ?? null) }),
|
|
62
|
+
since: kept.map((index) => since[index] ?? null),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The store as one version declares it: each entry keeps only the arms whose
|
|
67
|
+
// `since` the version meets, and an entry left with none is dropped.
|
|
68
|
+
export function signatureStoreFor(store: SignatureStore, version: string): SignatureStore {
|
|
69
|
+
const scoped: SignatureStore = {};
|
|
70
|
+
for (const [fqn, override] of Object.entries(store)) {
|
|
71
|
+
const arms = signatureArmsFor(override, version);
|
|
72
|
+
if (arms.signatures.length > 0) scoped[fqn] = arms;
|
|
73
|
+
}
|
|
74
|
+
return scoped;
|
|
75
|
+
}
|
package/src/timers.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// as an isolated Lua chunk with no shared global scope and no JS event loop, so
|
|
4
4
|
// these are named module exports (lowered to a `require`), not ambient globals:
|
|
5
5
|
// pay-for-use and explicit. The transpiler emits the runtime and the CLI writes
|
|
6
|
-
// it to
|
|
6
|
+
// it to `lib/defold_typescript/timers.lua` (moved by `runtime-dir`), respelling
|
|
7
|
+
// the import's `require` to that path.
|
|
7
8
|
declare module "@defold-typescript/types/timers" {
|
|
8
9
|
/**
|
|
9
10
|
* Run `callback` once after `delayMs` milliseconds, backed by Defold's
|
package/src/vmath-overloads.d.ts
CHANGED
|
@@ -85,6 +85,32 @@ declare global {
|
|
|
85
85
|
* @returns multiplied vector
|
|
86
86
|
*/
|
|
87
87
|
function mul_per_elem<T extends Vector3 | Vector4>(v1: T, v2: T): T;
|
|
88
|
+
/**
|
|
89
|
+
* The returned value is a scalar defined as:
|
|
90
|
+
* `P ⋅ Q = |P| |Q| cos θ`
|
|
91
|
+
* where θ is the angle between the vectors P and Q.
|
|
92
|
+
*
|
|
93
|
+
* - If the dot product is positive then the angle between the vectors is below 90 degrees.
|
|
94
|
+
* - If the dot product is zero the vectors are perpendicular (at right-angles to each other).
|
|
95
|
+
* - If the dot product is negative then the angle between the vectors is more than 90 degrees.
|
|
96
|
+
*
|
|
97
|
+
* Both vectors must have the same type: a vector3 paired with a vector4 raises.
|
|
98
|
+
*
|
|
99
|
+
* @param v1 - first vector
|
|
100
|
+
* @param v2 - second vector
|
|
101
|
+
* @returns dot product
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const vector1 = vmath.vector3(1, 0, 0);
|
|
105
|
+
* const vector2 = vmath.vector3(0, 1, 0);
|
|
106
|
+
*
|
|
107
|
+
* if (vmath.dot(vector1, vector2) === 0) {
|
|
108
|
+
* // The two vectors are perpendicular (at right-angles to each other)
|
|
109
|
+
* // ...
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function dot<T extends Vector3 | Vector4>(v1: T, v2: T): number;
|
|
88
114
|
/**
|
|
89
115
|
* Normalizes a vector, i.e. returns a new vector with the same
|
|
90
116
|
* direction as the input vector, but with length 1.
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// params, and the `WINDOW_EVENT_*` constants are branded numbers — so TS can
|
|
5
5
|
// neither correlate the two params nor use a branded number as a discriminant.
|
|
6
6
|
// This guard re-introduces the discriminant at the use site, narrowing the
|
|
7
|
-
// untyped `data` payload (only `WINDOW_EVENT_RESIZED` carries fields
|
|
7
|
+
// untyped `data` payload (only `WINDOW_EVENT_RESIZED` carries fields; every
|
|
8
|
+
// other event gets an empty table, script_window.cpp). It mirrors
|
|
8
9
|
// `isMessage` for `on_message`; the transpiler lowers the call to a bare
|
|
9
10
|
// `event == window.WINDOW_EVENT_*` (window-event-guard-lowering.ts), so this
|
|
10
11
|
// package emits no runtime Lua. The event kinds are read off the loaded
|
|
@@ -14,7 +15,7 @@ type WindowEventKind = (typeof window)[Extract<keyof typeof window, `WINDOW_EVEN
|
|
|
14
15
|
|
|
15
16
|
type WindowEventData<K extends WindowEventKind> = K extends typeof window.WINDOW_EVENT_RESIZED
|
|
16
17
|
? { width: number; height: number }
|
|
17
|
-
:
|
|
18
|
+
: Record<string, never>;
|
|
18
19
|
|
|
19
20
|
declare global {
|
|
20
21
|
/**
|
|
@@ -24,7 +25,8 @@ declare global {
|
|
|
24
25
|
* params and the constants are branded numbers, so TS cannot auto-narrow `data`
|
|
25
26
|
* from an `event === window.WINDOW_EVENT_RESIZED` check — this guard
|
|
26
27
|
* re-introduces the discriminant. Only `WINDOW_EVENT_RESIZED` carries fields
|
|
27
|
-
* (`{ width, height }`); every other event
|
|
28
|
+
* (`{ width, height }`); every other event receives an empty table, so `data`
|
|
29
|
+
* narrows to `Record<string, never>`.
|
|
28
30
|
*
|
|
29
31
|
* @param event - the event constant the callback received.
|
|
30
32
|
* @param data - the untyped data payload the callback received.
|