@menapo/machine 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +135 -2
- package/dist/chart-BWjU2VF4.js +395 -0
- package/dist/compiled.d.ts +58 -0
- package/dist/compiled.js +43 -0
- package/dist/component-DDXOyYUI.d.ts +147 -0
- package/dist/dev-BAz6e3W-.js +79 -0
- package/dist/dom.d.ts +187 -0
- package/dist/dom.js +659 -0
- package/dist/glue/preact.d.ts +4 -0
- package/dist/glue/preact.js +54 -0
- package/dist/glue/react.d.ts +4 -0
- package/dist/glue/react.js +50 -0
- package/dist/glue/solid.d.ts +4 -0
- package/dist/glue/solid.js +42 -0
- package/dist/glue/svelte.svelte.d.ts +4 -0
- package/dist/glue/svelte.svelte.js +57 -0
- package/dist/glue/vanilla.d.ts +4 -0
- package/dist/glue/vanilla.js +83 -0
- package/dist/glue/vue.d.ts +4 -0
- package/dist/glue/vue.js +41 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +582 -0
- package/dist/inspect-BmyLUhcy.js +74 -0
- package/dist/inspect-C3qosuCm.d.ts +22 -0
- package/dist/instance-BM2UqeXW.js +418 -0
- package/dist/machine-BstWHtWL.d.ts +335 -0
- package/dist/naming-Csj5186j.js +492 -0
- package/dist/records-7FFepzo9.js +10 -0
- package/dist/source-DdFTPjID.js +15 -0
- package/dist/test.d.ts +63 -0
- package/dist/test.js +262 -0
- package/dist/types-Bk8svtO6.d.ts +580 -0
- package/dist/vicss.d.ts +19 -0
- package/dist/vicss.js +51 -0
- package/dist/vite.d.ts +27 -0
- package/dist/vite.js +4281 -0
- package/package.json +87 -3
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { a as warnOnce, r as fail } from "./dev-BAz6e3W-.js";
|
|
2
|
+
//#region src/core/env.ts
|
|
3
|
+
/**
|
|
4
|
+
* Whether dev checks and messages run (PLAN §1, principle 4). Vite replaces
|
|
5
|
+
* `import.meta.env.DEV` with a literal, so a production build drops every
|
|
6
|
+
* `if (DEV)` branch and the messages in it (tests/production.test.ts checks
|
|
7
|
+
* the bundle). Without Vite (plain Node, wrangler's esbuild, a CDN) `env` is
|
|
8
|
+
* undefined, and the checks are off instead of throwing.
|
|
9
|
+
*/
|
|
10
|
+
const DEV = !!import.meta.env?.DEV;
|
|
11
|
+
/**
|
|
12
|
+
* Whether normalising a machine checks its config: in development, and in
|
|
13
|
+
* the plugin's build-time compilation (M7), which runs this normaliser in
|
|
14
|
+
* Node, where `import.meta.env` is undefined, and turns its errors into
|
|
15
|
+
* build errors. Only {@link checkAlways} assigns it, and only the plugin
|
|
16
|
+
* imports that, so an app's bundle never does and the bundler reads it as
|
|
17
|
+
* `DEV`, dropping the checks from production builds as before.
|
|
18
|
+
*/
|
|
19
|
+
let CHECK = DEV;
|
|
20
|
+
/**
|
|
21
|
+
* Dev-only bookkeeping: how deep the running code is inside actions, so a
|
|
22
|
+
* context write elsewhere can be named (D5). Only read and written behind
|
|
23
|
+
* `DEV`, so production builds drop it.
|
|
24
|
+
*/
|
|
25
|
+
const dev = { acting: 0 };
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../glue/src/record.ts
|
|
28
|
+
/**
|
|
29
|
+
* The record kit's state lives in (machine PLAN D5, spike S1; store PLAN
|
|
30
|
+
* D3): values in an array behind one accessor per field, defined once per
|
|
31
|
+
* key set on a class's prototype, and a change mask with one bit per field.
|
|
32
|
+
* A read is a few ns, and no proxy or snapshot is involved. `@menapo/machine`
|
|
33
|
+
* lays out context and props by `bit`, `@menapo/store` its stores by `bit`
|
|
34
|
+
* and `defineAccessors`, so the bit layout exists once. Machine writes its
|
|
35
|
+
* accessor loop out: the call cost its toggle's size gate 12 B.
|
|
36
|
+
*
|
|
37
|
+
* Read tracking stays with each owner: machine records one mask per
|
|
38
|
+
* derived value, the store one mask per store a derived value read.
|
|
39
|
+
*/
|
|
40
|
+
/** The bit of field `n`: fields past the 31st share the last bit. */
|
|
41
|
+
const bit = (n) => 1 << Math.min(n, 31);
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/core/store.ts
|
|
44
|
+
/**
|
|
45
|
+
* Context and props as objects with one accessor per field, defined once per
|
|
46
|
+
* machine on a prototype (D5, spike S1), with the bit layout of
|
|
47
|
+
* `@menapo/glue`'s record, which the store shares: a read is a few ns, a write that
|
|
48
|
+
* changes the value sets the field's bit in a change mask, and no proxy or
|
|
49
|
+
* snapshot is involved. Reads also record their bits while a derived value
|
|
50
|
+
* is being computed, so it is recomputed only when what it read changes.
|
|
51
|
+
*/
|
|
52
|
+
/** Bits read since the innermost derived value started computing. */
|
|
53
|
+
let reads = 0;
|
|
54
|
+
const track = (bits) => {
|
|
55
|
+
reads |= bits;
|
|
56
|
+
};
|
|
57
|
+
/** Starts recording reads afresh, or ends a recording: returns what was recorded. Parts record their attributes' reads with it. */
|
|
58
|
+
const swap = (bits) => {
|
|
59
|
+
const read = reads;
|
|
60
|
+
reads = bits;
|
|
61
|
+
return read;
|
|
62
|
+
};
|
|
63
|
+
/** Dev only: the name of the machine a store belongs to, for messages. */
|
|
64
|
+
const nameOf = (store) => store.i.M.name;
|
|
65
|
+
/** A class with an accessor per name; `get(k)` and `set(k)` make each one's pair. */
|
|
66
|
+
function accessors(names, get, set) {
|
|
67
|
+
class Values {
|
|
68
|
+
v;
|
|
69
|
+
m = 0;
|
|
70
|
+
i;
|
|
71
|
+
constructor(values, instance) {
|
|
72
|
+
this.v = values;
|
|
73
|
+
this.i = instance;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
names.forEach((name, k) => {
|
|
77
|
+
Object.defineProperty(Values.prototype, name, {
|
|
78
|
+
configurable: true,
|
|
79
|
+
get: get(k),
|
|
80
|
+
set: set?.(k, name)
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return Values;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Context (`writable`) or props, over `this.v[k]`. Context is written by
|
|
87
|
+
* actions only (D5: anywhere else throws in dev); props are the owner's,
|
|
88
|
+
* and only bindable ones (which `bindable` redefines) can be written.
|
|
89
|
+
*/
|
|
90
|
+
function storeClass(names, first, writable) {
|
|
91
|
+
const Values = accessors(names, (k) => {
|
|
92
|
+
const mask = bit(first + k);
|
|
93
|
+
return function() {
|
|
94
|
+
reads |= mask;
|
|
95
|
+
return this.v[k];
|
|
96
|
+
};
|
|
97
|
+
}, (k, name) => {
|
|
98
|
+
const mask = bit(first + k);
|
|
99
|
+
return writable ? function(value) {
|
|
100
|
+
if (DEV && !dev.acting) fail("CONTEXT_WRITE", nameOf(this), `context.${name} was written outside an action. Write context in a transition's \`do\`, \`entry\` or \`exit\`, and send an event from here instead.`);
|
|
101
|
+
if (this.v[k] !== value) {
|
|
102
|
+
this.v[k] = value;
|
|
103
|
+
this.m |= mask;
|
|
104
|
+
}
|
|
105
|
+
} : DEV ? function() {
|
|
106
|
+
fail("PROPS_WRITE", nameOf(this), `props.${name} belongs to the owner and is read-only. Declare it \`${name}: bindable(…)\` to let actions write it.`);
|
|
107
|
+
} : void 0;
|
|
108
|
+
});
|
|
109
|
+
if (writable) Values.s = (machine, given) => {
|
|
110
|
+
const values = machine.df.slice();
|
|
111
|
+
if (given) for (const key of Object.keys(given)) {
|
|
112
|
+
const at = machine.nm.indexOf(key);
|
|
113
|
+
if (DEV && !(at >= 0 && at < values.length)) fail("UNKNOWN_FIELD", machine.name, `start() was given context.${key}, which the machine does not declare; add it to \`context\`.`);
|
|
114
|
+
values[at] = given[key];
|
|
115
|
+
}
|
|
116
|
+
return values;
|
|
117
|
+
};
|
|
118
|
+
return Values;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The derived values' class: each getter returns the cached value while no
|
|
122
|
+
* field it read has changed, else recomputes it with its reads recorded.
|
|
123
|
+
* A value computed while a field it read is changed but not yet told is
|
|
124
|
+
* recomputed on every read until the notification forgets it.
|
|
125
|
+
*/
|
|
126
|
+
function derivedClass(names, fns) {
|
|
127
|
+
const Derived = accessors(names, (k) => function() {
|
|
128
|
+
const c = this.v;
|
|
129
|
+
const instance = this.i;
|
|
130
|
+
const read = c[2 * k];
|
|
131
|
+
if (read === void 0 || read & instance.live()) {
|
|
132
|
+
const outer = reads;
|
|
133
|
+
reads = 0;
|
|
134
|
+
c[2 * k + 1] = fns[k](instance);
|
|
135
|
+
c[2 * k] = reads;
|
|
136
|
+
reads |= outer;
|
|
137
|
+
} else reads |= read;
|
|
138
|
+
return c[2 * k + 1];
|
|
139
|
+
});
|
|
140
|
+
/** Forgets the values that read what `changed` says changed: the interpreter calls it as it notifies. */
|
|
141
|
+
Derived.prototype.f = function(changed) {
|
|
142
|
+
const c = this.v;
|
|
143
|
+
for (let k = 0; k < c.length; k += 2) if (c[k] & changed) c[k] = void 0;
|
|
144
|
+
};
|
|
145
|
+
return Derived;
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/core/instance.ts
|
|
149
|
+
/**
|
|
150
|
+
* The interpreter (PLAN §5.3): a started machine is a few numbers and
|
|
151
|
+
* objects, with every method on the prototype. Events run to completion
|
|
152
|
+
* synchronously (D3): a send made while one is being handled is queued and
|
|
153
|
+
* runs before the outer `send` returns, then subscribers hear once, with
|
|
154
|
+
* the change mask. An unhandled event costs one map lookup and allocates
|
|
155
|
+
* nothing.
|
|
156
|
+
*/
|
|
157
|
+
const IDLE = 0;
|
|
158
|
+
const BUSY = 1;
|
|
159
|
+
const STOPPED = 2;
|
|
160
|
+
const START = { type: "machine.start" };
|
|
161
|
+
/** `always` rules that keep passing this many times in one event are a loop. */
|
|
162
|
+
const ALWAYS_LIMIT = 100;
|
|
163
|
+
/** Context, props or derived values of a machine that declares none. */
|
|
164
|
+
const EMPTY = Object.freeze({});
|
|
165
|
+
function run(fns, view) {
|
|
166
|
+
if (fns) {
|
|
167
|
+
if (DEV) dev.acting++;
|
|
168
|
+
for (const fn of fns) fn(view);
|
|
169
|
+
if (DEV) dev.acting--;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const bindSend = (instance) => instance.sf = (event, payload) => instance.dispatch(event, payload);
|
|
173
|
+
const bindIs = (instance) => instance.wf = (state) => instance.within(state);
|
|
174
|
+
/**
|
|
175
|
+
* D17's hook, set only through `inspect()` (src/inspect.ts): told before each
|
|
176
|
+
* event an instance takes (`null` for owner props) and, with no event, once
|
|
177
|
+
* it is done. Unset, a handled event pays one check and an unhandled one
|
|
178
|
+
* never reaches it; a bundle that never imports `inspect` never assigns it,
|
|
179
|
+
* so the bundler drops the calls.
|
|
180
|
+
*/
|
|
181
|
+
let hook;
|
|
182
|
+
const setHook = (fn) => void (hook = fn);
|
|
183
|
+
/** Dev only: warns, once per name, of an event no state handles, sent now or queued. */
|
|
184
|
+
function unhandled(instance, type) {
|
|
185
|
+
if (!instance.M.handled.has(type)) warnOnce("UNHANDLED", instance.M.name, `no state handles "${type}"; add it to a state's \`on\`, or stop sending it.`);
|
|
186
|
+
}
|
|
187
|
+
var Interpreter = class {
|
|
188
|
+
M;
|
|
189
|
+
/** The active leaf; unset until started. */
|
|
190
|
+
s;
|
|
191
|
+
context;
|
|
192
|
+
props;
|
|
193
|
+
event = START;
|
|
194
|
+
/** IDLE, BUSY or STOPPED. */
|
|
195
|
+
b = IDLE;
|
|
196
|
+
/** STATE_BIT once the state changed in this event. */
|
|
197
|
+
d = 0;
|
|
198
|
+
/** Events sent while busy. */
|
|
199
|
+
q;
|
|
200
|
+
l;
|
|
201
|
+
/** What runs while a state is active: `[state, cleanup or timer, …]` (`effects.ts`). */
|
|
202
|
+
r;
|
|
203
|
+
/** States entered in this event whose timers and effects start once it settles. */
|
|
204
|
+
x;
|
|
205
|
+
/** The owner's props: the shared frozen empty object until an owner gives some (only read or replaced). */
|
|
206
|
+
o = EMPTY;
|
|
207
|
+
/** Owner props to take once the event being handled is done. */
|
|
208
|
+
n;
|
|
209
|
+
/** A move waiting for the owner (`bindable`): the rule's target and the event that asked. */
|
|
210
|
+
p;
|
|
211
|
+
/** `send` and `is`, bound on first use so they can be destructured. */
|
|
212
|
+
sf;
|
|
213
|
+
wf;
|
|
214
|
+
/** Derived values and `done`, made on first read. */
|
|
215
|
+
dq;
|
|
216
|
+
dn;
|
|
217
|
+
constructor(machine, context, owner) {
|
|
218
|
+
this.M = machine;
|
|
219
|
+
const Context = machine.C;
|
|
220
|
+
if (DEV && context && !Context) fail("UNKNOWN_FIELD", machine.name, `start() was given context, but the machine declares none; add \`context\` to it.`);
|
|
221
|
+
this.context = Context ? new Context(Context.s(machine, context), this) : EMPTY;
|
|
222
|
+
this.props = machine.Q ? new machine.Q(machine.pd.slice(), this) : EMPTY;
|
|
223
|
+
if (owner) machine.P?.(this, owner);
|
|
224
|
+
this.go(void 0, START);
|
|
225
|
+
this.mask = 0;
|
|
226
|
+
}
|
|
227
|
+
get state() {
|
|
228
|
+
track(1);
|
|
229
|
+
return this.s.path;
|
|
230
|
+
}
|
|
231
|
+
get send() {
|
|
232
|
+
return this.sf ?? bindSend(this);
|
|
233
|
+
}
|
|
234
|
+
get is() {
|
|
235
|
+
return this.wf ?? bindIs(this);
|
|
236
|
+
}
|
|
237
|
+
get derived() {
|
|
238
|
+
return this.M.D ? this.dq ??= new this.M.D([], this) : EMPTY;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Each part's id and element (`ids.content`, `el.content`): a component's
|
|
242
|
+
* (`parts/component.ts`). An instance `start` made renders nothing, so
|
|
243
|
+
* every part's id and element reads `undefined`, as the types say.
|
|
244
|
+
*/
|
|
245
|
+
get ids() {
|
|
246
|
+
return EMPTY;
|
|
247
|
+
}
|
|
248
|
+
get el() {
|
|
249
|
+
return EMPTY;
|
|
250
|
+
}
|
|
251
|
+
get changed() {
|
|
252
|
+
return this.M.nm.filter((_, n) => this.mask & bit(n + 1));
|
|
253
|
+
}
|
|
254
|
+
get done() {
|
|
255
|
+
return this.dn ??= new Promise((resolve) => this.s.fi ? resolve() : this.subscribe(() => this.s.fi && resolve()));
|
|
256
|
+
}
|
|
257
|
+
within(path) {
|
|
258
|
+
track(1);
|
|
259
|
+
if (DEV && !this.M.ss.some((state) => state.path === path)) fail("UNKNOWN_STATE", this.M.name, `is("${path}") names no state; the states are ${this.M.ss.map((state) => `"${state.path}"`).join(", ")}.`);
|
|
260
|
+
for (let at = this.s; at; at = at.up) if (at.path === path) return true;
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
/** Bits changed in the event being handled and not yet told. */
|
|
264
|
+
live() {
|
|
265
|
+
return this.context.m | this.props.m | this.d;
|
|
266
|
+
}
|
|
267
|
+
subscribe(listener) {
|
|
268
|
+
this.l = this.l ? [...this.l, listener] : [listener];
|
|
269
|
+
return () => {
|
|
270
|
+
const l = this.l.slice();
|
|
271
|
+
l.splice(l.indexOf(listener) >>> 0, 1);
|
|
272
|
+
this.l = l;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
dispatch(event, payload) {
|
|
276
|
+
const named = typeof event === "string";
|
|
277
|
+
const type = named ? event : event.type;
|
|
278
|
+
const handler = this.b ? void 0 : this.s.on.get(type);
|
|
279
|
+
if (this.b === BUSY) (this.q ??= []).push(named ? {
|
|
280
|
+
type,
|
|
281
|
+
...payload
|
|
282
|
+
} : event);
|
|
283
|
+
else if (handler) this.go(handler.ru, !named ? event : payload === void 0 ? handler.ev : {
|
|
284
|
+
type,
|
|
285
|
+
...payload
|
|
286
|
+
});
|
|
287
|
+
else if (DEV) {
|
|
288
|
+
if (this.b) warnOnce("STOPPED", this.M.name, `"${type}" was sent after ${this.s.fi ? `the final state "${this.s.path}"` : "stop()"} and is ignored; start a new instance with start().`);
|
|
289
|
+
else if (typeof type !== "string") fail("BAD_EVENT", this.M.name, `send() was given ${JSON.stringify(event)}; send an event name, or an object with a \`type\`.`);
|
|
290
|
+
else unhandled(this, type);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Handles one thing from idle (an event's rules; else, before start, the
|
|
295
|
+
* initial state; else the owner props in `n`), then runs to completion.
|
|
296
|
+
* After a throw in user code the queue is dropped and the instance accepts
|
|
297
|
+
* events again.
|
|
298
|
+
*/
|
|
299
|
+
go(rules, event) {
|
|
300
|
+
this.b = BUSY;
|
|
301
|
+
hook?.(this, rules || !this.s ? event : null);
|
|
302
|
+
try {
|
|
303
|
+
if (rules) this.take(rules, event);
|
|
304
|
+
else if (!this.s) {
|
|
305
|
+
const { k: control, i0: initial } = this.M;
|
|
306
|
+
this.enter(void 0, control ? control.initial(this, initial) : initial);
|
|
307
|
+
}
|
|
308
|
+
this.settle();
|
|
309
|
+
hook?.(this);
|
|
310
|
+
} finally {
|
|
311
|
+
if (this.b === BUSY) {
|
|
312
|
+
this.b = IDLE;
|
|
313
|
+
this.q = this.n = void 0;
|
|
314
|
+
if (DEV) dev.acting = 0;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/** Takes the first rule whose guard passes; true if one did and nothing waits for the owner. */
|
|
319
|
+
take(rules, event) {
|
|
320
|
+
this.event = event;
|
|
321
|
+
for (const rule of rules) if (!rule.if || rule.if(this)) {
|
|
322
|
+
const p = this.p;
|
|
323
|
+
if (!rule.to) run(rule.do, this);
|
|
324
|
+
else if (!this.M.k?.hold(this, rule)) this.move(rule.to, rule.do);
|
|
325
|
+
return this.p === p;
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Exits up to the nearest common ancestor strictly above the target, runs
|
|
331
|
+
* the rule's actions, enters down to the target's leaf. A target the
|
|
332
|
+
* machine is in is exited and entered again, so its timers restart.
|
|
333
|
+
*/
|
|
334
|
+
move(to, actions) {
|
|
335
|
+
const from = this.s;
|
|
336
|
+
let a = from;
|
|
337
|
+
let b = to.up;
|
|
338
|
+
while (a !== b) if (a.i > b.i) a = a.up;
|
|
339
|
+
else b = b.up;
|
|
340
|
+
for (let at = from; at !== a; at = at.up) this.exit(at);
|
|
341
|
+
run(actions, this);
|
|
342
|
+
this.enter(a, to.lf);
|
|
343
|
+
this.M.k?.moved(this, from);
|
|
344
|
+
}
|
|
345
|
+
/** Enters every state below `from` down to `to`, outermost first; timers and effects start once the event settles. */
|
|
346
|
+
enter(from, to) {
|
|
347
|
+
if (to.up !== from && to.up.i >= 0) this.enter(from, to.up);
|
|
348
|
+
this.s = to;
|
|
349
|
+
this.d = 1;
|
|
350
|
+
run(to.en, this);
|
|
351
|
+
if (to.af || to.ef) (this.x ??= []).push(to);
|
|
352
|
+
}
|
|
353
|
+
/** Stops what state `at` runs, latest first, then runs its exit actions. */
|
|
354
|
+
exit(at) {
|
|
355
|
+
if (this.r || this.x) this.M.X(this, at);
|
|
356
|
+
run(at.ex, this);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Sets the timers and starts the effects of states entered in this event
|
|
360
|
+
* that are still active. The glue's subclass defers it until the
|
|
361
|
+
* framework has committed the DOM, and never runs it on a server (D13).
|
|
362
|
+
*/
|
|
363
|
+
activate(states) {
|
|
364
|
+
this.M.A?.(this, states);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Runs to completion: `always` rules, queued events, owner props that
|
|
368
|
+
* arrived meanwhile and new states' effects, then one notification;
|
|
369
|
+
* again while listeners send.
|
|
370
|
+
*/
|
|
371
|
+
settle() {
|
|
372
|
+
for (;;) {
|
|
373
|
+
for (let n = 0; this.b === BUSY && this.s.al && this.take(this.s.al, this.event);) if (DEV && ++n > ALWAYS_LIMIT) fail("ALWAYS_LOOP", this.M.name, `"${this.s.path}" took an \`always\` transition ${ALWAYS_LIMIT} times in one event; give it an \`if\` that turns false.`);
|
|
374
|
+
if (this.b !== BUSY) return;
|
|
375
|
+
const { q, n, x } = this;
|
|
376
|
+
if (q?.length) {
|
|
377
|
+
const event = q.shift();
|
|
378
|
+
const handler = this.s.on.get(event.type);
|
|
379
|
+
if (handler) {
|
|
380
|
+
hook?.(this, event);
|
|
381
|
+
this.take(handler.ru, event);
|
|
382
|
+
} else if (DEV) unhandled(this, event.type);
|
|
383
|
+
} else if (n) {
|
|
384
|
+
this.n = void 0;
|
|
385
|
+
this.M.P(this, n);
|
|
386
|
+
} else if (x) {
|
|
387
|
+
this.x = void 0;
|
|
388
|
+
this.activate(x);
|
|
389
|
+
} else {
|
|
390
|
+
const changed = this.live();
|
|
391
|
+
if (!changed) break;
|
|
392
|
+
if (this.context.m) this.context.m = 0;
|
|
393
|
+
if (this.props.m) this.props.m = 0;
|
|
394
|
+
this.d = 0;
|
|
395
|
+
this.mask = changed;
|
|
396
|
+
this.dq?.f(changed);
|
|
397
|
+
if (this.l) for (const listener of this.l) listener(this);
|
|
398
|
+
if (!this.q?.length && !this.n) break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (this.s.fi) this.stop();
|
|
402
|
+
}
|
|
403
|
+
setProps(owner) {
|
|
404
|
+
this.M.P?.(this, owner, true);
|
|
405
|
+
}
|
|
406
|
+
stop() {
|
|
407
|
+
this.b = STOPPED;
|
|
408
|
+
this.q = void 0;
|
|
409
|
+
this.M.X?.(this);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Creates and starts an instance (PLAN §4.1, §4.8): enters the initial
|
|
414
|
+
* state, runs its entry actions, starts its effects and timers.
|
|
415
|
+
*/
|
|
416
|
+
const start = (machine, options) => new Interpreter(machine, options?.context, options?.props);
|
|
417
|
+
//#endregion
|
|
418
|
+
export { start as a, swap as c, CHECK as d, DEV as f, setHook as i, track as l, hook as n, derivedClass as o, dev as p, run as r, storeClass as s, Interpreter as t, bit as u };
|