@typeonce/effect-machine 0.38.1 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -35
- package/dist/Machine.d.ts +62 -88
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +11 -24
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/declaration.d.ts +10 -3
- package/dist/internal/machine/declaration.d.ts.map +1 -1
- package/dist/internal/machine/declaration.js +47 -16
- package/dist/internal/machine/declaration.js.map +1 -1
- package/dist/internal/machine/errors.d.ts +15 -1
- package/dist/internal/machine/errors.d.ts.map +1 -1
- package/dist/internal/machine/errors.js +10 -0
- package/dist/internal/machine/errors.js.map +1 -1
- package/dist/internal/machine/initialDeclaration.d.ts +2 -2
- package/dist/internal/machine/initialDeclaration.d.ts.map +1 -1
- package/dist/internal/machine/initialDeclaration.js +8 -9
- package/dist/internal/machine/initialDeclaration.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +26 -76
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +21 -16
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +216 -31
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +6 -12
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts +5 -9
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +19 -32
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +9 -12
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +7 -7
- package/dist/testing/MachineTest.js +7 -7
- package/dist/unstable/cluster/ClusterMachine.d.ts +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +3 -3
- package/dist/unstable/reactivity/AtomMachine.js +3 -3
- package/docs/agent-guide.md +23 -30
- package/docs/machine-review.md +5 -6
- package/docs/root-api.md +27 -19
- package/package.json +1 -1
- package/src/Machine.ts +125 -163
- package/src/internal/machine/atom.ts +4 -7
- package/src/internal/machine/declaration.ts +56 -17
- package/src/internal/machine/errors.ts +22 -1
- package/src/internal/machine/initialDeclaration.ts +10 -12
- package/src/internal/machine/machine.ts +85 -465
- package/src/internal/machine/planner.ts +84 -190
- package/src/internal/machine/process.ts +80 -279
- package/src/internal/testing/machine/finiteModel.ts +7 -11
- package/src/testing/MachineTest.ts +7 -7
- package/src/unstable/cluster/ClusterMachine.ts +1 -1
- package/src/unstable/reactivity/AtomMachine.ts +3 -3
- package/dist/internal/machine/targetReference.d.ts +0 -15
- package/dist/internal/machine/targetReference.d.ts.map +0 -1
- package/dist/internal/machine/targetReference.js +0 -41
- package/dist/internal/machine/targetReference.js.map +0 -1
- package/src/internal/machine/targetReference.ts +0 -55
|
@@ -245,7 +245,7 @@ export interface Scenarios<M extends AnyMachine> {
|
|
|
245
245
|
* events: Machine.eventsFromSchemas(Reset)
|
|
246
246
|
* }).handle({
|
|
247
247
|
* initial: {
|
|
248
|
-
* target:
|
|
248
|
+
* target: "Idle"
|
|
249
249
|
* },
|
|
250
250
|
* states: {
|
|
251
251
|
* Idle: {
|
|
@@ -505,7 +505,7 @@ export { ProbeUnavailableError } from "../internal/testing/machine/probe.js"
|
|
|
505
505
|
* events: Machine.eventsFromSchemas()
|
|
506
506
|
* }).handle({
|
|
507
507
|
* initial: {
|
|
508
|
-
* target:
|
|
508
|
+
* target: "Idle"
|
|
509
509
|
* },
|
|
510
510
|
* states: {
|
|
511
511
|
* Idle: {}
|
|
@@ -1121,7 +1121,7 @@ export const Invariant: {
|
|
|
1121
1121
|
* events: Machine.eventsFromSchemas()
|
|
1122
1122
|
* }).handle({
|
|
1123
1123
|
* initial: {
|
|
1124
|
-
* target:
|
|
1124
|
+
* target: "Count",
|
|
1125
1125
|
* decoded: true,
|
|
1126
1126
|
* data: new Count({ value: 0 })
|
|
1127
1127
|
* },
|
|
@@ -1461,7 +1461,7 @@ export type ExploreOptions<M extends AnyMachine, Key extends ExplorationKey = Ex
|
|
|
1461
1461
|
* events: Machine.eventsFromSchemas(Increment)
|
|
1462
1462
|
* }).handle({
|
|
1463
1463
|
* initial: {
|
|
1464
|
-
* target:
|
|
1464
|
+
* target: "Count",
|
|
1465
1465
|
* decoded: true,
|
|
1466
1466
|
* data: new Count({ value: 0 })
|
|
1467
1467
|
* },
|
|
@@ -1654,7 +1654,7 @@ export type RunServices<M extends AnyMachine> = IsAny<
|
|
|
1654
1654
|
* events: Machine.eventsFromSchemas()
|
|
1655
1655
|
* }).handle({
|
|
1656
1656
|
* initial: {
|
|
1657
|
-
* target:
|
|
1657
|
+
* target: "Idle"
|
|
1658
1658
|
* },
|
|
1659
1659
|
* states: {
|
|
1660
1660
|
* Idle: {}
|
|
@@ -1925,7 +1925,7 @@ export interface Coverage<M extends AnyMachine> {
|
|
|
1925
1925
|
* events: Machine.eventsFromSchemas()
|
|
1926
1926
|
* }).handle({
|
|
1927
1927
|
* initial: {
|
|
1928
|
-
* target:
|
|
1928
|
+
* target: "Idle"
|
|
1929
1929
|
* },
|
|
1930
1930
|
* states: {
|
|
1931
1931
|
* Idle: {}
|
|
@@ -2153,7 +2153,7 @@ export interface VerifyOptions {
|
|
|
2153
2153
|
* events: Machine.eventsFromSchemas()
|
|
2154
2154
|
* }).handle({
|
|
2155
2155
|
* initial: {
|
|
2156
|
-
* target:
|
|
2156
|
+
* target: "Idle"
|
|
2157
2157
|
* },
|
|
2158
2158
|
* states: {
|
|
2159
2159
|
* Idle: {}
|
|
@@ -352,7 +352,7 @@ export const layerMemory: Layer.Layer<Storage> = internal.layerMemory
|
|
|
352
352
|
* events: Machine.eventsFromSchemas()
|
|
353
353
|
* }).handle({
|
|
354
354
|
* initial: {
|
|
355
|
-
* target:
|
|
355
|
+
* target: "Idle"
|
|
356
356
|
* },
|
|
357
357
|
* states: {
|
|
358
358
|
* Idle: {}
|
|
@@ -397,7 +397,7 @@ type EnsureValuedSelectorPath<State, Path extends string> = [Path] extends [Valu
|
|
|
397
397
|
* events: Machine.eventsFromSchemas()
|
|
398
398
|
* }).handle({
|
|
399
399
|
* initial: {
|
|
400
|
-
* target:
|
|
400
|
+
* target: "Count",
|
|
401
401
|
* decoded: true,
|
|
402
402
|
* data: new Count({ value: 0 })
|
|
403
403
|
* },
|
|
@@ -642,7 +642,7 @@ export const selectSnapshotChild: {
|
|
|
642
642
|
* events: Machine.eventsFromSchemas()
|
|
643
643
|
* }).handle({
|
|
644
644
|
* initial: {
|
|
645
|
-
* target:
|
|
645
|
+
* target: "Idle"
|
|
646
646
|
* },
|
|
647
647
|
* states: {
|
|
648
648
|
* Idle: {}
|
|
@@ -1125,7 +1125,7 @@ export const familyChild: <
|
|
|
1125
1125
|
* events: Machine.eventsFromSchemas()
|
|
1126
1126
|
* }).handle({
|
|
1127
1127
|
* initial: {
|
|
1128
|
-
* target:
|
|
1128
|
+
* target: "Idle"
|
|
1129
1129
|
* },
|
|
1130
1130
|
* states: {
|
|
1131
1131
|
* Idle: {}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Machine, State } from "../../Machine.js";
|
|
2
|
-
/** Reference metadata is separate from child names, including names such as `path`. */
|
|
3
|
-
export declare const TypeId: unique symbol;
|
|
4
|
-
export interface Reference {
|
|
5
|
-
readonly [TypeId]: {
|
|
6
|
-
readonly root: State<Machine.StateNodeConfig>;
|
|
7
|
-
readonly path: string;
|
|
8
|
-
readonly kind: "state" | "choice" | "history";
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
/** Captures an immutable reference tree without allocating or executing a machine. */
|
|
12
|
-
export declare const make: (root: State<Machine.StateNodeConfig>) => {
|
|
13
|
-
readonly root: Reference;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=targetReference.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"targetReference.d.ts","sourceRoot":"","sources":["../../../src/internal/machine/targetReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAEtD,uFAAuF;AACvF,eAAO,MAAM,MAAM,EAAE,OAAO,MAAqD,CAAA;AAEjF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE;QACjB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;KAC9C,CAAA;CACF;AAED,sFAAsF;AACtF,eAAO,MAAM,IAAI,GAAI,MAAM,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,KAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAuCrF,CAAA"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as Schema from "effect/Schema";
|
|
2
|
-
/** Reference metadata is separate from child names, including names such as `path`. */
|
|
3
|
-
export const TypeId = Symbol.for("effect/Machine/TargetReference");
|
|
4
|
-
/** Captures an immutable reference tree without allocating or executing a machine. */
|
|
5
|
-
export const make = (root) => {
|
|
6
|
-
const nodes = [];
|
|
7
|
-
const visit = (node, path, key, parent) => {
|
|
8
|
-
const type = !Schema.isSchema(node) && "type" in node ? node.type ?? "active" : "active";
|
|
9
|
-
nodes.push({ path, key, parent, type });
|
|
10
|
-
if (!Schema.isSchema(node) && "states" in node) {
|
|
11
|
-
for (const [childKey, child] of Object.entries(node.states)) {
|
|
12
|
-
visit(child, path === "" ? childKey : `${path}.${childKey}`, childKey, path);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
visit(root.node, "", "", undefined);
|
|
17
|
-
const references = new Map();
|
|
18
|
-
for (const node of nodes) {
|
|
19
|
-
const reference = Object.create(null);
|
|
20
|
-
Object.defineProperty(reference, TypeId, {
|
|
21
|
-
value: Object.freeze({
|
|
22
|
-
root,
|
|
23
|
-
path: node.path,
|
|
24
|
-
kind: node.type === "history" || node.type === "choice" ? node.type : "state"
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
references.set(node.path, reference);
|
|
28
|
-
}
|
|
29
|
-
for (const node of nodes) {
|
|
30
|
-
if (node.parent !== undefined) {
|
|
31
|
-
Object.defineProperty(references.get(node.parent), node.key, {
|
|
32
|
-
value: references.get(node.path),
|
|
33
|
-
enumerable: true
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
for (const reference of references.values())
|
|
38
|
-
Object.freeze(reference);
|
|
39
|
-
return Object.freeze({ root: references.get("") });
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=targetReference.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"targetReference.js","sourceRoot":"","sources":["../../../src/internal/machine/targetReference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,uFAAuF;AACvF,MAAM,CAAC,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;AAUjF,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAoC,EAAgC,EAAE;IACzF,MAAM,KAAK,GAAmF,EAAE,CAAA;IAChG,MAAM,KAAK,GAAG,CACZ,IAAoD,EACpD,IAAY,EACZ,GAAW,EACX,MAA0B,EACpB,EAAE;QACR,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,QA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,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE;gBAC3D,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBAChC,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,MAAM,EAAE;QAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACrE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAAE,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as Schema from "effect/Schema"
|
|
2
|
-
import type { Machine, State } from "../../Machine.js"
|
|
3
|
-
|
|
4
|
-
/** Reference metadata is separate from child names, including names such as `path`. */
|
|
5
|
-
export const TypeId: unique symbol = Symbol.for("effect/Machine/TargetReference")
|
|
6
|
-
|
|
7
|
-
export interface Reference {
|
|
8
|
-
readonly [TypeId]: {
|
|
9
|
-
readonly root: State<Machine.StateNodeConfig>
|
|
10
|
-
readonly path: string
|
|
11
|
-
readonly kind: "state" | "choice" | "history"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** Captures an immutable reference tree without allocating or executing a machine. */
|
|
16
|
-
export const make = (root: State<Machine.StateNodeConfig>): { readonly root: Reference } => {
|
|
17
|
-
const nodes: Array<{ path: string; key: string; parent: string | undefined; type: string }> = []
|
|
18
|
-
const visit = (
|
|
19
|
-
node: Machine.StateNodeConfig | Machine.TaggedSchema,
|
|
20
|
-
path: string,
|
|
21
|
-
key: string,
|
|
22
|
-
parent: string | undefined
|
|
23
|
-
): void => {
|
|
24
|
-
const type = !Schema.isSchema(node) && "type" in node ? node.type ?? "active" : "active"
|
|
25
|
-
nodes.push({ path, key, parent, type })
|
|
26
|
-
if (!Schema.isSchema(node) && "states" in node) {
|
|
27
|
-
for (const [childKey, child] of Object.entries(node.states)) {
|
|
28
|
-
visit(child, path === "" ? childKey : `${path}.${childKey}`, childKey, path)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
visit(root.node, "", "", undefined)
|
|
33
|
-
const references = new Map<string, Reference>()
|
|
34
|
-
for (const node of nodes) {
|
|
35
|
-
const reference = Object.create(null)
|
|
36
|
-
Object.defineProperty(reference, TypeId, {
|
|
37
|
-
value: Object.freeze({
|
|
38
|
-
root,
|
|
39
|
-
path: node.path,
|
|
40
|
-
kind: node.type === "history" || node.type === "choice" ? node.type : "state"
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
references.set(node.path, reference)
|
|
44
|
-
}
|
|
45
|
-
for (const node of nodes) {
|
|
46
|
-
if (node.parent !== undefined) {
|
|
47
|
-
Object.defineProperty(references.get(node.parent), node.key, {
|
|
48
|
-
value: references.get(node.path),
|
|
49
|
-
enumerable: true
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
for (const reference of references.values()) Object.freeze(reference)
|
|
54
|
-
return Object.freeze({ root: references.get("")! })
|
|
55
|
-
}
|