@defold-typescript/types 0.44.1 → 0.46.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/examples/translations.json +34 -34
- package/generated/b2d_fixture.d.ts +23 -1
- package/generated/b2d_shape.d.ts +22 -1
- package/generated/compute.d.ts +29 -2
- package/generated/go.d.ts +2 -2
- package/generated/gui.d.ts +5 -7
- package/generated/material.d.ts +98 -8
- package/generated/model.d.ts +11 -5
- package/generated/particlefx.d.ts +5 -7
- package/generated/render.d.ts +12 -18
- package/generated/sys.d.ts +8 -10
- package/generated/versions/defold-1.12.4/go.d.ts +2 -2
- package/generated/versions/defold-1.12.4/gui.d.ts +5 -7
- package/generated/versions/defold-1.12.4/particlefx.d.ts +5 -7
- package/generated/versions/defold-1.12.4/render.d.ts +12 -18
- package/generated/versions/defold-1.12.4/sys.d.ts +8 -10
- package/generated/versions/defold-1.12.4/window.d.ts +13 -15
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +23 -1
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +22 -1
- package/generated/versions/defold-1.13.0/compute.d.ts +29 -2
- package/generated/versions/defold-1.13.0/go.d.ts +2 -2
- package/generated/versions/defold-1.13.0/gui.d.ts +5 -7
- package/generated/versions/defold-1.13.0/material.d.ts +98 -8
- package/generated/versions/defold-1.13.0/model.d.ts +11 -5
- package/generated/versions/defold-1.13.0/particlefx.d.ts +5 -7
- package/generated/versions/defold-1.13.0/render.d.ts +12 -18
- package/generated/versions/defold-1.13.0/sys.d.ts +8 -10
- package/generated/versions/defold-1.13.0/window.d.ts +13 -15
- package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +23 -1
- package/generated/versions/defold-1.13.1/b2d_shape.d.ts +22 -1
- package/generated/versions/defold-1.13.1/compute.d.ts +29 -2
- package/generated/versions/defold-1.13.1/go.d.ts +2 -2
- package/generated/versions/defold-1.13.1/gui.d.ts +5 -7
- package/generated/versions/defold-1.13.1/material.d.ts +98 -8
- package/generated/versions/defold-1.13.1/model.d.ts +11 -5
- package/generated/versions/defold-1.13.1/particlefx.d.ts +5 -7
- package/generated/versions/defold-1.13.1/render.d.ts +12 -18
- package/generated/versions/defold-1.13.1/sys.d.ts +8 -10
- package/generated/versions/defold-1.13.1/window.d.ts +13 -15
- package/generated/window.d.ts +13 -15
- package/hsm/async.d.ts +19 -1
- package/hsm/debug.d.ts +15 -1
- package/hsm/defold.d.ts +21 -1
- package/hsm/index.d.ts +222 -94
- package/package.json +3 -1
package/hsm/index.d.ts
CHANGED
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
// Generated from packages/hsm/src/index.ts by `bun run --cwd packages/hsm declarations`; do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* An event a machine handles: an object with a string `type`, plus any payload fields. A
|
|
4
|
+
* machine's event type is a union of these.
|
|
5
|
+
*/
|
|
2
6
|
export interface EventObject {
|
|
7
|
+
/** Names the event. A state's `on` takes these values as its keys. */
|
|
3
8
|
readonly type: string;
|
|
4
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* What made a move happen: `event` for a sent event, `after` for a timer, `update` for a path an
|
|
12
|
+
* `update` hook returned, `always` for an `always` rule, `stop` for `stop()`, and `reload` for a
|
|
13
|
+
* hot reload that changed the current state.
|
|
14
|
+
*/
|
|
5
15
|
export type MoveCause = "event" | "after" | "update" | "stop" | "reload" | "always";
|
|
6
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* A listener given to `onMove`. It gets the leaf left, the leaf entered (`undefined` after
|
|
18
|
+
* `stop()`), the cause, and the event, which is `undefined` unless the cause is `event`. It runs
|
|
19
|
+
* after the move's `enter` hooks.
|
|
20
|
+
* @noSelf
|
|
21
|
+
*/
|
|
7
22
|
export type MoveListener<E extends EventObject, P extends string = string> = (from: P, to: P | undefined, cause: MoveCause, event: E | undefined) => void;
|
|
8
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* One running machine, returned by `start`. `P` is the union of the machine's state paths; the
|
|
25
|
+
* `machine` a hook, a `run` or a `task` receives uses plain `string` paths instead.
|
|
26
|
+
* @noSelf
|
|
27
|
+
*/
|
|
9
28
|
export interface MachineInstance<Ctx, E extends EventObject, P extends string = string> {
|
|
29
|
+
/** The context passed to `start`. */
|
|
10
30
|
readonly ctx: Ctx;
|
|
31
|
+
/**
|
|
32
|
+
* The full path of the deepest active state, or `undefined` once stopped. In a parallel state
|
|
33
|
+
* it is the first region's leaf.
|
|
34
|
+
*/
|
|
11
35
|
readonly path: P | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The full path of every active leaf, in region order: one path without parallel states, empty
|
|
38
|
+
* once stopped. It is the same array on every read, updated in place.
|
|
39
|
+
*/
|
|
12
40
|
readonly leaves: readonly P[];
|
|
41
|
+
/** Whether the state at the full path `path` is active. Ancestors of the current state count. */
|
|
13
42
|
readonly matches: (path: P) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Handles `event`, or queues it when called during a step. An event no active state handles is
|
|
45
|
+
* dropped, and once the machine is stopped the call does nothing.
|
|
46
|
+
*/
|
|
14
47
|
readonly send: (event: E) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Advances the machine by `dt` seconds: runs the `update` hooks, then the `after` timers if no
|
|
50
|
+
* hook moved it. A machine whose `update` is not called is frozen in time, and once the machine
|
|
51
|
+
* is stopped the call does nothing.
|
|
52
|
+
*/
|
|
15
53
|
readonly update: (dt: number) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Exits every active state, deepest first, and sets `path` to `undefined`. Called during a
|
|
56
|
+
* step, it lets that step finish and drops the queued events.
|
|
57
|
+
*/
|
|
16
58
|
readonly stop: () => void;
|
|
17
59
|
/**
|
|
18
60
|
* Adds a listener called after each move completes, with the leaf left, the leaf entered and
|
|
@@ -22,14 +64,27 @@ export interface MachineInstance<Ctx, E extends EventObject, P extends string =
|
|
|
22
64
|
*/
|
|
23
65
|
readonly onMove: (listener: MoveListener<E, P>) => () => void;
|
|
24
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* 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.
|
|
70
|
+
*/
|
|
25
71
|
export type MoveAction<Ctx, E extends EventObject, V extends E = E> = (ctx: Ctx, event: V, machine: MachineInstance<Ctx, E>) => void;
|
|
26
|
-
|
|
27
|
-
|
|
72
|
+
interface RuleList<Rule> {
|
|
73
|
+
readonly 0: Rule;
|
|
74
|
+
readonly [index: number]: Rule;
|
|
75
|
+
readonly length: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The object form of a rule under `on`: a `to`, a `when` and a `run`, each optional. A rule with
|
|
79
|
+
* no `to` runs its `run` and nothing else: no state exits or enters.
|
|
80
|
+
* @noSelf
|
|
81
|
+
*/
|
|
82
|
+
export interface TransitionConfig<Ctx, E extends EventObject, V extends E = E, To extends string = string> {
|
|
28
83
|
/**
|
|
29
84
|
* The full path of the state to move to. A `to` naming the state the rule is on exits and
|
|
30
85
|
* re-enters it, restarting its timers and `task`; a `to` below it keeps it active.
|
|
31
86
|
*/
|
|
32
|
-
readonly to?:
|
|
87
|
+
readonly to?: To;
|
|
33
88
|
/**
|
|
34
89
|
* The rule is taken only when this returns `true`. It must have no side effects: it is also
|
|
35
90
|
* checked when the move does not happen, in guarded lists and on every `always` recheck.
|
|
@@ -51,10 +106,22 @@ export interface TransitionConfig<Ctx, E extends EventObject, V extends E = E> {
|
|
|
51
106
|
/** Removed: a `to` naming the state the rule is on restarts it. */
|
|
52
107
|
readonly reenter?: never;
|
|
53
108
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
109
|
+
/**
|
|
110
|
+
* What an `on` key maps to: a target path, a `TransitionConfig`, or a non-empty list of them
|
|
111
|
+
* tried in order. The first rule with no `when`, or whose `when` returns `true`, is taken.
|
|
112
|
+
*/
|
|
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>>;
|
|
114
|
+
/**
|
|
115
|
+
* The object form of an `always` rule: a `to` and an optional `when`. It gets no event and has
|
|
116
|
+
* no `run`; side effects belong in the target's `enter`.
|
|
117
|
+
* @noSelf
|
|
118
|
+
*/
|
|
119
|
+
export interface AlwaysConfig<Ctx, To extends string = string> {
|
|
120
|
+
/**
|
|
121
|
+
* The full path of the state to move to. An `always` rule without one throws when the machine
|
|
122
|
+
* is defined.
|
|
123
|
+
*/
|
|
124
|
+
readonly to: To;
|
|
58
125
|
/** Checked on every recheck, so it must have no side effects. */
|
|
59
126
|
readonly when?: (ctx: Ctx) => boolean;
|
|
60
127
|
/** Renamed to `to`. */
|
|
@@ -62,11 +129,19 @@ export interface AlwaysConfig<Ctx> {
|
|
|
62
129
|
/** Renamed to `when`. */
|
|
63
130
|
readonly guard?: never;
|
|
64
131
|
}
|
|
65
|
-
|
|
66
|
-
|
|
132
|
+
/**
|
|
133
|
+
* What `always` takes: a target path, an `AlwaysConfig`, or a non-empty list of them. The first
|
|
134
|
+
* whose `when` is missing or passes is taken.
|
|
135
|
+
*/
|
|
136
|
+
export type AlwaysSpec<Ctx, To extends string = string> = To | AlwaysConfig<Ctx, To> | RuleList<AlwaysConfig<Ctx, To>>;
|
|
137
|
+
/**
|
|
138
|
+
* A state's rules by event `type`. Only the machine's event types are keys, and each rule's
|
|
139
|
+
* `when` and `run` see the event variant its key names.
|
|
140
|
+
*/
|
|
141
|
+
export type OnConfig<Ctx, E extends EventObject, To extends string = string> = {
|
|
67
142
|
readonly [K in E["type"]]?: TransitionSpec<Ctx, E, Extract<E, {
|
|
68
143
|
type: K;
|
|
69
|
-
}
|
|
144
|
+
}>, To>;
|
|
70
145
|
};
|
|
71
146
|
/**
|
|
72
147
|
* Runs on every way in (`enter`) or out (`exit`) of the state: a move, `start` and `stop`. A hot
|
|
@@ -74,106 +149,159 @@ export type OnConfig<Ctx, E extends EventObject> = {
|
|
|
74
149
|
* event; event data reaches `enter` through `ctx`, set in `run`.
|
|
75
150
|
*/
|
|
76
151
|
export type StateHook<Ctx, E extends EventObject> = (ctx: Ctx, machine: MachineInstance<Ctx, E>) => void;
|
|
77
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Runs on every `update(dt)` while the state is active, deepest state first. It returns a full
|
|
154
|
+
* path to move there, or `undefined` to pass. The first hook to return a path wins: the hooks
|
|
155
|
+
* above it and the `after` timers do not run on that call, and the move has no `run`.
|
|
156
|
+
*/
|
|
157
|
+
export type UpdateHook<Ctx, E extends EventObject, To extends string = string> = (ctx: Ctx, dt: number, machine: MachineInstance<Ctx, E>) => To | undefined;
|
|
78
158
|
/**
|
|
79
159
|
* Starts work that lives as long as the state. `finish` sends one event and is ignored after the
|
|
80
160
|
* first call or once the state is left. The returned cleanup runs on every way out.
|
|
81
161
|
* @noSelf
|
|
82
162
|
*/
|
|
83
163
|
export type TaskStart<Ctx, E extends EventObject> = (ctx: Ctx, finish: (event: E) => void, machine: MachineInstance<Ctx, E>) => (() => void) | void;
|
|
164
|
+
/**
|
|
165
|
+
* A machine definition, returned by the second `defineMachine` call. Its `start` creates the
|
|
166
|
+
* instances that run.
|
|
167
|
+
* @noSelf
|
|
168
|
+
*/
|
|
169
|
+
export interface Machine<Ctx, E extends EventObject, P extends string = string> {
|
|
170
|
+
/**
|
|
171
|
+
* Creates an instance with `ctx` as its context and enters the root's `initial` chain. Each
|
|
172
|
+
* call returns a separate instance, which has already handled the events its `enter` hooks
|
|
173
|
+
* sent.
|
|
174
|
+
*/
|
|
175
|
+
readonly start: (ctx: Ctx) => MachineInstance<Ctx, E, P>;
|
|
176
|
+
}
|
|
177
|
+
type PathDepth = [never, 0, 1, 2, 3];
|
|
178
|
+
type NextCount = [never, 2, 3, 4, 5, 6];
|
|
179
|
+
type TreePathsBelow<T, D extends number> = {
|
|
180
|
+
[K in keyof T & string]: K | `${K}/${D extends 1 ? keyof T[K] extends never ? never : string : TreePathsBelow<T[K], PathDepth[D]>}`;
|
|
181
|
+
}[keyof T & string];
|
|
182
|
+
type TreePath<T> = `/${TreePathsBelow<T, 4>}`;
|
|
183
|
+
type SlotPathsBelow<T, D extends number> = unknown extends T ? string : {
|
|
184
|
+
[K in keyof T & string]: K | `${K}/${D extends 1 ? string : SlotPathsBelow<T[K], PathDepth[D]>}`;
|
|
185
|
+
}[keyof T & string];
|
|
186
|
+
type SlotPath<T> = `/${SlotPathsBelow<T, 4>}`;
|
|
187
|
+
type TreeOf<C> = C extends {
|
|
188
|
+
readonly states: infer Children;
|
|
189
|
+
} ? {
|
|
190
|
+
readonly [K in keyof Children]: TreeOf<Children[K]>;
|
|
191
|
+
} : unknown;
|
|
192
|
+
/**
|
|
193
|
+
* The union of a config's state paths, each with its leading `/`. Paths are spelled out four
|
|
194
|
+
* levels deep; below that, any string under a fourth-level path is accepted.
|
|
195
|
+
*/
|
|
196
|
+
export type StatePath<C> = TreePath<TreeOf<C>>;
|
|
197
|
+
type TreeDepth<T, D extends number> = unknown extends T ? number : [D] extends [never] ? number : 1 | ({
|
|
198
|
+
[K in keyof T]: unknown extends T[K] ? never : TreeDepth<T[K], PathDepth[D]>;
|
|
199
|
+
}[keyof T] extends infer N ? N extends number ? number extends N ? number : NextCount[N] : never : never);
|
|
200
|
+
type AnyChild<Ctx, E extends EventObject, T, To extends string> = unknown extends T ? {
|
|
201
|
+
readonly [name: string]: StateNode<Ctx, E, unknown, string, To>;
|
|
202
|
+
} : unknown;
|
|
84
203
|
/** @noSelf */
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
readonly initial?: string;
|
|
88
|
-
readonly restoreDepth?: number | "all";
|
|
204
|
+
interface StateBase<Ctx, E extends EventObject, T, Self extends string, To extends string> {
|
|
205
|
+
/** Child states, by name. A name is non-empty and contains no `/`. */
|
|
89
206
|
readonly states?: {
|
|
90
|
-
readonly [
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
readonly
|
|
207
|
+
readonly [K in keyof T]: StateNode<Ctx, E, T[K], `${Self}/${K & string}`, To>;
|
|
208
|
+
} & NoInfer<AnyChild<Ctx, E, T, To>>;
|
|
209
|
+
/**
|
|
210
|
+
* Rules by event `type`, each a target path, a rule object or a list of them. An event starts
|
|
211
|
+
* at the deepest active state and moves up to the parent while no rule takes it.
|
|
212
|
+
*/
|
|
213
|
+
readonly on?: NoInfer<OnConfig<Ctx, E, To>>;
|
|
214
|
+
/**
|
|
215
|
+
* Targets by delay in seconds of game time. The delay is counted by `update(dt)` while the
|
|
216
|
+
* state is active, from zero on each entry. One `update` call fires at most one timer, and
|
|
217
|
+
* none when an `update` hook moved the machine.
|
|
218
|
+
*/
|
|
219
|
+
readonly after?: NoInfer<{
|
|
220
|
+
readonly [seconds: number]: To;
|
|
221
|
+
}>;
|
|
222
|
+
/**
|
|
223
|
+
* Targets taken right after any move that leaves this state active; the first whose `when` is
|
|
224
|
+
* missing or passes wins. It is checked after a move only: not after a rule with no `to`, and
|
|
225
|
+
* not on an `update` call that moves nothing.
|
|
226
|
+
*/
|
|
227
|
+
readonly always?: AlwaysSpec<Ctx, To>;
|
|
228
|
+
/**
|
|
229
|
+
* Runs each time the state is entered, outermost state first: on a move, at `start`, and when
|
|
230
|
+
* a hot reload adds the state. It gets no event.
|
|
231
|
+
*/
|
|
97
232
|
readonly enter?: StateHook<Ctx, E>;
|
|
233
|
+
/**
|
|
234
|
+
* Runs each time the state is left, deepest state first, including on `stop()`. A state a hot
|
|
235
|
+
* reload removes is dropped without it.
|
|
236
|
+
*/
|
|
98
237
|
readonly exit?: StateHook<Ctx, E>;
|
|
99
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Runs on every `update(dt)` while the state is active. Return one of the machine's full paths
|
|
240
|
+
* to move there, or `undefined` to stay.
|
|
241
|
+
*/
|
|
242
|
+
readonly update?: NoInfer<UpdateHook<Ctx, E, To>>;
|
|
100
243
|
/** Started on each entry; see `TaskStart`. */
|
|
101
244
|
readonly task?: TaskStart<Ctx, E>;
|
|
102
245
|
/** Renamed to `task`. */
|
|
103
246
|
readonly invoke?: never;
|
|
104
247
|
}
|
|
105
|
-
export interface MachineConfig<Ctx, E extends EventObject> extends StateConfig<Ctx, E> {
|
|
106
|
-
readonly initial: string;
|
|
107
|
-
readonly states: {
|
|
108
|
-
readonly [name: string]: StateConfig<Ctx, E>;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
248
|
/** @noSelf */
|
|
112
|
-
|
|
113
|
-
|
|
249
|
+
interface CompoundState<Ctx, E extends EventObject, T, Self extends string, To extends string> extends StateBase<Ctx, E, T, Self, To> {
|
|
250
|
+
/**
|
|
251
|
+
* `"parallel"` keeps every child active at once, each as a region with its own active state.
|
|
252
|
+
* Not allowed on the root.
|
|
253
|
+
*/
|
|
254
|
+
readonly type?: never;
|
|
255
|
+
/**
|
|
256
|
+
* The full path of the child entered with this state, such as `/on/bright` inside `on`.
|
|
257
|
+
* Required when `states` is set, unless the state is parallel.
|
|
258
|
+
*/
|
|
259
|
+
readonly initial?: NoInfer<unknown extends T ? string : `${Self}/${keyof T & string}`>;
|
|
260
|
+
/**
|
|
261
|
+
* Makes the state remember which child was active when it was last left, and enter it again
|
|
262
|
+
* instead of `initial`. The count is how many levels down to restore, and `"all"` restores
|
|
263
|
+
* every level below the state. The first entry uses `initial`, and a move that targets a state
|
|
264
|
+
* inside this one lands on that target.
|
|
265
|
+
*/
|
|
266
|
+
readonly restoreDepth?: NoInfer<TreeDepth<T, 4> | "all">;
|
|
114
267
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} ? string : never : PathsBelow<Children[K], PathDepth[D]>}`;
|
|
122
|
-
}[keyof Children & string] : never;
|
|
123
|
-
export type StatePath<C> = `/${PathsBelow<C, 4>}`;
|
|
124
|
-
type NextCount = [never, 2, 3, 4, 5, 6];
|
|
125
|
-
type RestoreCountBelow<Children, D extends number> = {
|
|
126
|
-
[K in keyof Children]: RestoreCount<Children[K], D>;
|
|
127
|
-
}[keyof Children];
|
|
128
|
-
type RestoreCount<S, D extends number> = S extends {
|
|
129
|
-
readonly states: infer Children;
|
|
130
|
-
} ? [D] extends [never] ? number : S extends {
|
|
268
|
+
/** @noSelf */
|
|
269
|
+
interface ParallelState<Ctx, E extends EventObject, T, Self extends string, To extends string> extends StateBase<Ctx, E, T, Self, To> {
|
|
270
|
+
/**
|
|
271
|
+
* `"parallel"` keeps every child active at once, each as a region with its own active state.
|
|
272
|
+
* Not allowed on the root.
|
|
273
|
+
*/
|
|
131
274
|
readonly type: "parallel";
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
readonly to?: T;
|
|
135
|
-
readonly when?: unknown;
|
|
136
|
-
readonly run?: unknown;
|
|
275
|
+
readonly initial?: never;
|
|
276
|
+
readonly restoreDepth?: never;
|
|
137
277
|
}
|
|
138
|
-
type
|
|
139
|
-
type
|
|
140
|
-
readonly
|
|
141
|
-
readonly
|
|
142
|
-
readonly type: "parallel";
|
|
143
|
-
} ? never : S extends {
|
|
144
|
-
readonly states: infer Children;
|
|
145
|
-
} ? `${Self}/${keyof Children & string}` : never;
|
|
146
|
-
readonly restoreDepth?: S extends {
|
|
147
|
-
readonly type: "parallel";
|
|
148
|
-
} ? never : S extends {
|
|
149
|
-
readonly states: object;
|
|
150
|
-
} ? RestoreCount<S, 4> | "all" : never;
|
|
151
|
-
readonly states?: S extends {
|
|
152
|
-
readonly states: infer Children;
|
|
153
|
-
} ? {
|
|
154
|
-
readonly [K in keyof Children]: PathCheck<Children[K], `${Self}/${K & string}`, All, Ev>;
|
|
155
|
-
} : unknown;
|
|
156
|
-
readonly on?: S extends {
|
|
157
|
-
readonly on: infer On;
|
|
158
|
-
} ? {
|
|
159
|
-
readonly [K in keyof On]: K extends Ev ? SpecCheck<All> : never;
|
|
160
|
-
} : unknown;
|
|
161
|
-
readonly after?: S extends {
|
|
162
|
-
readonly after: infer After;
|
|
163
|
-
} ? {
|
|
164
|
-
readonly [K in keyof After]: All;
|
|
165
|
-
} : unknown;
|
|
166
|
-
readonly always?: S extends {
|
|
167
|
-
readonly always: unknown;
|
|
168
|
-
} ? SpecCheck<All> : unknown;
|
|
169
|
-
readonly enter?: unknown;
|
|
170
|
-
readonly exit?: unknown;
|
|
171
|
-
readonly update?: unknown;
|
|
172
|
-
readonly task?: unknown;
|
|
278
|
+
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>;
|
|
279
|
+
type RootState<Ctx, E extends EventObject, T> = CompoundState<Ctx, E, T, "", NoInfer<SlotPath<T>>> & {
|
|
280
|
+
readonly initial: string;
|
|
281
|
+
readonly states: object;
|
|
173
282
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
283
|
+
/**
|
|
284
|
+
* The config of one state. Every field is optional. A state with child `states` is a compound
|
|
285
|
+
* state and needs an `initial`, unless its `type` is `"parallel"`; a state without children is a
|
|
286
|
+
* leaf.
|
|
287
|
+
*/
|
|
288
|
+
export type StateConfig<Ctx, E extends EventObject> = StateNode<Ctx, E, unknown, string, string>;
|
|
289
|
+
/**
|
|
290
|
+
* The root config passed to `defineMachine`. It takes the fields of a state and requires
|
|
291
|
+
* `initial` and `states`. The root has no name and cannot be parallel.
|
|
292
|
+
*/
|
|
293
|
+
export type MachineConfig<Ctx, E extends EventObject> = CompoundState<Ctx, E, unknown, string, string> & {
|
|
294
|
+
readonly initial: string;
|
|
295
|
+
readonly states: {
|
|
296
|
+
readonly [name: string]: StateConfig<Ctx, E>;
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* Defines a machine in two calls: `defineMachine<Ctx, E>()` fixes the context and event types and
|
|
301
|
+
* takes an optional hot-reload key, and the second call takes the config. The config is checked
|
|
302
|
+
* when that call runs, and a mistake throws, naming the state path. With a key, a later
|
|
303
|
+
* definition under it puts its states into the machine already built, so every running instance
|
|
304
|
+
* sees the edit; without one, each call builds a separate machine.
|
|
305
|
+
*/
|
|
306
|
+
export declare function defineMachine<Ctx, E extends EventObject>(key?: string): <T>(config: RootState<Ctx, E, T>) => Machine<Ctx, E, TreePath<T>>;
|
|
179
307
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defold-typescript/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "TypeScript types for the Defold engine's Lua APIs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -85,7 +85,9 @@
|
|
|
85
85
|
"!scripts/lua-types-signature-index.ts",
|
|
86
86
|
"!scripts/fidelity-audit.ts",
|
|
87
87
|
"!scripts/augmentation-namespaces.ts",
|
|
88
|
+
"!scripts/example-loose-types.ts",
|
|
88
89
|
"!scripts/example-pins.ts",
|
|
90
|
+
"!scripts/example-scope-parity.ts",
|
|
89
91
|
"!scripts/example-semantics.ts",
|
|
90
92
|
"!scripts/example-surfaces.ts",
|
|
91
93
|
"!scripts/example-typecheck.ts",
|