@defold-typescript/types 0.48.0 → 0.50.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 +696 -624
- package/api-signatures.json +6799 -160
- package/api-targets.json +393 -2
- package/examples/translations.json +12 -0
- package/generated/b2d.d.ts +15 -0
- package/generated/bullet3d.d.ts +16 -0
- package/generated/font.d.ts +7 -3
- package/generated/graphics.d.ts +7 -0
- package/generated/gui.d.ts +5 -4
- package/generated/label.d.ts +3 -3
- package/generated/render.d.ts +16 -1
- package/generated/versions/defold-1.13.2/b2d.d.ts +709 -0
- package/generated/versions/defold-1.13.2/b2d_body.d.ts +593 -0
- package/generated/versions/defold-1.13.2/b2d_chain.d.ts +105 -0
- package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +175 -0
- package/generated/versions/defold-1.13.2/b2d_joint.d.ts +1301 -0
- package/generated/versions/defold-1.13.2/b2d_shape.d.ts +423 -0
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +308 -0
- package/generated/versions/defold-1.13.2/buffer.d.ts +192 -0
- package/generated/versions/defold-1.13.2/bullet3d.d.ts +91 -0
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +433 -0
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +818 -0
- package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +429 -0
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +123 -0
- package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +492 -0
- package/generated/versions/defold-1.13.2/camera.d.ts +300 -0
- package/generated/versions/defold-1.13.2/collectionfactory.d.ts +148 -0
- package/generated/versions/defold-1.13.2/collectionproxy.d.ts +109 -0
- package/generated/versions/defold-1.13.2/compute.d.ts +107 -0
- package/generated/versions/defold-1.13.2/crash.d.ts +157 -0
- package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +139 -0
- package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +48 -0
- package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +21 -0
- package/generated/versions/defold-1.13.2/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +126 -0
- package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +38 -0
- package/generated/versions/defold-1.13.2/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.2/editor.d.ts +2177 -0
- package/generated/versions/defold-1.13.2/factory.d.ts +121 -0
- package/generated/versions/defold-1.13.2/font.d.ts +123 -0
- package/generated/versions/defold-1.13.2/go.d.ts +1166 -0
- package/generated/versions/defold-1.13.2/graphics.d.ts +613 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +2212 -0
- package/generated/versions/defold-1.13.2/html5.d.ts +55 -0
- package/generated/versions/defold-1.13.2/http.d.ts +83 -0
- package/generated/versions/defold-1.13.2/image.d.ts +181 -0
- package/generated/versions/defold-1.13.2/index.d.ts +63 -0
- package/generated/versions/defold-1.13.2/json.d.ts +94 -0
- package/generated/versions/defold-1.13.2/kinds/editor-script.d.ts +14 -0
- package/generated/versions/defold-1.13.2/label.d.ts +164 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +143 -0
- package/generated/versions/defold-1.13.2/material.d.ts +490 -0
- package/generated/versions/defold-1.13.2/model.d.ts +287 -0
- package/generated/versions/defold-1.13.2/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.2/particlefx.d.ts +155 -0
- package/generated/versions/defold-1.13.2/physics.d.ts +789 -0
- package/generated/versions/defold-1.13.2/profiler.d.ts +228 -0
- package/generated/versions/defold-1.13.2/render.d.ts +1153 -0
- package/generated/versions/defold-1.13.2/resource.d.ts +1628 -0
- package/generated/versions/defold-1.13.2/socket.d.ts +797 -0
- package/generated/versions/defold-1.13.2/sound.d.ts +323 -0
- package/generated/versions/defold-1.13.2/sprite.d.ts +179 -0
- package/generated/versions/defold-1.13.2/sys.d.ts +754 -0
- package/generated/versions/defold-1.13.2/tilemap.d.ts +206 -0
- package/generated/versions/defold-1.13.2/timer.d.ts +136 -0
- package/generated/versions/defold-1.13.2/types.d.ts +61 -0
- package/generated/versions/defold-1.13.2/vmath.d.ts +775 -0
- package/generated/versions/defold-1.13.2/window.d.ts +196 -0
- package/generated/versions/defold-1.13.2/zlib.d.ts +41 -0
- package/hsm/debug.d.ts +6 -3
- package/hsm/index.d.ts +309 -77
- package/identity-vocabulary.json +1 -0
- package/package.json +2 -2
- package/scripts/import-defold-release.ts +3 -31
- package/scripts/materialize-version.ts +13 -7
- package/scripts/regen.ts +63 -29
- package/scripts/sync-api-docs.ts +31 -2
- package/src/emit-dts.ts +25 -3
package/hsm/index.d.ts
CHANGED
|
@@ -16,18 +16,26 @@ export type MoveCause = "event" | "after" | "update" | "stop" | "reload" | "alwa
|
|
|
16
16
|
/**
|
|
17
17
|
* A listener given to `onMove`. It gets the leaf left, the leaf entered (`undefined` after
|
|
18
18
|
* `stop()`), the cause, and the event, which is `undefined` unless the cause is `event`. It runs
|
|
19
|
-
* after the move's `enter` hooks.
|
|
19
|
+
* after the move's `enter` hooks. The event is read-only: the listener cannot assign to its
|
|
20
|
+
* fields.
|
|
20
21
|
* @noSelf
|
|
21
22
|
*/
|
|
22
|
-
export type MoveListener<E extends EventObject, P extends string = string> = (from: P, to: P | undefined, cause: MoveCause, event: E | undefined) => void;
|
|
23
|
+
export type MoveListener<E extends EventObject, P extends string = string> = (from: P, to: P | undefined, cause: MoveCause, event: Readonly<E> | undefined) => void;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
25
|
+
* A listener given to `onUnhandled`. It gets the event no rule of an active state took. The
|
|
26
|
+
* event is read-only: the listener cannot assign to its fields.
|
|
26
27
|
* @noSelf
|
|
27
28
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
export type UnhandledListener<E extends EventObject> = (event: Readonly<E>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* What a `when` sees of the running machine: which states are active, and nothing that changes
|
|
32
|
+
* it. `P` is the union of the paths it takes. The `machine` a `when` receives takes the machine's
|
|
33
|
+
* state paths, and also any path below a state that holds only callbacks with unannotated
|
|
34
|
+
* parameters and `after` or `every` lists with one in them, or whose child states all do. `Tag`
|
|
35
|
+
* is the union of the machine's tag names.
|
|
36
|
+
* @noSelf
|
|
37
|
+
*/
|
|
38
|
+
export interface MachineView<P extends string = string, Tag extends string = never> {
|
|
31
39
|
/**
|
|
32
40
|
* The full path of the deepest active state, or `undefined` once stopped. In a parallel state
|
|
33
41
|
* it is the first region's leaf.
|
|
@@ -39,16 +47,45 @@ export interface MachineInstance<Ctx, E extends EventObject, P extends string =
|
|
|
39
47
|
*/
|
|
40
48
|
readonly leaves: readonly P[];
|
|
41
49
|
/** Whether the state at the full path `path` is active. Ancestors of the current state count. */
|
|
42
|
-
readonly matches:
|
|
50
|
+
readonly matches: {
|
|
51
|
+
matches(this: void, path: P): boolean;
|
|
52
|
+
}["matches"];
|
|
53
|
+
/**
|
|
54
|
+
* Whether an active state carries `tag`. A parent's tag holds while any of its children is
|
|
55
|
+
* active, and a tag in any region of a parallel state counts. The answer is `false` for a name
|
|
56
|
+
* no state carries, and once stopped.
|
|
57
|
+
*/
|
|
58
|
+
readonly hasTag: (tag: Tag) => boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One running machine, returned by `start`. `P` is the union of the paths it takes: the
|
|
62
|
+
* machine's state paths on a started instance. The `machine` a hook, a `run` or a `task`
|
|
63
|
+
* receives takes those paths, and also any path below a state that holds only callbacks with
|
|
64
|
+
* unannotated parameters and `after` or `every` lists with one in them, or whose child states all
|
|
65
|
+
* do. `Tag` is the union of the machine's tag names.
|
|
66
|
+
* @noSelf
|
|
67
|
+
*/
|
|
68
|
+
export interface MachineInstance<Ctx, E extends EventObject, P extends string = string, Tag extends string = never> extends MachineView<P, Tag> {
|
|
69
|
+
/** The context passed to `start`. */
|
|
70
|
+
readonly ctx: Ctx;
|
|
71
|
+
/**
|
|
72
|
+
* Whether a rule of an active state would take `event` if it were sent at that moment. The
|
|
73
|
+
* answer is for that one event, payload included: a rule's `when` reads it. A rule with no
|
|
74
|
+
* `to` counts. No hook, `run` or listener runs and nothing is queued, and once the machine is
|
|
75
|
+
* stopped the answer is `false`.
|
|
76
|
+
*/
|
|
77
|
+
readonly can: (event: E) => boolean;
|
|
43
78
|
/**
|
|
44
79
|
* Handles `event`, or queues it when called during a step. An event no active state handles is
|
|
45
|
-
* dropped
|
|
80
|
+
* dropped: it runs the active states' `unhandled` hooks and is then reported to the
|
|
81
|
+
* `onUnhandled` listeners. Once the machine is stopped the call does nothing.
|
|
46
82
|
*/
|
|
47
83
|
readonly send: (event: E) => void;
|
|
48
84
|
/**
|
|
49
|
-
* Advances the machine by `dt` seconds: runs the `update` hooks, then
|
|
50
|
-
*
|
|
51
|
-
* is
|
|
85
|
+
* Advances the machine by `dt` seconds: runs the `update` hooks, then, in every region no hook
|
|
86
|
+
* moved, each state's `every` entries and after them its `after` timers. A machine with no
|
|
87
|
+
* parallel state is one region. A machine whose `update` is not called is frozen in time, and
|
|
88
|
+
* once the machine is stopped the call does nothing.
|
|
52
89
|
*/
|
|
53
90
|
readonly update: (dt: number) => void;
|
|
54
91
|
/**
|
|
@@ -63,12 +100,28 @@ export interface MachineInstance<Ctx, E extends EventObject, P extends string =
|
|
|
63
100
|
* function removes that one.
|
|
64
101
|
*/
|
|
65
102
|
readonly onMove: (listener: MoveListener<E, P>) => () => void;
|
|
103
|
+
/**
|
|
104
|
+
* Adds a listener called with each event the machine processes that no rule of an active state
|
|
105
|
+
* takes. It runs inside the step, after the active states' `unhandled` hooks and before the
|
|
106
|
+
* next queued event. A rule with no `to` takes its event. Each call adds a listener, and the
|
|
107
|
+
* returned function removes that one.
|
|
108
|
+
*/
|
|
109
|
+
readonly onUnhandled: (listener: UnhandledListener<E>) => () => void;
|
|
66
110
|
}
|
|
67
111
|
/**
|
|
68
112
|
* A function a rule's `run` calls during the move, after the `exit` hooks and before the `enter`
|
|
69
|
-
* hooks. Its `event` is the variant the `on` key names
|
|
113
|
+
* hooks. Its `event` is the variant the `on` key names, and is read-only: a `run` changes `ctx`
|
|
114
|
+
* and cannot assign to a field of the event. `Hook` is the union of the paths its `machine`
|
|
115
|
+
* takes: the machine's paths for a `run` written in the config, and any `string` when left out.
|
|
116
|
+
*/
|
|
117
|
+
export type MoveAction<Ctx, E extends EventObject, V extends E = E, Tag extends string = never, Hook extends string = string> = (ctx: Ctx, event: Readonly<V>, machine: MachineInstance<Ctx, E, Hook, Tag>) => void;
|
|
118
|
+
/**
|
|
119
|
+
* A function a `run` calls where there is no event: under `after`, `always` and `every`. `Hook`
|
|
120
|
+
* is the union of the paths its `machine` takes: the machine's paths for a `run` written in the
|
|
121
|
+
* config, and any `string` when left out.
|
|
70
122
|
*/
|
|
71
|
-
export type
|
|
123
|
+
export type RunAction<Ctx, E extends EventObject, Tag extends string = never, Hook extends string = string> = (ctx: Ctx, machine: MachineInstance<Ctx, E, Hook, Tag>) => void;
|
|
124
|
+
type RuleRun<Ctx, E extends EventObject, Tag extends string = never, Hook extends string = string> = [E] extends [never] ? never : RunAction<Ctx, E, Tag, Hook> | readonly RunAction<Ctx, E, Tag, Hook>[];
|
|
72
125
|
interface RuleList<Rule> {
|
|
73
126
|
readonly 0: Rule;
|
|
74
127
|
readonly [index: number]: Rule;
|
|
@@ -79,7 +132,7 @@ interface RuleList<Rule> {
|
|
|
79
132
|
* no `to` runs its `run` and nothing else: no state exits or enters.
|
|
80
133
|
* @noSelf
|
|
81
134
|
*/
|
|
82
|
-
export interface TransitionConfig<Ctx, E extends EventObject, V extends E = E, To extends string = string> {
|
|
135
|
+
export interface TransitionConfig<Ctx, E extends EventObject, V extends E = E, To extends string = string, Tag extends string = never, Hook extends string = string> {
|
|
83
136
|
/**
|
|
84
137
|
* The full path of the state to move to. A `to` naming the state the rule is on exits and
|
|
85
138
|
* re-enters it, restarting its timers and `task`; a `to` below it keeps it active.
|
|
@@ -88,15 +141,18 @@ export interface TransitionConfig<Ctx, E extends EventObject, V extends E = E, T
|
|
|
88
141
|
/**
|
|
89
142
|
* The rule is taken only when this returns `true`. It must have no side effects: it is also
|
|
90
143
|
* checked when the move does not happen, in guarded lists and on every `always` recheck.
|
|
144
|
+
* `ctx` and `event` are read-only here, one level deep: a write belongs in `run`.
|
|
145
|
+
* `machine` reads the active states; inside a parallel state it shows the regions that already
|
|
146
|
+
* took the event.
|
|
91
147
|
*/
|
|
92
|
-
readonly when?: (ctx: Ctx
|
|
148
|
+
readonly when?: (ctx: Readonly<Ctx>, event: Readonly<V>, machine: MachineView<Hook, Tag>) => boolean;
|
|
93
149
|
/**
|
|
94
150
|
* Runs during the move. The event is accepted when its key matches and `when` passes; then
|
|
95
151
|
* `exit` runs on each state left, deepest first; then `run`; then `enter` on each state
|
|
96
152
|
* entered, outermost first. Shared ancestors neither exit nor enter. A rule with no `to` runs
|
|
97
153
|
* only `run`.
|
|
98
154
|
*/
|
|
99
|
-
readonly run?: MoveAction<Ctx, E, V> | readonly MoveAction<Ctx, E, V>[];
|
|
155
|
+
readonly run?: MoveAction<Ctx, E, V, Tag, Hook> | readonly MoveAction<Ctx, E, V, Tag, Hook>[];
|
|
100
156
|
/** Renamed to `to`. */
|
|
101
157
|
readonly target?: never;
|
|
102
158
|
/** Renamed to `when`. */
|
|
@@ -110,20 +166,27 @@ export interface TransitionConfig<Ctx, E extends EventObject, V extends E = E, T
|
|
|
110
166
|
* What an `on` key maps to: a target path, a `TransitionConfig`, or a non-empty list of them
|
|
111
167
|
* tried in order. The first rule with no `when`, or whose `when` returns `true`, is taken.
|
|
112
168
|
*/
|
|
113
|
-
export type TransitionSpec<Ctx, E extends EventObject, V extends E = E, To extends string = string> = To | TransitionConfig<Ctx, E, V, To> | RuleList<TransitionConfig<Ctx, E, V, To>>;
|
|
169
|
+
export type TransitionSpec<Ctx, E extends EventObject, V extends E = E, To extends string = string, Tag extends string = never, Hook extends string = string> = To | TransitionConfig<Ctx, E, V, To, Tag, Hook> | RuleList<TransitionConfig<Ctx, E, V, To, Tag, Hook>>;
|
|
114
170
|
/**
|
|
115
|
-
* The object form of an `always` rule: a `to` and an optional `
|
|
116
|
-
* no `
|
|
171
|
+
* The object form of an `always` rule: a `to`, an optional `when` and an optional `run`. It gets
|
|
172
|
+
* no event. `E` is the machine's event type; a rule typed without it has no `run`. `Hook` is
|
|
173
|
+
* the union of the paths the `machine` of its `when` and `run` takes: any `string` when left out.
|
|
117
174
|
* @noSelf
|
|
118
175
|
*/
|
|
119
|
-
export interface AlwaysConfig<Ctx, To extends string = string> {
|
|
176
|
+
export interface AlwaysConfig<Ctx, To extends string = string, E extends EventObject = never, Tag extends string = never, Hook extends string = string> {
|
|
120
177
|
/**
|
|
121
178
|
* The full path of the state to move to. An `always` rule without one throws when the machine
|
|
122
179
|
* is defined.
|
|
123
180
|
*/
|
|
124
181
|
readonly to: To;
|
|
125
|
-
/**
|
|
126
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Checked on every recheck, so it must have no side effects. `ctx` is read-only here, one
|
|
184
|
+
* level deep: a write belongs in `run`. `machine` reads the active states; inside a parallel
|
|
185
|
+
* state it shows the regions that already moved.
|
|
186
|
+
*/
|
|
187
|
+
readonly when?: (ctx: Readonly<Ctx>, machine: MachineView<Hook, Tag>) => boolean;
|
|
188
|
+
/** Runs between the `exit` and `enter` hooks of the move, only when the rule is taken. */
|
|
189
|
+
readonly run?: RuleRun<Ctx, E, Tag, Hook>;
|
|
127
190
|
/** Renamed to `to`. */
|
|
128
191
|
readonly target?: never;
|
|
129
192
|
/** Renamed to `when`. */
|
|
@@ -133,61 +196,149 @@ export interface AlwaysConfig<Ctx, To extends string = string> {
|
|
|
133
196
|
* What `always` takes: a target path, an `AlwaysConfig`, or a non-empty list of them. The first
|
|
134
197
|
* whose `when` is missing or passes is taken.
|
|
135
198
|
*/
|
|
136
|
-
export type AlwaysSpec<Ctx, To extends string = string> = To | AlwaysConfig<Ctx, To> | RuleList<AlwaysConfig<Ctx, To>>;
|
|
199
|
+
export type AlwaysSpec<Ctx, To extends string = string, E extends EventObject = never, Tag extends string = never, Hook extends string = string> = To | AlwaysConfig<Ctx, To, E, Tag, Hook> | AlwaysConfig<Ctx, To, never, Tag, Hook> | RuleList<AlwaysConfig<Ctx, To, E, Tag, Hook> | AlwaysConfig<Ctx, To, never, Tag, Hook>>;
|
|
200
|
+
/**
|
|
201
|
+
* The object form of a rule on an `after` timer: a `to`, a `when` and a `run`, each optional. A
|
|
202
|
+
* rule with neither a `to` nor a `run` throws when the machine is defined. `E` is the machine's
|
|
203
|
+
* event type; a rule typed without it has no `run`. `Hook` is the union of the paths the
|
|
204
|
+
* `machine` of its `when` and `run` takes: any `string` when left out.
|
|
205
|
+
* @noSelf
|
|
206
|
+
*/
|
|
207
|
+
export interface AfterRule<Ctx, To extends string = string, E extends EventObject = never, Tag extends string = never, Hook extends string = string> {
|
|
208
|
+
/**
|
|
209
|
+
* The full path of the state to move to when the timer fires. A rule without one runs its
|
|
210
|
+
* `run` and nothing else: no state exits or enters, and it is not a move.
|
|
211
|
+
*/
|
|
212
|
+
readonly to?: To;
|
|
213
|
+
/**
|
|
214
|
+
* The timer fires only when this returns `true`. It is first checked once the delay has
|
|
215
|
+
* passed, then on every `update` call until it passes or the state is left, so it must have no
|
|
216
|
+
* side effects. `ctx` is read-only here, one level deep: a write belongs in `run`. `machine`
|
|
217
|
+
* reads the active states.
|
|
218
|
+
*/
|
|
219
|
+
readonly when?: (ctx: Readonly<Ctx>, machine: MachineView<Hook, Tag>) => boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Runs when the timer fires: between the `exit` and `enter` hooks of the move, or on its own
|
|
222
|
+
* for a rule with no `to`.
|
|
223
|
+
*/
|
|
224
|
+
readonly run?: RuleRun<Ctx, E, Tag, Hook>;
|
|
225
|
+
}
|
|
137
226
|
/**
|
|
138
|
-
* One entry of the list form of `after`: a `delay`
|
|
227
|
+
* One entry of the list form of `after`: a `delay` beside the fields of an `AfterRule`.
|
|
139
228
|
* @noSelf
|
|
140
229
|
*/
|
|
141
|
-
export interface AfterConfig<Ctx, To extends string = string> {
|
|
230
|
+
export interface AfterConfig<Ctx, To extends string = string, E extends EventObject = never, Tag extends string = never, Hook extends string = string> extends AfterRule<Ctx, To, E, Tag, Hook> {
|
|
142
231
|
/**
|
|
143
232
|
* The delay in seconds of game time: a number, or a function of the context that returns one.
|
|
144
233
|
* A function is read once each time the state is entered, after its `enter` hook, and again on
|
|
145
|
-
* a hot reload, so the delay is fixed for that stay.
|
|
234
|
+
* a hot reload, so the delay is fixed for that stay. The function only reads the context: it
|
|
235
|
+
* cannot assign to a field of `ctx`. A result that is not a non-negative number throws, naming
|
|
236
|
+
* the state.
|
|
237
|
+
*/
|
|
238
|
+
readonly delay: number | ((ctx: Readonly<Ctx>) => number);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* One entry of the list form of `every`: a `delay` and the `run` it repeats.
|
|
242
|
+
* @noSelf
|
|
243
|
+
*/
|
|
244
|
+
export interface EveryConfig<Ctx, E extends EventObject, Tag extends string = never, Hook extends string = string> {
|
|
245
|
+
/**
|
|
246
|
+
* The seconds of game time between two runs: a number, or a function of the context that
|
|
247
|
+
* returns one. A function is read once each time the state is entered, after its `enter` hook,
|
|
248
|
+
* and again on a hot reload, so the delay is fixed for that stay. The function only reads the
|
|
249
|
+
* context: it cannot assign to a field of `ctx`. A result that is not a positive number
|
|
146
250
|
* throws, naming the state.
|
|
147
251
|
*/
|
|
148
|
-
readonly delay: number | ((ctx: Ctx) => number);
|
|
149
|
-
/**
|
|
150
|
-
readonly
|
|
252
|
+
readonly delay: number | ((ctx: Readonly<Ctx>) => number);
|
|
253
|
+
/** Runs each time the delay passes: one function, or a list run in order. */
|
|
254
|
+
readonly run: RunAction<Ctx, E, Tag, Hook> | readonly RunAction<Ctx, E, Tag, Hook>[];
|
|
255
|
+
/** Not taken here: an `after` timer leaves the state. */
|
|
256
|
+
readonly to?: never;
|
|
257
|
+
/** Not taken here: a `run` tests a condition itself. */
|
|
258
|
+
readonly when?: never;
|
|
151
259
|
}
|
|
152
260
|
/**
|
|
153
261
|
* A state's rules by event `type`. Only the machine's event types are keys, and each rule's
|
|
154
262
|
* `when` and `run` see the event variant its key names.
|
|
155
263
|
*/
|
|
156
|
-
export type OnConfig<Ctx, E extends EventObject, To extends string = string> = {
|
|
264
|
+
export type OnConfig<Ctx, E extends EventObject, To extends string = string, Tag extends string = never, Hook extends string = string> = {
|
|
157
265
|
readonly [K in E["type"]]?: TransitionSpec<Ctx, E, Extract<E, {
|
|
158
266
|
type: K;
|
|
159
|
-
}>, To>;
|
|
267
|
+
}>, To, Tag, Hook>;
|
|
160
268
|
};
|
|
161
269
|
/**
|
|
162
270
|
* Runs on every way in (`enter`) or out (`exit`) of the state: a move, `start` and `stop`. A hot
|
|
163
271
|
* reload enters the states it adds, but drops a removed state without its `exit`. It gets no
|
|
164
|
-
* event; event data reaches `enter` through `ctx`, set in `run`.
|
|
272
|
+
* event; event data reaches `enter` through `ctx`, set in `run`. `Hook` is the union of the
|
|
273
|
+
* paths its `machine` takes: the machine's paths for a hook written in the config, and any
|
|
274
|
+
* `string` when left out.
|
|
165
275
|
*/
|
|
166
|
-
export type StateHook<Ctx, E extends EventObject> = (ctx: Ctx, machine: MachineInstance<Ctx, E>) => void;
|
|
276
|
+
export type StateHook<Ctx, E extends EventObject, Tag extends string = never, Hook extends string = string> = (ctx: Ctx, machine: MachineInstance<Ctx, E, Hook, Tag>) => void;
|
|
167
277
|
/**
|
|
168
278
|
* Runs on every `update(dt)` while the state is active, deepest state first. It returns a full
|
|
169
279
|
* path to move there, or `undefined` to pass. The first hook to return a path wins: the hooks
|
|
170
|
-
* above it and the `after` timers do not run on that call, and the move has no
|
|
280
|
+
* above it and the `after` timers of its region do not run on that call, and the move has no
|
|
281
|
+
* `run`. Under a parallel state the other regions still run their hooks and timers, unless the
|
|
282
|
+
* move left the parallel state or entered it again. `Hook` is the union of the paths its
|
|
283
|
+
* `machine` takes: the machine's paths for a hook written in the config, and any `string` when
|
|
284
|
+
* left out.
|
|
285
|
+
*/
|
|
286
|
+
export type UpdateHook<Ctx, E extends EventObject, To extends string = string, Tag extends string = never, Hook extends string = string> = (ctx: Ctx, dt: number, machine: MachineInstance<Ctx, E, Hook, Tag>) => To | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* Runs when the machine drops an event while the state is active: for the events `onUnhandled`
|
|
289
|
+
* reports, and no others. Every active state that has the hook runs it, deepest first, in the
|
|
290
|
+
* order `update` hooks run. `event` is the machine's whole event union, and is read-only: the
|
|
291
|
+
* hook cannot assign to its fields. The hook moves nothing: a `send` from it queues, and a
|
|
292
|
+
* `stop()` ends the step once every hook and listener has run for the event. `Hook` is the
|
|
293
|
+
* union of the paths its `machine` takes: the machine's paths for a hook written in the config,
|
|
294
|
+
* and any `string` when left out.
|
|
171
295
|
*/
|
|
172
|
-
export type
|
|
296
|
+
export type UnhandledHook<Ctx, E extends EventObject, Tag extends string = never, Hook extends string = string> = (ctx: Ctx, event: Readonly<E>, machine: MachineInstance<Ctx, E, Hook, Tag>) => void;
|
|
173
297
|
/**
|
|
174
298
|
* Starts work that lives as long as the state. `finish` sends one event and is ignored after the
|
|
175
|
-
* first call or once the state is left. The returned cleanup runs on every way out.
|
|
299
|
+
* first call or once the state is left. The returned cleanup runs on every way out. A task that
|
|
300
|
+
* starts several callbacks counts them with `waitGroup`. `Hook` is the union of the paths its
|
|
301
|
+
* `machine` takes: the machine's paths for a task written in the config, and any `string` when
|
|
302
|
+
* left out.
|
|
176
303
|
* @noSelf
|
|
177
304
|
*/
|
|
178
|
-
export type TaskStart<Ctx, E extends EventObject> = (ctx: Ctx, finish: (event: E) => void, machine: MachineInstance<Ctx, E>) => (() => void) | void;
|
|
305
|
+
export type TaskStart<Ctx, E extends EventObject, Tag extends string = never, Hook extends string = string> = (ctx: Ctx, finish: (event: E) => void, machine: MachineInstance<Ctx, E, Hook, Tag>) => (() => void) | void;
|
|
306
|
+
/**
|
|
307
|
+
* Counts several pieces of engine work a state starts and waits for, returned by `waitGroup()`.
|
|
308
|
+
* It knows nothing about a machine: built inside a `task`, it is new for each entry of the
|
|
309
|
+
* state.
|
|
310
|
+
* @noSelf
|
|
311
|
+
*/
|
|
312
|
+
export interface WaitGroup {
|
|
313
|
+
/**
|
|
314
|
+
* Records one pending piece of work and returns the function that reports it finished. That
|
|
315
|
+
* function counts once, and a later call does nothing. It ignores its arguments, so an engine
|
|
316
|
+
* function takes it as its callback, as in `http.request(url, "GET", group.add())`.
|
|
317
|
+
*/
|
|
318
|
+
readonly add: () => () => void;
|
|
319
|
+
/**
|
|
320
|
+
* Calls `callback` once when no added work is pending: at once when none is pending at the
|
|
321
|
+
* call, and otherwise inside the report that finishes the last pending piece. Each call
|
|
322
|
+
* registers one callback, and several run in the order registered. A `wait` made before the
|
|
323
|
+
* first `add` runs at once, so it goes after them.
|
|
324
|
+
*/
|
|
325
|
+
readonly wait: (callback: () => void) => void;
|
|
326
|
+
}
|
|
179
327
|
/**
|
|
180
328
|
* A machine definition, returned by the second `defineMachine` call. Its `start` creates the
|
|
181
329
|
* instances that run.
|
|
182
330
|
* @noSelf
|
|
183
331
|
*/
|
|
184
|
-
export interface Machine<Ctx, E extends EventObject, P extends string = string> {
|
|
332
|
+
export interface Machine<Ctx, E extends EventObject, P extends string = string, Tag extends string = never> {
|
|
185
333
|
/**
|
|
186
|
-
* Creates an instance with `ctx` as its context
|
|
187
|
-
*
|
|
188
|
-
*
|
|
334
|
+
* Creates an instance with `ctx` as its context. Without `at` it enters the root's `initial`
|
|
335
|
+
* chain. With `at`, a list of full state paths such as a copy of `leaves`, it enters toward
|
|
336
|
+
* each path: a level or region no path names goes through `initial`, a path the machine lacks
|
|
337
|
+
* falls back to its closest parent, and of two paths that cannot be active together the first
|
|
338
|
+
* wins. Timer progress and `restoreDepth` memory are not part of the list. Each call returns a
|
|
339
|
+
* separate instance, which has already handled the events its `enter` hooks sent.
|
|
189
340
|
*/
|
|
190
|
-
readonly start: (ctx: Ctx) => MachineInstance<Ctx, E, P>;
|
|
341
|
+
readonly start: (ctx: Ctx, at?: readonly P[]) => MachineInstance<Ctx, E, P, Tag>;
|
|
191
342
|
}
|
|
192
343
|
type PathDepth = [never, 0, 1, 2, 3];
|
|
193
344
|
type NextCount = [never, 2, 3, 4, 5, 6];
|
|
@@ -195,10 +346,6 @@ type TreePathsBelow<T, D extends number> = {
|
|
|
195
346
|
[K in keyof T & string]: K | `${K}/${D extends 1 ? keyof T[K] extends never ? never : string : TreePathsBelow<T[K], PathDepth[D]>}`;
|
|
196
347
|
}[keyof T & string];
|
|
197
348
|
type TreePath<T> = `/${TreePathsBelow<T, 4>}`;
|
|
198
|
-
type SlotPathsBelow<T, D extends number> = unknown extends T ? string : {
|
|
199
|
-
[K in keyof T & string]: K | `${K}/${D extends 1 ? string : SlotPathsBelow<T[K], PathDepth[D]>}`;
|
|
200
|
-
}[keyof T & string];
|
|
201
|
-
type SlotPath<T> = `/${SlotPathsBelow<T, 4>}`;
|
|
202
349
|
type TreeOf<C> = C extends {
|
|
203
350
|
readonly states: infer Children;
|
|
204
351
|
} ? {
|
|
@@ -212,60 +359,89 @@ export type StatePath<C> = TreePath<TreeOf<C>>;
|
|
|
212
359
|
type TreeDepth<T, D extends number> = unknown extends T ? number : [D] extends [never] ? number : 1 | ({
|
|
213
360
|
[K in keyof T]: unknown extends T[K] ? never : TreeDepth<T[K], PathDepth[D]>;
|
|
214
361
|
}[keyof T] extends infer N ? N extends number ? number extends N ? number : NextCount[N] : never : never);
|
|
215
|
-
type AnyChild<Ctx, E extends EventObject, T, To extends string> = unknown extends T ? {
|
|
216
|
-
readonly [name: string]: StateNode<Ctx, E, unknown, string, To>;
|
|
362
|
+
type AnyChild<Ctx, E extends EventObject, T, To extends string, Tag extends string = never, Hook extends string = string> = unknown extends T ? {
|
|
363
|
+
readonly [name: string]: StateNode<Ctx, E, unknown, string, To, Tag, Hook>;
|
|
217
364
|
} : unknown;
|
|
218
365
|
/** @noSelf */
|
|
219
|
-
interface StateBase<Ctx, E extends EventObject, T, Self extends string, To extends string> {
|
|
366
|
+
interface StateBase<Ctx, E extends EventObject, T, Self extends string, To extends string, Tag extends string = never, Hook extends string = string> {
|
|
220
367
|
/** Child states, by name. A name is non-empty and contains no `/`. */
|
|
221
368
|
readonly states?: {
|
|
222
|
-
readonly [K in keyof T]: StateNode<Ctx, E, T[K], `${Self}/${K & string}`, To>;
|
|
223
|
-
} & NoInfer<AnyChild<Ctx, E, T, To>>;
|
|
369
|
+
readonly [K in keyof T]: StateNode<Ctx, E, T[K], `${Self}/${K & string}`, To, Tag, Hook>;
|
|
370
|
+
} & NoInfer<AnyChild<Ctx, E, T, To, Tag, Hook>>;
|
|
371
|
+
/**
|
|
372
|
+
* Names from the machine's third type argument that hold while the state is active, read with
|
|
373
|
+
* `hasTag`.
|
|
374
|
+
*/
|
|
375
|
+
readonly tags?: readonly Tag[];
|
|
224
376
|
/**
|
|
225
377
|
* Rules by event `type`, each a target path, a rule object or a list of them. An event starts
|
|
226
378
|
* at the deepest active state and moves up to the parent while no rule takes it.
|
|
227
379
|
*/
|
|
228
|
-
readonly on?: NoInfer<OnConfig<Ctx, E, To>>;
|
|
380
|
+
readonly on?: NoInfer<OnConfig<Ctx, E, To, Tag, Hook>>;
|
|
229
381
|
/**
|
|
230
|
-
* Timers, in one of two forms: targets by delay in seconds of game
|
|
231
|
-
* `{ 2: "/idle" }`, or a list of `AfterConfig` entries, such as
|
|
382
|
+
* Timers, in one of two forms: targets or `AfterRule` objects by delay in seconds of game
|
|
383
|
+
* time, such as `{ 2: "/idle" }`, or a list of `AfterConfig` entries, such as
|
|
232
384
|
* `[{ delay: (ctx) => ctx.patrolFor, to: "/rest" }]`, whose `delay` is a number or a function
|
|
233
385
|
* of the context. A delay function is read once each time the state is entered, after its
|
|
234
386
|
* `enter` hook, and again on a hot reload. The delay is counted by `update(dt)` while the state
|
|
235
|
-
* is active, from zero on each entry
|
|
236
|
-
*
|
|
387
|
+
* is active, from zero on each entry, and a timer fires at most once per stay. An `update`
|
|
388
|
+
* call tries the due timers in delay order: one whose `when` fails stays pending, one with no
|
|
389
|
+
* `to` runs its `run` and the call goes on, and the first that moves ends the timers of its
|
|
390
|
+
* region for that call. None is tried in a region an `update` hook moved on that call. Under a
|
|
391
|
+
* parallel state each region follows both rules on its own, and the parallel state's own
|
|
392
|
+
* timers are tried only when no region moved. A state's `every` entries run before its timers.
|
|
237
393
|
*/
|
|
238
394
|
readonly after?: NoInfer<{
|
|
239
|
-
readonly [seconds: number]: To
|
|
240
|
-
} | readonly AfterConfig<Ctx, To>[]>;
|
|
395
|
+
readonly [seconds: number]: To | AfterRule<Ctx, To, E, Tag, Hook> | AfterRule<Ctx, To, never, Tag, Hook>;
|
|
396
|
+
} | readonly (AfterConfig<Ctx, To, E, Tag, Hook> | AfterConfig<Ctx, To, never, Tag, Hook>)[]>;
|
|
241
397
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
398
|
+
* Code that repeats while the state is active, in one of two forms: a `run` by delay in
|
|
399
|
+
* seconds of game time, such as `{ 0.5: (ctx) => burn(ctx) }`, or a list of `EveryConfig`
|
|
400
|
+
* entries, such as `[{ delay: (ctx) => ctx.fireEvery, run: fire }]`, whose `delay` is a number
|
|
401
|
+
* or a function of the context, read as an `after` delay is. A `run` is one function or a list
|
|
402
|
+
* run in order. An entry first runs one delay after the state is entered, then each time
|
|
403
|
+
* another delay has passed on the state's clock, which `update(dt)` advances while the state
|
|
404
|
+
* is active, from zero on each entry. It runs at most once per `update` call: a call that
|
|
405
|
+
* covers several delays runs it once, and its later runs stay on multiples of the delay. A run
|
|
406
|
+
* is not a move: no `update` hook is skipped, `always` is not rechecked and `onMove` is not
|
|
407
|
+
* called. A state's entries run where its `after` timers are tried and before them, a list in
|
|
408
|
+
* list order and the other form shortest delay first; on a call in which an `update` hook or a
|
|
409
|
+
* timer of a deeper state moved, they wait for the next call. A delay that is not a positive
|
|
410
|
+
* number throws, naming the state.
|
|
245
411
|
*/
|
|
246
|
-
readonly
|
|
412
|
+
readonly every?: NoInfer<{
|
|
413
|
+
readonly [seconds: number]: RunAction<Ctx, E, Tag, Hook> | readonly RunAction<Ctx, E, Tag, Hook>[];
|
|
414
|
+
} | readonly EveryConfig<Ctx, E, Tag, Hook>[]>;
|
|
415
|
+
/**
|
|
416
|
+
* Rules taken right after any move that leaves this state active; the first whose `when` is
|
|
417
|
+
* missing or passes wins, and its `run` runs during the move. It is checked after a move only:
|
|
418
|
+
* not after a rule with no `to`, and not on an `update` call that moves nothing.
|
|
419
|
+
*/
|
|
420
|
+
readonly always?: AlwaysSpec<Ctx, To, E, Tag, Hook>;
|
|
247
421
|
/**
|
|
248
422
|
* Runs each time the state is entered, outermost state first: on a move, at `start`, and when
|
|
249
423
|
* a hot reload adds the state. It gets no event.
|
|
250
424
|
*/
|
|
251
|
-
readonly enter?: StateHook<Ctx, E>;
|
|
425
|
+
readonly enter?: StateHook<Ctx, E, Tag, Hook>;
|
|
252
426
|
/**
|
|
253
427
|
* Runs each time the state is left, deepest state first, including on `stop()`. A state a hot
|
|
254
428
|
* reload removes is dropped without it.
|
|
255
429
|
*/
|
|
256
|
-
readonly exit?: StateHook<Ctx, E>;
|
|
430
|
+
readonly exit?: StateHook<Ctx, E, Tag, Hook>;
|
|
257
431
|
/**
|
|
258
432
|
* Runs on every `update(dt)` while the state is active. Return one of the machine's full paths
|
|
259
433
|
* to move there, or `undefined` to stay.
|
|
260
434
|
*/
|
|
261
|
-
readonly update?: NoInfer<UpdateHook<Ctx, E, To>>;
|
|
435
|
+
readonly update?: NoInfer<UpdateHook<Ctx, E, To, Tag, Hook>>;
|
|
262
436
|
/** Started on each entry; see `TaskStart`. */
|
|
263
|
-
readonly task?: TaskStart<Ctx, E>;
|
|
437
|
+
readonly task?: TaskStart<Ctx, E, Tag, Hook>;
|
|
438
|
+
/** Runs when the machine drops an event while the state is active; see `UnhandledHook`. */
|
|
439
|
+
readonly unhandled?: UnhandledHook<Ctx, E, Tag, Hook>;
|
|
264
440
|
/** Renamed to `task`. */
|
|
265
441
|
readonly invoke?: never;
|
|
266
442
|
}
|
|
267
443
|
/** @noSelf */
|
|
268
|
-
interface CompoundState<Ctx, E extends EventObject, T, Self extends string, To extends string> extends StateBase<Ctx, E, T, Self, To> {
|
|
444
|
+
interface CompoundState<Ctx, E extends EventObject, T, Self extends string, To extends string, Tag extends string = never, Hook extends string = string> extends StateBase<Ctx, E, T, Self, To, Tag, Hook> {
|
|
269
445
|
/**
|
|
270
446
|
* `"parallel"` keeps every child active at once, each as a region with its own active state.
|
|
271
447
|
* Not allowed on the root.
|
|
@@ -285,7 +461,7 @@ interface CompoundState<Ctx, E extends EventObject, T, Self extends string, To e
|
|
|
285
461
|
readonly restoreDepth?: NoInfer<TreeDepth<T, 4> | "all">;
|
|
286
462
|
}
|
|
287
463
|
/** @noSelf */
|
|
288
|
-
interface ParallelState<Ctx, E extends EventObject, T, Self extends string, To extends string> extends StateBase<Ctx, E, T, Self, To> {
|
|
464
|
+
interface ParallelState<Ctx, E extends EventObject, T, Self extends string, To extends string, Tag extends string = never, Hook extends string = string> extends StateBase<Ctx, E, T, Self, To, Tag, Hook> {
|
|
289
465
|
/**
|
|
290
466
|
* `"parallel"` keeps every child active at once, each as a region with its own active state.
|
|
291
467
|
* Not allowed on the root.
|
|
@@ -294,25 +470,49 @@ interface ParallelState<Ctx, E extends EventObject, T, Self extends string, To e
|
|
|
294
470
|
readonly initial?: never;
|
|
295
471
|
readonly restoreDepth?: never;
|
|
296
472
|
}
|
|
297
|
-
type StateNode<Ctx, E extends EventObject, T, Self extends string, To extends string> = CompoundState<Ctx, E, T, Self, To> | ParallelState<Ctx, E, T, Self, To>;
|
|
298
|
-
type
|
|
473
|
+
type StateNode<Ctx, E extends EventObject, T, Self extends string, To extends string, Tag extends string = never, Hook extends string = string> = CompoundState<Ctx, E, T, Self, To, Tag, Hook> | ParallelState<Ctx, E, T, Self, To, Tag, Hook>;
|
|
474
|
+
type StateKey = keyof CompoundState<unknown, EventObject, unknown, string, string> | keyof ParallelState<unknown, EventObject, unknown, string, string>;
|
|
475
|
+
type NodeLevel<NT> = {
|
|
476
|
+
readonly [K in keyof NT]: NodeKeys<NT[K]> & InferOnly<NT[K]>;
|
|
477
|
+
};
|
|
478
|
+
type NodeKeys<N> = {
|
|
479
|
+
readonly [P in keyof N]: NodeSlot<P, N[P], keyof N>;
|
|
480
|
+
};
|
|
481
|
+
type NodeSlot<P, V, Keys> = P extends "states" ? NodeLevel<V> : P extends "initial" | "restoreDepth" ? "states" extends Keys ? unknown : never : P extends StateKey ? unknown : never;
|
|
482
|
+
type InferOnly<X> = X extends unknown ? unknown : X;
|
|
483
|
+
type StatesOf<N> = N extends {
|
|
484
|
+
readonly states: infer C;
|
|
485
|
+
} ? C : unknown;
|
|
486
|
+
type HasStates<N> = "states" extends keyof N ? true : false;
|
|
487
|
+
type NodePathsBelow<L, D extends number> = unknown extends L ? string : {
|
|
488
|
+
[K in keyof L & string]: K | (unknown extends L[K] ? `${K}/${string}` : HasStates<L[K]> extends true ? `${K}/${D extends 1 ? string : NodePathsBelow<StatesOf<L[K]>, PathDepth[D]>}` : never);
|
|
489
|
+
}[keyof L & string];
|
|
490
|
+
type NodePath<NT> = `/${NodePathsBelow<NT, 4>}`;
|
|
491
|
+
type RootState<Ctx, E extends EventObject, T, Tag extends string = never, NT = unknown, HT = unknown> = CompoundState<Ctx, E, T, "", NoInfer<NodePath<NT>>, Tag, NoInfer<NodePath<HT>>> & {
|
|
299
492
|
readonly initial: string;
|
|
300
493
|
readonly states: object;
|
|
494
|
+
} & {
|
|
495
|
+
readonly states: NodeLevel<NT>;
|
|
496
|
+
} & {
|
|
497
|
+
readonly states: NodeLevel<HT>;
|
|
301
498
|
};
|
|
302
499
|
/**
|
|
303
500
|
* The config of one state. Every field is optional. A state with child `states` is a compound
|
|
304
501
|
* state and needs an `initial`, unless its `type` is `"parallel"`; a state without children is a
|
|
305
|
-
* leaf.
|
|
502
|
+
* leaf. `Tag` is the union of the machine's tag names. The `machine` a callback of a config
|
|
503
|
+
* typed this way receives takes any `string` path.
|
|
306
504
|
*/
|
|
307
|
-
export type StateConfig<Ctx, E extends EventObject> = StateNode<Ctx, E, unknown, string, string>;
|
|
505
|
+
export type StateConfig<Ctx, E extends EventObject, Tag extends string = never> = StateNode<Ctx, E, unknown, string, string, Tag>;
|
|
308
506
|
/**
|
|
309
507
|
* The root config passed to `defineMachine`. It takes the fields of a state and requires
|
|
310
|
-
* `initial` and `states`. The root has no name and cannot be parallel.
|
|
508
|
+
* `initial` and `states`. The root has no name and cannot be parallel. `Tag` is the union of the
|
|
509
|
+
* machine's tag names. The `machine` a callback of a config typed this way receives takes any
|
|
510
|
+
* `string` path.
|
|
311
511
|
*/
|
|
312
|
-
export type MachineConfig<Ctx, E extends EventObject> = CompoundState<Ctx, E, unknown, string, string> & {
|
|
512
|
+
export type MachineConfig<Ctx, E extends EventObject, Tag extends string = never> = CompoundState<Ctx, E, unknown, string, string, Tag> & {
|
|
313
513
|
readonly initial: string;
|
|
314
514
|
readonly states: {
|
|
315
|
-
readonly [name: string]: StateConfig<Ctx, E>;
|
|
515
|
+
readonly [name: string]: StateConfig<Ctx, E, Tag>;
|
|
316
516
|
};
|
|
317
517
|
};
|
|
318
518
|
type WithPrivate<Ctx, Priv> = [Priv] extends [never] ? Ctx : Ctx & Priv;
|
|
@@ -323,12 +523,44 @@ type WithPrivate<Ctx, Priv> = [Priv] extends [never] ? Ctx : Ctx & Priv;
|
|
|
323
523
|
* definition under it puts its states into the machine already built, so every running instance
|
|
324
524
|
* sees the edit; without one, each call builds a separate machine.
|
|
325
525
|
*
|
|
526
|
+
* A third type argument, as in `defineMachine<Ctx, E, Tag>()`, is a union of tag names: a state's
|
|
527
|
+
* `tags` lists some of them, and `hasTag` asks whether an active state carries one. A machine
|
|
528
|
+
* defined without it has no tags.
|
|
529
|
+
*
|
|
326
530
|
* The root config may hold `privateCtx`, for a machine that keeps fields of its own, such as a
|
|
327
531
|
* counter, a heat level or a list it builds up. Every hook, `when`, `run`, `task` and `update`
|
|
328
532
|
* then sees those fields beside `Ctx`, while `start` takes only `Ctx` and the instance it returns
|
|
329
533
|
* shows only `Ctx` in its `ctx`. A machine without fields of its own leaves `privateCtx` out.
|
|
330
534
|
*/
|
|
331
|
-
export declare function defineMachine<Ctx, E extends EventObject>(key?: string): <T, Priv extends object = never>(config: RootState<WithPrivate<Ctx, Priv>, E, T> & PrivateCtxConfig<Ctx, Priv>) => Machine<Ctx, E, TreePath<T
|
|
535
|
+
export declare function defineMachine<Ctx, E extends EventObject, Tag extends string = never>(key?: string): <T, Priv extends object = never, NT = unknown, HT = unknown>(config: RootState<WithPrivate<Ctx, Priv>, E, T, Tag, NT, HT> & PrivateCtxConfig<Ctx, Priv>) => Machine<Ctx, E, TreePath<T>, Tag>;
|
|
536
|
+
/**
|
|
537
|
+
* Makes a group that counts the engine work a `task` started and tells when all of it has
|
|
538
|
+
* finished. Each `add()` returns the callback to pass to one engine call, and `wait` runs its
|
|
539
|
+
* callback once every one of them has reported.
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```ts
|
|
543
|
+
* loading: {
|
|
544
|
+
* task: (ctx, finish) => {
|
|
545
|
+
* const group = waitGroup();
|
|
546
|
+
* http.request(ctx.url, "GET", group.add());
|
|
547
|
+
* go.animate(
|
|
548
|
+
* ctx.curtain,
|
|
549
|
+
* "tint.w",
|
|
550
|
+
* go.PLAYBACK_ONCE_FORWARD,
|
|
551
|
+
* 0,
|
|
552
|
+
* go.EASING_LINEAR,
|
|
553
|
+
* 0.5,
|
|
554
|
+
* 0,
|
|
555
|
+
* group.add(),
|
|
556
|
+
* );
|
|
557
|
+
* group.wait(() => finish({ type: "READY" }));
|
|
558
|
+
* },
|
|
559
|
+
* on: { READY: "/playing" },
|
|
560
|
+
* },
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
export declare function waitGroup(): WaitGroup;
|
|
332
564
|
/**
|
|
333
565
|
* The optional key a `defineMachine` root config takes beside `initial` and `states`.
|
|
334
566
|
* @noSelf
|
package/identity-vocabulary.json
CHANGED
|
@@ -158,6 +158,7 @@
|
|
|
158
158
|
"graphics.COMPRESSION_TYPE": "number",
|
|
159
159
|
"graphics.CONTEXT_FEATURE": "number",
|
|
160
160
|
"graphics.COORDINATE_SPACE": "number",
|
|
161
|
+
"graphics.CUBEMAP_FACE": "number",
|
|
161
162
|
"graphics.DATA_TYPE": "number",
|
|
162
163
|
"graphics.FACE_TYPE": "number",
|
|
163
164
|
"graphics.SEMANTIC_TYPE": "number",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defold-typescript/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "TypeScript types for the Defold engine's Lua APIs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"import-defold-release": "bun scripts/import-defold-release.ts",
|
|
117
117
|
"sync-api-docs": "bun scripts/sync-api-docs.ts",
|
|
118
118
|
"sync-engine-bindings": "bun scripts/sync-engine-bindings.ts",
|
|
119
|
-
"ref-doc-delta": "bun scripts/ref-doc-delta.ts --target defold-1.9.8 --namespace label --present label.get_text --absent label.
|
|
119
|
+
"ref-doc-delta": "bun scripts/ref-doc-delta.ts --target defold-1.9.8 --namespace label --present label.get_text --present label.set_text --absent label.get_layout_objects"
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
122
|
"lua-types": "^2.13.1",
|