@defold-typescript/types 0.51.0 → 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.
Files changed (130) hide show
  1. package/api-availability.json +4 -58
  2. package/api-signatures.json +878 -1356
  3. package/api-targets.json +15 -5
  4. package/examples/translations.json +4 -56
  5. package/generated/b2d_world.d.ts +10 -10
  6. package/generated/buffer.d.ts +9 -9
  7. package/generated/bullet3d_collision_object.d.ts +1 -1
  8. package/generated/bullet3d_constraint.d.ts +109 -7
  9. package/generated/bullet3d_shape.d.ts +2 -2
  10. package/generated/go.d.ts +114 -220
  11. package/generated/graphics.d.ts +1 -0
  12. package/generated/gui.d.ts +148 -371
  13. package/generated/http.d.ts +2 -2
  14. package/generated/image.d.ts +55 -3
  15. package/generated/kinds/gui-script.d.ts +2 -0
  16. package/generated/kinds/render-script.d.ts +14 -15
  17. package/generated/liveupdate.d.ts +5 -1
  18. package/generated/material.d.ts +3 -3
  19. package/generated/particlefx.d.ts +20 -1
  20. package/generated/physics.d.ts +45 -1
  21. package/generated/render-script-modules/b2d.d.ts +711 -0
  22. package/generated/render-script-modules/bullet3d.d.ts +73 -0
  23. package/generated/render-script-modules/collectionfactory.d.ts +25 -0
  24. package/generated/render-script-modules/collectionproxy.d.ts +39 -0
  25. package/generated/render-script-modules/factory.d.ts +25 -0
  26. package/generated/render-script-modules/go.d.ts +436 -0
  27. package/generated/render-script-modules/label.d.ts +105 -0
  28. package/generated/render-script-modules/model.d.ts +89 -0
  29. package/generated/render-script-modules/particlefx.d.ts +59 -0
  30. package/generated/render-script-modules/physics.d.ts +333 -0
  31. package/generated/render-script-modules/resource.d.ts +1233 -0
  32. package/generated/render-script-modules/sound.d.ts +227 -0
  33. package/generated/render-script-modules/sprite.d.ts +68 -0
  34. package/generated/render-script-modules/tilemap.d.ts +43 -0
  35. package/generated/render.d.ts +134 -8
  36. package/generated/resource.d.ts +31 -10
  37. package/generated/sprite.d.ts +49 -1
  38. package/generated/sys.d.ts +70 -6
  39. package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
  40. package/generated/versions/defold-1.12.4/go.d.ts +115 -343
  41. package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
  42. package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
  43. package/generated/versions/defold-1.12.4/http.d.ts +2 -2
  44. package/generated/versions/defold-1.12.4/image.d.ts +82 -2
  45. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  46. package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
  47. package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
  48. package/generated/versions/defold-1.12.4/physics.d.ts +45 -1
  49. package/generated/versions/defold-1.12.4/render.d.ts +78 -2
  50. package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
  51. package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
  52. package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
  53. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
  54. package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
  55. package/generated/versions/defold-1.13.0/go.d.ts +115 -370
  56. package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
  57. package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
  58. package/generated/versions/defold-1.13.0/http.d.ts +2 -2
  59. package/generated/versions/defold-1.13.0/image.d.ts +82 -2
  60. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  61. package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
  62. package/generated/versions/defold-1.13.0/material.d.ts +3 -1
  63. package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
  64. package/generated/versions/defold-1.13.0/physics.d.ts +45 -1
  65. package/generated/versions/defold-1.13.0/render.d.ts +142 -4
  66. package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
  67. package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
  68. package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
  69. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
  70. package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
  71. package/generated/versions/defold-1.13.1/go.d.ts +115 -370
  72. package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
  73. package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
  74. package/generated/versions/defold-1.13.1/http.d.ts +2 -2
  75. package/generated/versions/defold-1.13.1/image.d.ts +82 -2
  76. package/generated/versions/defold-1.13.1/index.d.ts +2 -0
  77. package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
  78. package/generated/versions/defold-1.13.1/material.d.ts +3 -1
  79. package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
  80. package/generated/versions/defold-1.13.1/physics.d.ts +45 -1
  81. package/generated/versions/defold-1.13.1/render.d.ts +142 -4
  82. package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
  83. package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
  84. package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
  85. package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
  86. package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
  87. package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
  88. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
  89. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
  90. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
  91. package/generated/versions/defold-1.13.2/go.d.ts +114 -220
  92. package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
  93. package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
  94. package/generated/versions/defold-1.13.2/http.d.ts +2 -2
  95. package/generated/versions/defold-1.13.2/image.d.ts +55 -3
  96. package/generated/versions/defold-1.13.2/index.d.ts +2 -0
  97. package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
  98. package/generated/versions/defold-1.13.2/material.d.ts +3 -3
  99. package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
  100. package/generated/versions/defold-1.13.2/physics.d.ts +45 -1
  101. package/generated/versions/defold-1.13.2/render.d.ts +123 -7
  102. package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
  103. package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
  104. package/generated/versions/defold-1.13.2/sys.d.ts +70 -6
  105. package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
  106. package/generated/vmath.d.ts +0 -24
  107. package/identity-vocabulary.json +52 -7
  108. package/index.d.ts +2 -0
  109. package/package.json +2 -1
  110. package/scripts/generate-api-availability.ts +1 -21
  111. package/scripts/generate-api-signatures.ts +75 -14
  112. package/scripts/materialize-version.ts +48 -7
  113. package/scripts/regen.ts +214 -19
  114. package/scripts/signature-store-fs.ts +1 -0
  115. package/scripts/target-version.ts +26 -0
  116. package/src/api-doc.ts +26 -0
  117. package/src/component-properties.d.ts +89 -0
  118. package/src/core-types.ts +42 -15
  119. package/src/doc-corrections.ts +53 -5
  120. package/src/emit-dts.ts +758 -198
  121. package/src/engine-globals.d.ts +5 -1
  122. package/src/go-overloads.d.ts +68 -13
  123. package/src/gui-overloads.d.ts +489 -0
  124. package/src/gui-texture-removal.d.ts +41 -0
  125. package/src/index.ts +2 -0
  126. package/src/lifecycle.ts +30 -21
  127. package/src/msg-overloads.d.ts +25 -13
  128. package/src/signature-store.ts +50 -0
  129. package/src/timers.d.ts +2 -1
  130. package/src/vmath-overloads.d.ts +26 -0
