@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.25
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/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +46 -47
- package/dist/debug/api/RaphFacadeSession.cjs +1 -1
- package/dist/debug/api/RaphFacadeSession.js +85 -89
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
- package/dist/debug/api/RaphReactivityInstance.js +27 -30
- package/dist/debug/path/DataPath.cjs +1 -1
- package/dist/debug/path/DataPath.js +198 -202
- package/dist/debug/path/PathRouter.cjs +1 -1
- package/dist/debug/path/PathRouter.js +44 -50
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +257 -228
- package/dist/debug/path/data-path.utils.cjs +1 -1
- package/dist/debug/path/data-path.utils.js +41 -41
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
- package/dist/debug/path/derived/DerivedRegistry.js +52 -66
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
- package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
- package/dist/debug/path/derived/derived-collection.utils.js +70 -70
- package/dist/debug/path/meta/MetaController.cjs +1 -1
- package/dist/debug/path/meta/MetaController.js +57 -65
- package/dist/debug/path/meta/RaphMeta.cjs +1 -1
- package/dist/debug/path/meta/RaphMeta.js +26 -32
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
- package/dist/debug/path/meta/RaphMetaStore.js +24 -30
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
- package/dist/debug/path/storage/AdapterPathStore.js +49 -54
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
- package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
- package/dist/debug/path/storage/PathEventHub.cjs +1 -1
- package/dist/debug/path/storage/PathEventHub.js +74 -61
- package/dist/debug/path/storage/PathStore.cjs +1 -1
- package/dist/debug/path/storage/PathStore.js +89 -99
- package/dist/debug/path/storage/createDataDraft.cjs +1 -1
- package/dist/debug/path/storage/createDataDraft.js +24 -28
- package/dist/debug/reactivity/disposal.cjs +1 -0
- package/dist/debug/reactivity/disposal.js +32 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +787 -392
- package/dist/debug/reactivity/reactive-object.cjs +1 -1
- package/dist/debug/reactivity/reactive-object.js +81 -96
- package/dist/debug/reactivity/scope.cjs +1 -1
- package/dist/debug/reactivity/scope.js +221 -117
- package/dist/debug/reactivity/watch.cjs +1 -1
- package/dist/debug/reactivity/watch.js +1 -1
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +764 -411
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
- package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphNode.js +595 -136
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphScope.js +203 -68
- package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
- package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
- package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
- package/dist/entrypoints/runtime.d.ts +2 -1
- package/dist/machine-testing.cjs +1 -1
- package/dist/machine-testing.js +1 -1
- package/dist/machine.cjs +1 -1
- package/dist/machine.js +216 -231
- package/dist/path/RaphKernel.d.ts +24 -0
- package/dist/path/storage/PathEventHub.d.ts +14 -0
- package/dist/path/storage/PathStore.d.ts +4 -4
- package/dist/reactivity/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +177 -4
- package/dist/reactivity/scope.d.ts +108 -30
- package/dist/runtime/RaphRuntime.d.ts +236 -17
- package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
- package/dist/runtime/ownership/RaphNode.d.ts +276 -6
- package/dist/runtime/ownership/RaphScope.d.ts +144 -14
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/phase.types.d.ts +83 -4
- package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
- package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
- package/package.json +9 -1
- package/dist/core-ugchZNqC.cjs +0 -1
|
@@ -1,84 +1,80 @@
|
|
|
1
1
|
const Z = /* @__PURE__ */ new WeakMap(), mt = 16384;
|
|
2
2
|
function Jt(t) {
|
|
3
|
-
|
|
4
|
-
if ($t(t.id, t.version), typeof t.states != "object" || t.states === null || Array.isArray(t.states))
|
|
3
|
+
if (Tt(t.id, t.version), typeof t.states != "object" || t.states === null || Array.isArray(t.states))
|
|
5
4
|
throw new TypeError("[Raph machine] states must be an object.");
|
|
6
|
-
const e = t, n = [], r = /* @__PURE__ */ new Map(),
|
|
7
|
-
for (const [
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
5
|
+
const e = t, n = [], r = /* @__PURE__ */ new Map(), o = [];
|
|
6
|
+
for (const [f, w] of Object.entries(e.states))
|
|
7
|
+
o.push(ct(f, w, void 0, 0, n, r));
|
|
8
|
+
const i = r.get(t.initial);
|
|
9
|
+
if (i === void 0 || n[i]?.parent !== void 0)
|
|
11
10
|
throw new Error(`[Raph machine] Initial state "${t.initial}" must be a root state key.`);
|
|
12
|
-
const s = /* @__PURE__ */ new Set(), a = n.map((
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
throw new Error(`[Raph machine] Compound state "${h.path}" cannot use history as its initial child.`);
|
|
21
|
-
const E = h.historyFallbackPath === void 0 ? void 0 : r.get(h.historyFallbackPath);
|
|
22
|
-
if (h.historyFallbackPath !== void 0 && E === void 0)
|
|
11
|
+
const s = /* @__PURE__ */ new Set(), a = n.map((f) => {
|
|
12
|
+
const w = f.initialKey === void 0 ? void 0 : f.children.find((g) => n[g]?.key === f.initialKey);
|
|
13
|
+
if (f.kind === "compound" && w === void 0)
|
|
14
|
+
throw new Error(`[Raph machine] Compound state "${f.path}" requires a valid direct initial child.`);
|
|
15
|
+
if (w !== void 0 && n[w].kind === "history")
|
|
16
|
+
throw new Error(`[Raph machine] Compound state "${f.path}" cannot use history as its initial child.`);
|
|
17
|
+
const b = f.historyFallbackPath === void 0 ? void 0 : r.get(f.historyFallbackPath);
|
|
18
|
+
if (f.historyFallbackPath !== void 0 && b === void 0)
|
|
23
19
|
throw new Error(
|
|
24
|
-
`[Raph machine] History state "${
|
|
20
|
+
`[Raph machine] History state "${f.path}" has unknown fallback "${f.historyFallbackPath}".`
|
|
25
21
|
);
|
|
26
|
-
for (const
|
|
27
|
-
s.add(
|
|
22
|
+
for (const g of f.on.keys())
|
|
23
|
+
s.add(g);
|
|
28
24
|
return {
|
|
29
|
-
after:
|
|
30
|
-
always:
|
|
31
|
-
children: Object.freeze([...
|
|
32
|
-
depth:
|
|
33
|
-
entry:
|
|
34
|
-
exit:
|
|
35
|
-
history:
|
|
36
|
-
...
|
|
37
|
-
id:
|
|
38
|
-
...
|
|
39
|
-
invokes:
|
|
40
|
-
key:
|
|
41
|
-
kind:
|
|
42
|
-
...
|
|
43
|
-
on:
|
|
44
|
-
onDone:
|
|
45
|
-
...
|
|
46
|
-
...
|
|
47
|
-
path:
|
|
48
|
-
resources:
|
|
49
|
-
tags:
|
|
25
|
+
after: f.after,
|
|
26
|
+
always: f.always,
|
|
27
|
+
children: Object.freeze([...f.children]),
|
|
28
|
+
depth: f.depth,
|
|
29
|
+
entry: f.entry,
|
|
30
|
+
exit: f.exit,
|
|
31
|
+
history: f.history,
|
|
32
|
+
...b === void 0 ? {} : { historyFallback: b },
|
|
33
|
+
id: f.id,
|
|
34
|
+
...w === void 0 ? {} : { initial: w },
|
|
35
|
+
invokes: f.invokes,
|
|
36
|
+
key: f.key,
|
|
37
|
+
kind: f.kind,
|
|
38
|
+
...f.meta === void 0 ? {} : { meta: f.meta },
|
|
39
|
+
on: f.on,
|
|
40
|
+
onDone: f.onDone,
|
|
41
|
+
...f.output === void 0 ? {} : { output: f.output },
|
|
42
|
+
...f.parent === void 0 ? {} : { parent: f.parent },
|
|
43
|
+
path: f.path,
|
|
44
|
+
resources: f.resources,
|
|
45
|
+
tags: f.tags
|
|
50
46
|
};
|
|
51
47
|
});
|
|
52
|
-
for (const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const
|
|
48
|
+
for (const f of a)
|
|
49
|
+
St(f, r, a);
|
|
50
|
+
const u = t.version ?? 1;
|
|
51
|
+
$t(a);
|
|
52
|
+
const h = Object.freeze([...s]), c = new Map(h.map((f, w) => [f, w])), d = Object.freeze(a.map((f) => Object.freeze(Et(a, f.id)))), l = gt(a), y = l && h.length <= Math.floor(
|
|
57
53
|
mt / a.length
|
|
58
|
-
) ? jt(a,
|
|
54
|
+
) ? jt(a, c, h.length) : void 0, v = Object.freeze({
|
|
59
55
|
ancestry: d,
|
|
60
56
|
context: It(e.context),
|
|
61
|
-
eventIndexes:
|
|
62
|
-
eventTypes:
|
|
63
|
-
flat:
|
|
64
|
-
...
|
|
57
|
+
eventIndexes: c,
|
|
58
|
+
eventTypes: h,
|
|
59
|
+
flat: l,
|
|
60
|
+
...y === void 0 ? {} : { flatDispatch: y },
|
|
65
61
|
id: t.id,
|
|
66
|
-
initial:
|
|
67
|
-
migrations: At(t.migrations,
|
|
62
|
+
initial: i,
|
|
63
|
+
migrations: At(t.migrations, u),
|
|
68
64
|
...e.output === void 0 ? {} : { output: e.output },
|
|
69
65
|
pathToState: r,
|
|
70
|
-
rootChildren: Object.freeze(
|
|
66
|
+
rootChildren: Object.freeze(o),
|
|
71
67
|
states: Object.freeze(a),
|
|
72
|
-
version:
|
|
73
|
-
}), m = Object.freeze({ id: t.id, version:
|
|
74
|
-
return Z.set(m,
|
|
68
|
+
version: u
|
|
69
|
+
}), m = Object.freeze({ id: t.id, version: u });
|
|
70
|
+
return Z.set(m, v), m;
|
|
75
71
|
}
|
|
76
72
|
function jt(t, e, n) {
|
|
77
73
|
const r = Array.from({ length: t.length * n }).fill(void 0);
|
|
78
|
-
for (const
|
|
79
|
-
const
|
|
80
|
-
for (const [s, a] of
|
|
81
|
-
r[
|
|
74
|
+
for (const o of t) {
|
|
75
|
+
const i = o.id * n;
|
|
76
|
+
for (const [s, a] of o.on)
|
|
77
|
+
r[i + e.get(s)] = a;
|
|
82
78
|
}
|
|
83
79
|
return Object.freeze(r);
|
|
84
80
|
}
|
|
@@ -88,7 +84,7 @@ function Et(t, e) {
|
|
|
88
84
|
n.push(r);
|
|
89
85
|
return n;
|
|
90
86
|
}
|
|
91
|
-
function
|
|
87
|
+
function gt(t) {
|
|
92
88
|
return t.every((e) => {
|
|
93
89
|
if (e.parent !== void 0 || e.kind !== "atomic" && e.kind !== "final" || e.always.length !== 0 || e.onDone.length !== 0 || e.after.size !== 0 || e.entry.length !== 0 || e.exit.length !== 0 || e.resources.length !== 0 || e.invokes.length !== 0)
|
|
94
90
|
return !1;
|
|
@@ -104,14 +100,14 @@ function F(t) {
|
|
|
104
100
|
throw new TypeError("[Raph machine] Model was not created by defineMachine().");
|
|
105
101
|
return e;
|
|
106
102
|
}
|
|
107
|
-
function ct(t, e, n, r,
|
|
103
|
+
function ct(t, e, n, r, o, i) {
|
|
108
104
|
if (typeof e != "object" || e === null || Array.isArray(e))
|
|
109
105
|
throw new TypeError(`[Raph machine] State "${t}" must be an object.`);
|
|
110
|
-
|
|
111
|
-
const s = n === void 0 ? "" :
|
|
112
|
-
if (
|
|
106
|
+
kt(e, t), Mt(t);
|
|
107
|
+
const s = n === void 0 ? "" : o[n].path, a = s ? `${s}.${t}` : t, u = o.length;
|
|
108
|
+
if (i.has(a))
|
|
113
109
|
throw new Error(`[Raph machine] Duplicate state path "${a}".`);
|
|
114
|
-
const
|
|
110
|
+
const h = zt(e), c = {
|
|
115
111
|
after: /* @__PURE__ */ new Map(),
|
|
116
112
|
always: Object.freeze([]),
|
|
117
113
|
children: [],
|
|
@@ -120,11 +116,11 @@ function ct(t, e, n, r, i, o) {
|
|
|
120
116
|
exit: P(e.exit),
|
|
121
117
|
history: e.history ?? "shallow",
|
|
122
118
|
...e.target === void 0 ? {} : { historyFallbackPath: e.target },
|
|
123
|
-
id:
|
|
119
|
+
id: u,
|
|
124
120
|
...e.initial === void 0 ? {} : { initialKey: e.initial },
|
|
125
121
|
invokes: Object.freeze([]),
|
|
126
122
|
key: t,
|
|
127
|
-
kind:
|
|
123
|
+
kind: h,
|
|
128
124
|
...e.meta === void 0 ? {} : { meta: Object.freeze({ ...e.meta }) },
|
|
129
125
|
on: /* @__PURE__ */ new Map(),
|
|
130
126
|
onDone: Object.freeze([]),
|
|
@@ -134,43 +130,43 @@ function ct(t, e, n, r, i, o) {
|
|
|
134
130
|
resources: ot(e.resources),
|
|
135
131
|
tags: ot(e.tags)
|
|
136
132
|
};
|
|
137
|
-
|
|
138
|
-
for (const [
|
|
139
|
-
|
|
133
|
+
o.push(c), i.set(a, u);
|
|
134
|
+
for (const [y, v] of Object.entries(e.states ?? {}))
|
|
135
|
+
c.children.push(ct(y, v, u, r + 1, o, i));
|
|
140
136
|
let d = 0;
|
|
141
|
-
for (const [
|
|
142
|
-
if (!
|
|
137
|
+
for (const [y, v] of Object.entries(e.on ?? {})) {
|
|
138
|
+
if (!y.trim())
|
|
143
139
|
throw new Error(`[Raph machine] State "${a}" has an empty event type.`);
|
|
144
|
-
|
|
140
|
+
c.on.set(y, M(v, u, () => d++));
|
|
145
141
|
}
|
|
146
|
-
|
|
147
|
-
for (const [
|
|
148
|
-
if (!
|
|
142
|
+
c.always = M(e.always, u, () => d++), c.onDone = M(e.onDone, u, () => d++);
|
|
143
|
+
for (const [y, v] of Object.entries(e.after ?? {})) {
|
|
144
|
+
if (!y.trim())
|
|
149
145
|
throw new Error(`[Raph machine] State "${a}" has an empty delay key.`);
|
|
150
|
-
|
|
146
|
+
c.after.set(y, M(v, u, () => d++));
|
|
151
147
|
}
|
|
152
|
-
const
|
|
153
|
-
return
|
|
148
|
+
const l = Pt(e.invoke);
|
|
149
|
+
return c.invokes = Object.freeze(l.map((y, v) => xt(
|
|
150
|
+
y,
|
|
151
|
+
c,
|
|
154
152
|
v,
|
|
155
|
-
f,
|
|
156
|
-
w,
|
|
157
153
|
() => d++
|
|
158
|
-
))), Rt(
|
|
154
|
+
))), Rt(c, o), u;
|
|
159
155
|
}
|
|
160
|
-
function
|
|
156
|
+
function xt(t, e, n, r) {
|
|
161
157
|
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
162
158
|
throw new TypeError(`[Raph machine] Invoke in "${e.path}" must be an object.`);
|
|
163
|
-
const
|
|
159
|
+
const o = typeof t.src == "string" ? "task" : "machine", i = t.type ?? o, s = t.id ?? `${e.path}:invoke#${n + 1}`;
|
|
164
160
|
if (!s.trim())
|
|
165
161
|
throw new Error(`[Raph machine] Invoke id in "${e.path}" must not be empty.`);
|
|
166
|
-
if (
|
|
167
|
-
throw new Error(`[Raph machine] Invoke "${s}" has unsupported type "${String(
|
|
162
|
+
if (i !== "machine" && i !== "task")
|
|
163
|
+
throw new Error(`[Raph machine] Invoke "${s}" has unsupported type "${String(i)}".`);
|
|
168
164
|
if (typeof t.src == "string") {
|
|
169
165
|
if (!t.src.trim())
|
|
170
166
|
throw new Error(`[Raph machine] Invoke "${s}" source must not be empty.`);
|
|
171
167
|
} else if (!Z.has(t.src))
|
|
172
168
|
throw new TypeError(`[Raph machine] Invoke "${s}" actor source must come from defineMachine().`);
|
|
173
|
-
if (
|
|
169
|
+
if (i === "task" && typeof t.src != "string")
|
|
174
170
|
throw new TypeError(`[Raph machine] Task invoke "${s}" requires a string source.`);
|
|
175
171
|
return Object.freeze({
|
|
176
172
|
id: s,
|
|
@@ -178,54 +174,53 @@ function St(t, e, n, r) {
|
|
|
178
174
|
onDone: M(t.onDone, e.id, r),
|
|
179
175
|
onError: M(t.onError, e.id, r),
|
|
180
176
|
src: t.src,
|
|
181
|
-
type:
|
|
177
|
+
type: i
|
|
182
178
|
});
|
|
183
179
|
}
|
|
184
180
|
function M(t, e, n) {
|
|
185
181
|
if (t === void 0)
|
|
186
182
|
return Object.freeze([]);
|
|
187
183
|
const r = Array.isArray(t) ? t : [t];
|
|
188
|
-
return Object.freeze(r.map((
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
184
|
+
return Object.freeze(r.map((o) => {
|
|
185
|
+
const i = typeof o == "string" ? { target: o } : o;
|
|
186
|
+
if (i === null || typeof i != "object")
|
|
191
187
|
throw new TypeError("[Raph machine] Transition must be a target string or object.");
|
|
192
|
-
if (
|
|
188
|
+
if (i.reenter === !0 && i.target === void 0)
|
|
193
189
|
throw new Error("[Raph machine] A targetless transition cannot declare reenter: true.");
|
|
194
|
-
if (
|
|
190
|
+
if (i.reason !== void 0 && (typeof i.reason != "string" || !i.reason.trim()))
|
|
195
191
|
throw new Error("[Raph machine] Transition reason must be a non-empty string.");
|
|
196
|
-
return W(
|
|
197
|
-
emit: P(
|
|
198
|
-
...
|
|
192
|
+
return W(i.guard === void 0 ? [] : [i.guard], "guard"), W(P(i.reduce), "reducer"), W(P(i.emit), "output"), {
|
|
193
|
+
emit: P(i.emit),
|
|
194
|
+
...i.guard === void 0 ? {} : { guard: i.guard },
|
|
199
195
|
index: n(),
|
|
200
|
-
...
|
|
201
|
-
...
|
|
202
|
-
reduce: P(
|
|
203
|
-
reenter:
|
|
196
|
+
...i.raise === void 0 ? {} : { raise: i.raise },
|
|
197
|
+
...i.reason === void 0 ? {} : { reason: i.reason },
|
|
198
|
+
reduce: P(i.reduce),
|
|
199
|
+
reenter: i.reenter === !0,
|
|
204
200
|
source: e,
|
|
205
|
-
...
|
|
201
|
+
...i.target === void 0 ? {} : { target: i.target }
|
|
206
202
|
};
|
|
207
203
|
}));
|
|
208
204
|
}
|
|
209
|
-
function
|
|
210
|
-
var i;
|
|
205
|
+
function St(t, e, n) {
|
|
211
206
|
const r = [t.always, t.onDone, ...t.on.values(), ...t.after.values()];
|
|
212
207
|
for (const o of t.invokes)
|
|
213
208
|
r.push(o.onDone, o.onError);
|
|
214
209
|
for (const o of r)
|
|
215
|
-
for (const
|
|
216
|
-
if (
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
210
|
+
for (const i of o) {
|
|
211
|
+
if (i.target !== void 0) {
|
|
212
|
+
const s = i.target, a = e.get(s);
|
|
213
|
+
if (a === void 0)
|
|
219
214
|
throw new Error(
|
|
220
|
-
`[Raph machine] Transition from "${t.path}" targets unknown state "${
|
|
215
|
+
`[Raph machine] Transition from "${t.path}" targets unknown state "${s}".`
|
|
221
216
|
);
|
|
222
|
-
|
|
217
|
+
i.target = a;
|
|
223
218
|
}
|
|
224
|
-
Object.freeze(
|
|
219
|
+
Object.freeze(i);
|
|
225
220
|
}
|
|
226
221
|
if (t.kind === "history" && t.historyFallback !== void 0) {
|
|
227
|
-
const o =
|
|
228
|
-
if (o === void 0 || o === t.path || t.historyFallback === void 0 || !o.startsWith(`${
|
|
222
|
+
const o = [...e].find(([, s]) => s === t.historyFallback)?.[0], i = t.path.slice(0, t.path.lastIndexOf("."));
|
|
223
|
+
if (o === void 0 || o === t.path || t.historyFallback === void 0 || !o.startsWith(`${i}.`))
|
|
229
224
|
throw new Error(
|
|
230
225
|
`[Raph machine] History fallback for "${t.path}" must stay inside its parent state.`
|
|
231
226
|
);
|
|
@@ -233,7 +228,7 @@ function zt(t, e, n) {
|
|
|
233
228
|
throw new Error(`[Raph machine] History fallback for "${t.path}" cannot target another history state.`);
|
|
234
229
|
}
|
|
235
230
|
}
|
|
236
|
-
function
|
|
231
|
+
function zt(t) {
|
|
237
232
|
if (t.type !== void 0) {
|
|
238
233
|
if (t.type !== "atomic" && t.type !== "compound" && t.type !== "final" && t.type !== "history" && t.type !== "parallel")
|
|
239
234
|
throw new TypeError(`[Raph machine] Unsupported state type "${String(t.type)}".`);
|
|
@@ -257,7 +252,7 @@ function Rt(t, e) {
|
|
|
257
252
|
if ((t.kind === "final" || t.kind === "history") && (t.on.size !== 0 || t.always.length !== 0 || t.after.size !== 0 || t.onDone.length !== 0 || t.invokes.length !== 0))
|
|
258
253
|
throw new Error(`[Raph machine] ${t.kind} state "${t.path}" cannot declare transitions or invokes.`);
|
|
259
254
|
}
|
|
260
|
-
function
|
|
255
|
+
function kt(t, e) {
|
|
261
256
|
if (V(t.states, `State "${e}" states`), V(t.on, `State "${e}" on`), V(t.after, `State "${e}" after`), t.history !== void 0 && t.history !== "deep" && t.history !== "shallow")
|
|
262
257
|
throw new TypeError(`[Raph machine] State "${e}" has unsupported history mode.`);
|
|
263
258
|
}
|
|
@@ -265,14 +260,14 @@ function V(t, e) {
|
|
|
265
260
|
if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
|
|
266
261
|
throw new TypeError(`[Raph machine] ${e} must be an object.`);
|
|
267
262
|
}
|
|
268
|
-
function
|
|
263
|
+
function Tt(t, e) {
|
|
269
264
|
if (typeof t != "string" || !t.trim())
|
|
270
265
|
throw new TypeError("[Raph machine] Model id must be a non-empty string.");
|
|
271
266
|
const n = e ?? 1;
|
|
272
267
|
if (!Number.isSafeInteger(n) || n < 1)
|
|
273
268
|
throw new TypeError("[Raph machine] Model version must be a positive safe integer.");
|
|
274
269
|
}
|
|
275
|
-
function
|
|
270
|
+
function $t(t) {
|
|
276
271
|
const e = /* @__PURE__ */ new Set();
|
|
277
272
|
for (const n of t)
|
|
278
273
|
for (const r of n.invokes) {
|
|
@@ -283,13 +278,13 @@ function kt(t) {
|
|
|
283
278
|
}
|
|
284
279
|
function At(t, e) {
|
|
285
280
|
const n = /* @__PURE__ */ new Map();
|
|
286
|
-
for (const [r,
|
|
287
|
-
const
|
|
288
|
-
if (!Number.isSafeInteger(
|
|
281
|
+
for (const [r, o] of Object.entries(t ?? {})) {
|
|
282
|
+
const i = Number(r);
|
|
283
|
+
if (!Number.isSafeInteger(i) || i < 1 || i >= e)
|
|
289
284
|
throw new Error(`[Raph machine] Migration version "${r}" must be a positive integer below ${e}.`);
|
|
290
|
-
if (typeof
|
|
291
|
-
throw new TypeError(`[Raph machine] Migration from version ${
|
|
292
|
-
n.set(
|
|
285
|
+
if (typeof o != "function")
|
|
286
|
+
throw new TypeError(`[Raph machine] Migration from version ${i} must be a function.`);
|
|
287
|
+
n.set(i, o);
|
|
293
288
|
}
|
|
294
289
|
return n;
|
|
295
290
|
}
|
|
@@ -321,33 +316,33 @@ function It(t) {
|
|
|
321
316
|
return Array.isArray(t) ? Object.freeze([...t]) : typeof t == "object" && t !== null && Object.getPrototypeOf(t) === Object.prototype ? Object.freeze({ ...t }) : t;
|
|
322
317
|
}
|
|
323
318
|
const T = Symbol("RaphMachineSnapshot"), it = /* @__PURE__ */ new WeakMap();
|
|
324
|
-
function
|
|
319
|
+
function ut(t) {
|
|
325
320
|
const e = Object.getPrototypeOf(t);
|
|
326
321
|
return e !== null && Object.hasOwn(e, T) ? e : void 0;
|
|
327
322
|
}
|
|
328
|
-
function
|
|
323
|
+
function ft(t) {
|
|
329
324
|
return t[T];
|
|
330
325
|
}
|
|
331
326
|
function L(t, e, n) {
|
|
332
|
-
const r = n ?? Object.freeze({ [T]: e }),
|
|
333
|
-
return
|
|
327
|
+
const r = n ?? Object.freeze({ [T]: e }), o = Object.create(r);
|
|
328
|
+
return o.active = t.active, o.context = t.context, o.history = t.history, t.output !== void 0 && (o.output = t.output), o.revision = t.revision, o.status = t.status, Object.freeze(o);
|
|
334
329
|
}
|
|
335
|
-
function J(t, e, n, r,
|
|
336
|
-
let
|
|
337
|
-
|
|
338
|
-
const s =
|
|
330
|
+
function J(t, e, n, r, o) {
|
|
331
|
+
let i = t?.flatPrototypes;
|
|
332
|
+
i === void 0 && (n === void 0 ? (i = it.get(r), i === void 0 && (i = [], it.set(r, i))) : i = []);
|
|
333
|
+
const s = i[e];
|
|
339
334
|
if (s !== void 0)
|
|
340
335
|
return s;
|
|
341
336
|
const a = Object.freeze({
|
|
342
337
|
[T]: Object.freeze({
|
|
343
338
|
active: Object.freeze([e]),
|
|
344
|
-
flatPrototypes:
|
|
339
|
+
flatPrototypes: i,
|
|
345
340
|
input: n,
|
|
346
341
|
model: r,
|
|
347
|
-
publicActive: Object.freeze([
|
|
342
|
+
publicActive: Object.freeze([o])
|
|
348
343
|
})
|
|
349
344
|
});
|
|
350
|
-
return
|
|
345
|
+
return i[e] = a, a;
|
|
351
346
|
}
|
|
352
347
|
const Dt = 100, G = Object.freeze({ type: "@@init" }), ht = Object.freeze([]), q = Object.freeze({}), K = Object.freeze([]), D = Object.freeze([]), Ft = Object.freeze([]), Q = Object.freeze({
|
|
353
348
|
entered: K,
|
|
@@ -360,9 +355,9 @@ const Dt = 100, G = Object.freeze({ type: "@@init" }), ht = Object.freeze([]), q
|
|
|
360
355
|
function Qt(t, e) {
|
|
361
356
|
return _t(t, e, void 0).snapshot;
|
|
362
357
|
}
|
|
363
|
-
function te(t, e, n, r,
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
358
|
+
function te(t, e, n, r, o) {
|
|
359
|
+
const i = ft(e);
|
|
360
|
+
if (i !== void 0 && i.model !== t)
|
|
366
361
|
throw new TypeError("[Raph machine] Snapshot belongs to another model.");
|
|
367
362
|
const s = F(t);
|
|
368
363
|
return tt(
|
|
@@ -370,14 +365,13 @@ function te(t, e, n, r, i) {
|
|
|
370
365
|
e,
|
|
371
366
|
n,
|
|
372
367
|
r,
|
|
373
|
-
|
|
374
|
-
|
|
368
|
+
i?.input,
|
|
369
|
+
o,
|
|
375
370
|
s
|
|
376
371
|
).snapshot;
|
|
377
372
|
}
|
|
378
373
|
function Ct(t, e) {
|
|
379
|
-
|
|
380
|
-
if (((n = ft(e)) == null ? void 0 : n[T].model) !== t)
|
|
374
|
+
if (ut(e)?.[T].model !== t)
|
|
381
375
|
throw new TypeError("[Raph machine] Snapshot belongs to another model or was not created by Raph.");
|
|
382
376
|
}
|
|
383
377
|
function ee(t, e) {
|
|
@@ -386,7 +380,7 @@ function ee(t, e) {
|
|
|
386
380
|
e
|
|
387
381
|
), e.status === "stopped")
|
|
388
382
|
return e;
|
|
389
|
-
const n =
|
|
383
|
+
const n = ut(e);
|
|
390
384
|
return L({
|
|
391
385
|
active: e.active,
|
|
392
386
|
context: e.context,
|
|
@@ -397,139 +391,139 @@ function ee(t, e) {
|
|
|
397
391
|
}, n[T], n);
|
|
398
392
|
}
|
|
399
393
|
function _t(t, e, n, r) {
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
394
|
+
const o = F(t), i = o.context, s = typeof i == "function" ? i(e) : i;
|
|
395
|
+
if (o.flat) {
|
|
396
|
+
const h = o.states[o.initial], c = h.kind === "final" ? "done" : "active", d = c === "done" ? h.output ?? o.output : void 0, l = typeof d == "function" ? d({ context: s, event: G, input: e }) : d, y = J(
|
|
403
397
|
void 0,
|
|
404
|
-
|
|
398
|
+
o.initial,
|
|
405
399
|
e,
|
|
406
400
|
t,
|
|
407
|
-
|
|
408
|
-
),
|
|
409
|
-
active:
|
|
401
|
+
h.path
|
|
402
|
+
), v = y[T], m = L({
|
|
403
|
+
active: v.publicActive,
|
|
410
404
|
context: rt(s),
|
|
411
405
|
history: q,
|
|
412
|
-
...
|
|
406
|
+
...l === void 0 ? {} : { output: l },
|
|
413
407
|
revision: 0,
|
|
414
|
-
status:
|
|
415
|
-
},
|
|
408
|
+
status: c
|
|
409
|
+
}, v, y);
|
|
416
410
|
return { changed: !1, plan: Q, snapshot: m };
|
|
417
411
|
}
|
|
418
|
-
const a = $(
|
|
412
|
+
const a = $(o, o.initial, q), u = C(t, e, {
|
|
419
413
|
active: a,
|
|
420
414
|
context: s,
|
|
421
415
|
history: q
|
|
422
|
-
}, 0, "active", void 0,
|
|
423
|
-
return tt(t,
|
|
416
|
+
}, 0, "active", void 0, o);
|
|
417
|
+
return tt(t, u, G, n, e, r, o, !0);
|
|
424
418
|
}
|
|
425
|
-
function tt(t, e, n, r,
|
|
419
|
+
function tt(t, e, n, r, o, i, s, a = !1, u = ht) {
|
|
426
420
|
return Ot(n), Nt(
|
|
427
421
|
t,
|
|
428
422
|
e,
|
|
429
423
|
n,
|
|
430
424
|
r,
|
|
431
|
-
i,
|
|
432
425
|
o,
|
|
426
|
+
i,
|
|
433
427
|
s,
|
|
434
428
|
void 0,
|
|
435
429
|
a,
|
|
436
|
-
|
|
430
|
+
u
|
|
437
431
|
);
|
|
438
432
|
}
|
|
439
|
-
function Nt(t, e, n, r,
|
|
440
|
-
const
|
|
433
|
+
function Nt(t, e, n, r, o, i, s, a, u = !1, h = ht) {
|
|
434
|
+
const c = s ?? F(t);
|
|
441
435
|
if (e.status !== "active")
|
|
442
436
|
return I(e);
|
|
443
|
-
if (!
|
|
444
|
-
const
|
|
445
|
-
return
|
|
437
|
+
if (!u && c.flat) {
|
|
438
|
+
const E = a ?? c.eventIndexes.get(n.type);
|
|
439
|
+
return E === void 0 ? I(e) : Ht(t, c, e, n, E, r, o, i);
|
|
446
440
|
}
|
|
447
|
-
if (!
|
|
441
|
+
if (!u && !Gt(c, e.active, n.type))
|
|
448
442
|
return I(e);
|
|
449
443
|
const d = {
|
|
450
|
-
active: e.active.map((
|
|
444
|
+
active: e.active.map((E) => N(c, E)),
|
|
451
445
|
context: e.context,
|
|
452
446
|
history: { ...e.history }
|
|
453
|
-
},
|
|
454
|
-
let
|
|
455
|
-
if (!
|
|
456
|
-
const
|
|
457
|
-
at(y, v,
|
|
447
|
+
}, l = r, y = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), m = [], f = [], w = [], b = [...h];
|
|
448
|
+
let g = !1;
|
|
449
|
+
if (!u) {
|
|
450
|
+
const E = st(c, d, n, l, o, i);
|
|
451
|
+
at(E, y, v, m, f, w), g = E.changed, b.push(...E.raised);
|
|
458
452
|
}
|
|
459
|
-
const
|
|
460
|
-
let
|
|
453
|
+
const p = /* @__PURE__ */ new Set();
|
|
454
|
+
let O = 0;
|
|
461
455
|
for (; ; ) {
|
|
462
|
-
const
|
|
456
|
+
const E = b.shift();
|
|
463
457
|
let x;
|
|
464
|
-
if (
|
|
465
|
-
|
|
458
|
+
if (E !== void 0 ? x = st(c, d, E, l, o, i) : (x = Kt(c, d, n, l, o, i), x.changed || (x = Lt(
|
|
459
|
+
c,
|
|
466
460
|
d,
|
|
467
461
|
n,
|
|
462
|
+
l,
|
|
463
|
+
o,
|
|
468
464
|
p,
|
|
469
|
-
i
|
|
470
|
-
z,
|
|
471
|
-
o
|
|
465
|
+
i
|
|
472
466
|
))), !x.changed) {
|
|
473
467
|
if (b.length !== 0)
|
|
474
468
|
continue;
|
|
475
469
|
break;
|
|
476
470
|
}
|
|
477
|
-
if (++
|
|
471
|
+
if (++O > Dt)
|
|
478
472
|
throw new Error("[Raph machine] Macrostep exceeded 100 stabilization microsteps.");
|
|
479
473
|
for (const U of x.exited)
|
|
480
|
-
|
|
474
|
+
p.delete(U);
|
|
481
475
|
for (const U of x.entered)
|
|
482
|
-
|
|
483
|
-
|
|
476
|
+
p.delete(U);
|
|
477
|
+
g = !0, at(x, y, v, m, f, w), b.push(...x.raised);
|
|
484
478
|
}
|
|
485
|
-
const
|
|
486
|
-
if (!
|
|
479
|
+
const R = nt(c, d.active) ? "done" : "active";
|
|
480
|
+
if (!g && R === e.status)
|
|
487
481
|
return I(e);
|
|
488
|
-
const
|
|
482
|
+
const z = R === "done" ? yt(c, d, n, o) : void 0, k = C(
|
|
489
483
|
t,
|
|
490
|
-
|
|
484
|
+
o,
|
|
491
485
|
d,
|
|
492
486
|
e.revision + 1,
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
),
|
|
487
|
+
R,
|
|
488
|
+
z,
|
|
489
|
+
c
|
|
490
|
+
), j = new Set(_(c, d.active));
|
|
497
491
|
return Object.freeze({
|
|
498
492
|
changed: !0,
|
|
499
493
|
plan: Object.freeze({
|
|
500
|
-
entered: Object.freeze([...
|
|
501
|
-
entryOutputs: Object.freeze(
|
|
494
|
+
entered: Object.freeze([...v].filter((E) => j.has(E)).sort((E, x) => c.states[E].depth - c.states[x].depth)),
|
|
495
|
+
entryOutputs: Object.freeze(w),
|
|
502
496
|
event: n,
|
|
503
|
-
exited: Object.freeze([...
|
|
497
|
+
exited: Object.freeze([...y].sort((E, x) => c.states[x].depth - c.states[E].depth)),
|
|
504
498
|
exitOutputs: Object.freeze(m),
|
|
505
|
-
transitionOutputs: Object.freeze(
|
|
499
|
+
transitionOutputs: Object.freeze(f)
|
|
506
500
|
}),
|
|
507
|
-
snapshot:
|
|
501
|
+
snapshot: k
|
|
508
502
|
});
|
|
509
503
|
}
|
|
510
|
-
function Ht(t, e, n, r,
|
|
511
|
-
const
|
|
512
|
-
|
|
504
|
+
function Ht(t, e, n, r, o, i, s, a) {
|
|
505
|
+
const u = ft(n), h = u?.active[0] ?? N(e, n.active[0]), c = e.flatDispatch === void 0 ? e.states[h].on.get(r.type) : e.flatDispatch[h * e.eventTypes.length + o], d = H(
|
|
506
|
+
c ?? Ft,
|
|
513
507
|
n.context,
|
|
514
508
|
r,
|
|
515
|
-
|
|
509
|
+
i,
|
|
516
510
|
s,
|
|
517
511
|
a
|
|
518
512
|
);
|
|
519
513
|
if (d === void 0)
|
|
520
514
|
return I(n);
|
|
521
515
|
dt(e, d, a);
|
|
522
|
-
let
|
|
523
|
-
for (const
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
)({ context:
|
|
528
|
-
const
|
|
529
|
-
active:
|
|
530
|
-
context:
|
|
516
|
+
let l = n.context;
|
|
517
|
+
for (const p of d.reduce)
|
|
518
|
+
l = vt(
|
|
519
|
+
p,
|
|
520
|
+
i
|
|
521
|
+
)({ context: l, event: r, input: s });
|
|
522
|
+
const y = d.target ?? h, v = e.states[y], m = v.kind === "final" ? "done" : "active", f = m === "done" ? v.output ?? e.output : void 0, w = typeof f == "function" ? f({ context: l, event: r, input: s }) : f, b = J(u, y, s, t, v.path), g = L({
|
|
523
|
+
active: y === h ? n.active : b[T].publicActive,
|
|
524
|
+
context: l === n.context ? n.context : rt(l),
|
|
531
525
|
history: n.history,
|
|
532
|
-
...
|
|
526
|
+
...w === void 0 ? {} : { output: w },
|
|
533
527
|
revision: n.revision + 1,
|
|
534
528
|
status: m
|
|
535
529
|
}, b[T], b);
|
|
@@ -544,77 +538,77 @@ function Ht(t, e, n, r, i, o, s, a) {
|
|
|
544
538
|
transitionOutputRefs: d.emit,
|
|
545
539
|
transitionOutputs: D
|
|
546
540
|
},
|
|
547
|
-
snapshot:
|
|
541
|
+
snapshot: g
|
|
548
542
|
};
|
|
549
543
|
}
|
|
550
|
-
function ne(t, e, n, r,
|
|
551
|
-
const a = F(t),
|
|
544
|
+
function ne(t, e, n, r, o, i, s) {
|
|
545
|
+
const a = F(t), u = H(
|
|
552
546
|
r,
|
|
553
547
|
e.context,
|
|
554
548
|
n,
|
|
555
|
-
i,
|
|
556
549
|
o,
|
|
550
|
+
i,
|
|
557
551
|
s
|
|
558
552
|
);
|
|
559
|
-
if (
|
|
553
|
+
if (u === void 0)
|
|
560
554
|
return I(e);
|
|
561
|
-
const
|
|
555
|
+
const h = {
|
|
562
556
|
active: e.active.map((b) => N(a, b)),
|
|
563
557
|
context: e.context,
|
|
564
558
|
history: { ...e.history }
|
|
565
|
-
},
|
|
559
|
+
}, c = Y(
|
|
566
560
|
a,
|
|
567
|
-
|
|
568
|
-
[
|
|
561
|
+
h,
|
|
562
|
+
[u],
|
|
569
563
|
n,
|
|
570
|
-
i,
|
|
571
564
|
o,
|
|
565
|
+
i,
|
|
572
566
|
s
|
|
573
567
|
), d = C(
|
|
574
568
|
t,
|
|
575
|
-
|
|
576
|
-
|
|
569
|
+
i,
|
|
570
|
+
h,
|
|
577
571
|
e.revision,
|
|
578
572
|
"active",
|
|
579
573
|
void 0,
|
|
580
574
|
a
|
|
581
|
-
),
|
|
575
|
+
), l = tt(
|
|
582
576
|
t,
|
|
583
577
|
d,
|
|
584
578
|
n,
|
|
585
|
-
i,
|
|
586
579
|
o,
|
|
580
|
+
i,
|
|
587
581
|
s,
|
|
588
582
|
a,
|
|
589
583
|
!0,
|
|
590
|
-
|
|
591
|
-
),
|
|
592
|
-
active:
|
|
593
|
-
context:
|
|
594
|
-
history: { ...
|
|
595
|
-
} :
|
|
584
|
+
c.raised
|
|
585
|
+
), y = l.changed ? {
|
|
586
|
+
active: l.snapshot.active.map((b) => N(a, b)),
|
|
587
|
+
context: l.snapshot.context,
|
|
588
|
+
history: { ...l.snapshot.history }
|
|
589
|
+
} : h, v = l.changed ? l.snapshot.status : nt(a, y.active) ? "done" : "active", m = v === "done" ? l.snapshot.output ?? yt(a, y, n, i) : void 0, f = C(
|
|
596
590
|
t,
|
|
597
|
-
|
|
598
|
-
|
|
591
|
+
i,
|
|
592
|
+
y,
|
|
599
593
|
e.revision + 1,
|
|
600
|
-
|
|
594
|
+
v,
|
|
601
595
|
m,
|
|
602
596
|
a
|
|
603
|
-
),
|
|
597
|
+
), w = new Set(_(a, y.active));
|
|
604
598
|
return Object.freeze({
|
|
605
599
|
changed: !0,
|
|
606
600
|
plan: Object.freeze({
|
|
607
|
-
entered: Object.freeze(A([...
|
|
608
|
-
entryOutputs: Object.freeze([...
|
|
601
|
+
entered: Object.freeze(A([...c.entered, ...l.plan.entered]).filter((b) => w.has(b)).sort((b, g) => a.states[b].depth - a.states[g].depth)),
|
|
602
|
+
entryOutputs: Object.freeze([...c.entryOutputs, ...l.plan.entryOutputs]),
|
|
609
603
|
event: n,
|
|
610
|
-
exited: Object.freeze(A([...
|
|
611
|
-
exitOutputs: Object.freeze([...
|
|
604
|
+
exited: Object.freeze(A([...c.exited, ...l.plan.exited]).sort((b, g) => a.states[g].depth - a.states[b].depth)),
|
|
605
|
+
exitOutputs: Object.freeze([...c.exitOutputs, ...l.plan.exitOutputs]),
|
|
612
606
|
transitionOutputs: Object.freeze([
|
|
613
|
-
...
|
|
614
|
-
...
|
|
607
|
+
...c.transitionOutputs,
|
|
608
|
+
...l.plan.transitionOutputs
|
|
615
609
|
])
|
|
616
610
|
}),
|
|
617
|
-
snapshot:
|
|
611
|
+
snapshot: f
|
|
618
612
|
});
|
|
619
613
|
}
|
|
620
614
|
function re(t, e, n) {
|
|
@@ -623,12 +617,12 @@ function re(t, e, n) {
|
|
|
623
617
|
throw new Error(`[Raph machine] Unknown persisted status "${String(e.status)}".`);
|
|
624
618
|
if (!Number.isSafeInteger(e.revision) || e.revision < 0)
|
|
625
619
|
throw new Error("[Raph machine] Persisted revision must be a non-negative safe integer.");
|
|
626
|
-
const
|
|
627
|
-
return qt(r,
|
|
620
|
+
const o = e.active.map((i) => N(r, i));
|
|
621
|
+
return qt(r, o, e.history, e.status), C(
|
|
628
622
|
t,
|
|
629
623
|
n,
|
|
630
624
|
{
|
|
631
|
-
active: A(
|
|
625
|
+
active: A(o),
|
|
632
626
|
context: e.context,
|
|
633
627
|
history: { ...e.history }
|
|
634
628
|
},
|
|
@@ -651,45 +645,45 @@ function qt(t, e, n, r) {
|
|
|
651
645
|
for (const s of t.states) {
|
|
652
646
|
if (s.kind !== "compound" && s.kind !== "parallel")
|
|
653
647
|
continue;
|
|
654
|
-
const a = s.children.filter((
|
|
655
|
-
if (e.some((
|
|
648
|
+
const a = s.children.filter((h) => t.states[h].kind !== "history" && e.some((c) => c === h || S(t, h, c)));
|
|
649
|
+
if (e.some((h) => S(t, s.id, h))) {
|
|
656
650
|
if (s.kind === "compound" && a.length !== 1)
|
|
657
651
|
throw new Error(`[Raph machine] Compound state "${s.path}" requires one active child.`);
|
|
658
|
-
if (s.kind === "parallel" && a.length !== s.children.filter((
|
|
652
|
+
if (s.kind === "parallel" && a.length !== s.children.filter((h) => t.states[h].kind !== "history").length)
|
|
659
653
|
throw new Error(`[Raph machine] Parallel state "${s.path}" requires every region.`);
|
|
660
654
|
}
|
|
661
655
|
}
|
|
662
|
-
const
|
|
663
|
-
if (r === "done" && !
|
|
656
|
+
const i = nt(t, e);
|
|
657
|
+
if (r === "done" && !i)
|
|
664
658
|
throw new Error("[Raph machine] Done persisted snapshot is not in a final configuration.");
|
|
665
|
-
if (r === "active" &&
|
|
659
|
+
if (r === "active" && i)
|
|
666
660
|
throw new Error("[Raph machine] Active persisted snapshot is already final.");
|
|
667
661
|
for (const [s, a] of Object.entries(n)) {
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
662
|
+
const u = t.pathToState.get(s);
|
|
663
|
+
if (u === void 0)
|
|
670
664
|
throw new Error(`[Raph machine] Persisted history has unknown owner "${s}".`);
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
665
|
+
const h = t.states[u];
|
|
666
|
+
if (h.kind !== "compound" && h.kind !== "parallel")
|
|
673
667
|
throw new Error(`[Raph machine] Persisted history owner "${s}" cannot own history.`);
|
|
674
668
|
if (!Array.isArray(a))
|
|
675
669
|
throw new TypeError(`[Raph machine] Persisted history for "${s}" must be an array.`);
|
|
676
|
-
for (const
|
|
677
|
-
const d = t.pathToState.get(
|
|
678
|
-
if (d === void 0 || !S(t,
|
|
679
|
-
throw new Error(`[Raph machine] Persisted history path "${
|
|
670
|
+
for (const c of a) {
|
|
671
|
+
const d = t.pathToState.get(c);
|
|
672
|
+
if (d === void 0 || !S(t, u, d))
|
|
673
|
+
throw new Error(`[Raph machine] Persisted history path "${c}" is invalid for "${s}".`);
|
|
680
674
|
}
|
|
681
675
|
}
|
|
682
676
|
}
|
|
683
|
-
function st(t, e, n, r,
|
|
684
|
-
const s = [], a = /* @__PURE__ */ new Set(),
|
|
685
|
-
for (const
|
|
686
|
-
for (let
|
|
687
|
-
const d = t.states[
|
|
677
|
+
function st(t, e, n, r, o, i) {
|
|
678
|
+
const s = [], a = /* @__PURE__ */ new Set(), u = [...e.active].sort((h, c) => t.states[c].depth - t.states[h].depth || h - c);
|
|
679
|
+
for (const h of u)
|
|
680
|
+
for (let c = h; c !== void 0 && !a.has(c); c = t.states[c].parent) {
|
|
681
|
+
const d = t.states[c].on.get(n.type);
|
|
688
682
|
if (d === void 0)
|
|
689
683
|
continue;
|
|
690
|
-
const
|
|
691
|
-
if (
|
|
692
|
-
a.add(
|
|
684
|
+
const l = H(d, e.context, n, r, o, i);
|
|
685
|
+
if (l !== void 0) {
|
|
686
|
+
a.add(c), s.push(l);
|
|
693
687
|
break;
|
|
694
688
|
}
|
|
695
689
|
}
|
|
@@ -699,26 +693,26 @@ function st(t, e, n, r, i, o) {
|
|
|
699
693
|
pt(t, s),
|
|
700
694
|
n,
|
|
701
695
|
r,
|
|
702
|
-
|
|
703
|
-
|
|
696
|
+
o,
|
|
697
|
+
i
|
|
704
698
|
);
|
|
705
699
|
}
|
|
706
|
-
function Kt(t, e, n, r,
|
|
700
|
+
function Kt(t, e, n, r, o, i) {
|
|
707
701
|
const s = [], a = /* @__PURE__ */ new Set();
|
|
708
|
-
for (const
|
|
709
|
-
for (let
|
|
710
|
-
if (a.has(
|
|
702
|
+
for (const u of e.active)
|
|
703
|
+
for (let h = u; h !== void 0; h = t.states[h].parent) {
|
|
704
|
+
if (a.has(h))
|
|
711
705
|
continue;
|
|
712
|
-
a.add(
|
|
713
|
-
const
|
|
714
|
-
t.states[
|
|
706
|
+
a.add(h);
|
|
707
|
+
const c = H(
|
|
708
|
+
t.states[h].always,
|
|
715
709
|
e.context,
|
|
716
710
|
n,
|
|
717
711
|
r,
|
|
718
|
-
|
|
719
|
-
|
|
712
|
+
o,
|
|
713
|
+
i
|
|
720
714
|
);
|
|
721
|
-
|
|
715
|
+
c !== void 0 && s.push(c);
|
|
722
716
|
}
|
|
723
717
|
return Y(
|
|
724
718
|
t,
|
|
@@ -726,65 +720,64 @@ function Kt(t, e, n, r, i, o) {
|
|
|
726
720
|
pt(t, s),
|
|
727
721
|
n,
|
|
728
722
|
r,
|
|
729
|
-
|
|
730
|
-
|
|
723
|
+
o,
|
|
724
|
+
i
|
|
731
725
|
);
|
|
732
726
|
}
|
|
733
|
-
function Lt(t, e, n, r,
|
|
734
|
-
const a = _(t, e.active).filter((
|
|
735
|
-
for (const
|
|
736
|
-
|
|
737
|
-
const
|
|
738
|
-
t.states[
|
|
727
|
+
function Lt(t, e, n, r, o, i, s) {
|
|
728
|
+
const a = _(t, e.active).filter((u) => !i.has(u) && et(t, u, e.active)).sort((u, h) => t.states[h].depth - t.states[u].depth);
|
|
729
|
+
for (const u of a) {
|
|
730
|
+
i.add(u);
|
|
731
|
+
const h = H(
|
|
732
|
+
t.states[u].onDone,
|
|
739
733
|
e.context,
|
|
740
734
|
n,
|
|
741
735
|
r,
|
|
742
|
-
|
|
736
|
+
o,
|
|
743
737
|
s
|
|
744
738
|
);
|
|
745
|
-
if (
|
|
746
|
-
return Y(t, e, [
|
|
739
|
+
if (h !== void 0)
|
|
740
|
+
return Y(t, e, [h], n, r, o, s);
|
|
747
741
|
}
|
|
748
|
-
return
|
|
742
|
+
return bt();
|
|
749
743
|
}
|
|
750
|
-
function Y(t, e, n, r,
|
|
751
|
-
var z;
|
|
744
|
+
function Y(t, e, n, r, o, i, s) {
|
|
752
745
|
if (n.length === 0)
|
|
753
|
-
return
|
|
754
|
-
const a = [...e.active],
|
|
755
|
-
let
|
|
756
|
-
for (const
|
|
757
|
-
dt(t,
|
|
758
|
-
for (const
|
|
759
|
-
e.context = vt(
|
|
746
|
+
return bt();
|
|
747
|
+
const a = [...e.active], u = new Set(_(t, a)), h = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), l = [], y = [];
|
|
748
|
+
let v = !1;
|
|
749
|
+
for (const p of n) {
|
|
750
|
+
dt(t, p, s);
|
|
751
|
+
for (const j of p.reduce)
|
|
752
|
+
e.context = vt(j, o)({
|
|
760
753
|
context: e.context,
|
|
761
754
|
event: r,
|
|
762
|
-
input:
|
|
763
|
-
}),
|
|
764
|
-
for (const
|
|
765
|
-
|
|
766
|
-
if (
|
|
767
|
-
const
|
|
768
|
-
Ot(
|
|
755
|
+
input: i
|
|
756
|
+
}), v = !0;
|
|
757
|
+
for (const j of p.emit)
|
|
758
|
+
l.push({ event: r, ref: j });
|
|
759
|
+
if (p.emit.length !== 0 && (v = !0), p.raise !== void 0) {
|
|
760
|
+
const j = typeof p.raise == "function" ? p.raise({ context: e.context, event: r, input: i }) : p.raise;
|
|
761
|
+
Ot(j), y.push(j), v = !0;
|
|
769
762
|
}
|
|
770
|
-
if (
|
|
771
|
-
|
|
763
|
+
if (p.target === void 0) {
|
|
764
|
+
v = !0;
|
|
772
765
|
continue;
|
|
773
766
|
}
|
|
774
|
-
const O =
|
|
775
|
-
if (O ===
|
|
776
|
-
|
|
767
|
+
const O = p.source, R = p.target;
|
|
768
|
+
if (O === R && !p.reenter) {
|
|
769
|
+
v = !0;
|
|
777
770
|
continue;
|
|
778
771
|
}
|
|
779
|
-
const
|
|
780
|
-
if (
|
|
781
|
-
d.add(
|
|
782
|
-
for (const
|
|
783
|
-
(
|
|
772
|
+
const z = X(t, O, R);
|
|
773
|
+
if (p.reenter) {
|
|
774
|
+
d.add(z);
|
|
775
|
+
for (const j of u)
|
|
776
|
+
(j === z || S(t, z, j)) && h.add(j);
|
|
784
777
|
}
|
|
785
|
-
e.active = e.active.filter((
|
|
786
|
-
const
|
|
787
|
-
e.active.push(...
|
|
778
|
+
e.active = e.active.filter((j) => j !== z && !S(t, z, j));
|
|
779
|
+
const k = lt(t, R, e.history);
|
|
780
|
+
e.active.push(...k), v = !0;
|
|
788
781
|
}
|
|
789
782
|
e.active = Bt(
|
|
790
783
|
t,
|
|
@@ -792,98 +785,96 @@ function Y(t, e, n, r, i, o, s) {
|
|
|
792
785
|
e.history
|
|
793
786
|
);
|
|
794
787
|
const m = new Set(_(t, e.active));
|
|
795
|
-
for (const
|
|
788
|
+
for (const p of d)
|
|
796
789
|
for (const O of m)
|
|
797
|
-
(O ===
|
|
798
|
-
const
|
|
799
|
-
for (const
|
|
800
|
-
const O = t.states[
|
|
790
|
+
(O === p || S(t, p, O)) && c.add(O);
|
|
791
|
+
const f = [...u].filter((p) => !m.has(p) || h.has(p)).sort((p, O) => t.states[O].depth - t.states[p].depth), w = [...m].filter((p) => !u.has(p) || c.has(p)).sort((p, O) => t.states[p].depth - t.states[O].depth);
|
|
792
|
+
for (const p of f) {
|
|
793
|
+
const O = t.states[p];
|
|
801
794
|
if (O.kind === "compound" || O.kind === "parallel") {
|
|
802
|
-
const
|
|
803
|
-
if (
|
|
804
|
-
const
|
|
805
|
-
e.history[O.path] = Object.freeze(
|
|
806
|
-
if (
|
|
807
|
-
return t.states[
|
|
808
|
-
const
|
|
809
|
-
return t.states[
|
|
795
|
+
const R = a.filter((z) => S(t, p, z));
|
|
796
|
+
if (R.length !== 0) {
|
|
797
|
+
const z = O.children.map((k) => t.states[k]).find((k) => k.kind === "history")?.history ?? O.history;
|
|
798
|
+
e.history[O.path] = Object.freeze(R.map((k) => {
|
|
799
|
+
if (z === "deep")
|
|
800
|
+
return t.states[k].path;
|
|
801
|
+
const j = wt(t, p, k);
|
|
802
|
+
return t.states[j].path;
|
|
810
803
|
}));
|
|
811
804
|
}
|
|
812
805
|
}
|
|
813
806
|
}
|
|
814
|
-
const b =
|
|
807
|
+
const b = f.flatMap((p) => t.states[p].exit.map((O) => ({ event: r, ref: O }))), g = w.flatMap((p) => t.states[p].entry.map((O) => ({ event: r, ref: O })));
|
|
815
808
|
return Object.freeze({
|
|
816
|
-
changed:
|
|
817
|
-
entered: Object.freeze(
|
|
818
|
-
entryOutputs: Object.freeze(
|
|
819
|
-
exited: Object.freeze(
|
|
809
|
+
changed: v || f.length !== 0 || w.length !== 0,
|
|
810
|
+
entered: Object.freeze(w),
|
|
811
|
+
entryOutputs: Object.freeze(g),
|
|
812
|
+
exited: Object.freeze(f),
|
|
820
813
|
exitOutputs: Object.freeze(b),
|
|
821
|
-
raised: Object.freeze(
|
|
822
|
-
transitionOutputs: Object.freeze(
|
|
814
|
+
raised: Object.freeze(y),
|
|
815
|
+
transitionOutputs: Object.freeze(l)
|
|
823
816
|
});
|
|
824
817
|
}
|
|
825
818
|
function dt(t, e, n) {
|
|
826
|
-
|
|
819
|
+
n?.transition !== void 0 && n.transition({
|
|
827
820
|
...e.reason === void 0 ? {} : { reason: e.reason },
|
|
828
821
|
source: t.states[e.source].path,
|
|
829
822
|
...e.target === void 0 ? {} : { target: t.states[e.target].path }
|
|
830
823
|
});
|
|
831
824
|
}
|
|
832
|
-
function H(t, e, n, r,
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
o,
|
|
840
|
-
typeof a.guard == "string" ? a.guard : c.name || "inline",
|
|
825
|
+
function H(t, e, n, r, o, i) {
|
|
826
|
+
for (const s of t) {
|
|
827
|
+
if (s.guard === void 0)
|
|
828
|
+
return s;
|
|
829
|
+
const a = Ut(s.guard, r), u = a({ context: e, event: n, input: o });
|
|
830
|
+
if (i?.guard?.(
|
|
831
|
+
typeof s.guard == "string" ? s.guard : a.name || "inline",
|
|
841
832
|
u,
|
|
842
833
|
Zt(e) ? e : void 0
|
|
843
834
|
), u)
|
|
844
|
-
return
|
|
835
|
+
return s;
|
|
845
836
|
}
|
|
846
837
|
}
|
|
847
838
|
function pt(t, e) {
|
|
848
|
-
const n = [...e].sort((
|
|
849
|
-
for (const
|
|
850
|
-
r.some((s) => Yt(t,
|
|
839
|
+
const n = [...e].sort((o, i) => t.states[i.source].depth - t.states[o.source].depth || o.source - i.source || o.index - i.index), r = [];
|
|
840
|
+
for (const o of n)
|
|
841
|
+
r.some((s) => Yt(t, o, s)) || r.push(o);
|
|
851
842
|
return r;
|
|
852
843
|
}
|
|
853
844
|
function Yt(t, e, n) {
|
|
854
|
-
const r = X(t, e.source, e.target ?? e.source),
|
|
855
|
-
return e.source === n.source || S(t, e.source, n.source) || S(t, n.source, e.source) || r ===
|
|
845
|
+
const r = X(t, e.source, e.target ?? e.source), o = X(t, n.source, n.target ?? n.source);
|
|
846
|
+
return e.source === n.source || S(t, e.source, n.source) || S(t, n.source, e.source) || r === o || S(t, r, o) || S(t, o, r);
|
|
856
847
|
}
|
|
857
848
|
function X(t, e, n) {
|
|
858
849
|
if (e === n || S(t, e, n))
|
|
859
850
|
return e;
|
|
860
851
|
const r = Vt(t, e, n);
|
|
861
|
-
return r !== void 0 && t.states[r].kind === "parallel" ? r : r === void 0 ? B(t, e) :
|
|
852
|
+
return r !== void 0 && t.states[r].kind === "parallel" ? r : r === void 0 ? B(t, e) : wt(t, r, e);
|
|
862
853
|
}
|
|
863
854
|
function lt(t, e, n) {
|
|
864
855
|
const r = t.states[e];
|
|
865
856
|
if (r.kind !== "history")
|
|
866
857
|
return $(t, e, n);
|
|
867
|
-
const
|
|
868
|
-
if (
|
|
858
|
+
const o = r.parent, i = n[t.states[o].path];
|
|
859
|
+
if (i !== void 0 && i.length !== 0) {
|
|
869
860
|
const s = [];
|
|
870
|
-
for (const a of
|
|
871
|
-
const
|
|
872
|
-
|
|
861
|
+
for (const a of i) {
|
|
862
|
+
const u = t.pathToState.get(a);
|
|
863
|
+
u !== void 0 && s.push(...r.history === "deep" ? $(t, u, n) : $(t, u, {}));
|
|
873
864
|
}
|
|
874
865
|
if (s.length !== 0)
|
|
875
866
|
return A(s);
|
|
876
867
|
}
|
|
877
|
-
return r.historyFallback !== void 0 ? $(t, r.historyFallback, n) : $(t,
|
|
868
|
+
return r.historyFallback !== void 0 ? $(t, r.historyFallback, n) : $(t, o, {});
|
|
878
869
|
}
|
|
879
870
|
function Bt(t, e, n) {
|
|
880
871
|
const r = [...e];
|
|
881
|
-
for (let
|
|
882
|
-
for (const
|
|
883
|
-
const s = t.states[
|
|
872
|
+
for (let o = 0; o < r.length; o++)
|
|
873
|
+
for (const i of t.ancestry[r[o]].slice(1)) {
|
|
874
|
+
const s = t.states[i];
|
|
884
875
|
if (s.kind === "parallel")
|
|
885
876
|
for (const a of s.children)
|
|
886
|
-
t.states[a].kind !== "history" && (r.some((
|
|
877
|
+
t.states[a].kind !== "history" && (r.some((u) => u === a || S(t, a, u)) || r.push(...$(t, a, n)));
|
|
887
878
|
}
|
|
888
879
|
return A(r);
|
|
889
880
|
}
|
|
@@ -895,55 +886,53 @@ function $(t, e, n) {
|
|
|
895
886
|
return [e];
|
|
896
887
|
if (r.kind === "compound")
|
|
897
888
|
return $(t, r.initial, n);
|
|
898
|
-
const
|
|
899
|
-
for (const
|
|
900
|
-
t.states[
|
|
901
|
-
return A(
|
|
889
|
+
const o = [];
|
|
890
|
+
for (const i of r.children)
|
|
891
|
+
t.states[i].kind !== "history" && o.push(...$(t, i, n));
|
|
892
|
+
return A(o);
|
|
902
893
|
}
|
|
903
894
|
function et(t, e, n) {
|
|
904
895
|
const r = t.states[e];
|
|
905
|
-
return r.kind === "final" ? n.includes(e) : r.kind === "compound" ? r.children.some((
|
|
896
|
+
return r.kind === "final" ? n.includes(e) : r.kind === "compound" ? r.children.some((o) => t.states[o].kind === "final" && n.includes(o)) : r.kind === "parallel" ? r.children.filter((o) => t.states[o].kind !== "history").every((o) => et(t, o, n)) : !1;
|
|
906
897
|
}
|
|
907
898
|
function nt(t, e) {
|
|
908
899
|
const n = Wt(t, e[0]);
|
|
909
900
|
return n === void 0 ? !1 : et(t, n, e);
|
|
910
901
|
}
|
|
911
902
|
function yt(t, e, n, r) {
|
|
912
|
-
const
|
|
903
|
+
const o = B(t, e.active[0]), i = t.states[o], s = i.kind === "compound" ? e.active.find((u) => t.states[u].parent === o && t.states[u].kind === "final") : i.kind === "final" ? o : void 0, a = s === void 0 ? t.output : t.states[s].output ?? t.output;
|
|
913
904
|
return typeof a == "function" ? a({ context: e.context, event: n, input: r }) : a;
|
|
914
905
|
}
|
|
915
906
|
function Ut(t, e) {
|
|
916
|
-
var r;
|
|
917
907
|
if (typeof t == "function")
|
|
918
908
|
return t;
|
|
919
|
-
const n =
|
|
909
|
+
const n = e?.guards?.[t];
|
|
920
910
|
if (n === void 0)
|
|
921
911
|
throw new Error(`[Raph machine] Guard binding "${t}" is not defined.`);
|
|
922
912
|
return n;
|
|
923
913
|
}
|
|
924
914
|
function vt(t, e) {
|
|
925
|
-
var r;
|
|
926
915
|
if (typeof t == "function")
|
|
927
916
|
return t;
|
|
928
|
-
const n =
|
|
917
|
+
const n = e?.reducers?.[t];
|
|
929
918
|
if (n === void 0)
|
|
930
919
|
throw new Error(`[Raph machine] Reducer binding "${t}" is not defined.`);
|
|
931
920
|
return n;
|
|
932
921
|
}
|
|
933
|
-
function C(t, e, n, r,
|
|
934
|
-
const a = s ?? F(t),
|
|
935
|
-
active:
|
|
922
|
+
function C(t, e, n, r, o, i, s) {
|
|
923
|
+
const a = s ?? F(t), u = a.flat && n.active.length === 1 ? n.active[0] : void 0, h = u === void 0 ? void 0 : J(void 0, u, e, t, a.states[u].path), c = h === void 0 ? Object.freeze([...n.active]) : void 0, d = h?.[T] ?? Object.freeze({
|
|
924
|
+
active: c,
|
|
936
925
|
input: e,
|
|
937
926
|
model: t
|
|
938
927
|
});
|
|
939
928
|
return L({
|
|
940
|
-
active: d.publicActive ?? Object.freeze(
|
|
929
|
+
active: d.publicActive ?? Object.freeze(c.map((l) => a.states[l].path)),
|
|
941
930
|
context: rt(n.context),
|
|
942
931
|
history: a.flat ? q : Xt(n.history),
|
|
943
|
-
...
|
|
932
|
+
...i === void 0 ? {} : { output: i },
|
|
944
933
|
revision: r,
|
|
945
|
-
status:
|
|
946
|
-
}, d,
|
|
934
|
+
status: o
|
|
935
|
+
}, d, h);
|
|
947
936
|
}
|
|
948
937
|
function I(t, e) {
|
|
949
938
|
return {
|
|
@@ -952,7 +941,7 @@ function I(t, e) {
|
|
|
952
941
|
snapshot: t
|
|
953
942
|
};
|
|
954
943
|
}
|
|
955
|
-
function
|
|
944
|
+
function bt() {
|
|
956
945
|
return Object.freeze({
|
|
957
946
|
changed: !1,
|
|
958
947
|
entered: Object.freeze([]),
|
|
@@ -963,37 +952,37 @@ function wt() {
|
|
|
963
952
|
transitionOutputs: Object.freeze([])
|
|
964
953
|
});
|
|
965
954
|
}
|
|
966
|
-
function at(t, e, n, r,
|
|
955
|
+
function at(t, e, n, r, o, i) {
|
|
967
956
|
for (const s of t.exited)
|
|
968
957
|
e.add(s);
|
|
969
958
|
for (const s of t.entered)
|
|
970
959
|
n.add(s);
|
|
971
|
-
r.push(...t.exitOutputs),
|
|
960
|
+
r.push(...t.exitOutputs), o.push(...t.transitionOutputs), i.push(...t.entryOutputs);
|
|
972
961
|
}
|
|
973
962
|
function _(t, e) {
|
|
974
963
|
const n = /* @__PURE__ */ new Set();
|
|
975
964
|
for (const r of e)
|
|
976
|
-
for (const
|
|
977
|
-
n.add(
|
|
965
|
+
for (const o of t.ancestry[r])
|
|
966
|
+
n.add(o);
|
|
978
967
|
return [...n];
|
|
979
968
|
}
|
|
980
969
|
function Vt(t, e, n) {
|
|
981
970
|
const r = new Set(t.ancestry[e]);
|
|
982
|
-
for (const
|
|
983
|
-
if (r.has(
|
|
984
|
-
return
|
|
971
|
+
for (const o of t.ancestry[n])
|
|
972
|
+
if (r.has(o))
|
|
973
|
+
return o;
|
|
985
974
|
}
|
|
986
975
|
function S(t, e, n) {
|
|
987
976
|
const r = t.ancestry[n];
|
|
988
977
|
return r.length > 1 && r.includes(e, 1);
|
|
989
978
|
}
|
|
990
|
-
function
|
|
979
|
+
function wt(t, e, n) {
|
|
991
980
|
let r = n;
|
|
992
981
|
for (; t.states[r].parent !== e; ) {
|
|
993
|
-
const
|
|
994
|
-
if (
|
|
982
|
+
const o = t.states[r].parent;
|
|
983
|
+
if (o === void 0)
|
|
995
984
|
return r;
|
|
996
|
-
r =
|
|
985
|
+
r = o;
|
|
997
986
|
}
|
|
998
987
|
return r;
|
|
999
988
|
}
|
|
@@ -1013,10 +1002,10 @@ function Gt(t, e, n) {
|
|
|
1013
1002
|
if (!t.eventIndexes.has(n))
|
|
1014
1003
|
return !1;
|
|
1015
1004
|
for (const r of e) {
|
|
1016
|
-
const
|
|
1017
|
-
if (
|
|
1018
|
-
for (const
|
|
1019
|
-
if (t.states[
|
|
1005
|
+
const o = t.pathToState.get(r);
|
|
1006
|
+
if (o !== void 0) {
|
|
1007
|
+
for (const i of t.ancestry[o])
|
|
1008
|
+
if (t.states[i].on.has(n))
|
|
1020
1009
|
return !0;
|
|
1021
1010
|
}
|
|
1022
1011
|
}
|