effect-machine 0.13.0 → 0.15.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 +19 -11
- package/dist/actor.d.ts +18 -6
- package/dist/actor.js +151 -61
- package/dist/cluster/entity-machine.d.ts +1 -1
- package/dist/cluster/entity-machine.js +2 -1
- package/dist/cluster/to-entity.d.ts +1 -1
- package/dist/errors.d.ts +9 -2
- package/dist/errors.js +8 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/internal/runtime.d.ts +21 -2
- package/dist/internal/runtime.js +64 -56
- package/dist/internal/transition.d.ts +9 -9
- package/dist/internal/transition.js +3 -5
- package/dist/machine.d.ts +129 -135
- package/dist/machine.js +97 -112
- package/dist/schema.d.ts +17 -1
- package/dist/schema.js +10 -0
- package/dist/slot.d.ts +112 -86
- package/dist/slot.js +92 -59
- package/dist/testing.d.ts +16 -16
- package/dist/testing.js +3 -3
- package/package.json +3 -3
- package/v3/dist/actor.d.ts +25 -12
- package/v3/dist/actor.js +174 -89
- package/v3/dist/cluster/entity-machine.d.ts +1 -1
- package/v3/dist/cluster/entity-machine.js +1 -0
- package/v3/dist/cluster/to-entity.d.ts +1 -1
- package/v3/dist/errors.d.ts +12 -3
- package/v3/dist/errors.js +10 -4
- package/v3/dist/index.d.ts +6 -6
- package/v3/dist/index.js +2 -2
- package/v3/dist/inspection.d.ts +3 -22
- package/v3/dist/inspection.js +1 -15
- package/v3/dist/internal/brands.d.ts +4 -8
- package/v3/dist/internal/inspection.js +1 -1
- package/v3/dist/internal/runtime.d.ts +27 -8
- package/v3/dist/internal/runtime.js +91 -61
- package/v3/dist/internal/transition.d.ts +10 -10
- package/v3/dist/internal/transition.js +8 -10
- package/v3/dist/internal/utils.js +5 -1
- package/v3/dist/machine.d.ts +160 -120
- package/v3/dist/machine.js +118 -115
- package/v3/dist/schema.d.ts +25 -11
- package/v3/dist/schema.js +18 -5
- package/v3/dist/slot.d.ts +112 -86
- package/v3/dist/slot.js +92 -59
- package/v3/dist/testing.d.ts +16 -16
- package/v3/dist/testing.js +7 -7
package/dist/slot.js
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import { ServiceMap } from "effect";
|
|
1
|
+
import { Schema, ServiceMap } from "effect";
|
|
2
2
|
//#region src/slot.ts
|
|
3
3
|
/**
|
|
4
|
-
* Slot module
|
|
4
|
+
* Slot module — unified, schema-based parameterized slots.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Replaces the split Guards/Effects API with a single `Slot.define` + `Slot.fn`.
|
|
7
|
+
* Each slot declares its parameter schema and (optional) return schema.
|
|
8
|
+
* Handlers receive only params — machine context is accessed via `yield* machine.Context`.
|
|
8
9
|
*
|
|
9
10
|
* @example
|
|
10
11
|
* ```ts
|
|
11
12
|
* import { Slot } from "effect-machine"
|
|
12
13
|
* import { Schema } from "effect"
|
|
13
14
|
*
|
|
14
|
-
* const
|
|
15
|
-
* canRetry: { max: Schema.Number },
|
|
16
|
-
* isValid: {},
|
|
17
|
-
* })
|
|
18
|
-
*
|
|
19
|
-
* const MyEffects = Slot.Effects({
|
|
20
|
-
* fetchData: { url: Schema.String },
|
|
21
|
-
* notify: { message: Schema.String },
|
|
15
|
+
* const MySlots = Slot.define({
|
|
16
|
+
* canRetry: Slot.fn({ max: Schema.Number }, Schema.Boolean),
|
|
17
|
+
* isValid: Slot.fn({}, Schema.Boolean),
|
|
18
|
+
* fetchData: Slot.fn({ url: Schema.String }),
|
|
19
|
+
* notify: Slot.fn({ message: Schema.String }),
|
|
22
20
|
* })
|
|
23
21
|
*
|
|
24
22
|
* // Used in handlers:
|
|
25
|
-
* .on(State.X, Event.Y, ({
|
|
23
|
+
* .on(State.X, Event.Y, ({ slots }) =>
|
|
26
24
|
* Effect.gen(function* () {
|
|
27
|
-
* if (yield*
|
|
28
|
-
* yield*
|
|
25
|
+
* if (yield* slots.canRetry({ max: 3 })) {
|
|
26
|
+
* yield* slots.fetchData({ url: "/api" })
|
|
29
27
|
* return State.Next
|
|
30
28
|
* }
|
|
31
29
|
* return state
|
|
@@ -36,62 +34,97 @@ import { ServiceMap } from "effect";
|
|
|
36
34
|
* @module
|
|
37
35
|
*/
|
|
38
36
|
/**
|
|
39
|
-
*
|
|
40
|
-
* Single module-level tag instead of per-machine allocation.
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
const MachineContextTag = ServiceMap.Service("@effect-machine/Context");
|
|
44
|
-
/**
|
|
45
|
-
* Generic slot schema factory. Used internally by Guards() and Effects().
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
const createSlotSchema = (tag, slotTag, definitions) => ({
|
|
49
|
-
_tag: tag,
|
|
50
|
-
definitions,
|
|
51
|
-
_createSlots: (resolve) => {
|
|
52
|
-
const slots = {};
|
|
53
|
-
for (const name of Object.keys(definitions)) {
|
|
54
|
-
const slot = (params) => resolve(name, params);
|
|
55
|
-
Object.defineProperty(slot, "_tag", {
|
|
56
|
-
value: slotTag,
|
|
57
|
-
enumerable: true
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(slot, "name", {
|
|
60
|
-
value: name,
|
|
61
|
-
enumerable: true
|
|
62
|
-
});
|
|
63
|
-
slots[name] = slot;
|
|
64
|
-
}
|
|
65
|
-
return slots;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
/**
|
|
69
|
-
* Create a guards schema with parameterized guard definitions.
|
|
37
|
+
* Define a single slot function with parameter schema and optional return schema.
|
|
70
38
|
*
|
|
71
39
|
* @example
|
|
72
40
|
* ```ts
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
41
|
+
* // Guard-like: returns boolean
|
|
42
|
+
* Slot.fn({ max: Schema.Number }, Schema.Boolean)
|
|
43
|
+
*
|
|
44
|
+
* // Effect-like: returns void (default)
|
|
45
|
+
* Slot.fn({ url: Schema.String })
|
|
46
|
+
*
|
|
47
|
+
* // No params, returns boolean
|
|
48
|
+
* Slot.fn({}, Schema.Boolean)
|
|
77
49
|
* ```
|
|
78
50
|
*/
|
|
79
|
-
const
|
|
51
|
+
const fn = (fields, returnSchema) => {
|
|
52
|
+
return {
|
|
53
|
+
_tag: "SlotFnDef",
|
|
54
|
+
fields,
|
|
55
|
+
returnSchema,
|
|
56
|
+
inputSchema: Object.keys(fields).length > 0 ? Schema.Struct(fields) : Schema.Void,
|
|
57
|
+
outputSchema: returnSchema ?? Schema.Void
|
|
58
|
+
};
|
|
59
|
+
};
|
|
80
60
|
/**
|
|
81
|
-
*
|
|
61
|
+
* Shared Context tag for all machines.
|
|
62
|
+
* Single module-level tag instead of per-machine allocation.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
const MachineContextTag = ServiceMap.Service("@effect-machine/Context");
|
|
66
|
+
/**
|
|
67
|
+
* Define a set of slots with parameter and return schemas.
|
|
82
68
|
*
|
|
83
69
|
* @example
|
|
84
70
|
* ```ts
|
|
85
|
-
* const
|
|
86
|
-
*
|
|
87
|
-
*
|
|
71
|
+
* const MySlots = Slot.define({
|
|
72
|
+
* canRetry: Slot.fn({ max: Schema.Number }, Schema.Boolean),
|
|
73
|
+
* fetchData: Slot.fn({ url: Schema.String }),
|
|
74
|
+
* notify: Slot.fn({ message: Schema.String }),
|
|
88
75
|
* })
|
|
89
76
|
* ```
|
|
90
77
|
*/
|
|
91
|
-
const
|
|
78
|
+
const define = (definitions) => {
|
|
79
|
+
const names = Object.keys(definitions);
|
|
80
|
+
const requestSchemas = [];
|
|
81
|
+
const resultSchemas = [];
|
|
82
|
+
const invocationSchemas = [];
|
|
83
|
+
for (const name of names) {
|
|
84
|
+
const def = definitions[name];
|
|
85
|
+
if (def === void 0) continue;
|
|
86
|
+
requestSchemas.push(Schema.TaggedStruct("SlotRequest", {
|
|
87
|
+
name: Schema.Literal(name),
|
|
88
|
+
params: def.inputSchema
|
|
89
|
+
}));
|
|
90
|
+
resultSchemas.push(Schema.TaggedStruct("SlotResult", {
|
|
91
|
+
name: Schema.Literal(name),
|
|
92
|
+
result: def.outputSchema
|
|
93
|
+
}));
|
|
94
|
+
invocationSchemas.push(Schema.TaggedStruct("SlotInvocation", {
|
|
95
|
+
name: Schema.Literal(name),
|
|
96
|
+
params: def.inputSchema,
|
|
97
|
+
result: def.outputSchema
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
const buildUnion = (schemas) => schemas.length === 0 ? Schema.Never : Schema.Union(schemas);
|
|
101
|
+
return {
|
|
102
|
+
_tag: "SlotsSchema",
|
|
103
|
+
definitions,
|
|
104
|
+
requestSchema: buildUnion(requestSchemas),
|
|
105
|
+
resultSchema: buildUnion(resultSchemas),
|
|
106
|
+
invocationSchema: buildUnion(invocationSchemas),
|
|
107
|
+
_createSlots: (resolve) => {
|
|
108
|
+
const slots = {};
|
|
109
|
+
for (const name of names) {
|
|
110
|
+
const slot = (params) => resolve(name, params);
|
|
111
|
+
Object.defineProperty(slot, "_tag", {
|
|
112
|
+
value: "Slot",
|
|
113
|
+
enumerable: true
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(slot, "name", {
|
|
116
|
+
value: name,
|
|
117
|
+
enumerable: true
|
|
118
|
+
});
|
|
119
|
+
slots[name] = slot;
|
|
120
|
+
}
|
|
121
|
+
return slots;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
};
|
|
92
125
|
const Slot = {
|
|
93
|
-
|
|
94
|
-
|
|
126
|
+
fn,
|
|
127
|
+
define
|
|
95
128
|
};
|
|
96
129
|
//#endregion
|
|
97
|
-
export {
|
|
130
|
+
export { MachineContextTag, Slot, define, fn };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AssertionError } from "./errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MachineContext, ProvideSlots, SlotsDef } from "./slot.js";
|
|
3
3
|
import { Machine, MachineRef } from "./machine.js";
|
|
4
4
|
import { Effect, SubscriptionRef } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/testing.d.ts
|
|
7
|
-
type MachineInput<S, E, R,
|
|
7
|
+
type MachineInput<S, E, R, SD extends SlotsDef = Record<string, never>> = Machine<S, E, R, any, any, SD>;
|
|
8
8
|
/**
|
|
9
9
|
* Result of simulating events through a machine
|
|
10
10
|
*/
|
|
@@ -15,7 +15,7 @@ interface SimulationResult<S> {
|
|
|
15
15
|
/**
|
|
16
16
|
* Simulate a sequence of events through a machine without running an actor.
|
|
17
17
|
* Useful for testing state transitions in isolation.
|
|
18
|
-
* Does not run onEnter/spawn/background effects, but does run
|
|
18
|
+
* Does not run onEnter/spawn/background effects, but does run slots
|
|
19
19
|
* within transition handlers.
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
@@ -36,8 +36,8 @@ declare const simulate: <S extends {
|
|
|
36
36
|
readonly _tag: string;
|
|
37
37
|
}, E extends {
|
|
38
38
|
readonly _tag: string;
|
|
39
|
-
}, R,
|
|
40
|
-
slots?:
|
|
39
|
+
}, R, SD extends SlotsDef = Record<string, never>>(input: MachineInput<S, E, R, SD>, events: readonly E[], options?: {
|
|
40
|
+
slots?: ProvideSlots<SD, any>;
|
|
41
41
|
} | undefined) => Effect.Effect<{
|
|
42
42
|
states: S[];
|
|
43
43
|
finalState: S;
|
|
@@ -49,8 +49,8 @@ declare const assertReaches: <S extends {
|
|
|
49
49
|
readonly _tag: string;
|
|
50
50
|
}, E extends {
|
|
51
51
|
readonly _tag: string;
|
|
52
|
-
}, R,
|
|
53
|
-
slots?:
|
|
52
|
+
}, R, SD extends SlotsDef = Record<string, never>>(input: MachineInput<S, E, R, SD>, events: readonly E[], expectedTag: string, options?: {
|
|
53
|
+
slots?: ProvideSlots<SD, any>;
|
|
54
54
|
} | undefined) => Effect.Effect<S, AssertionError, Exclude<R, MachineContext<S, E, MachineRef<E>>>>;
|
|
55
55
|
/**
|
|
56
56
|
* Assert that a machine follows a specific path of state tags
|
|
@@ -68,8 +68,8 @@ declare const assertPath: <S extends {
|
|
|
68
68
|
readonly _tag: string;
|
|
69
69
|
}, E extends {
|
|
70
70
|
readonly _tag: string;
|
|
71
|
-
}, R,
|
|
72
|
-
slots?:
|
|
71
|
+
}, R, SD extends SlotsDef = Record<string, never>>(input: MachineInput<S, E, R, SD>, events: readonly E[], expectedPath: readonly string[], options?: {
|
|
72
|
+
slots?: ProvideSlots<SD, any>;
|
|
73
73
|
} | undefined) => Effect.Effect<{
|
|
74
74
|
states: S[];
|
|
75
75
|
finalState: S;
|
|
@@ -91,8 +91,8 @@ declare const assertNeverReaches: <S extends {
|
|
|
91
91
|
readonly _tag: string;
|
|
92
92
|
}, E extends {
|
|
93
93
|
readonly _tag: string;
|
|
94
|
-
}, R,
|
|
95
|
-
slots?:
|
|
94
|
+
}, R, SD extends SlotsDef = Record<string, never>>(input: MachineInput<S, E, R, SD>, events: readonly E[], forbiddenTag: string, options?: {
|
|
95
|
+
slots?: ProvideSlots<SD, any>;
|
|
96
96
|
} | undefined) => Effect.Effect<{
|
|
97
97
|
states: S[];
|
|
98
98
|
finalState: S;
|
|
@@ -108,18 +108,18 @@ interface TestHarness<S, E, R> {
|
|
|
108
108
|
/**
|
|
109
109
|
* Options for creating a test harness
|
|
110
110
|
*/
|
|
111
|
-
interface TestHarnessOptions<S, E
|
|
111
|
+
interface TestHarnessOptions<S, E, SD extends SlotsDef = Record<string, never>> {
|
|
112
112
|
/**
|
|
113
113
|
* Called after each transition with the previous state, event, and new state.
|
|
114
114
|
* Useful for logging or spying on transitions.
|
|
115
115
|
*/
|
|
116
116
|
readonly onTransition?: (from: S, event: E, to: S) => void;
|
|
117
|
-
/** Slot handler implementations
|
|
118
|
-
readonly slots?:
|
|
117
|
+
/** Slot handler implementations. */
|
|
118
|
+
readonly slots?: ProvideSlots<SD, any>;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Create a test harness for step-by-step testing.
|
|
122
|
-
* Does not run onEnter/spawn/background effects, but does run
|
|
122
|
+
* Does not run onEnter/spawn/background effects, but does run slots
|
|
123
123
|
* within transition handlers.
|
|
124
124
|
*
|
|
125
125
|
* @example Basic usage
|
|
@@ -142,7 +142,7 @@ declare const createTestHarness: <S extends {
|
|
|
142
142
|
readonly _tag: string;
|
|
143
143
|
}, E extends {
|
|
144
144
|
readonly _tag: string;
|
|
145
|
-
}, R,
|
|
145
|
+
}, R, SD extends SlotsDef = Record<string, never>>(input: MachineInput<S, E, R, SD>, options?: TestHarnessOptions<S, E, SD> | undefined) => Effect.Effect<{
|
|
146
146
|
state: SubscriptionRef.SubscriptionRef<S>;
|
|
147
147
|
send: (event: E) => Effect.Effect<S, never, Exclude<R, MachineContext<S, E, MachineRef<E>>>>;
|
|
148
148
|
getState: Effect.Effect<S, never, never>;
|
package/dist/testing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { stubSystem } from "./internal/utils.js";
|
|
2
|
-
import { executeTransition, shouldPostpone } from "./internal/transition.js";
|
|
3
2
|
import { AssertionError } from "./errors.js";
|
|
3
|
+
import { executeTransition, shouldPostpone } from "./internal/transition.js";
|
|
4
4
|
import { materializeMachine } from "./machine.js";
|
|
5
5
|
import { Effect, SubscriptionRef } from "effect";
|
|
6
6
|
//#region src/testing.ts
|
|
@@ -16,7 +16,7 @@ const makeDummySelf = (label) => {
|
|
|
16
16
|
/**
|
|
17
17
|
* Simulate a sequence of events through a machine without running an actor.
|
|
18
18
|
* Useful for testing state transitions in isolation.
|
|
19
|
-
* Does not run onEnter/spawn/background effects, but does run
|
|
19
|
+
* Does not run onEnter/spawn/background effects, but does run slots
|
|
20
20
|
* within transition handlers.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
@@ -122,7 +122,7 @@ const assertNeverReaches = Effect.fn("effect-machine.assertNeverReaches")(functi
|
|
|
122
122
|
});
|
|
123
123
|
/**
|
|
124
124
|
* Create a test harness for step-by-step testing.
|
|
125
|
-
* Does not run onEnter/spawn/background effects, but does run
|
|
125
|
+
* Does not run onEnter/spawn/background effects, but does run slots
|
|
126
126
|
* within transition handlers.
|
|
127
127
|
*
|
|
128
128
|
* @example Basic usage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-machine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/cevr/effect-machine.git"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"release": "bun run build && changeset publish"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"effect": "4.0.0-beta.
|
|
59
|
+
"effect": "4.0.0-beta.43"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@changesets/changelog-github": "^0.6.0",
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"overrides": {
|
|
84
|
-
"effect": "4.0.0-beta.
|
|
84
|
+
"effect": "4.0.0-beta.43"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/v3/dist/actor.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ActorExit, Supervision } from "./supervision.js";
|
|
2
1
|
import { ExtractReply, ReplyTypeBrand } from "./internal/brands.js";
|
|
3
2
|
import { ActorStoppedError, DuplicateActorError, NoReplyError } from "./errors.js";
|
|
4
|
-
import {
|
|
3
|
+
import { ProvideSlots, SlotsDef } from "./slot.js";
|
|
4
|
+
import { ActorExit, Supervision } from "./supervision.js";
|
|
5
5
|
import { ProcessEventError, ProcessEventHooks, ProcessEventResult, processEventCore, resolveTransition, runSpawnEffects } from "./internal/transition.js";
|
|
6
|
-
import { Machine } from "./machine.js";
|
|
6
|
+
import { Lifecycle, Machine } from "./machine.js";
|
|
7
7
|
import { RuntimeQueuedEvent } from "./internal/runtime.js";
|
|
8
8
|
import { Context, Deferred, Effect, Layer, Option, PubSub, Queue, Ref, Scope, Stream, SubscriptionRef } from "effect";
|
|
9
9
|
|
|
@@ -54,6 +54,12 @@ interface ActorRef<State extends {
|
|
|
54
54
|
readonly state: SubscriptionRef.SubscriptionRef<State>;
|
|
55
55
|
/** Stop the actor gracefully. */
|
|
56
56
|
readonly stop: Effect.Effect<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Start the actor — fork event loop, background effects, spawn effects.
|
|
59
|
+
* Called automatically by `system.spawn`. For `Machine.spawn`, the caller
|
|
60
|
+
* must call `start` explicitly. Events sent before start() are queued.
|
|
61
|
+
*/
|
|
62
|
+
readonly start: Effect.Effect<void>;
|
|
57
63
|
/** Get current state snapshot. */
|
|
58
64
|
readonly snapshot: Effect.Effect<State>;
|
|
59
65
|
/** Check if current state matches tag. */
|
|
@@ -96,7 +102,7 @@ interface ActorRef<State extends {
|
|
|
96
102
|
readonly awaitExit: Effect.Effect<ActorExit<State>>;
|
|
97
103
|
/**
|
|
98
104
|
* Watch another actor. Returns an Effect that resolves with the exit reason
|
|
99
|
-
* when the watched actor terminally stops. Ignores restarts.
|
|
105
|
+
* when the watched actor terminally stops. Ignores restarts (Step 3).
|
|
100
106
|
* Built on the other actor's exitDeferred — authoritative, not system events.
|
|
101
107
|
*/
|
|
102
108
|
readonly watch: (other: {
|
|
@@ -148,14 +154,20 @@ type SystemEventListener = (event: SystemEvent) => void;
|
|
|
148
154
|
interface ActorSystem {
|
|
149
155
|
/**
|
|
150
156
|
* Spawn a new actor with the given machine.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const actor = yield* system.spawn("my-actor", machine);
|
|
161
|
+
* ```
|
|
151
162
|
*/
|
|
152
163
|
readonly spawn: <S extends {
|
|
153
164
|
readonly _tag: string;
|
|
154
165
|
}, E extends {
|
|
155
166
|
readonly _tag: string;
|
|
156
|
-
}, R
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
}, R, SD extends SlotsDef = Record<string, never>>(id: string, machine: Machine<S, E, R, any, any, SD>, options?: {
|
|
168
|
+
readonly supervision?: Supervision.Policy;
|
|
169
|
+
readonly slots?: ProvideSlots<SD, any>;
|
|
170
|
+
readonly lifecycle?: Lifecycle<S, E>;
|
|
159
171
|
}) => Effect.Effect<ActorRef<S, E>, DuplicateActorError, R>;
|
|
160
172
|
/**
|
|
161
173
|
* Get an existing actor by ID
|
|
@@ -198,18 +210,19 @@ declare const buildActorRefCore: <S extends {
|
|
|
198
210
|
readonly _tag: string;
|
|
199
211
|
}, E extends {
|
|
200
212
|
readonly _tag: string;
|
|
201
|
-
}, R,
|
|
213
|
+
}, R, SD extends SlotsDef>(id: string, machine: Machine<S, E, R, any, any, SD>, stateRef: SubscriptionRef.SubscriptionRef<S>, eventQueueRef: Ref.Ref<Queue.Queue<QueuedEvent<E>>>, stoppedRef: Ref.Ref<boolean>, listeners: Listeners<S>, stop: Effect.Effect<void>, start: Effect.Effect<void>, system: ActorSystem, childrenMap: ReadonlyMap<string, ActorRef<AnyState, unknown>>, pendingReplies: Set<Deferred.Deferred<unknown, unknown>>, transitionsPubSub: PubSub.PubSub<TransitionInfo<S, E>> | undefined, exitDeferred: Deferred.Deferred<ActorExit<S>, never>) => ActorRef<S, E>;
|
|
202
214
|
/**
|
|
203
215
|
* Create and start an actor for a machine.
|
|
204
|
-
*
|
|
216
|
+
* Delegates to the shared runtime kernel with actor-specific lifecycle hooks.
|
|
205
217
|
*/
|
|
206
218
|
declare const createActor: <S extends {
|
|
207
219
|
readonly _tag: string;
|
|
208
220
|
}, E extends {
|
|
209
221
|
readonly _tag: string;
|
|
210
|
-
}, R,
|
|
222
|
+
}, R, SD extends SlotsDef>(id: string, machine: Machine<S, E, R, any, any, SD>, options?: {
|
|
211
223
|
initialState?: S;
|
|
212
|
-
supervision?: Supervision.Policy;
|
|
224
|
+
supervision?: Supervision.Policy;
|
|
225
|
+
lifecycle?: Lifecycle<S, E>; /** @internal Called by system after each restart — emits ActorRestarted system event */
|
|
213
226
|
onRestart?: (generation: number, exit: ActorExit<unknown>) => Effect.Effect<void>;
|
|
214
227
|
} | undefined) => Effect.Effect<ActorRef<S, E>, never, never>;
|
|
215
228
|
/** Fail all pending call/ask Deferreds with ActorStoppedError. Safe to call multiple times. */
|
|
@@ -222,6 +235,6 @@ declare const makeSystem: () => Effect.Effect<ActorSystem, never, Scope.Scope>;
|
|
|
222
235
|
/**
|
|
223
236
|
* Default ActorSystem layer
|
|
224
237
|
*/
|
|
225
|
-
declare const Default: Layer.Layer<ActorSystem, never,
|
|
238
|
+
declare const Default: Layer.Layer<ActorSystem, never, never>;
|
|
226
239
|
//#endregion
|
|
227
240
|
export { ActorRef, ActorRefSync, ActorSystem, Default, Listeners, type ProcessEventError, type ProcessEventHooks, type ProcessEventResult, QueuedEvent, SystemEvent, SystemEventListener, TransitionInfo, buildActorRefCore, createActor, makeSystem, notifyListeners, processEventCore, resolveTransition, runSpawnEffects, settlePendingReplies };
|