@@ -4,12 +4,16 @@ import type * as Core from "./core-types";
4
4
  // Hand-maintained surface: Defold ships no machine-readable export for the
5
5
  // prefixless globals, so add or remove entries here from the Defold API
6
6
  // reference and mirror the change in fixtures/globals_doc.json — the
7
- // engine-globals test fails if the two fall out of sync.
7
+ // engine-globals test fails if the two fall out of sync. That canonical file
8
+ // seeds each new target on release import; also mirror the change into every
9
+ // committed fixtures/defold-*/globals_doc.json, which the API reference reads.
8
10
  declare global {
9
11
  /** An opaque, branded handle to a hashed name; see {@link Core.Hash}. */
10
12
  type Hash<S extends string = string> = Core.Hash<S>;
11
13
  /** Hash a string into the engine's `Hash` handle. */
12
14
  function hash<S extends string>(s: S): Core.Hash<S>;
15
+ /** Return a `Hash` unchanged. */
16
+ function hash<S extends string>(h: Core.Hash<S>): Core.Hash<S>;
13
17
  /** Render a `Hash` handle as its hexadecimal string. */
14
18
  function hash_to_hex(h: Core.Hash): string;
15
19
  /** Pretty-print any values to the console for debugging. */
@@ -21,12 +21,17 @@ type WritableKey<P> = {
21
21
 
22
22
  declare global {
23
23
  namespace go {
24
- interface GoPropertyOptions {
25
- /** **⚠️ 1-based index into an array property; passed to Defold unchanged.** */
26
- index?: number;
27
- key?: Hash | string;
28
- keys?: (Hash | string)[];
29
- }
24
+ // LuaToPropertyOptions raises when more than one of the three is non-nil, and
25
+ // reads a nil one as absent.
26
+ type GoPropertyOptions =
27
+ | {
28
+ /** **⚠️ 1-based index into an array property; passed to Defold unchanged.** */
29
+ index?: number;
30
+ key?: undefined;
31
+ keys?: undefined;
32
+ }
33
+ | { index?: undefined; key?: Hash | string; keys?: undefined }
34
+ | { index?: undefined; key?: undefined; keys?: (Hash | string)[] };
30
35
 
31
36
  /**
32
37
  * gets a named property of the specified game object or component
@@ -39,6 +44,8 @@ declare global {
39
44
  * - keys array of hashes or strings identifying internal component resources (e.g. a particle fx emitter, see examples below)
40
45
  * @returns the value of the specified property
41
46
  * A `string` value is a text property, which needs Defold 1.13.2 or later.
47
+ * An array material constant read without `index` returns every element as a
48
+ * `Vector4[]`.
42
49
  * @example
43
50
  * ```ts
44
51
  * const position = go.get("#sprite", "position");
@@ -50,18 +57,46 @@ declare global {
50
57
  function get<P>(): <K extends keyof P>(
51
58
  url: SceneAddress | Hash | Url,
52
59
  property: K,
53
- options?: GoPropertyOptions,
60
+ ...options: [] | [GoPropertyOptions]
54
61
  ) => P[K];
55
62
  function get<K extends keyof go.properties>(
56
63
  url: SceneAddress | Hash | Url,
57
64
  property: K,
58
- options?: GoPropertyOptions,
59
65
  ): go.properties[K];
66
+ function get<K extends keyof go.properties>(
67
+ url: SceneAddress | Hash | Url,
68
+ property: K,
69
+ options: GoPropertyOptions,
70
+ ): go.properties[K];
71
+ function get(
72
+ url: SceneAddress | Hash | Url,
73
+ property: string | Hash,
74
+ ):
75
+ | number
76
+ | boolean
77
+ | string
78
+ | Hash
79
+ | Url
80
+ | Vector3
81
+ | Vector4
82
+ | Quaternion
83
+ | Matrix4
84
+ | Vector4[];
60
85
  function get(
61
86
  url: SceneAddress | Hash | Url,
62
87
  property: string | Hash,
63
- options?: GoPropertyOptions,
64
- ): number | boolean | string | Hash | Url | Vector3 | Vector4 | Quaternion | Matrix4;
88
+ options: GoPropertyOptions,
89
+ ):
90
+ | number
91
+ | boolean
92
+ | string
93
+ | Hash
94
+ | Url
95
+ | Vector3
96
+ | Vector4
97
+ | Quaternion
98
+ | Matrix4
99
+ | Vector4[];
65
100
  /**
66
101
  * sets a named property of the specified game object or component, or a material constant
67
102
  *
@@ -86,13 +121,33 @@ declare global {
86
121
  url: SceneAddress | Hash | Url,
87
122
  property: K,
88
123
  value: P[K],
89
- options?: GoPropertyOptions,
124
+ ...options: [] | [GoPropertyOptions]
90
125
  ) => void;
91
126
  function set<K extends keyof go.properties>(
92
127
  url: SceneAddress | Hash | Url,
93
128
  property: K,
94
129
  value: go.properties[K],
95
- options?: GoPropertyOptions,
130
+ ): void;
131
+ function set<K extends keyof go.properties>(
132
+ url: SceneAddress | Hash | Url,
133
+ property: K,
134
+ value: go.properties[K],
135
+ options: GoPropertyOptions,
136
+ ): void;
137
+ function set(
138
+ url: SceneAddress | Hash | Url,
139
+ property: string | Hash,
140
+ value:
141
+ | number
142
+ | boolean
143
+ | string
144
+ | Hash
145
+ | Url
146
+ | Vector3
147
+ | Vector4
148
+ | Quaternion
149
+ | Matrix4
150
+ | Vector4[],
96
151
  ): void;
97
152
  function set(
98
153
  url: SceneAddress | Hash | Url,
@@ -108,7 +163,7 @@ declare global {
108
163
  | Quaternion
109
164
  | Matrix4
110
165
  | Vector4[],
111
- options?: GoPropertyOptions,
166
+ options: GoPropertyOptions,
112
167
  ): void;
113
168
  /**
114
169
  * Registers a script property, which the Defold editor exposes on every game
@@ -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.Property>, ScalarName>;
21
+
22
+ type NodePropertyName<K> = K extends keyof gui.node_properties
23
+ ? K
24
+ : Extract<PropName<K>, keyof gui.node_properties>;
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.node_properties> = N extends "rotation"
29
+ ? Quaternion
30
+ : gui.node_properties[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 node_properties = {
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.node_properties | gui.Property>(
91
+ node: Opaque<"node">,
92
+ property: K,
93
+ ): gui.node_properties[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.node_properties | gui.Property>(
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.node_properties | gui.Property | 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.node_properties | gui.Property | 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
@@ -136,6 +136,8 @@ export {
136
136
  lookupSignature,
137
137
  type SignatureOverride,
138
138
  type SignatureStore,
139
+ signatureArmsFor,
140
+ signatureStoreFor,
139
141
  } from "./signature-store";
140
142
  export {
141
143
  classifyUrlParameter,