@demlik/tea 0.20.0 → 0.21.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 +11 -2
- package/dist/agent/index.d.ts +17 -17
- package/dist/agent/index.js +10 -10
- package/dist/{chunk-FTCYY2DO.js → chunk-4I2LCQKB.js} +3 -3
- package/dist/{chunk-FTCYY2DO.js.map → chunk-4I2LCQKB.js.map} +1 -1
- package/dist/{chunk-EA47MI5Q.js → chunk-6NIQIUGR.js} +4 -4
- package/dist/{chunk-EA47MI5Q.js.map → chunk-6NIQIUGR.js.map} +1 -1
- package/dist/{chunk-HX3C6LDK.js → chunk-7Z2IDZ7R.js} +3 -3
- package/dist/{chunk-HX3C6LDK.js.map → chunk-7Z2IDZ7R.js.map} +1 -1
- package/dist/{chunk-XWIE5V7R.js → chunk-BFSZ4L6Y.js} +4 -4
- package/dist/{chunk-XWIE5V7R.js.map → chunk-BFSZ4L6Y.js.map} +1 -1
- package/dist/{chunk-JAKM53JF.js → chunk-EB5OMOXX.js} +4 -4
- package/dist/chunk-EB5OMOXX.js.map +1 -0
- package/dist/{chunk-RKVUVALV.js → chunk-GAVLND5C.js} +19 -4
- package/dist/chunk-GAVLND5C.js.map +1 -0
- package/dist/{chunk-AIXC33SE.js → chunk-HU3Y2AZY.js} +4 -4
- package/dist/chunk-HU3Y2AZY.js.map +1 -0
- package/dist/{chunk-72CN3VPY.js → chunk-MBQR3LFW.js} +5 -5
- package/dist/{chunk-72CN3VPY.js.map → chunk-MBQR3LFW.js.map} +1 -1
- package/dist/{chunk-TAKPC6SD.js → chunk-QIE4Y6BK.js} +4 -4
- package/dist/{chunk-TAKPC6SD.js.map → chunk-QIE4Y6BK.js.map} +1 -1
- package/dist/{chunk-TGJLXZAU.js → chunk-TMYUDZLE.js} +3 -3
- package/dist/{chunk-TGJLXZAU.js.map → chunk-TMYUDZLE.js.map} +1 -1
- package/dist/{chunk-DVNXEB7V.js → chunk-VHKDUBXC.js} +3 -3
- package/dist/chunk-VHKDUBXC.js.map +1 -0
- package/dist/{chunk-UHAQ4PI6.js → chunk-VM7PMFV5.js} +70 -47
- package/dist/chunk-VM7PMFV5.js.map +1 -0
- package/dist/{chunk-2774I242.js → chunk-W6XWI6QE.js} +20 -20
- package/dist/chunk-W6XWI6QE.js.map +1 -0
- package/dist/{chunk-NGYFBD5G.js → chunk-YCJPLPQQ.js} +3 -3
- package/dist/{chunk-NGYFBD5G.js.map → chunk-YCJPLPQQ.js.map} +1 -1
- package/dist/{chunk-2R62Q5UK.js → chunk-YDF6P74H.js} +3 -3
- package/dist/{chunk-2R62Q5UK.js.map → chunk-YDF6P74H.js.map} +1 -1
- package/dist/{chunk-A73IJ27X.js → chunk-Z7IL735U.js} +3 -3
- package/dist/{chunk-A73IJ27X.js.map → chunk-Z7IL735U.js.map} +1 -1
- package/dist/{chunk-5HVKDHY6.js → chunk-ZV4WGW74.js} +3 -3
- package/dist/{chunk-5HVKDHY6.js.map → chunk-ZV4WGW74.js.map} +1 -1
- package/dist/{core-CtvAyPpH.d.ts → core-BKJW1Kmq.d.ts} +2 -2
- package/dist/do/index.d.ts +17 -15
- package/dist/do/index.js +11 -11
- package/dist/do/index.js.map +1 -1
- package/dist/{drive-loop-Dw1sGSsW.d.ts → drive-loop-Dc6Z8Vbs.d.ts} +1 -1
- package/dist/{durable-effects-Ump5lSdO.d.ts → durable-effects-CgrLNccA.d.ts} +1 -1
- package/dist/effect/index.d.ts +74 -7
- package/dist/effect/index.js +44 -6
- package/dist/effect/index.js.map +1 -1
- package/dist/extension/index.d.ts +3 -3
- package/dist/extension/index.js +2 -2
- package/dist/extension/index.js.map +1 -1
- package/dist/flow/index.d.ts +17 -13
- package/dist/flow/index.js +13 -12
- package/dist/flow/index.js.map +1 -1
- package/dist/idempotency/index.d.ts +3 -3
- package/dist/idempotency/index.js +3 -3
- package/dist/{index-CrcoVfd_.d.ts → index-1hit3dJ9.d.ts} +2 -2
- package/dist/{index-CKtEKGyp.d.ts → index-B-VC4qjx.d.ts} +3 -3
- package/dist/{index-EIgfl83J.d.ts → index-BjwRcjBi.d.ts} +2 -2
- package/dist/{index-CZZ3HI-Z.d.ts → index-CYrUWi1c.d.ts} +4 -4
- package/dist/{index-D3NY3VCN.d.ts → index-Cuy1_xTh.d.ts} +1 -1
- package/dist/{index-Bk2hBUdK.d.ts → index-DB8Yn0-K.d.ts} +1 -1
- package/dist/{index-CVU7SK3a.d.ts → index-Diyo8WBO.d.ts} +2 -2
- package/dist/{index-Dl71V7kt.d.ts → index-Z6Uw7C9t.d.ts} +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +2 -2
- package/dist/jev/index.d.ts +15 -15
- package/dist/jev/index.js +5 -5
- package/dist/jev/index.js.map +1 -1
- package/dist/{machine-Dtre2TmN.d.ts → machine-BuPTS1QH.d.ts} +7 -7
- package/dist/machine-viz/index.d.ts +1 -1
- package/dist/machine-viz/index.js +2 -2
- package/dist/mem/index.d.ts +2 -2
- package/dist/mem/index.js +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +2 -2
- package/dist/node/index.js.map +1 -1
- package/dist/otel/index.d.ts +10 -10
- package/dist/otel/index.js +10 -10
- package/dist/paginate/index.d.ts +4 -4
- package/dist/paginate/index.js +5 -5
- package/dist/parity/index.d.ts +3 -3
- package/dist/parity/index.js +3 -3
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +1 -1
- package/dist/pbt/index.js +2 -2
- package/dist/persistence/index.d.ts +5 -5
- package/dist/persistence/index.js +4 -4
- package/dist/promise/index.d.ts +25 -10
- package/dist/promise/index.js +4 -4
- package/dist/react/index.d.ts +7 -6
- package/dist/react/index.js.map +1 -1
- package/dist/resilience/index.d.ts +6 -6
- package/dist/resilience/index.js +5 -5
- package/dist/{run-fiBe7pOG.d.ts → run-D0sxbyno.d.ts} +22 -9
- package/dist/{runtime-types-DEluQgGO.d.ts → runtime-types-BPKp2bGo.d.ts} +48 -9
- package/dist/testing/effect/index.d.ts +5 -5
- package/dist/testing/effect/index.js +8 -8
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +3 -3
- package/dist/testing/promise/index.d.ts +4 -4
- package/dist/testing/promise/index.js +5 -5
- package/dist/timing/index.d.ts +4 -4
- package/dist/timing/index.js +4 -4
- package/dist/{types-CXNzlbAg.d.ts → types-BiXj7k_k.d.ts} +1 -1
- package/dist/work-queue/index.d.ts +4 -4
- package/dist/work-queue/index.js +2 -2
- package/package.json +4 -2
- package/dist/chunk-2774I242.js.map +0 -1
- package/dist/chunk-AIXC33SE.js.map +0 -1
- package/dist/chunk-DVNXEB7V.js.map +0 -1
- package/dist/chunk-JAKM53JF.js.map +0 -1
- package/dist/chunk-RKVUVALV.js.map +0 -1
- package/dist/chunk-UHAQ4PI6.js.map +0 -1
package/dist/effect/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Scope, Effect } from 'effect';
|
|
2
|
-
import { C as Cmd,
|
|
3
|
-
import {
|
|
4
|
-
export { C as CellErrors,
|
|
1
|
+
import { Scope, Effect, Schema } from 'effect';
|
|
2
|
+
import { C as Cmd$1, c as Sub, M as Machine, k as CmdInput, b as CmdDef, f as TaggedError } from '../core-BKJW1Kmq.js';
|
|
3
|
+
import { c as EffectRuntime, d as StoreFailed } from '../run-D0sxbyno.js';
|
|
4
|
+
export { C as CellErrors, e as EffectBootingRuntime, E as EffectInterpret, f as EffectInterpretCell, g as EffectRunOptions, h as EffectRunner, a as EffectSubscribe, I as InterpretServices, i as Stopped, b as SubscribeServices, r as run } from '../run-D0sxbyno.js';
|
|
5
5
|
import '@standard-schema/spec';
|
|
6
|
-
import '../runtime-types-
|
|
6
|
+
import '../runtime-types-BPKp2bGo.js';
|
|
7
7
|
import 'effect/Cause';
|
|
8
8
|
import 'effect/Types';
|
|
9
9
|
|
|
@@ -35,7 +35,7 @@ import 'effect/Types';
|
|
|
35
35
|
*/
|
|
36
36
|
declare const tell: <S, M extends {
|
|
37
37
|
type: string;
|
|
38
|
-
}, C extends Cmd, U extends Sub, Ctx, E extends {
|
|
38
|
+
}, C extends Cmd$1, U extends Sub, Ctx, E extends {
|
|
39
39
|
type: string;
|
|
40
40
|
} = never, Err = never>(machine: Machine<S, M, C, U, Ctx>, runtime: EffectRuntime<S, M, E, Err>, msg: NoInfer<M>) => Effect.Effect<void, Err | StoreFailed>;
|
|
41
41
|
/**
|
|
@@ -123,4 +123,71 @@ declare const spawn: <A, E = never, R = never>(parentScope: Scope.Scope, steps:
|
|
|
123
123
|
*/
|
|
124
124
|
declare const stop: (scope: Scope.Closeable) => Effect.Effect<void>;
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
/**
|
|
127
|
+
* The Effect entry's `Cmd`: the core `Cmd` with a `define` that takes plain
|
|
128
|
+
* Effect schemas (#631). It is a function over the core `Cmd.define`, so the
|
|
129
|
+
* def it returns is the same `CmdDef` a hand-wrapped call builds.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* An Effect schema that checks a value and hands the same type on. Both sides
|
|
134
|
+
* are one type, and decoding needs no service.
|
|
135
|
+
*
|
|
136
|
+
* tea types a handler's answer by the type the `ok` schema hands on, and checks
|
|
137
|
+
* that answer by parsing it. A schema whose two sides differ — a
|
|
138
|
+
* transformation like `Schema.FiniteFromString`, a brand — would refuse the
|
|
139
|
+
* very value the handler's type asks for, so it does not compile here. Pass
|
|
140
|
+
* `Schema.toType(schema)` to keep the checks and drop the translation.
|
|
141
|
+
*/
|
|
142
|
+
type CheckingSchema<T> = Schema.Codec<T, NoInfer<T>>;
|
|
143
|
+
declare function define<const Name extends string, Input extends CmdInput, Ok, const Tags extends readonly string[]>(name: Name, spec: {
|
|
144
|
+
readonly input: CheckingSchema<Input>;
|
|
145
|
+
readonly ok: CheckingSchema<Ok>;
|
|
146
|
+
readonly err: Tags;
|
|
147
|
+
}): CmdDef<Name, Input, Ok, TaggedError<Tags[number]>>;
|
|
148
|
+
/**
|
|
149
|
+
* A Cmd value, as the core types it. Exported beside the `Cmd` helpers so an
|
|
150
|
+
* Effect user reads both from this entry.
|
|
151
|
+
*/
|
|
152
|
+
type Cmd<T extends string = string, Ok = unknown, E = unknown> = Cmd$1<T, Ok, E>;
|
|
153
|
+
/**
|
|
154
|
+
* The helpers for building Cmds on the Effect engine. `Cmd.none`, `Cmd.batch`,
|
|
155
|
+
* `Cmd.when` and `Cmd.whenDefined` are the core's; `Cmd.define` is this
|
|
156
|
+
* entry's own.
|
|
157
|
+
*/
|
|
158
|
+
declare const Cmd: {
|
|
159
|
+
/**
|
|
160
|
+
* Declare a typed Cmd constructor from plain Effect schemas. It returns what
|
|
161
|
+
* the core `Cmd.define` returns, with each schema passed through
|
|
162
|
+
* `Schema.toStandardSchemaV1` for you:
|
|
163
|
+
*
|
|
164
|
+
* const fetchUser = Cmd.define("fetch_user", {
|
|
165
|
+
* input: Schema.Struct({ id: Schema.String }),
|
|
166
|
+
* ok: Schema.Struct({ name: Schema.String }),
|
|
167
|
+
* err: ["not_found"],
|
|
168
|
+
* });
|
|
169
|
+
*
|
|
170
|
+
* `input` and `ok` take a schema that checks and never translates: both of
|
|
171
|
+
* its sides are one type and decoding needs no service. A transformation, a
|
|
172
|
+
* brand or a schema that needs a service is a compile error.
|
|
173
|
+
*
|
|
174
|
+
* To keep the checks of a transformation or a brand, pass
|
|
175
|
+
* `Schema.toType(schema)`. That is no way through for a schema that needs a
|
|
176
|
+
* service: its check lives in the decode step, and `Schema.toType` drops that
|
|
177
|
+
* step, so the Cmd would compile and never run the check. Run such a check in
|
|
178
|
+
* the handler.
|
|
179
|
+
*
|
|
180
|
+
* A schema whose validation needs a Promise compiles, and is refused with
|
|
181
|
+
* `AsyncSchemaError` when the Cmd settles, as the core's is.
|
|
182
|
+
*
|
|
183
|
+
* It takes Effect schemas only. A zod schema, or any other Standard Schema,
|
|
184
|
+
* goes to `Cmd.define` from `@demlik/tea`.
|
|
185
|
+
*/
|
|
186
|
+
readonly define: typeof define;
|
|
187
|
+
readonly none: readonly never[];
|
|
188
|
+
readonly batch: <const C extends Cmd$1>(...arrs: readonly (readonly C[])[]) => readonly C[];
|
|
189
|
+
readonly when: <const C extends Cmd$1>(cond: boolean, cmd: C) => readonly C[];
|
|
190
|
+
readonly whenDefined: <T, const C extends Cmd$1>(value: T | undefined, build: (value: T) => C) => readonly C[];
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export { type CheckingSchema, Cmd, EffectRuntime, type SpawnSteps, StoreFailed, spawn, stop, tell };
|
package/dist/effect/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { Stopped, StoreFailed, run } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import { acceptedTypes, NoCellError } from '../chunk-
|
|
5
|
-
import { Effect, Scope, Exit } from 'effect';
|
|
1
|
+
export { Stopped, StoreFailed, run } from '../chunk-HU3Y2AZY.js';
|
|
2
|
+
import '../chunk-VM7PMFV5.js';
|
|
3
|
+
import '../chunk-Z7IL735U.js';
|
|
4
|
+
import { Cmd, acceptedTypes, NoCellError } from '../chunk-GAVLND5C.js';
|
|
5
|
+
import { Effect, Scope, Exit, Schema } from 'effect';
|
|
6
6
|
|
|
7
7
|
var tell = (machine, runtime, msg) => Effect.suspend(
|
|
8
8
|
() => acceptedTypes(machine, runtime.getState()).includes(msg.type) ? runtime.dispatch(msg) : Effect.void
|
|
@@ -29,7 +29,45 @@ var spawn = (parentScope, steps) => Effect.uninterruptible(
|
|
|
29
29
|
})
|
|
30
30
|
);
|
|
31
31
|
var stop = (scope) => Scope.close(scope, Exit.void);
|
|
32
|
+
function define(name, spec) {
|
|
33
|
+
return Cmd.define(name, {
|
|
34
|
+
input: Schema.toStandardSchemaV1(spec.input),
|
|
35
|
+
ok: Schema.toStandardSchemaV1(spec.ok),
|
|
36
|
+
err: spec.err
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var Cmd2 = {
|
|
40
|
+
...Cmd,
|
|
41
|
+
/**
|
|
42
|
+
* Declare a typed Cmd constructor from plain Effect schemas. It returns what
|
|
43
|
+
* the core `Cmd.define` returns, with each schema passed through
|
|
44
|
+
* `Schema.toStandardSchemaV1` for you:
|
|
45
|
+
*
|
|
46
|
+
* const fetchUser = Cmd.define("fetch_user", {
|
|
47
|
+
* input: Schema.Struct({ id: Schema.String }),
|
|
48
|
+
* ok: Schema.Struct({ name: Schema.String }),
|
|
49
|
+
* err: ["not_found"],
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* `input` and `ok` take a schema that checks and never translates: both of
|
|
53
|
+
* its sides are one type and decoding needs no service. A transformation, a
|
|
54
|
+
* brand or a schema that needs a service is a compile error.
|
|
55
|
+
*
|
|
56
|
+
* To keep the checks of a transformation or a brand, pass
|
|
57
|
+
* `Schema.toType(schema)`. That is no way through for a schema that needs a
|
|
58
|
+
* service: its check lives in the decode step, and `Schema.toType` drops that
|
|
59
|
+
* step, so the Cmd would compile and never run the check. Run such a check in
|
|
60
|
+
* the handler.
|
|
61
|
+
*
|
|
62
|
+
* A schema whose validation needs a Promise compiles, and is refused with
|
|
63
|
+
* `AsyncSchemaError` when the Cmd settles, as the core's is.
|
|
64
|
+
*
|
|
65
|
+
* It takes Effect schemas only. A zod schema, or any other Standard Schema,
|
|
66
|
+
* goes to `Cmd.define` from `@demlik/tea`.
|
|
67
|
+
*/
|
|
68
|
+
define
|
|
69
|
+
};
|
|
32
70
|
|
|
33
|
-
export { spawn, stop, tell };
|
|
71
|
+
export { Cmd2 as Cmd, spawn, stop, tell };
|
|
34
72
|
//# sourceMappingURL=index.js.map
|
|
35
73
|
//# sourceMappingURL=index.js.map
|
package/dist/effect/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/effect/children.ts"],"names":[],"mappings":";;;;;;AAgCO,IAAM,IAAA,GAAO,CASlB,OAAA,EACA,OAAA,EACA,QAEA,MAAA,C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,KACnB,MAAM,KAAA,CAAM,KAAA,EAAO,KAAK,IAAI","file":"index.js","sourcesContent":["/**\n * Helpers for running child machines under a parent on the Effect engine\n * (#556, ruling R1.1 of #554).\n *\n * tea still runs one machine per `run` and keeps no table of runs (#312). A\n * host that builds a tree of runs keeps its own table, ids and Msg names, and\n * hands the steps that race to these functions: `spawn` starts a child and\n * enrols it as one step, `stop` stops one child, and `tell` sends the parent a\n * notice it may no longer take.\n */\n\nimport { Effect, Exit, Scope } from \"effect\";\nimport type { Cmd, Machine, Sub } from \"../pure/core\";\nimport { acceptedTypes, NoCellError } from \"../pure/core\";\nimport type { StoreFailed } from \"./failures\";\nimport type { EffectRuntime } from \"./handle\";\n\n/**\n * Hand `msg` to a run only when its State has a cell for it, and drop it when\n * the run no longer takes it.\n *\n * `machine` is the machine `runtime` runs. The dispatch lands a moment after\n * the check, so a State that changed in between refuses the Msg with a\n * `NoCellError`, and a run that stopped refuses it with `Stopped`. Both mean\n * the run no longer takes the notice, so both are dropped and `tell` succeeds.\n * A failed save stays a `StoreFailed`, and a hand-written cell's declared\n * failure stays that failure.\n *\n * ```ts\n * yield* tell(parent, parentRun, { type: \"child_stopped\", id });\n * ```\n */\nexport const tell = <\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n E extends { type: string } = never,\n Err = never,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n runtime: EffectRuntime<S, M, E, Err>,\n msg: NoInfer<M>,\n): Effect.Effect<void, Err | StoreFailed> =>\n Effect.suspend(() =>\n acceptedTypes(machine, runtime.getState()).includes(msg.type)\n ? runtime.dispatch(msg)\n : Effect.void,\n ).pipe(\n Effect.catchTag(\"Stopped\", () => Effect.void),\n Effect.catchDefect((defect) =>\n defect instanceof NoCellError ? Effect.void : Effect.die(defect),\n ),\n ) as Effect.Effect<void, Err | StoreFailed>;\n\n/**\n * The host's own steps of a {@link spawn}. The host owns the table of\n * children, their ids and the parent's Msg names; `spawn` owns the order the\n * steps run in and keeps an interrupt from landing between them.\n */\nexport interface SpawnSteps<A, E = never, R = never> {\n /**\n * Start the child and return what the host keeps for it. It runs with the\n * child's scope provided, so a `run(machine, opts)` in it belongs to that\n * scope, and so does anything else it acquires. `scope` is the same scope,\n * for a host that keeps it to stop the child with `stop`. A failure\n * closes the child's scope, which runs `remove` and `notify`.\n */\n readonly start: (scope: Scope.Closeable) => Effect.Effect<A, E, R>;\n /** Add the started child to the host's table. */\n readonly enrol: (child: A) => Effect.Effect<unknown>;\n /**\n * Take the child out of the host's table. It runs when the child's scope\n * closes, after its run has stopped, whether or not `enrol` ran, so it must\n * be safe on a child the table does not hold.\n */\n readonly remove: Effect.Effect<unknown>;\n /**\n * Say the child stopped, usually a {@link tell} to the parent. It runs\n * after `remove`, on a fiber of its own that the closing scope never waits\n * for, so it may wait on the parent.\n *\n * It cannot fail: nothing reads that fiber, so the step itself handles what\n * its notice can fail with, such as the `StoreFailed` of a `tell`. A defect\n * in it is not observed by `spawn` and ends the fiber unseen.\n */\n readonly notify: Effect.Effect<unknown>;\n}\n\n/**\n * Start a child in a scope forked from `parentScope` and enrol it in the\n * host's table, as one uninterruptible step. Stop a child with `stop`,\n * or by closing its scope; closing `parentScope` stops every child spawned\n * under it.\n *\n * What it guarantees, with no guard in host code:\n *\n * - the table never holds a child whose scope has closed. The fork, the\n * removal finalizer, `start` and `enrol` all happen or none do, and a\n * child whose scope closed before `enrol` is removed again;\n * - closing a child never waits for the parent. `notify` runs on a detached\n * fiber, so a parent Cmd handler can stop a child;\n * - `remove` runs after the child's run has stopped.\n *\n * Nothing reads the fiber `notify` runs on, so `spawn` reports no failure of\n * it and `notify` is typed to have none. The host handles what its notice can\n * fail with inside the step, as the `Effect.catch` below does for a parent\n * whose save failed. A defect in `notify` ends that fiber unseen.\n *\n * `child.run.stop()` is not one of the two ways to stop a child. It stops the\n * run and leaves the scope open, so the entry stays in the table and the\n * parent is not told.\n *\n * ```ts\n * const child = yield* spawn(parentScope, {\n * start: (scope) =>\n * Effect.map(run(worker, {}), (run) => ({ run, scope })),\n * enrol: (child) => Effect.sync(() => children.set(id, child)),\n * remove: Effect.sync(() => children.delete(id)),\n * notify: tell(parent, parentRun, { type: \"child_stopped\", id }).pipe(\n * Effect.catch((failure) => Effect.logError(\"notice failed\", failure)),\n * ),\n * });\n * ```\n */\nexport const spawn = <A, E = never, R = never>(\n parentScope: Scope.Scope,\n steps: SpawnSteps<A, E, R>,\n): Effect.Effect<A, E, Exclude<R, Scope.Scope>> =>\n Effect.uninterruptible(\n Effect.gen(function* () {\n const scope = yield* Scope.fork(parentScope);\n // Added before `start`, so it runs after everything `start` put in the\n // scope has been released, the child's run included.\n yield* Scope.addFinalizer(\n scope,\n Effect.andThen(steps.remove, Effect.forkDetach(steps.notify)),\n );\n const child = yield* steps.start(scope).pipe(\n Scope.provide(scope),\n Effect.onError((cause) => Scope.close(scope, Exit.failCause(cause))),\n );\n yield* steps.enrol(child);\n // A scope that closed under `start` ran `remove` before `enrol`.\n if (scope.state._tag === \"Closed\") yield* steps.remove;\n return child;\n }),\n );\n\n/**\n * Stop one child that `spawn` started. `scope` is the child's scope,\n * the one its `start` was handed.\n *\n * It closes that scope, so the child's run stops, `remove` takes the entry\n * out of the host's table and `notify` tells the parent. It does not wait for\n * `notify`, so a parent Cmd handler can call it. Stopping a child that has\n * already stopped succeeds and sends no second notice.\n *\n * ```ts\n * yield* stop(child.scope);\n * ```\n */\nexport const stop = (scope: Scope.Closeable): Effect.Effect<void> =>\n Scope.close(scope, Exit.void);\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/effect/children.ts","../../src/effect/cmd.ts"],"names":["Cmd"],"mappings":";;;;;;AAgCO,IAAM,IAAA,GAAO,CASlB,OAAA,EACA,OAAA,EACA,QAEA,MAAA,CAAO,OAAA;AAAA,EAAQ,MACb,aAAA,CAAc,OAAA,EAAS,OAAA,CAAQ,UAAU,CAAA,CAAE,QAAA,CAAS,GAAA,CAAI,IAAI,CAAA,GACxD,OAAA,CAAQ,Q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M;AAAA,IAC1B,KAAA,EAAO,MAAA,CAAO,kBAAA,CAAmB,IAAA,CAAK,KAAK,CAAA;AAAA,IAC3C,EAAA,EAAI,MAAA,CAAO,kBAAA,CAAmB,IAAA,CAAK,EAAE,CAAA;AAAA,IACrC,KAAK,IAAA,CAAK;AAAA,GACX,CAAA;AACH;AAiBO,IAAMA,IAAAA,GAAM;AAAA,EACjB,GAAG,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BH;AACF","file":"index.js","sourcesContent":["/**\n * Helpers for running child machines under a parent on the Effect engine\n * (#556, ruling R1.1 of #554).\n *\n * tea still runs one machine per `run` and keeps no table of runs (#312). A\n * host that builds a tree of runs keeps its own table, ids and Msg names, and\n * hands the steps that race to these functions: `spawn` starts a child and\n * enrols it as one step, `stop` stops one child, and `tell` sends the parent a\n * notice it may no longer take.\n */\n\nimport { Effect, Exit, Scope } from \"effect\";\nimport type { Cmd, Machine, Sub } from \"../pure/core\";\nimport { acceptedTypes, NoCellError } from \"../pure/core\";\nimport type { StoreFailed } from \"./failures\";\nimport type { EffectRuntime } from \"./handle\";\n\n/**\n * Hand `msg` to a run only when its State has a cell for it, and drop it when\n * the run no longer takes it.\n *\n * `machine` is the machine `runtime` runs. The dispatch lands a moment after\n * the check, so a State that changed in between refuses the Msg with a\n * `NoCellError`, and a run that stopped refuses it with `Stopped`. Both mean\n * the run no longer takes the notice, so both are dropped and `tell` succeeds.\n * A failed save stays a `StoreFailed`, and a hand-written cell's declared\n * failure stays that failure.\n *\n * ```ts\n * yield* tell(parent, parentRun, { type: \"child_stopped\", id });\n * ```\n */\nexport const tell = <\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n E extends { type: string } = never,\n Err = never,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n runtime: EffectRuntime<S, M, E, Err>,\n msg: NoInfer<M>,\n): Effect.Effect<void, Err | StoreFailed> =>\n Effect.suspend(() =>\n acceptedTypes(machine, runtime.getState()).includes(msg.type)\n ? runtime.dispatch(msg)\n : Effect.void,\n ).pipe(\n Effect.catchTag(\"Stopped\", () => Effect.void),\n Effect.catchDefect((defect) =>\n defect instanceof NoCellError ? Effect.void : Effect.die(defect),\n ),\n ) as Effect.Effect<void, Err | StoreFailed>;\n\n/**\n * The host's own steps of a {@link spawn}. The host owns the table of\n * children, their ids and the parent's Msg names; `spawn` owns the order the\n * steps run in and keeps an interrupt from landing between them.\n */\nexport interface SpawnSteps<A, E = never, R = never> {\n /**\n * Start the child and return what the host keeps for it. It runs with the\n * child's scope provided, so a `run(machine, opts)` in it belongs to that\n * scope, and so does anything else it acquires. `scope` is the same scope,\n * for a host that keeps it to stop the child with `stop`. A failure\n * closes the child's scope, which runs `remove` and `notify`.\n */\n readonly start: (scope: Scope.Closeable) => Effect.Effect<A, E, R>;\n /** Add the started child to the host's table. */\n readonly enrol: (child: A) => Effect.Effect<unknown>;\n /**\n * Take the child out of the host's table. It runs when the child's scope\n * closes, after its run has stopped, whether or not `enrol` ran, so it must\n * be safe on a child the table does not hold.\n */\n readonly remove: Effect.Effect<unknown>;\n /**\n * Say the child stopped, usually a {@link tell} to the parent. It runs\n * after `remove`, on a fiber of its own that the closing scope never waits\n * for, so it may wait on the parent.\n *\n * It cannot fail: nothing reads that fiber, so the step itself handles what\n * its notice can fail with, such as the `StoreFailed` of a `tell`. A defect\n * in it is not observed by `spawn` and ends the fiber unseen.\n */\n readonly notify: Effect.Effect<unknown>;\n}\n\n/**\n * Start a child in a scope forked from `parentScope` and enrol it in the\n * host's table, as one uninterruptible step. Stop a child with `stop`,\n * or by closing its scope; closing `parentScope` stops every child spawned\n * under it.\n *\n * What it guarantees, with no guard in host code:\n *\n * - the table never holds a child whose scope has closed. The fork, the\n * removal finalizer, `start` and `enrol` all happen or none do, and a\n * child whose scope closed before `enrol` is removed again;\n * - closing a child never waits for the parent. `notify` runs on a detached\n * fiber, so a parent Cmd handler can stop a child;\n * - `remove` runs after the child's run has stopped.\n *\n * Nothing reads the fiber `notify` runs on, so `spawn` reports no failure of\n * it and `notify` is typed to have none. The host handles what its notice can\n * fail with inside the step, as the `Effect.catch` below does for a parent\n * whose save failed. A defect in `notify` ends that fiber unseen.\n *\n * `child.run.stop()` is not one of the two ways to stop a child. It stops the\n * run and leaves the scope open, so the entry stays in the table and the\n * parent is not told.\n *\n * ```ts\n * const child = yield* spawn(parentScope, {\n * start: (scope) =>\n * Effect.map(run(worker, {}), (run) => ({ run, scope })),\n * enrol: (child) => Effect.sync(() => children.set(id, child)),\n * remove: Effect.sync(() => children.delete(id)),\n * notify: tell(parent, parentRun, { type: \"child_stopped\", id }).pipe(\n * Effect.catch((failure) => Effect.logError(\"notice failed\", failure)),\n * ),\n * });\n * ```\n */\nexport const spawn = <A, E = never, R = never>(\n parentScope: Scope.Scope,\n steps: SpawnSteps<A, E, R>,\n): Effect.Effect<A, E, Exclude<R, Scope.Scope>> =>\n Effect.uninterruptible(\n Effect.gen(function* () {\n const scope = yield* Scope.fork(parentScope);\n // Added before `start`, so it runs after everything `start` put in the\n // scope has been released, the child's run included.\n yield* Scope.addFinalizer(\n scope,\n Effect.andThen(steps.remove, Effect.forkDetach(steps.notify)),\n );\n const child = yield* steps.start(scope).pipe(\n Scope.provide(scope),\n Effect.onError((cause) => Scope.close(scope, Exit.failCause(cause))),\n );\n yield* steps.enrol(child);\n // A scope that closed under `start` ran `remove` before `enrol`.\n if (scope.state._tag === \"Closed\") yield* steps.remove;\n return child;\n }),\n );\n\n/**\n * Stop one child that `spawn` started. `scope` is the child's scope,\n * the one its `start` was handed.\n *\n * It closes that scope, so the child's run stops, `remove` takes the entry\n * out of the host's table and `notify` tells the parent. It does not wait for\n * `notify`, so a parent Cmd handler can call it. Stopping a child that has\n * already stopped succeeds and sends no second notice.\n *\n * ```ts\n * yield* stop(child.scope);\n * ```\n */\nexport const stop = (scope: Scope.Closeable): Effect.Effect<void> =>\n Scope.close(scope, Exit.void);\n","/**\n * The Effect entry's `Cmd`: the core `Cmd` with a `define` that takes plain\n * Effect schemas (#631). It is a function over the core `Cmd.define`, so the\n * def it returns is the same `CmdDef` a hand-wrapped call builds.\n */\n\nimport { Schema } from \"effect\";\nimport {\n type CmdDef,\n type CmdInput,\n Cmd as CoreCmd,\n type TaggedError,\n} from \"../pure/core\";\n\n/**\n * An Effect schema that checks a value and hands the same type on. Both sides\n * are one type, and decoding needs no service.\n *\n * tea types a handler's answer by the type the `ok` schema hands on, and checks\n * that answer by parsing it. A schema whose two sides differ — a\n * transformation like `Schema.FiniteFromString`, a brand — would refuse the\n * very value the handler's type asks for, so it does not compile here. Pass\n * `Schema.toType(schema)` to keep the checks and drop the translation.\n */\nexport type CheckingSchema<T> = Schema.Codec<T, NoInfer<T>>;\n\nfunction define<\n const Name extends string,\n Input extends CmdInput,\n Ok,\n const Tags extends readonly string[],\n>(\n name: Name,\n spec: {\n readonly input: CheckingSchema<Input>;\n readonly ok: CheckingSchema<Ok>;\n readonly err: Tags;\n },\n): CmdDef<Name, Input, Ok, TaggedError<Tags[number]>> {\n return CoreCmd.define(name, {\n input: Schema.toStandardSchemaV1(spec.input),\n ok: Schema.toStandardSchemaV1(spec.ok),\n err: spec.err,\n });\n}\n\n/**\n * A Cmd value, as the core types it. Exported beside the `Cmd` helpers so an\n * Effect user reads both from this entry.\n */\nexport type Cmd<T extends string = string, Ok = unknown, E = unknown> = CoreCmd<\n T,\n Ok,\n E\n>;\n\n/**\n * The helpers for building Cmds on the Effect engine. `Cmd.none`, `Cmd.batch`,\n * `Cmd.when` and `Cmd.whenDefined` are the core's; `Cmd.define` is this\n * entry's own.\n */\nexport const Cmd = {\n ...CoreCmd,\n /**\n * Declare a typed Cmd constructor from plain Effect schemas. It returns what\n * the core `Cmd.define` returns, with each schema passed through\n * `Schema.toStandardSchemaV1` for you:\n *\n * const fetchUser = Cmd.define(\"fetch_user\", {\n * input: Schema.Struct({ id: Schema.String }),\n * ok: Schema.Struct({ name: Schema.String }),\n * err: [\"not_found\"],\n * });\n *\n * `input` and `ok` take a schema that checks and never translates: both of\n * its sides are one type and decoding needs no service. A transformation, a\n * brand or a schema that needs a service is a compile error.\n *\n * To keep the checks of a transformation or a brand, pass\n * `Schema.toType(schema)`. That is no way through for a schema that needs a\n * service: its check lives in the decode step, and `Schema.toType` drops that\n * step, so the Cmd would compile and never run the check. Run such a check in\n * the handler.\n *\n * A schema whose validation needs a Promise compiles, and is refused with\n * `AsyncSchemaError` when the Cmd settles, as the core's is.\n *\n * It takes Effect schemas only. A zod schema, or any other Standard Schema,\n * goes to `Cmd.define` from `@demlik/tea`.\n */\n define,\n} as const;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as Runtime, M as Migrated, S as Store } from '../runtime-types-
|
|
1
|
+
import { R as Runtime, M as Migrated, S as Store } from '../runtime-types-BPKp2bGo.js';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { S as SubscribeHandler } from '../types-
|
|
3
|
+
import { c as Sub } from '../core-BKJW1Kmq.js';
|
|
4
|
+
import { S as SubscribeHandler } from '../types-BiXj7k_k.js';
|
|
5
5
|
import '@standard-schema/spec';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/extension/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { historyTracker, dispatchIfPresent } from '../chunk-
|
|
2
|
-
import { describeError } from '../chunk-
|
|
1
|
+
import { historyTracker, dispatchIfPresent } from '../chunk-VHKDUBXC.js';
|
|
2
|
+
import { describeError } from '../chunk-GAVLND5C.js';
|
|
3
3
|
import { useRef, useSyncExternalStore, useEffect, useCallback, createContext, useMemo, useContext } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|