@defold-typescript/types 0.51.0 → 0.53.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 +2804 -3172
- package/api-targets.json +15 -5
- package/examples/translations.json +19 -71
- package/generated/b2d.d.ts +39 -39
- package/generated/b2d_body.d.ts +11 -11
- package/generated/b2d_chain.d.ts +3 -3
- package/generated/b2d_fixture.d.ts +5 -5
- package/generated/b2d_joint.d.ts +29 -29
- package/generated/b2d_shape.d.ts +13 -13
- package/generated/b2d_world.d.ts +15 -15
- package/generated/buffer.d.ts +10 -11
- package/generated/bullet3d.d.ts +6 -6
- package/generated/bullet3d_collision_object.d.ts +10 -10
- package/generated/bullet3d_constraint.d.ts +173 -71
- package/generated/bullet3d_rigid_body.d.ts +3 -3
- package/generated/bullet3d_shape.d.ts +11 -11
- package/generated/bullet3d_world.d.ts +20 -20
- package/generated/camera.d.ts +4 -4
- package/generated/collectionfactory.d.ts +2 -3
- package/generated/collectionproxy.d.ts +5 -5
- package/generated/compute.d.ts +5 -5
- package/generated/crash.d.ts +7 -7
- package/generated/editor-vm/http.d.ts +13 -13
- package/generated/editor-vm/image.d.ts +4 -4
- package/generated/editor-vm/json.d.ts +1 -1
- package/generated/editor-vm/tilemap_tiles.d.ts +9 -9
- package/generated/editor-vm/zip.d.ts +4 -4
- package/generated/editor.d.ts +183 -183
- package/generated/factory.d.ts +2 -3
- package/generated/font.d.ts +4 -4
- package/generated/go.d.ts +122 -230
- package/generated/graphics.d.ts +23 -25
- package/generated/gui.d.ts +186 -423
- package/generated/http.d.ts +3 -3
- package/generated/image.d.ts +63 -11
- package/generated/json.d.ts +4 -4
- package/generated/kinds/gui-script.d.ts +2 -0
- package/generated/kinds/render-script.d.ts +14 -15
- package/generated/label.d.ts +5 -5
- package/generated/liveupdate.d.ts +7 -3
- package/generated/material.d.ts +49 -49
- package/generated/model.d.ts +46 -14
- package/generated/particlefx.d.ts +24 -5
- package/generated/physics.d.ts +64 -20
- package/generated/profiler.d.ts +3 -5
- 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 +24 -0
- package/generated/render-script-modules/collectionproxy.d.ts +39 -0
- package/generated/render-script-modules/factory.d.ts +24 -0
- package/generated/render-script-modules/go.d.ts +434 -0
- package/generated/render-script-modules/label.d.ts +105 -0
- package/generated/render-script-modules/model.d.ts +121 -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 +1232 -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 +172 -47
- package/generated/resource.d.ts +81 -61
- package/generated/socket.d.ts +18 -23
- package/generated/sound.d.ts +6 -6
- package/generated/sprite.d.ts +51 -3
- package/generated/sys.d.ts +87 -24
- package/generated/tilemap.d.ts +3 -3
- package/generated/timer.d.ts +3 -3
- package/generated/versions/defold-1.12.4/b2d.d.ts +2 -2
- package/generated/versions/defold-1.12.4/b2d_body.d.ts +2 -2
- package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
- package/generated/versions/defold-1.12.4/go.d.ts +117 -345
- package/generated/versions/defold-1.12.4/graphics.d.ts +2 -1
- package/generated/versions/defold-1.12.4/gui.d.ts +169 -532
- package/generated/versions/defold-1.12.4/http.d.ts +2 -2
- package/generated/versions/defold-1.12.4/image.d.ts +82 -2
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/label.d.ts +1 -1
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.12.4/model.d.ts +42 -10
- package/generated/versions/defold-1.12.4/particlefx.d.ts +23 -2
- package/generated/versions/defold-1.12.4/physics.d.ts +46 -2
- package/generated/versions/defold-1.12.4/render.d.ts +83 -7
- package/generated/versions/defold-1.12.4/resource.d.ts +50 -17
- package/generated/versions/defold-1.12.4/socket.d.ts +12 -12
- package/generated/versions/defold-1.12.4/sound.d.ts +1 -1
- package/generated/versions/defold-1.12.4/sprite.d.ts +59 -2
- package/generated/versions/defold-1.12.4/sys.d.ts +103 -8
- package/generated/versions/defold-1.12.4/tilemap.d.ts +1 -1
- package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
- package/generated/versions/defold-1.12.4/window.d.ts +3 -4
- package/generated/versions/defold-1.13.0/b2d.d.ts +2 -2
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +2 -2
- package/generated/versions/defold-1.13.0/b2d_chain.d.ts +1 -1
- package/generated/versions/defold-1.13.0/b2d_joint.d.ts +1 -1
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +1 -1
- package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.0/camera.d.ts +1 -1
- package/generated/versions/defold-1.13.0/go.d.ts +117 -372
- package/generated/versions/defold-1.13.0/graphics.d.ts +2 -1
- package/generated/versions/defold-1.13.0/gui.d.ts +169 -532
- package/generated/versions/defold-1.13.0/http.d.ts +2 -2
- package/generated/versions/defold-1.13.0/image.d.ts +82 -2
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/label.d.ts +1 -1
- 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 +42 -10
- package/generated/versions/defold-1.13.0/particlefx.d.ts +23 -2
- package/generated/versions/defold-1.13.0/physics.d.ts +46 -2
- package/generated/versions/defold-1.13.0/render.d.ts +147 -9
- package/generated/versions/defold-1.13.0/resource.d.ts +50 -17
- package/generated/versions/defold-1.13.0/socket.d.ts +12 -12
- package/generated/versions/defold-1.13.0/sound.d.ts +1 -1
- package/generated/versions/defold-1.13.0/sprite.d.ts +59 -2
- package/generated/versions/defold-1.13.0/sys.d.ts +103 -8
- package/generated/versions/defold-1.13.0/tilemap.d.ts +1 -1
- package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.0/window.d.ts +3 -4
- package/generated/versions/defold-1.13.1/b2d.d.ts +2 -2
- package/generated/versions/defold-1.13.1/b2d_body.d.ts +2 -2
- package/generated/versions/defold-1.13.1/b2d_chain.d.ts +1 -1
- package/generated/versions/defold-1.13.1/b2d_joint.d.ts +1 -1
- package/generated/versions/defold-1.13.1/b2d_shape.d.ts +1 -1
- package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.1/camera.d.ts +1 -1
- package/generated/versions/defold-1.13.1/go.d.ts +117 -372
- package/generated/versions/defold-1.13.1/graphics.d.ts +2 -1
- package/generated/versions/defold-1.13.1/gui.d.ts +169 -548
- package/generated/versions/defold-1.13.1/http.d.ts +2 -2
- package/generated/versions/defold-1.13.1/image.d.ts +82 -2
- package/generated/versions/defold-1.13.1/index.d.ts +2 -0
- package/generated/versions/defold-1.13.1/label.d.ts +1 -1
- 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 +42 -10
- package/generated/versions/defold-1.13.1/particlefx.d.ts +23 -2
- package/generated/versions/defold-1.13.1/physics.d.ts +46 -2
- package/generated/versions/defold-1.13.1/render.d.ts +147 -9
- package/generated/versions/defold-1.13.1/resource.d.ts +50 -17
- package/generated/versions/defold-1.13.1/socket.d.ts +12 -12
- package/generated/versions/defold-1.13.1/sound.d.ts +1 -1
- package/generated/versions/defold-1.13.1/sprite.d.ts +59 -2
- package/generated/versions/defold-1.13.1/sys.d.ts +103 -8
- package/generated/versions/defold-1.13.1/tilemap.d.ts +1 -1
- package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.1/window.d.ts +3 -4
- package/generated/versions/defold-1.13.2/b2d.d.ts +39 -39
- package/generated/versions/defold-1.13.2/b2d_body.d.ts +11 -11
- package/generated/versions/defold-1.13.2/b2d_chain.d.ts +3 -3
- package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +5 -5
- package/generated/versions/defold-1.13.2/b2d_joint.d.ts +29 -29
- package/generated/versions/defold-1.13.2/b2d_shape.d.ts +13 -13
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +15 -15
- package/generated/versions/defold-1.13.2/buffer.d.ts +10 -11
- package/generated/versions/defold-1.13.2/bullet3d.d.ts +6 -6
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +10 -10
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +173 -71
- package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +3 -3
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +11 -11
- package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +20 -20
- package/generated/versions/defold-1.13.2/camera.d.ts +4 -4
- package/generated/versions/defold-1.13.2/collectionfactory.d.ts +2 -3
- package/generated/versions/defold-1.13.2/collectionproxy.d.ts +5 -5
- package/generated/versions/defold-1.13.2/compute.d.ts +5 -5
- package/generated/versions/defold-1.13.2/crash.d.ts +7 -7
- package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +13 -13
- package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +4 -4
- package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +1 -1
- package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +9 -9
- package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +4 -4
- package/generated/versions/defold-1.13.2/editor.d.ts +183 -183
- package/generated/versions/defold-1.13.2/factory.d.ts +2 -3
- package/generated/versions/defold-1.13.2/font.d.ts +4 -4
- package/generated/versions/defold-1.13.2/go.d.ts +122 -230
- package/generated/versions/defold-1.13.2/graphics.d.ts +22 -24
- package/generated/versions/defold-1.13.2/gui.d.ts +186 -423
- package/generated/versions/defold-1.13.2/http.d.ts +3 -3
- package/generated/versions/defold-1.13.2/image.d.ts +63 -11
- package/generated/versions/defold-1.13.2/index.d.ts +2 -0
- package/generated/versions/defold-1.13.2/json.d.ts +4 -4
- package/generated/versions/defold-1.13.2/label.d.ts +5 -5
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +7 -3
- package/generated/versions/defold-1.13.2/material.d.ts +49 -49
- package/generated/versions/defold-1.13.2/model.d.ts +46 -14
- package/generated/versions/defold-1.13.2/particlefx.d.ts +24 -5
- package/generated/versions/defold-1.13.2/physics.d.ts +64 -20
- package/generated/versions/defold-1.13.2/profiler.d.ts +3 -5
- package/generated/versions/defold-1.13.2/render.d.ts +161 -46
- package/generated/versions/defold-1.13.2/resource.d.ts +81 -61
- package/generated/versions/defold-1.13.2/socket.d.ts +18 -23
- package/generated/versions/defold-1.13.2/sound.d.ts +6 -6
- package/generated/versions/defold-1.13.2/sprite.d.ts +51 -3
- package/generated/versions/defold-1.13.2/sys.d.ts +87 -24
- package/generated/versions/defold-1.13.2/tilemap.d.ts +3 -3
- package/generated/versions/defold-1.13.2/timer.d.ts +3 -3
- package/generated/versions/defold-1.13.2/vmath.d.ts +0 -25
- package/generated/versions/defold-1.13.2/window.d.ts +8 -10
- package/generated/vmath.d.ts +0 -25
- package/generated/window.d.ts +8 -10
- package/identity-vocabulary.json +86 -34
- package/index.d.ts +2 -0
- package/package.json +3 -1
- package/scripts/generate-api-availability.ts +10 -24
- package/scripts/generate-api-signatures.ts +75 -14
- package/scripts/materialize-version.ts +48 -7
- package/scripts/regen.ts +214 -19
- package/scripts/shared-handle-methods.ts +3 -2
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/target-version.ts +26 -0
- package/src/api-doc.ts +34 -0
- package/src/api-identity.ts +32 -1
- package/src/component-properties.d.ts +96 -7
- package/src/core-types.ts +71 -28
- package/src/doc-corrections.ts +62 -5
- package/src/emit-dts.ts +1423 -401
- package/src/engine-globals.d.ts +5 -1
- package/src/engine-type-name.ts +33 -0
- package/src/go-overloads.d.ts +74 -19
- package/src/gui-overloads.d.ts +489 -0
- package/src/gui-texture-removal.d.ts +41 -0
- package/src/index.ts +3 -0
- package/src/lifecycle.ts +32 -23
- package/src/msg-overloads.d.ts +25 -13
- package/src/signature-store.ts +50 -0
- package/src/socket-types.d.ts +3 -3
- package/src/timers.d.ts +2 -1
- package/src/vmath-overloads.d.ts +26 -0
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
Hash,
|
|
5
|
+
Matrix4,
|
|
6
|
+
Opaque,
|
|
7
|
+
Quaternion,
|
|
8
|
+
Url,
|
|
9
|
+
Vector,
|
|
10
|
+
Vector3,
|
|
11
|
+
Vector4,
|
|
12
|
+
} from "./core-types";
|
|
13
|
+
|
|
14
|
+
// The property name a `gui.PROP_*` constant equals: its brand suffix, lowercased.
|
|
15
|
+
type PropName<P> = P extends { readonly __brand: `gui.PROP_${infer S}` } ? Lowercase<S> : never;
|
|
16
|
+
|
|
17
|
+
// gui.cpp g_Properties: these four have no `.x`..`.w` sub-keys.
|
|
18
|
+
type ScalarName = "inner_radius" | "fill_angle" | "leading" | "tracking";
|
|
19
|
+
|
|
20
|
+
type VectorName = Exclude<PropName<gui.Prop>, ScalarName>;
|
|
21
|
+
|
|
22
|
+
type NodePropertyName<K> = K extends keyof gui.NodeProperties
|
|
23
|
+
? K
|
|
24
|
+
: Extract<PropName<K>, keyof gui.NodeProperties>;
|
|
25
|
+
|
|
26
|
+
// gui_script.cpp:LuaSet: `rotation` takes only a quat, every other vector a
|
|
27
|
+
// vector4 or a vector3, and a sub-key or scalar a number.
|
|
28
|
+
type NodePropertyWrite<N extends keyof gui.NodeProperties> = N extends "rotation"
|
|
29
|
+
? Quaternion
|
|
30
|
+
: gui.NodeProperties[N] extends number
|
|
31
|
+
? number
|
|
32
|
+
: Vector4 | Vector3;
|
|
33
|
+
|
|
34
|
+
declare global {
|
|
35
|
+
namespace gui {
|
|
36
|
+
/**
|
|
37
|
+
* The GUI node properties and the type each one reads as. A vector
|
|
38
|
+
* property reads as a vmath.vector4 and `rotation` as a vmath.quat; their
|
|
39
|
+
* `.x`..`.w` sub-keys and the four scalar properties read as a number.
|
|
40
|
+
*/
|
|
41
|
+
type NodeProperties = {
|
|
42
|
+
[K in
|
|
43
|
+
| VectorName
|
|
44
|
+
| `${VectorName}.${"x" | "y" | "z" | "w"}`
|
|
45
|
+
| ScalarName]: K extends "rotation" ? Quaternion : K extends VectorName ? Vector4 : number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
interface PropertyOptions {
|
|
49
|
+
/** **⚠️ 1-based index into an array property; passed to Defold unchanged.** */
|
|
50
|
+
index?: number;
|
|
51
|
+
key?: string | Hash;
|
|
52
|
+
keys?: (Hash | string)[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Instead of using specific getters such as gui.get_position or gui.get_scale,
|
|
57
|
+
* you can use gui.get instead and supply the property as a string or a
|
|
58
|
+
* `gui.PROP_*` constant. Only these node properties are supported:
|
|
59
|
+
*
|
|
60
|
+
* - `"position"`
|
|
61
|
+
* - `"rotation"`
|
|
62
|
+
* - `"euler"`
|
|
63
|
+
* - `"scale"`
|
|
64
|
+
* - `"color"`
|
|
65
|
+
* - `"outline"`
|
|
66
|
+
* - `"shadow"`
|
|
67
|
+
* - `"size"`
|
|
68
|
+
* - `"fill_angle"` (pie)
|
|
69
|
+
* - `"inner_radius"` (pie)
|
|
70
|
+
* - `"leading"` (text)
|
|
71
|
+
* - `"tracking"` (text)
|
|
72
|
+
* - `"slice9"` (slice9)
|
|
73
|
+
*
|
|
74
|
+
* Each property but the four scalars (`fill_angle`, `inner_radius`, `leading`
|
|
75
|
+
* and `tracking`) also exposes its components as `"<name>.x"` to `"<name>.w"`.
|
|
76
|
+
* Getting `"rotation"` returns a vmath.quat, another vector property a
|
|
77
|
+
* vmath.vector4, and a component or a scalar property a single number. To get
|
|
78
|
+
* a material constant, pass its name as a hash.
|
|
79
|
+
*
|
|
80
|
+
* @param node - node to get the property for
|
|
81
|
+
* @param property - the property to retrieve; each `gui.PROP_*` constant equals its corresponding property name string
|
|
82
|
+
* @returns the property value
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* // Get properties on existing nodes:
|
|
86
|
+
* const node = gui.get_node("my_box_node");
|
|
87
|
+
* const node_position = gui.get(node, "position");
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
function get<K extends keyof gui.NodeProperties | gui.Prop>(
|
|
91
|
+
node: Opaque<"node">,
|
|
92
|
+
property: K,
|
|
93
|
+
): gui.NodeProperties[NodePropertyName<K>];
|
|
94
|
+
/**
|
|
95
|
+
* Gets a material constant of a node, or any property named by a hash. Pass
|
|
96
|
+
* the constant's name as a hash, such as `hash("tint")`. Reading an array
|
|
97
|
+
* constant without `index` returns every element in a table.
|
|
98
|
+
*
|
|
99
|
+
* @param node - node to get the property for
|
|
100
|
+
* @param property - the property to retrieve, as a hash
|
|
101
|
+
* @param options - optional options table (only applicable for material constants)
|
|
102
|
+
* - `index` integer index into array property (1 based)
|
|
103
|
+
*
|
|
104
|
+
* **⚠️ `index` is 1-based; passed to Defold unchanged.**
|
|
105
|
+
* @returns the property value
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const node = gui.get_node("my_box_node");
|
|
109
|
+
* const tint = gui.get(node, hash("tint"));
|
|
110
|
+
* const second = gui.get(node, hash("tint_array"), { index: 2 });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function get(
|
|
114
|
+
node: Opaque<"node">,
|
|
115
|
+
property: Hash,
|
|
116
|
+
): number | Vector4 | Quaternion | Matrix4 | number[] | Vector4[] | Matrix4[];
|
|
117
|
+
/**
|
|
118
|
+
* Gets a material constant of a node, or any property named by a hash. Pass
|
|
119
|
+
* the constant's name as a hash, such as `hash("tint")`. Reading an array
|
|
120
|
+
* constant without `index` returns every element in a table.
|
|
121
|
+
*
|
|
122
|
+
* @param node - node to get the property for
|
|
123
|
+
* @param property - the property to retrieve, as a hash
|
|
124
|
+
* @param options - optional options table (only applicable for material constants)
|
|
125
|
+
* - `index` integer index into array property (1 based)
|
|
126
|
+
*
|
|
127
|
+
* **⚠️ `index` is 1-based; passed to Defold unchanged.**
|
|
128
|
+
* @returns the property value
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* const node = gui.get_node("my_box_node");
|
|
132
|
+
* const tint = gui.get(node, hash("tint"));
|
|
133
|
+
* const second = gui.get(node, hash("tint_array"), { index: 2 });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
function get(
|
|
137
|
+
node: Opaque<"node">,
|
|
138
|
+
property: Hash,
|
|
139
|
+
options: gui.PropertyOptions,
|
|
140
|
+
): number | Vector4 | Quaternion | Matrix4 | number[] | Vector4[] | Matrix4[];
|
|
141
|
+
/**
|
|
142
|
+
* Instead of using specific setters such as gui.set_position or gui.set_scale,
|
|
143
|
+
* you can use gui.set instead and supply the property as a string or a
|
|
144
|
+
* `gui.PROP_*` constant. Only the node properties gui.get lists are supported.
|
|
145
|
+
*
|
|
146
|
+
* The value depends on the property name. Setting `"rotation"` takes a
|
|
147
|
+
* vmath.quat, which differs from gui.set_rotation; to set the rotation in
|
|
148
|
+
* degrees, set `"euler"` instead. The rotation and euler properties are
|
|
149
|
+
* linked, so changing one changes the other. Every other vector property
|
|
150
|
+
* takes a vmath.vector4 or a vmath.vector3, and a component such as
|
|
151
|
+
* `"position.x"` or one of the four scalar properties takes a single number.
|
|
152
|
+
*
|
|
153
|
+
* @param node - node to set the property for
|
|
154
|
+
* @param property - the property to set; each `gui.PROP_*` constant equals its corresponding property name string
|
|
155
|
+
* @param value - the value to set
|
|
156
|
+
* @example
|
|
157
|
+
* Updates the position property on an existing node:
|
|
158
|
+
* ```ts
|
|
159
|
+
* const node = gui.get_node("my_box_node");
|
|
160
|
+
* const node_position = gui.get(node, "position");
|
|
161
|
+
* gui.set(node, "position.x", node_position.x + 128);
|
|
162
|
+
* ```
|
|
163
|
+
* @example
|
|
164
|
+
* Updates the rotation property on an existing node:
|
|
165
|
+
* ```ts
|
|
166
|
+
* const node = gui.get_node("my_box_node");
|
|
167
|
+
* gui.set(node, "rotation", vmath.quat_rotation_z(math.rad(45)));
|
|
168
|
+
* // this is equivalent to:
|
|
169
|
+
* gui.set(node, "euler.z", 45);
|
|
170
|
+
* // or using the entire vector:
|
|
171
|
+
* gui.set(node, "euler", vmath.vector3(0, 0, 45));
|
|
172
|
+
* // or using the set_rotation
|
|
173
|
+
* gui.set_rotation(node, vmath.vector3(0, 0, 45));
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
function set<K extends keyof gui.NodeProperties | gui.Prop>(
|
|
177
|
+
node: Opaque<"node">,
|
|
178
|
+
property: K,
|
|
179
|
+
value: NodePropertyWrite<NodePropertyName<K>>,
|
|
180
|
+
): void;
|
|
181
|
+
/**
|
|
182
|
+
* Sets a material constant of a node, or any property named by a hash. If a
|
|
183
|
+
* material specifies a constant called `tint` in the .material file, set it
|
|
184
|
+
* with `gui.set(node, hash("tint"), vmath.vector4(1, 0, 0, 1))`, or pass a
|
|
185
|
+
* vmath.matrix4 if the constant is a matrix. To set one element of an array
|
|
186
|
+
* constant, pass an options table with `index` set.
|
|
187
|
+
*
|
|
188
|
+
* @param node - node to set the property for
|
|
189
|
+
* @param property - the property to set, as a hash
|
|
190
|
+
* @param value - the value to set
|
|
191
|
+
* @param options - optional material-constant options. **⚠️ `index` is 1-based; passed to Defold unchanged.**
|
|
192
|
+
* @example
|
|
193
|
+
* Sets various material constants for a node:
|
|
194
|
+
* ```ts
|
|
195
|
+
* const node = gui.get_node("my_box_node");
|
|
196
|
+
* gui.set(node, hash("tint"), vmath.vector4(1, 0, 0, 1));
|
|
197
|
+
* // matrix4 is also supported
|
|
198
|
+
* gui.set(node, hash("light_matrix"), vmath.matrix4());
|
|
199
|
+
* // update a constant in an array at position 4. the array is specified in the shader as:
|
|
200
|
+
* // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
|
|
201
|
+
* gui.set(node, hash("tint_array"), vmath.vector4(1, 0, 0, 1), { index: 4 });
|
|
202
|
+
* // update a matrix constant in an array at position 4. the array is specified in the shader as:
|
|
203
|
+
* // uniform mat4 light_matrix_array[4];
|
|
204
|
+
* gui.set(node, hash("light_matrix_array"), vmath.matrix4(), { index: 4 });
|
|
205
|
+
* // update a sub-element in a constant
|
|
206
|
+
* gui.set(node, hash("tint.x"), 1);
|
|
207
|
+
* // update a sub-element in an array constant at position 4
|
|
208
|
+
* gui.set(node, hash("tint_array.x"), 1, { index: 4 });
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
function set(
|
|
212
|
+
node: Opaque<"node">,
|
|
213
|
+
property: Hash,
|
|
214
|
+
value: number | Vector4 | Vector3 | Quaternion | Matrix4 | Hash,
|
|
215
|
+
): void;
|
|
216
|
+
/**
|
|
217
|
+
* Sets a material constant of a node, or any property named by a hash. If a
|
|
218
|
+
* material specifies a constant called `tint` in the .material file, set it
|
|
219
|
+
* with `gui.set(node, hash("tint"), vmath.vector4(1, 0, 0, 1))`, or pass a
|
|
220
|
+
* vmath.matrix4 if the constant is a matrix. To set one element of an array
|
|
221
|
+
* constant, pass an options table with `index` set.
|
|
222
|
+
*
|
|
223
|
+
* @param node - node to set the property for
|
|
224
|
+
* @param property - the property to set, as a hash
|
|
225
|
+
* @param value - the value to set
|
|
226
|
+
* @param options - optional material-constant options. **⚠️ `index` is 1-based; passed to Defold unchanged.**
|
|
227
|
+
* @example
|
|
228
|
+
* Sets various material constants for a node:
|
|
229
|
+
* ```ts
|
|
230
|
+
* const node = gui.get_node("my_box_node");
|
|
231
|
+
* gui.set(node, hash("tint"), vmath.vector4(1, 0, 0, 1));
|
|
232
|
+
* // matrix4 is also supported
|
|
233
|
+
* gui.set(node, hash("light_matrix"), vmath.matrix4());
|
|
234
|
+
* // update a constant in an array at position 4. the array is specified in the shader as:
|
|
235
|
+
* // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
|
|
236
|
+
* gui.set(node, hash("tint_array"), vmath.vector4(1, 0, 0, 1), { index: 4 });
|
|
237
|
+
* // update a matrix constant in an array at position 4. the array is specified in the shader as:
|
|
238
|
+
* // uniform mat4 light_matrix_array[4];
|
|
239
|
+
* gui.set(node, hash("light_matrix_array"), vmath.matrix4(), { index: 4 });
|
|
240
|
+
* // update a sub-element in a constant
|
|
241
|
+
* gui.set(node, hash("tint.x"), 1);
|
|
242
|
+
* // update a sub-element in an array constant at position 4
|
|
243
|
+
* gui.set(node, hash("tint_array.x"), 1, { index: 4 });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
function set(
|
|
247
|
+
node: Opaque<"node">,
|
|
248
|
+
property: Hash,
|
|
249
|
+
value: number | Vector4 | Vector3 | Quaternion | Matrix4 | Hash,
|
|
250
|
+
options: gui.PropertyOptions,
|
|
251
|
+
): void;
|
|
252
|
+
/**
|
|
253
|
+
* Sets a resource property of the gui component itself, addressed with
|
|
254
|
+
* `msg.url()`: `"material"`, or the `"materials"`, `"fonts"` or `"textures"`
|
|
255
|
+
* entry named by the `key` option. A property a native extension registers is
|
|
256
|
+
* named by a hash.
|
|
257
|
+
*
|
|
258
|
+
* @param url - msg.url() to the gui itself
|
|
259
|
+
* @param property - the property to set
|
|
260
|
+
* @param value - the resource to set
|
|
261
|
+
* @param options - options table; `key` names the entry to set
|
|
262
|
+
* @example
|
|
263
|
+
* Set a named property
|
|
264
|
+
* ```ts
|
|
265
|
+
* export default defineGuiScript({
|
|
266
|
+
* on_message(self, message_id, message) {
|
|
267
|
+
* if (message_id === hash("set_font") && types.is_hash(message.font)) {
|
|
268
|
+
* gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
|
|
269
|
+
* gui.set_font(gui.get_node("text"), "my_font_name");
|
|
270
|
+
* } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
|
|
271
|
+
* gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
|
|
272
|
+
* gui.set_texture(gui.get_node("box"), "my_texture");
|
|
273
|
+
* gui.play_flipbook(gui.get_node("box"), "logo_256");
|
|
274
|
+
* }
|
|
275
|
+
* },
|
|
276
|
+
* });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
function set(
|
|
280
|
+
url: Url,
|
|
281
|
+
property: "material" | "materials" | "fonts" | "textures" | Hash,
|
|
282
|
+
value: Hash,
|
|
283
|
+
): void;
|
|
284
|
+
/**
|
|
285
|
+
* Sets a resource property of the gui component itself, addressed with
|
|
286
|
+
* `msg.url()`: `"material"`, or the `"materials"`, `"fonts"` or `"textures"`
|
|
287
|
+
* entry named by the `key` option. A property a native extension registers is
|
|
288
|
+
* named by a hash.
|
|
289
|
+
*
|
|
290
|
+
* @param url - msg.url() to the gui itself
|
|
291
|
+
* @param property - the property to set
|
|
292
|
+
* @param value - the resource to set
|
|
293
|
+
* @param options - options table; `key` names the entry to set
|
|
294
|
+
* @example
|
|
295
|
+
* Set a named property
|
|
296
|
+
* ```ts
|
|
297
|
+
* export default defineGuiScript({
|
|
298
|
+
* on_message(self, message_id, message) {
|
|
299
|
+
* if (message_id === hash("set_font") && types.is_hash(message.font)) {
|
|
300
|
+
* gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
|
|
301
|
+
* gui.set_font(gui.get_node("text"), "my_font_name");
|
|
302
|
+
* } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
|
|
303
|
+
* gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
|
|
304
|
+
* gui.set_texture(gui.get_node("box"), "my_texture");
|
|
305
|
+
* gui.play_flipbook(gui.get_node("box"), "logo_256");
|
|
306
|
+
* }
|
|
307
|
+
* },
|
|
308
|
+
* });
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
function set(
|
|
312
|
+
url: Url,
|
|
313
|
+
property: "material" | "materials" | "fonts" | "textures" | Hash,
|
|
314
|
+
value: Hash,
|
|
315
|
+
options: gui.PropertyOptions,
|
|
316
|
+
): void;
|
|
317
|
+
/**
|
|
318
|
+
* This starts an animation of a node property according to the specified parameters.
|
|
319
|
+
* If the node property is already being animated, that animation will be canceled and
|
|
320
|
+
* replaced by the new one. Note however that several different node properties
|
|
321
|
+
* can be animated simultaneously. Use `gui.cancel_animations` to stop the animation
|
|
322
|
+
* before it has completed.
|
|
323
|
+
* Only the node properties gui.get lists can be animated; a material constant
|
|
324
|
+
* cannot. Composite properties of type vector3, vector4 or quaternion
|
|
325
|
+
* also expose their sub-components (x, y, z and w).
|
|
326
|
+
* You can address the components individually by suffixing the name with a dot '.'
|
|
327
|
+
* and the name of the component.
|
|
328
|
+
* For instance, `"position.x"` (the position x coordinate) or `"color.w"`
|
|
329
|
+
* (the color alpha value).
|
|
330
|
+
* If a `complete_function` (Lua function) is specified, that function will be called
|
|
331
|
+
* when the animation has completed.
|
|
332
|
+
* By starting a new animation in that function, several animations can be sequenced
|
|
333
|
+
* together. See the examples below for more information.
|
|
334
|
+
*
|
|
335
|
+
* @param node - node to animate
|
|
336
|
+
* @param property - property to animate; each `gui.PROP_*` constant equals its corresponding property name string
|
|
337
|
+
* @param to - target property value
|
|
338
|
+
* @param easing - easing to use during animation.
|
|
339
|
+
* Either specify one of the `gui.EASING_*` constants or provide a
|
|
340
|
+
* vector with a custom curve. See the animation guide for more information.
|
|
341
|
+
* @param duration - duration of the animation in seconds.
|
|
342
|
+
* @param delay - delay before the animation starts in seconds.
|
|
343
|
+
* @param complete_function - function to call when the
|
|
344
|
+
* animation has completed
|
|
345
|
+
* @param playback - playback mode
|
|
346
|
+
* @example
|
|
347
|
+
* How to start a simple color animation, where the node fades in to white during 0.5 seconds:
|
|
348
|
+
* ```ts
|
|
349
|
+
* // How to start a simple color animation, where the node fades in to white during 0.5 seconds:
|
|
350
|
+
* const node = gui.get_node("my_node");
|
|
351
|
+
* gui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent
|
|
352
|
+
* gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation
|
|
353
|
+
* ```
|
|
354
|
+
* @example
|
|
355
|
+
* How to start a sequenced animation where the node fades in to white during 0.5 seconds, stays visible for 2 seconds and then fades out:
|
|
356
|
+
* ```ts
|
|
357
|
+
* // How to start a sequenced animation where the node fades in to white during 0.5
|
|
358
|
+
* // seconds, stays visible for 2 seconds and then fades out:
|
|
359
|
+
* function on_animation_done(self: unknown, node: Opaque<"node">) {
|
|
360
|
+
* // fade out node, but wait 2 seconds before the animation starts
|
|
361
|
+
* gui.animate(node, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
|
|
362
|
+
* }
|
|
363
|
+
*
|
|
364
|
+
* export default defineGuiScript({
|
|
365
|
+
* init(self) {
|
|
366
|
+
* // fetch the node we want to animate
|
|
367
|
+
* const my_node = gui.get_node("my_node");
|
|
368
|
+
* // node is initially set to fully transparent
|
|
369
|
+
* gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));
|
|
370
|
+
* // animate the node immediately and call on_animation_done when the animation has completed
|
|
371
|
+
* gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);
|
|
372
|
+
* },
|
|
373
|
+
* });
|
|
374
|
+
* ```
|
|
375
|
+
* @example
|
|
376
|
+
* How to animate a node's y position using a crazy custom easing curve:
|
|
377
|
+
* ```ts
|
|
378
|
+
* // How to animate a node's y position using a crazy custom easing curve:
|
|
379
|
+
* export default defineGuiScript({
|
|
380
|
+
* init(self) {
|
|
381
|
+
* const values = [
|
|
382
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
383
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
384
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
385
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
386
|
+
* ];
|
|
387
|
+
* const vec = vmath.vector(values);
|
|
388
|
+
* const node = gui.get_node("box");
|
|
389
|
+
* gui.animate(node, "position.y", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);
|
|
390
|
+
* },
|
|
391
|
+
* });
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
function animate(
|
|
395
|
+
node: Opaque<"node">,
|
|
396
|
+
property: keyof gui.NodeProperties | gui.Prop | Hash,
|
|
397
|
+
to: number | Vector3 | Vector4 | Quaternion,
|
|
398
|
+
easing: gui.Easing | Vector,
|
|
399
|
+
duration: number,
|
|
400
|
+
): void;
|
|
401
|
+
/**
|
|
402
|
+
* This starts an animation of a node property according to the specified parameters.
|
|
403
|
+
* If the node property is already being animated, that animation will be canceled and
|
|
404
|
+
* replaced by the new one. Note however that several different node properties
|
|
405
|
+
* can be animated simultaneously. Use `gui.cancel_animations` to stop the animation
|
|
406
|
+
* before it has completed.
|
|
407
|
+
* Only the node properties gui.get lists can be animated; a material constant
|
|
408
|
+
* cannot. Composite properties of type vector3, vector4 or quaternion
|
|
409
|
+
* also expose their sub-components (x, y, z and w).
|
|
410
|
+
* You can address the components individually by suffixing the name with a dot '.'
|
|
411
|
+
* and the name of the component.
|
|
412
|
+
* For instance, `"position.x"` (the position x coordinate) or `"color.w"`
|
|
413
|
+
* (the color alpha value).
|
|
414
|
+
* If a `complete_function` (Lua function) is specified, that function will be called
|
|
415
|
+
* when the animation has completed.
|
|
416
|
+
* By starting a new animation in that function, several animations can be sequenced
|
|
417
|
+
* together. See the examples below for more information.
|
|
418
|
+
*
|
|
419
|
+
* @param node - node to animate
|
|
420
|
+
* @param property - property to animate; each `gui.PROP_*` constant equals its corresponding property name string
|
|
421
|
+
* @param to - target property value
|
|
422
|
+
* @param easing - easing to use during animation.
|
|
423
|
+
* Either specify one of the `gui.EASING_*` constants or provide a
|
|
424
|
+
* vector with a custom curve. See the animation guide for more information.
|
|
425
|
+
* @param duration - duration of the animation in seconds.
|
|
426
|
+
* @param delay - delay before the animation starts in seconds.
|
|
427
|
+
* @param complete_function - function to call when the
|
|
428
|
+
* animation has completed
|
|
429
|
+
* @param playback - playback mode
|
|
430
|
+
* @example
|
|
431
|
+
* How to start a simple color animation, where the node fades in to white during 0.5 seconds:
|
|
432
|
+
* ```ts
|
|
433
|
+
* // How to start a simple color animation, where the node fades in to white during 0.5 seconds:
|
|
434
|
+
* const node = gui.get_node("my_node");
|
|
435
|
+
* gui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent
|
|
436
|
+
* gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation
|
|
437
|
+
* ```
|
|
438
|
+
* @example
|
|
439
|
+
* How to start a sequenced animation where the node fades in to white during 0.5 seconds, stays visible for 2 seconds and then fades out:
|
|
440
|
+
* ```ts
|
|
441
|
+
* // How to start a sequenced animation where the node fades in to white during 0.5
|
|
442
|
+
* // seconds, stays visible for 2 seconds and then fades out:
|
|
443
|
+
* function on_animation_done(self: unknown, node: Opaque<"node">) {
|
|
444
|
+
* // fade out node, but wait 2 seconds before the animation starts
|
|
445
|
+
* gui.animate(node, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
|
|
446
|
+
* }
|
|
447
|
+
*
|
|
448
|
+
* export default defineGuiScript({
|
|
449
|
+
* init(self) {
|
|
450
|
+
* // fetch the node we want to animate
|
|
451
|
+
* const my_node = gui.get_node("my_node");
|
|
452
|
+
* // node is initially set to fully transparent
|
|
453
|
+
* gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));
|
|
454
|
+
* // animate the node immediately and call on_animation_done when the animation has completed
|
|
455
|
+
* gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);
|
|
456
|
+
* },
|
|
457
|
+
* });
|
|
458
|
+
* ```
|
|
459
|
+
* @example
|
|
460
|
+
* How to animate a node's y position using a crazy custom easing curve:
|
|
461
|
+
* ```ts
|
|
462
|
+
* // How to animate a node's y position using a crazy custom easing curve:
|
|
463
|
+
* export default defineGuiScript({
|
|
464
|
+
* init(self) {
|
|
465
|
+
* const values = [
|
|
466
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
467
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
468
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
469
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
470
|
+
* ];
|
|
471
|
+
* const vec = vmath.vector(values);
|
|
472
|
+
* const node = gui.get_node("box");
|
|
473
|
+
* gui.animate(node, "position.y", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);
|
|
474
|
+
* },
|
|
475
|
+
* });
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
function animate(
|
|
479
|
+
node: Opaque<"node">,
|
|
480
|
+
property: keyof gui.NodeProperties | gui.Prop | Hash,
|
|
481
|
+
to: number | Vector3 | Vector4 | Quaternion,
|
|
482
|
+
easing: gui.Easing | Vector,
|
|
483
|
+
duration: number,
|
|
484
|
+
delay: number,
|
|
485
|
+
complete_function?: (self: unknown, node: Opaque<"node">) => void,
|
|
486
|
+
playback?: gui.Playback,
|
|
487
|
+
): void;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
|
|
3
|
+
import type { Hash, Url } from "./core-types";
|
|
4
|
+
|
|
5
|
+
// The nil branch of gui_script.cpp:LuaSet exists from Defold 1.13.1, so this
|
|
6
|
+
// arm rides only the surfaces whose import gate (`regen.ts`) admits it.
|
|
7
|
+
declare global {
|
|
8
|
+
namespace gui {
|
|
9
|
+
/**
|
|
10
|
+
* Removes the runtime texture mapping the `key` option names from the gui
|
|
11
|
+
* component itself. Needs Defold 1.13.1 or later.
|
|
12
|
+
*
|
|
13
|
+
* @param url - msg.url() to the gui itself
|
|
14
|
+
* @param property - the textures property
|
|
15
|
+
* @param value - nil, to remove the mapping
|
|
16
|
+
* @param options - options table; `key` names the texture to remove
|
|
17
|
+
* @example
|
|
18
|
+
* Remove a named runtime texture resource mapping:
|
|
19
|
+
* ```ts
|
|
20
|
+
* const atlas_params = {
|
|
21
|
+
* texture: "/runtime.texturec",
|
|
22
|
+
* animations: [{ id: "runtime", width: 1, height: 1, frames: [1] }],
|
|
23
|
+
* geometries: [{ vertices: [0, 0, 0, 1, 1, 1, 1, 0], uvs: [0, 0, 0, 1, 1, 1, 1, 0], indices: [0, 1, 2, 0, 2, 3] }],
|
|
24
|
+
* } satisfies Parameters<typeof resource.create_atlas>[1];
|
|
25
|
+
* const atlas_id = resource.create_atlas("/runtime.texturesetc", atlas_params);
|
|
26
|
+
* gui.set(msg.url(), "textures", atlas_id, { key: "runtime_texture" });
|
|
27
|
+
* gui.set_texture(gui.get_node("box"), "runtime_texture");
|
|
28
|
+
*
|
|
29
|
+
* // Later, remove the GUI mapping before releasing the atlas resource.
|
|
30
|
+
* gui.set(msg.url(), "textures", undefined, { key: "runtime_texture" });
|
|
31
|
+
* resource.release(atlas_id);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function set(
|
|
35
|
+
url: Url,
|
|
36
|
+
property: "textures",
|
|
37
|
+
value: undefined,
|
|
38
|
+
options: { key: string | Hash },
|
|
39
|
+
): void;
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -67,6 +67,7 @@ export {
|
|
|
67
67
|
TS_IDENTIFIER,
|
|
68
68
|
TS_RESERVED_NAMES,
|
|
69
69
|
} from "./emit-dts";
|
|
70
|
+
export { ENGINE_TYPE_NAME_OVERRIDES, engineTypeName } from "./engine-type-name";
|
|
70
71
|
export {
|
|
71
72
|
hashExampleSource,
|
|
72
73
|
lookupExampleSegments,
|
|
@@ -136,6 +137,8 @@ export {
|
|
|
136
137
|
lookupSignature,
|
|
137
138
|
type SignatureOverride,
|
|
138
139
|
type SignatureStore,
|
|
140
|
+
signatureArmsFor,
|
|
141
|
+
signatureStoreFor,
|
|
139
142
|
} from "./signature-store";
|
|
140
143
|
export {
|
|
141
144
|
classifyUrlParameter,
|
package/src/lifecycle.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Hash, Url } from "./core-types";
|
|
2
2
|
|
|
3
|
-
// Fields and docs follow the go ref-doc's `on_input.touch` STRUCT, whose keys are
|
|
3
|
+
// Fields and docs follow the go ref-doc's `on_input.touch` STRUCT (`go.on_input.Touch`), whose keys are
|
|
4
4
|
// the ones comp_script.cpp pushes; lifecycle-member-docs drift-guards the docs
|
|
5
5
|
// against it, and a ref-doc re-pin is reconciled by hand.
|
|
6
6
|
export interface InputTouch {
|
|
@@ -54,7 +54,7 @@ export interface InputTouch {
|
|
|
54
54
|
screen_dy: number;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// Fields and docs follow the go ref-doc's `on_input.action` STRUCT, whose keys are
|
|
57
|
+
// Fields and docs follow the go ref-doc's `on_input.action` STRUCT (`go.on_input.Action`), whose keys are
|
|
58
58
|
// the ones comp_script.cpp pushes; lifecycle-member-docs drift-guards the docs
|
|
59
59
|
// against it, and a ref-doc re-pin is reconciled by hand.
|
|
60
60
|
export interface InputAction {
|
|
@@ -370,7 +370,10 @@ export type RenderScriptHooks<TSelf, TInitState = TSelf> = Omit<
|
|
|
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,9 +552,9 @@ 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
559
|
* `RenderScriptHooks` is `Omit<ScriptHooks, "on_input" | "final" |
|
|
551
560
|
* "fixed_update" | "late_update">` — the engine calls only four render-script
|