@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.26
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 +10 -2
- package/dist/core-ugchZNqC.cjs +0 -1
package/dist/machine.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { b as
|
|
2
|
-
import { e as
|
|
3
|
-
import { RaphScope as
|
|
4
|
-
class
|
|
1
|
+
import { b as I, g as M, h as j, c as P, r as k, d as A, s as z } from "./core-CClhT8WR.js";
|
|
2
|
+
import { e as K, a as U, t as X } from "./core-CClhT8WR.js";
|
|
3
|
+
import { RaphScope as D } from "./debug/runtime/ownership/RaphScope.js";
|
|
4
|
+
class _ extends Error {
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function N(o, t) {
|
|
7
|
+
return I(
|
|
8
8
|
o,
|
|
9
9
|
t
|
|
10
|
-
),
|
|
10
|
+
), v(t.context, "context"), t.output !== void 0 && v(t.output, "output"), Object.freeze({
|
|
11
11
|
active: Object.freeze([...t.active]),
|
|
12
|
-
context:
|
|
12
|
+
context: O(t.context),
|
|
13
13
|
history: Object.freeze(Object.fromEntries(
|
|
14
14
|
Object.entries(t.history).map(([e, r]) => [e, Object.freeze([...r])])
|
|
15
15
|
)),
|
|
16
16
|
modelId: o.id,
|
|
17
|
-
...t.output === void 0 ? {} : { output:
|
|
17
|
+
...t.output === void 0 ? {} : { output: O(t.output) },
|
|
18
18
|
revision: t.revision,
|
|
19
19
|
status: t.status,
|
|
20
20
|
version: o.version
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const r =
|
|
23
|
+
function B(o, t, e) {
|
|
24
|
+
const r = M(o);
|
|
25
25
|
try {
|
|
26
26
|
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
27
|
-
throw new
|
|
27
|
+
throw new _("[Raph machine] Persisted snapshot must be an object.");
|
|
28
28
|
if (t.modelId !== o.id)
|
|
29
|
-
throw new
|
|
29
|
+
throw new _(
|
|
30
30
|
`[Raph machine] Snapshot model "${t.modelId}" is incompatible with "${o.id}".`
|
|
31
31
|
);
|
|
32
32
|
if (!Number.isSafeInteger(t.version) || t.version < 1)
|
|
33
|
-
throw new
|
|
33
|
+
throw new _("[Raph machine] Persisted version must be a positive integer.");
|
|
34
34
|
let i = t;
|
|
35
35
|
for (; i.version < o.version; ) {
|
|
36
36
|
const s = r.migrations.get(i.version);
|
|
37
37
|
if (s === void 0)
|
|
38
|
-
throw new
|
|
38
|
+
throw new _(
|
|
39
39
|
`[Raph machine] Missing migration from version ${i.version} for "${o.id}".`
|
|
40
40
|
);
|
|
41
41
|
const n = s(i);
|
|
42
42
|
if (n.version !== i.version + 1 || n.modelId !== o.id)
|
|
43
|
-
throw new
|
|
43
|
+
throw new _(
|
|
44
44
|
`[Raph machine] Migration from version ${i.version} must produce version ${i.version + 1}.`
|
|
45
45
|
);
|
|
46
46
|
i = n;
|
|
47
47
|
}
|
|
48
48
|
if (i.version !== o.version)
|
|
49
|
-
throw new
|
|
49
|
+
throw new _(
|
|
50
50
|
`[Raph machine] Snapshot version ${i.version} is newer than model version ${o.version}.`
|
|
51
51
|
);
|
|
52
|
-
return
|
|
52
|
+
return v(i.context, "context"), i.output !== void 0 && v(i.output, "output"), j(
|
|
53
53
|
o,
|
|
54
54
|
i,
|
|
55
55
|
e
|
|
56
56
|
);
|
|
57
57
|
} catch (i) {
|
|
58
|
-
throw i instanceof
|
|
58
|
+
throw i instanceof _ ? i : new _(
|
|
59
59
|
`[Raph machine] Persisted snapshot is invalid: ${i instanceof Error ? i.message : String(i)}`
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function v(o, t, e = /* @__PURE__ */ new Set()) {
|
|
64
64
|
if (o === null)
|
|
65
65
|
return;
|
|
66
66
|
const r = typeof o;
|
|
@@ -68,101 +68,99 @@ function y(o, t, e = /* @__PURE__ */ new Set()) {
|
|
|
68
68
|
return;
|
|
69
69
|
if (r === "number") {
|
|
70
70
|
if (!Number.isFinite(o))
|
|
71
|
-
throw new
|
|
71
|
+
throw new _(`[Raph machine] ${t} contains a non-finite number.`);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (r !== "object")
|
|
75
|
-
throw new
|
|
75
|
+
throw new _(`[Raph machine] ${t} is not JSON-safe.`);
|
|
76
76
|
const i = o;
|
|
77
77
|
if (e.has(i))
|
|
78
|
-
throw new
|
|
78
|
+
throw new _(`[Raph machine] ${t} contains a cycle.`);
|
|
79
79
|
if (e.add(i), Array.isArray(o))
|
|
80
|
-
o.forEach((s, n) =>
|
|
80
|
+
o.forEach((s, n) => v(s, `${t}[${n}]`, e));
|
|
81
81
|
else {
|
|
82
82
|
const s = Object.getPrototypeOf(o);
|
|
83
83
|
if (s !== Object.prototype && s !== null)
|
|
84
|
-
throw new
|
|
85
|
-
for (const [n,
|
|
86
|
-
|
|
84
|
+
throw new _(`[Raph machine] ${t} contains a non-plain object.`);
|
|
85
|
+
for (const [n, h] of Object.entries(o))
|
|
86
|
+
v(h, `${t}.${n}`, e);
|
|
87
87
|
}
|
|
88
88
|
e.delete(i);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function O(o) {
|
|
91
91
|
return JSON.parse(JSON.stringify(o));
|
|
92
92
|
}
|
|
93
|
-
const
|
|
93
|
+
const E = /* @__PURE__ */ new WeakMap(), y = Symbol("RaphMachineActivationCancelled"), C = Object.freeze({ type: "@@init" }), L = Object.freeze({
|
|
94
94
|
clearTimeout: (o) => clearTimeout(o),
|
|
95
95
|
now: () => Date.now(),
|
|
96
96
|
setTimeout: (o, t) => setTimeout(o, t)
|
|
97
97
|
});
|
|
98
|
-
class
|
|
98
|
+
class S {
|
|
99
99
|
constructor(t, e, r, i) {
|
|
100
|
-
if (this.id = void 0, this.model = void 0, this.snapshot = void 0, this._owner = void 0, this._runtime = void 0, this._compiled = void 0, this._bindings = void 0, this._clock = void 0, this._input = void 0, this._errorPolicy = void 0, this._releaseSnapshot =
|
|
100
|
+
if (this.id = void 0, this.model = void 0, this.snapshot = void 0, this._owner = void 0, this._runtime = void 0, this._compiled = void 0, this._bindings = void 0, this._clock = void 0, this._input = void 0, this._errorPolicy = void 0, this._releaseSnapshot = R, this._writeSnapshotInBoundary = void 0, this._currentSnapshot = void 0, this._queue = void 0, this._listeners = void 0, this._stateCleanups = void 0, this._invocations = void 0, this._actors = void 0, this._releaseOwnership = R, this._releaseDebug = R, this._restored = !1, this._initialPlan = void 0, this._onError = void 0, this._queueCursor = 0, this._processing = !1, this._started = !1, this._stopped = !1, this._lastIgnoredSnapshot = void 0, this._lastIgnoredResult = void 0, !(t instanceof D))
|
|
101
101
|
throw new TypeError("[Raph machine] Machine owner must be a Raph Runtime scope or node.");
|
|
102
|
-
if (t._assertAlive(), this._owner = t, this._runtime = t.runtime, this._compiled =
|
|
102
|
+
if (t._assertAlive(), this._owner = t, this._runtime = t.runtime, this._compiled = M(
|
|
103
103
|
e
|
|
104
|
-
), this.model = e, this._bindings = r, this._clock = i.clock ??
|
|
104
|
+
), this.model = e, this._bindings = r, this._clock = i.clock ?? L, this._input = i.input, this._errorPolicy = i.errorPolicy ?? "throw", this._errorPolicy !== "ignore" && this._errorPolicy !== "stop" && this._errorPolicy !== "throw")
|
|
105
105
|
throw new TypeError(`[Raph machine] Unknown error policy "${String(this._errorPolicy)}".`);
|
|
106
106
|
this._onError = i.onError;
|
|
107
|
-
const s = (
|
|
108
|
-
if (
|
|
107
|
+
const s = (E.get(this._runtime) ?? 0) + 1;
|
|
108
|
+
if (E.set(this._runtime, s), this.id = i.id ?? `${e.id}#${s}`, !this.id.trim())
|
|
109
109
|
throw new TypeError("[Raph machine] Instance id must not be empty.");
|
|
110
110
|
if (this._runtime._hasMachineDebug(this.id))
|
|
111
111
|
throw new Error(`[Raph] Machine diagnostic id "${this.id}" is already registered.`);
|
|
112
|
-
const n = i.persisted === void 0 ? this._runtime.untracked(() =>
|
|
112
|
+
const n = i.persisted === void 0 ? this._runtime.untracked(() => P(
|
|
113
113
|
e,
|
|
114
114
|
this._input,
|
|
115
115
|
r,
|
|
116
116
|
this._runtime._traces("machine") ? this._traceHooks() : void 0
|
|
117
|
-
)) : void 0,
|
|
118
|
-
this._initialPlan = n
|
|
119
|
-
const c =
|
|
120
|
-
this._releaseSnapshot = c.dispose, this._writeSnapshotInBoundary = c.writeInBoundary, this._currentSnapshot =
|
|
117
|
+
)) : void 0, h = n?.snapshot ?? B(e, i.persisted, this._input);
|
|
118
|
+
this._initialPlan = n?.plan, this._restored = i.persisted !== void 0;
|
|
119
|
+
const c = J(this._runtime, t, h);
|
|
120
|
+
this._releaseSnapshot = c.dispose, this._writeSnapshotInBoundary = c.writeInBoundary, this._currentSnapshot = h, this.snapshot = c.source;
|
|
121
121
|
try {
|
|
122
122
|
this._releaseDebug = this._runtime._registerMachineDebug({
|
|
123
123
|
id: this.id,
|
|
124
124
|
ownerId: t.id,
|
|
125
125
|
...i.parentId === void 0 ? {} : { parentId: i.parentId },
|
|
126
126
|
snapshot: () => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return d === void 0 ? [] : [[this._compiled.states[f].path, d]];
|
|
127
|
+
const a = this._currentSnapshot, u = Object.fromEntries(this._activeClosure(a).flatMap((d) => {
|
|
128
|
+
const g = this._compiled.states[d].meta;
|
|
129
|
+
return g === void 0 ? [] : [[this._compiled.states[d].path, g]];
|
|
131
130
|
}));
|
|
132
131
|
return Object.freeze({
|
|
133
|
-
active:
|
|
134
|
-
actors: Object.freeze([...
|
|
135
|
-
contextKeys: Object.freeze(
|
|
132
|
+
active: a.active,
|
|
133
|
+
actors: Object.freeze([...this._actors?.keys() ?? []]),
|
|
134
|
+
contextKeys: Object.freeze(T(a.context) ? Object.keys(a.context) : []),
|
|
136
135
|
id: this.id,
|
|
137
136
|
meta: Object.freeze(u),
|
|
138
137
|
modelId: e.id,
|
|
139
138
|
ownerId: t.id,
|
|
140
139
|
...i.parentId === void 0 ? {} : { parentId: i.parentId },
|
|
141
|
-
revision:
|
|
142
|
-
status:
|
|
140
|
+
revision: a.revision,
|
|
141
|
+
status: a.status
|
|
143
142
|
});
|
|
144
143
|
}
|
|
145
144
|
}), this._releaseOwnership = t.own(() => this._dispose(!1));
|
|
146
|
-
} catch (
|
|
147
|
-
const u = [
|
|
145
|
+
} catch (a) {
|
|
146
|
+
const u = [a];
|
|
148
147
|
try {
|
|
149
148
|
this._releaseDebug();
|
|
150
|
-
} catch (
|
|
151
|
-
u.push(
|
|
149
|
+
} catch (d) {
|
|
150
|
+
u.push(d);
|
|
152
151
|
}
|
|
153
152
|
try {
|
|
154
153
|
this._releaseSnapshot();
|
|
155
|
-
} catch (
|
|
156
|
-
u.push(
|
|
154
|
+
} catch (d) {
|
|
155
|
+
u.push(d);
|
|
157
156
|
}
|
|
158
|
-
throw u.length > 1 ? new AggregateError(u, `[Raph machine] Machine "${this.id}" construction rollback failed.`) :
|
|
157
|
+
throw u.length > 1 ? new AggregateError(u, `[Raph machine] Machine "${this.id}" construction rollback failed.`) : a;
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
get started() {
|
|
162
161
|
return this._started && !this._stopped;
|
|
163
162
|
}
|
|
164
163
|
start() {
|
|
165
|
-
var s, n;
|
|
166
164
|
if (this._stopped)
|
|
167
165
|
throw new Error(`[Raph machine] Machine "${this.id}" is stopped.`);
|
|
168
166
|
if (this._started)
|
|
@@ -173,56 +171,56 @@ class E {
|
|
|
173
171
|
throw new Error(`[Raph machine] Persisted machine "${this.id}" is stopped.`);
|
|
174
172
|
if (this._started = !0, this._compiled.flat)
|
|
175
173
|
return this;
|
|
176
|
-
const e = this._activeClosure(t).sort((
|
|
174
|
+
const e = this._activeClosure(t).sort((s, n) => this._compiled.states[s].depth - this._compiled.states[n].depth);
|
|
177
175
|
let r = !1, i;
|
|
178
176
|
this._processing = !0;
|
|
179
177
|
try {
|
|
180
|
-
const
|
|
178
|
+
const s = [];
|
|
181
179
|
if (!this._restored) {
|
|
182
180
|
try {
|
|
183
181
|
this._runOutputs(
|
|
184
|
-
|
|
182
|
+
this._initialPlan?.exitOutputs ?? [],
|
|
185
183
|
t,
|
|
186
184
|
this._runtime._currentTraceCauseId()
|
|
187
185
|
);
|
|
188
|
-
} catch (
|
|
189
|
-
|
|
186
|
+
} catch (n) {
|
|
187
|
+
s.push(n);
|
|
190
188
|
}
|
|
191
189
|
if (this.started)
|
|
192
190
|
try {
|
|
193
191
|
this._runOutputs(
|
|
194
|
-
|
|
192
|
+
this._initialPlan?.transitionOutputs ?? [],
|
|
195
193
|
t,
|
|
196
194
|
this._runtime._currentTraceCauseId()
|
|
197
195
|
);
|
|
198
|
-
} catch (
|
|
199
|
-
|
|
196
|
+
} catch (n) {
|
|
197
|
+
s.push(n);
|
|
200
198
|
}
|
|
201
199
|
if (this.started) {
|
|
202
|
-
const
|
|
200
|
+
const n = e.flatMap((h) => this._compiled.states[h].entry.map((c) => ({ event: C, ref: c })));
|
|
203
201
|
try {
|
|
204
|
-
this._runOutputs(
|
|
202
|
+
this._runOutputs(n, t, this._runtime._currentTraceCauseId());
|
|
205
203
|
} catch (h) {
|
|
206
|
-
|
|
204
|
+
s.push(h);
|
|
207
205
|
}
|
|
208
206
|
}
|
|
209
207
|
}
|
|
210
208
|
if (this.started && t.status === "active")
|
|
211
|
-
for (const
|
|
209
|
+
for (const n of e) {
|
|
212
210
|
if (!this.started)
|
|
213
211
|
break;
|
|
214
212
|
try {
|
|
215
|
-
this._activateState(
|
|
213
|
+
this._activateState(n, C, t);
|
|
216
214
|
} catch (h) {
|
|
217
|
-
|
|
215
|
+
s.push(h);
|
|
218
216
|
}
|
|
219
217
|
}
|
|
220
|
-
|
|
221
|
-
} catch (
|
|
218
|
+
l(s, `[Raph machine] Machine "${this.id}" start work failed.`);
|
|
219
|
+
} catch (s) {
|
|
222
220
|
try {
|
|
223
|
-
this._handlePostCommitError(
|
|
224
|
-
} catch (
|
|
225
|
-
r = !0, i =
|
|
221
|
+
this._handlePostCommitError(s, "start", this._runtime._currentTraceCauseId());
|
|
222
|
+
} catch (n) {
|
|
223
|
+
r = !0, i = n;
|
|
226
224
|
}
|
|
227
225
|
} finally {
|
|
228
226
|
this._processing = !1, r ? (this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0) : this._drainQueued();
|
|
@@ -235,8 +233,7 @@ class E {
|
|
|
235
233
|
return this._enqueue(t);
|
|
236
234
|
}
|
|
237
235
|
sendTo(t, e) {
|
|
238
|
-
|
|
239
|
-
const r = (i = this._actors) == null ? void 0 : i.get(t);
|
|
236
|
+
const r = this._actors?.get(t);
|
|
240
237
|
if (r === void 0)
|
|
241
238
|
throw new Error(`[Raph machine] Actor "${t}" is not active in "${this.id}".`);
|
|
242
239
|
return r.send(e);
|
|
@@ -260,27 +257,27 @@ class E {
|
|
|
260
257
|
return this._listeners = r === void 0 ? [e] : [...r, e], () => this._removeListener(e);
|
|
261
258
|
}
|
|
262
259
|
persist() {
|
|
263
|
-
return
|
|
260
|
+
return N(this.model, this.snapshot.get());
|
|
264
261
|
}
|
|
265
262
|
stop() {
|
|
266
263
|
let t;
|
|
267
264
|
try {
|
|
268
265
|
this._dispose(!0);
|
|
269
266
|
} catch (e) {
|
|
270
|
-
(t
|
|
267
|
+
(t ??= []).push(e);
|
|
271
268
|
}
|
|
272
269
|
try {
|
|
273
270
|
this._releaseOwnership();
|
|
274
271
|
} catch (e) {
|
|
275
|
-
(t
|
|
272
|
+
(t ??= []).push(e);
|
|
276
273
|
}
|
|
277
|
-
|
|
274
|
+
l(t, `[Raph machine] Machine "${this.id}" stop failed.`);
|
|
278
275
|
}
|
|
279
276
|
_enqueue(t, e) {
|
|
280
277
|
if (!this.started)
|
|
281
278
|
throw new Error(`[Raph machine] Machine "${this.id}" must be started before send().`);
|
|
282
|
-
if (
|
|
283
|
-
return (this._queue
|
|
279
|
+
if (Q(t), this._processing)
|
|
280
|
+
return (this._queue ??= []).push({ event: t, ...e === void 0 ? {} : { transitions: e } }), { snapshot: this._currentSnapshot, status: "queued" };
|
|
284
281
|
this._processing = !0;
|
|
285
282
|
let r;
|
|
286
283
|
try {
|
|
@@ -295,50 +292,50 @@ class E {
|
|
|
295
292
|
let n;
|
|
296
293
|
i !== void 0 && this._trace(t.type, "start", i, s, r);
|
|
297
294
|
try {
|
|
298
|
-
const
|
|
299
|
-
if (e === void 0 &&
|
|
295
|
+
const h = e === void 0 ? this._compiled.eventIndexes.get(t.type) : void 0;
|
|
296
|
+
if (e === void 0 && h === void 0)
|
|
300
297
|
return i !== void 0 && this._trace(t.type, "ignored", i, s, r), this._ignored(r);
|
|
301
|
-
const c = i === void 0 ? void 0 : this._traceHooks(i, s),
|
|
302
|
-
if (!
|
|
298
|
+
const c = i === void 0 ? void 0 : this._traceHooks(i, s), a = this._runtime._hasActiveReactiveContext() ? this._runtime.untracked(() => this._evaluate(r, t, h, e, c)) : this._evaluate(r, t, h, e, c);
|
|
299
|
+
if (!a.changed)
|
|
303
300
|
return i !== void 0 && this._trace(t.type, "ignored", i, s, r), this._ignored(r);
|
|
304
301
|
this._runtime._batchReactive(() => {
|
|
305
|
-
this._writeSnapshotInBoundary(
|
|
302
|
+
this._writeSnapshotInBoundary(a.snapshot), this._currentSnapshot = a.snapshot, n = a.snapshot;
|
|
306
303
|
});
|
|
307
304
|
let u;
|
|
308
305
|
try {
|
|
309
|
-
this._applyPlan(
|
|
310
|
-
} catch (
|
|
311
|
-
(u
|
|
306
|
+
this._applyPlan(a.plan, a.snapshot, s);
|
|
307
|
+
} catch (m) {
|
|
308
|
+
(u ??= []).push(m);
|
|
312
309
|
}
|
|
313
|
-
const
|
|
314
|
-
if (this.started &&
|
|
315
|
-
const
|
|
316
|
-
|
|
310
|
+
const d = this._listeners;
|
|
311
|
+
if (this.started && d !== void 0) {
|
|
312
|
+
const m = this._notifyListeners(d, a.snapshot);
|
|
313
|
+
m !== void 0 && (u ??= []).push(...m);
|
|
317
314
|
}
|
|
318
|
-
if (this.started &&
|
|
315
|
+
if (this.started && a.snapshot.status === "done")
|
|
319
316
|
try {
|
|
320
317
|
this._stopStateResources();
|
|
321
|
-
} catch (
|
|
322
|
-
(u
|
|
318
|
+
} catch (m) {
|
|
319
|
+
(u ??= []).push(m);
|
|
323
320
|
}
|
|
324
|
-
u !== void 0 &&
|
|
325
|
-
const
|
|
326
|
-
return i !== void 0 && this._trace(t.type, "end", i, s,
|
|
327
|
-
} catch (
|
|
321
|
+
u !== void 0 && l(u, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
|
|
322
|
+
const g = this.started ? a.snapshot : this._currentSnapshot;
|
|
323
|
+
return i !== void 0 && this._trace(t.type, "end", i, s, g), { snapshot: g, status: "transitioned" };
|
|
324
|
+
} catch (h) {
|
|
328
325
|
if (n !== void 0)
|
|
329
|
-
return this._handlePostCommitError(
|
|
330
|
-
if (this._traceError(t.type,
|
|
331
|
-
return this._onError(
|
|
326
|
+
return this._handlePostCommitError(h, t.type, s), { snapshot: this._currentSnapshot, status: "transitioned" };
|
|
327
|
+
if (this._traceError(t.type, h, i, s), this._onError !== void 0)
|
|
328
|
+
return this._onError(h), this._ignored(this._currentSnapshot);
|
|
332
329
|
if (this._errorPolicy === "stop" && this._dispose(!0), this._errorPolicy === "ignore")
|
|
333
330
|
return this._ignored(this._currentSnapshot);
|
|
334
|
-
throw
|
|
331
|
+
throw h;
|
|
335
332
|
}
|
|
336
333
|
}
|
|
337
334
|
_ignored(t) {
|
|
338
335
|
return this._lastIgnoredSnapshot !== t && (this._lastIgnoredSnapshot = t, this._lastIgnoredResult = { snapshot: t, status: "ignored" }), this._lastIgnoredResult;
|
|
339
336
|
}
|
|
340
337
|
_evaluate(t, e, r, i, s) {
|
|
341
|
-
return i === void 0 ?
|
|
338
|
+
return i === void 0 ? k(
|
|
342
339
|
this.model,
|
|
343
340
|
t,
|
|
344
341
|
e,
|
|
@@ -347,7 +344,7 @@ class E {
|
|
|
347
344
|
s,
|
|
348
345
|
this._compiled,
|
|
349
346
|
r
|
|
350
|
-
) :
|
|
347
|
+
) : A(
|
|
351
348
|
this.model,
|
|
352
349
|
t,
|
|
353
350
|
e,
|
|
@@ -424,165 +421,154 @@ class E {
|
|
|
424
421
|
i.push(n);
|
|
425
422
|
}
|
|
426
423
|
}
|
|
427
|
-
|
|
424
|
+
l(i, `[Raph machine] Machine "${this.id}" post-commit work failed.`);
|
|
428
425
|
}
|
|
429
426
|
_activateState(t, e, r) {
|
|
430
|
-
|
|
431
|
-
if (!this.started || (a = this._stateCleanups) != null && a.has(t))
|
|
427
|
+
if (!this.started || this._stateCleanups?.has(t))
|
|
432
428
|
return;
|
|
433
429
|
const i = this._compiled.states[t];
|
|
434
430
|
if (i.resources.length === 0 && i.after.size === 0 && i.invokes.length === 0)
|
|
435
431
|
return;
|
|
436
|
-
const s = [], n = this._stateCleanups
|
|
432
|
+
const s = [], n = this._stateCleanups ??= /* @__PURE__ */ new Map();
|
|
437
433
|
n.set(t, s);
|
|
438
434
|
try {
|
|
439
435
|
for (const h of i.resources) {
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
436
|
+
const c = this._bindings.resources?.[h];
|
|
437
|
+
if (c === void 0)
|
|
442
438
|
throw new Error(`[Raph machine] Resource binding "${h}" is not defined.`);
|
|
443
|
-
const
|
|
444
|
-
let
|
|
439
|
+
const a = new AbortController();
|
|
440
|
+
let u;
|
|
445
441
|
try {
|
|
446
|
-
const d = this._runtime.untracked(() =>
|
|
442
|
+
const d = this._runtime.untracked(() => c({
|
|
447
443
|
context: r.context,
|
|
448
444
|
event: e,
|
|
449
445
|
input: this._input,
|
|
450
446
|
owner: this._owner,
|
|
451
|
-
signal:
|
|
447
|
+
signal: a.signal,
|
|
452
448
|
snapshot: r
|
|
453
449
|
}));
|
|
454
|
-
typeof d == "function" && (
|
|
450
|
+
typeof d == "function" && (u = d);
|
|
455
451
|
} catch (d) {
|
|
456
|
-
throw
|
|
452
|
+
throw a.abort(), d;
|
|
457
453
|
}
|
|
458
|
-
if (s.push(
|
|
459
|
-
|
|
454
|
+
if (s.push(b(() => {
|
|
455
|
+
a.abort(), u?.();
|
|
460
456
|
})), !this.started)
|
|
461
|
-
throw
|
|
457
|
+
throw y;
|
|
462
458
|
}
|
|
463
|
-
for (const [h,
|
|
464
|
-
const
|
|
459
|
+
for (const [h, c] of i.after) {
|
|
460
|
+
const a = this._resolveDelay(h, r, e);
|
|
465
461
|
if (!this.started)
|
|
466
|
-
throw
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
throw S;
|
|
462
|
+
throw y;
|
|
463
|
+
const u = this._clock.setTimeout(() => {
|
|
464
|
+
!this.started || !this._stateCleanups?.has(t) || this._enqueue(Object.freeze({ type: `@@after:${i.path}:${h}` }), c);
|
|
465
|
+
}, a);
|
|
466
|
+
if (s.push(b(() => this._clock.clearTimeout(u))), !this.started)
|
|
467
|
+
throw y;
|
|
473
468
|
}
|
|
474
469
|
for (const h of i.invokes)
|
|
475
470
|
if (this._startInvoke(i, h, e, r, s), !this.started)
|
|
476
|
-
throw
|
|
471
|
+
throw y;
|
|
477
472
|
} catch (h) {
|
|
478
473
|
n.get(t) === s && n.delete(t), n.size === 0 && this._stateCleanups === n && (this._stateCleanups = void 0);
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
h ===
|
|
474
|
+
const c = x(s);
|
|
475
|
+
l(
|
|
476
|
+
h === y ? c : [h, ...c],
|
|
482
477
|
`[Raph machine] State "${i.path}" activation failed.`
|
|
483
478
|
);
|
|
484
479
|
}
|
|
485
480
|
}
|
|
486
481
|
_startInvoke(t, e, r, i, s) {
|
|
487
|
-
|
|
488
|
-
const n = this._invocations ?? (this._invocations = /* @__PURE__ */ new Map());
|
|
482
|
+
const n = this._invocations ??= /* @__PURE__ */ new Map();
|
|
489
483
|
if (n.has(e.id))
|
|
490
484
|
throw new Error(`[Raph machine] Invoke id "${e.id}" is already active.`);
|
|
491
|
-
const
|
|
492
|
-
n.set(e.id,
|
|
485
|
+
const h = new AbortController(), c = {}, a = { controller: h, invoke: e, token: c };
|
|
486
|
+
n.set(e.id, a);
|
|
493
487
|
const u = () => {
|
|
494
|
-
|
|
495
|
-
a.abort();
|
|
496
|
-
const l = n.get(e.id);
|
|
497
|
-
(l == null ? void 0 : l.token) === c && n.delete(e.id), n.size === 0 && this._invocations === n && (this._invocations = void 0);
|
|
488
|
+
h.abort(), n.get(e.id)?.token === c && n.delete(e.id), n.size === 0 && this._invocations === n && (this._invocations = void 0);
|
|
498
489
|
const p = this._actors;
|
|
499
|
-
p
|
|
490
|
+
p?.delete(e.id), p?.size === 0 && this._actors === p && (this._actors = void 0), a.actor?.stop();
|
|
500
491
|
};
|
|
501
|
-
s.push(
|
|
502
|
-
const
|
|
492
|
+
s.push(b(u));
|
|
493
|
+
const d = typeof e.input == "function" ? e.input({ context: i.context, event: r, input: this._input }) : e.input;
|
|
503
494
|
if (!this.started)
|
|
504
495
|
return;
|
|
505
496
|
if (e.type === "machine") {
|
|
506
|
-
const
|
|
507
|
-
if (
|
|
497
|
+
const f = typeof e.src == "string" ? this._bindings.actors?.[e.src] : e.src;
|
|
498
|
+
if (f === void 0)
|
|
508
499
|
throw new Error(`[Raph machine] Actor source "${String(e.src)}" is not defined.`);
|
|
509
|
-
const p = new
|
|
500
|
+
const p = new S(
|
|
510
501
|
this._owner,
|
|
511
|
-
|
|
502
|
+
f,
|
|
512
503
|
{},
|
|
513
504
|
{
|
|
514
505
|
errorPolicy: e.onError.length === 0 ? "throw" : "ignore",
|
|
515
506
|
id: `${this.id}/${e.id}`,
|
|
516
|
-
input:
|
|
517
|
-
onError: e.onError.length === 0 ? void 0 : (
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
Object.freeze({ error: $, type: `@@error.actor:${e.id}` }),
|
|
507
|
+
input: d,
|
|
508
|
+
onError: e.onError.length === 0 ? void 0 : (w) => {
|
|
509
|
+
!this.started || this._invocations?.get(e.id)?.token !== c || this._enqueue(
|
|
510
|
+
Object.freeze({ error: w, type: `@@error.actor:${e.id}` }),
|
|
521
511
|
e.onError
|
|
522
512
|
);
|
|
523
513
|
},
|
|
524
514
|
parentId: this.id
|
|
525
515
|
}
|
|
526
516
|
);
|
|
527
|
-
if (!this.started ||
|
|
517
|
+
if (!this.started || this._invocations?.get(e.id)?.token !== c || h.signal.aborted) {
|
|
528
518
|
p.stop();
|
|
529
519
|
return;
|
|
530
520
|
}
|
|
531
|
-
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
Object.freeze({ output: $.output, type: `@@done.actor:${e.id}` }),
|
|
521
|
+
a.actor = p, (this._actors ??= /* @__PURE__ */ new Map()).set(e.id, p);
|
|
522
|
+
const q = p.subscribe((w) => {
|
|
523
|
+
w.status === "done" && this._invocations?.get(e.id)?.token === c && this._enqueue(
|
|
524
|
+
Object.freeze({ output: w.output, type: `@@done.actor:${e.id}` }),
|
|
536
525
|
e.onDone
|
|
537
526
|
);
|
|
538
527
|
});
|
|
539
|
-
if (s.push(
|
|
528
|
+
if (s.push(b(q)), p.start(), !this.started)
|
|
540
529
|
return;
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
Object.freeze({ output:
|
|
530
|
+
const $ = p.snapshot.peek();
|
|
531
|
+
$.status === "done" && this._invocations?.get(e.id)?.token === c && this._enqueue(
|
|
532
|
+
Object.freeze({ output: $.output, type: `@@done.actor:${e.id}` }),
|
|
544
533
|
e.onDone
|
|
545
534
|
);
|
|
546
535
|
return;
|
|
547
536
|
}
|
|
548
537
|
if (typeof e.src != "string")
|
|
549
538
|
throw new TypeError(`[Raph machine] Task invoke "${e.id}" requires a string source.`);
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
539
|
+
const g = this._bindings.tasks?.[e.src];
|
|
540
|
+
if (g === void 0)
|
|
552
541
|
throw new Error(`[Raph machine] Task binding "${e.src}" is not defined.`);
|
|
553
|
-
let
|
|
542
|
+
let m;
|
|
554
543
|
try {
|
|
555
|
-
|
|
544
|
+
m = this._runtime.untracked(() => g({
|
|
556
545
|
context: i.context,
|
|
557
546
|
event: r,
|
|
558
547
|
input: this._input,
|
|
559
|
-
send: (
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
!this.started || (p == null ? void 0 : p.token) !== c || a.signal.aborted || this.send(l);
|
|
548
|
+
send: (f) => {
|
|
549
|
+
const p = this._invocations?.get(e.id);
|
|
550
|
+
!this.started || p?.token !== c || h.signal.aborted || this.send(f);
|
|
563
551
|
},
|
|
564
|
-
signal:
|
|
552
|
+
signal: h.signal
|
|
565
553
|
}));
|
|
566
|
-
} catch (
|
|
567
|
-
this._completeInvoke(e, c, !1,
|
|
554
|
+
} catch (f) {
|
|
555
|
+
this._completeInvoke(e, c, !1, f);
|
|
568
556
|
return;
|
|
569
557
|
}
|
|
570
|
-
this.started && Promise.resolve(
|
|
571
|
-
(
|
|
572
|
-
(
|
|
558
|
+
this.started && Promise.resolve(m).then(
|
|
559
|
+
(f) => this._completeInvoke(e, c, !0, f),
|
|
560
|
+
(f) => this._completeInvoke(e, c, !1, f)
|
|
573
561
|
);
|
|
574
562
|
}
|
|
575
563
|
_completeInvoke(t, e, r, i) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
!this.started || (s == null ? void 0 : s.token) !== e || s.controller.signal.aborted || this._enqueue(
|
|
564
|
+
const s = this._invocations?.get(t.id);
|
|
565
|
+
!this.started || s?.token !== e || s.controller.signal.aborted || this._enqueue(
|
|
579
566
|
Object.freeze(r ? { data: i, type: `@@done.invoke:${t.id}` } : { error: i, type: `@@error.invoke:${t.id}` }),
|
|
580
567
|
r ? t.onDone : t.onError
|
|
581
568
|
);
|
|
582
569
|
}
|
|
583
570
|
_resolveDelay(t, e, r) {
|
|
584
|
-
|
|
585
|
-
const i = Number(t), s = Number.isFinite(i) && t.trim() !== "" ? i : (a = this._bindings.delays) == null ? void 0 : a[t];
|
|
571
|
+
const i = Number(t), s = Number.isFinite(i) && t.trim() !== "" ? i : this._bindings.delays?.[t];
|
|
586
572
|
if (s === void 0)
|
|
587
573
|
throw new Error(`[Raph machine] Delay binding "${t}" is not defined.`);
|
|
588
574
|
const n = typeof s == "function" ? s({ context: e.context, event: r, input: this._input }) : s;
|
|
@@ -604,12 +590,12 @@ class E {
|
|
|
604
590
|
snapshot: e
|
|
605
591
|
})));
|
|
606
592
|
} catch (n) {
|
|
607
|
-
(i
|
|
593
|
+
(i ??= []).push(n);
|
|
608
594
|
}
|
|
609
595
|
if (!this.started)
|
|
610
596
|
break;
|
|
611
597
|
}
|
|
612
|
-
i !== void 0 &&
|
|
598
|
+
i !== void 0 && l(i, `[Raph machine] Machine "${this.id}" output work failed.`);
|
|
613
599
|
}
|
|
614
600
|
_notifyListeners(t, e) {
|
|
615
601
|
let r;
|
|
@@ -617,7 +603,7 @@ class E {
|
|
|
617
603
|
try {
|
|
618
604
|
t[i].listener(e);
|
|
619
605
|
} catch (s) {
|
|
620
|
-
(r
|
|
606
|
+
(r ??= []).push(s);
|
|
621
607
|
}
|
|
622
608
|
return r;
|
|
623
609
|
}
|
|
@@ -632,34 +618,33 @@ class E {
|
|
|
632
618
|
let s;
|
|
633
619
|
for (const n of t) {
|
|
634
620
|
try {
|
|
635
|
-
const
|
|
636
|
-
this._runtime._runWithTraceCause(i, () => this._runtime.untracked(() =>
|
|
621
|
+
const h = this._resolveOutput(n);
|
|
622
|
+
this._runtime._runWithTraceCause(i, () => this._runtime.untracked(() => h({
|
|
637
623
|
context: r.context,
|
|
638
624
|
event: e,
|
|
639
625
|
input: this._input,
|
|
640
626
|
snapshot: r
|
|
641
627
|
})));
|
|
642
|
-
} catch (
|
|
643
|
-
(s
|
|
628
|
+
} catch (h) {
|
|
629
|
+
(s ??= []).push(h);
|
|
644
630
|
}
|
|
645
631
|
if (!this.started)
|
|
646
632
|
break;
|
|
647
633
|
}
|
|
648
|
-
s !== void 0 &&
|
|
634
|
+
s !== void 0 && l(s, `[Raph machine] Machine "${this.id}" output work failed.`);
|
|
649
635
|
}
|
|
650
636
|
_resolveOutput(t) {
|
|
651
|
-
var r;
|
|
652
637
|
if (typeof t == "function")
|
|
653
638
|
return t;
|
|
654
|
-
const e =
|
|
639
|
+
const e = this._bindings.outputs?.[t];
|
|
655
640
|
if (e === void 0)
|
|
656
641
|
throw new Error(`[Raph machine] Output binding "${t}" is not defined.`);
|
|
657
642
|
return e;
|
|
658
643
|
}
|
|
659
644
|
_cleanupState(t) {
|
|
660
|
-
const e = this._stateCleanups, r = e
|
|
661
|
-
e === void 0 || r === void 0 || (e.delete(t), e.size === 0 && this._stateCleanups === e && (this._stateCleanups = void 0),
|
|
662
|
-
|
|
645
|
+
const e = this._stateCleanups, r = e?.get(t);
|
|
646
|
+
e === void 0 || r === void 0 || (e.delete(t), e.size === 0 && this._stateCleanups === e && (this._stateCleanups = void 0), l(
|
|
647
|
+
x(r),
|
|
663
648
|
`[Raph machine] State "${this._compiled.states[t].path}" cleanup failed.`
|
|
664
649
|
));
|
|
665
650
|
}
|
|
@@ -673,7 +658,7 @@ class E {
|
|
|
673
658
|
} catch (i) {
|
|
674
659
|
e.push(i);
|
|
675
660
|
}
|
|
676
|
-
|
|
661
|
+
l(e, `[Raph machine] Machine "${this.id}" final cleanup failed.`);
|
|
677
662
|
}
|
|
678
663
|
_dispose(t) {
|
|
679
664
|
if (this._stopped)
|
|
@@ -683,30 +668,30 @@ class E {
|
|
|
683
668
|
try {
|
|
684
669
|
this._stopStateResources();
|
|
685
670
|
} catch (r) {
|
|
686
|
-
(e
|
|
671
|
+
(e ??= []).push(r);
|
|
687
672
|
}
|
|
688
673
|
this._queue !== void 0 && (this._queue.length = 0), this._queueCursor = 0, this._listeners = void 0;
|
|
689
674
|
try {
|
|
690
675
|
this._releaseDebug();
|
|
691
676
|
} catch (r) {
|
|
692
|
-
(e
|
|
677
|
+
(e ??= []).push(r);
|
|
693
678
|
}
|
|
694
679
|
if (t && !this._runtime.disposed) {
|
|
695
|
-
const r = this._currentSnapshot, i =
|
|
680
|
+
const r = this._currentSnapshot, i = z(this.model, r);
|
|
696
681
|
try {
|
|
697
682
|
this._runtime._batchReactive(() => {
|
|
698
683
|
this._writeSnapshotInBoundary(i), this._currentSnapshot = i;
|
|
699
684
|
});
|
|
700
685
|
} catch (s) {
|
|
701
|
-
(e
|
|
686
|
+
(e ??= []).push(s);
|
|
702
687
|
}
|
|
703
688
|
}
|
|
704
689
|
try {
|
|
705
690
|
this._releaseSnapshot();
|
|
706
691
|
} catch (r) {
|
|
707
|
-
(e
|
|
692
|
+
(e ??= []).push(r);
|
|
708
693
|
}
|
|
709
|
-
|
|
694
|
+
l(e, `[Raph machine] Machine "${this.id}" stop failed.`);
|
|
710
695
|
}
|
|
711
696
|
_activeClosure(t) {
|
|
712
697
|
const e = /* @__PURE__ */ new Set();
|
|
@@ -739,7 +724,7 @@ class E {
|
|
|
739
724
|
_trace(t, e, r, i, s) {
|
|
740
725
|
this._runtime._recordTrace({
|
|
741
726
|
...i === void 0 ? {} : { causeId: i },
|
|
742
|
-
context:
|
|
727
|
+
context: T(s.context) ? s.context : void 0,
|
|
743
728
|
details: { active: s.active, revision: s.revision },
|
|
744
729
|
kind: "machine",
|
|
745
730
|
name: `${this.id}:${t}`,
|
|
@@ -774,28 +759,28 @@ class E {
|
|
|
774
759
|
throw t;
|
|
775
760
|
}
|
|
776
761
|
}
|
|
777
|
-
function
|
|
778
|
-
return new
|
|
762
|
+
function F(o, t, e = {}, r = {}) {
|
|
763
|
+
return new S(o, t, e, r);
|
|
779
764
|
}
|
|
780
|
-
function
|
|
765
|
+
function J(o, t, e) {
|
|
781
766
|
const r = o._getWorkGraph(), i = r.createProducer(t), s = o._getReactivity()._ownedSignal(e, r.producerHooks(i));
|
|
782
|
-
let n = s.source,
|
|
767
|
+
let n = s.source, h = e;
|
|
783
768
|
const c = Object.freeze({
|
|
784
|
-
get: () => (o._assertSourceReadable(t), n === void 0 ?
|
|
785
|
-
peek: () => (t._assertAlive(), n === void 0 ?
|
|
769
|
+
get: () => (o._assertSourceReadable(t), n === void 0 ? h : n.get()),
|
|
770
|
+
peek: () => (t._assertAlive(), n === void 0 ? h : n.peek())
|
|
786
771
|
});
|
|
787
772
|
return r.attachProducer(i, c), {
|
|
788
773
|
dispose: () => {
|
|
789
|
-
const
|
|
790
|
-
|
|
774
|
+
const a = n;
|
|
775
|
+
a !== void 0 && (h = a.peek(), n = void 0, s.dispose());
|
|
791
776
|
},
|
|
792
777
|
source: c,
|
|
793
|
-
writeInBoundary: (
|
|
794
|
-
t._assertAlive(), n.set(
|
|
778
|
+
writeInBoundary: (a) => {
|
|
779
|
+
t._assertAlive(), n.set(a), h = a;
|
|
795
780
|
}
|
|
796
781
|
};
|
|
797
782
|
}
|
|
798
|
-
function
|
|
783
|
+
function x(o) {
|
|
799
784
|
const t = [];
|
|
800
785
|
for (let e = o.length - 1; e >= 0; e--)
|
|
801
786
|
try {
|
|
@@ -805,33 +790,33 @@ function z(o) {
|
|
|
805
790
|
}
|
|
806
791
|
return t;
|
|
807
792
|
}
|
|
808
|
-
function
|
|
809
|
-
if (
|
|
793
|
+
function l(o, t) {
|
|
794
|
+
if (o?.length === 1)
|
|
810
795
|
throw o[0];
|
|
811
796
|
if (o !== void 0 && o.length > 1)
|
|
812
797
|
throw new AggregateError(o, t);
|
|
813
798
|
}
|
|
814
|
-
function
|
|
799
|
+
function Q(o) {
|
|
815
800
|
if (typeof o != "object" || o === null || typeof o.type != "string" || !o.type)
|
|
816
801
|
throw new TypeError("[Raph machine] Event must contain a non-empty string type.");
|
|
817
802
|
}
|
|
818
|
-
function
|
|
803
|
+
function T(o) {
|
|
819
804
|
return typeof o == "object" && o !== null && !Array.isArray(o);
|
|
820
805
|
}
|
|
821
|
-
function
|
|
806
|
+
function R() {
|
|
822
807
|
}
|
|
823
|
-
function
|
|
808
|
+
function b(o) {
|
|
824
809
|
let t = !0;
|
|
825
810
|
return () => {
|
|
826
811
|
t && (t = !1, o());
|
|
827
812
|
};
|
|
828
813
|
}
|
|
829
814
|
export {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
815
|
+
_ as MachinePersistenceError,
|
|
816
|
+
F as createMachine,
|
|
817
|
+
K as defineMachine,
|
|
818
|
+
U as getInitialSnapshot,
|
|
819
|
+
N as persistMachineSnapshot,
|
|
820
|
+
B as restoreMachineSnapshot,
|
|
821
|
+
X as transition
|
|
837
822
|
};
|