@systemfsoftware/effect-atom 2.0.0 → 3.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @systemfsoftware/effect-atom
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Published types no longer include names tagged `@internal`. If you imported one of those names from the package, switch to a public export or stop using it.
8
+
9
+ ### Patch Changes
10
+
11
+ - The peer requirements for `effect` and for the Effect test-runner integration now accept any compatible `4.0.0-rc` release, instead of demanding one exact release candidate.
12
+
13
+ Installing alongside a newer release candidate no longer reports an unmet peer dependency or resolves a second copy of `effect` into the dependency tree.
14
+
3
15
  ## 2.0.0
4
16
 
5
17
  ### Major Changes
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { a as getResult$1, d as toStream$1, f as toStreamResult$1, m as batch$1, t as AtomRegistry, u as mount$1 } from "./Registry-BE4aKSZk.mjs";
3
- import { D as value, F as isResult, I as success, N as failure, O as waiting, P as initial, T as toExit, b as map$1, c as failureWithPrevious, d as fromExitWithPrevious, h as isInitial, k as waitingFrom, m as isFailure, p as getOrThrow, s as failWithPrevious, v as isSuccess, w as replacePrevious } from "./Result-rlUvoHzK.mjs";
2
+ import { a as batch$1, d as mount$1, f as toStream$1, o as getResult$1, p as toStreamResult$1, t as AtomRegistry } from "./Registry-Bwb4SHbP.mjs";
3
+ import { D as value, F as isResult, I as success, N as failure, O as waiting, P as initial, T as toExit, b as map$1, c as failureWithPrevious, d as fromExitWithPrevious, h as isInitial, k as waitingFrom, m as isFailure, p as getOrThrow, s as failWithPrevious, v as isSuccess, w as replacePrevious } from "./Result-CBWUo7aQ.mjs";
4
4
  import * as Arr from "effect/Array";
5
5
  import * as Cause from "effect/Cause";
6
6
  import * as Channel from "effect/Channel";
@@ -25,8 +25,7 @@ import { NodeInspectSymbol } from "effect/Inspectable";
25
25
  import { pipeArguments } from "effect/Pipeable";
26
26
  import { hasProperty } from "effect/Predicate";
27
27
  import * as Result from "effect/Result";
28
- //#region src/internal/Core.ts
29
- /** @internal */
28
+ //#region src/AtomCore.ts
30
29
  const PipeInspectableProto = { pipe() {
31
30
  return pipeArguments(this, arguments);
32
31
  } };
@@ -68,9 +67,7 @@ const setIdleTTL = dual(2, (self, durationInput) => {
68
67
  Reflect.setPrototypeOf(copy, Reflect.getPrototypeOf(self));
69
68
  return copy;
70
69
  });
71
- /** @internal */
72
70
  const removeTtl = setIdleTTL(0);
73
- /** @internal */
74
71
  const AtomProto = {
75
72
  [TypeId]: TypeId,
76
73
  equals: Object.is,
@@ -87,7 +84,6 @@ const AtomProto = {
87
84
  };
88
85
  }
89
86
  };
90
- /** @internal */
91
87
  const WritableProto = {
92
88
  ...AtomProto,
93
89
  [WritableTypeId]: WritableTypeId
@@ -1,4 +1,4 @@
1
- import { L as Result } from "./Result-BHH-qTvm.js";
1
+ import { L as Result } from "./Result-pXS4ZOef.js";
2
2
  import * as Arr from "effect/Array";
3
3
  import * as Cause from "effect/Cause";
4
4
  import * as Context from "effect/Context";
@@ -7,18 +7,18 @@ import * as Effect from "effect/Effect";
7
7
  import { LazyArg } from "effect/Function";
8
8
  import * as Layer from "effect/Layer";
9
9
  import * as Option from "effect/Option";
10
- import { Scheduler } from "effect/Scheduler";
10
+ import { Scheduler, SchedulerDispatcher } from "effect/Scheduler";
11
11
  import * as Schema from "effect/Schema";
12
12
  import * as Scope from "effect/Scope";
13
13
  import * as Stream from "effect/Stream";
14
14
  import * as SubscriptionRef from "effect/SubscriptionRef";
15
15
  import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore";
16
16
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
17
- import { Inspectable } from "effect/Inspectable";
17
+ import { Inspectable, NodeInspectSymbol } from "effect/Inspectable";
18
18
  import { Pipeable } from "effect/Pipeable";
19
19
  import { ReadonlyRecord } from "effect/Record";
20
20
  import { NoInfer } from "effect/Types";
21
- //#region src/internal/Core.d.ts
21
+ //#region src/AtomCore.d.ts
22
22
  /**
23
23
  * Type-level identifier used to recognize `Atom` values.
24
24
  *
@@ -106,8 +106,65 @@ declare const transform: {
106
106
  readonly initialValueTarget?: Atom<B> | undefined;
107
107
  }): [R] extends [Writable<infer _, infer RW>] ? Writable<B, RW> : Atom<B>;
108
108
  };
109
+ //#endregion
110
+ //#region src/AtomNode.d.ts
111
+ declare const NodeState: {
112
+ readonly uninitialized: number;
113
+ readonly stale: number;
114
+ readonly valid: number;
115
+ readonly removed: 0;
116
+ };
117
+ type NodeState = number;
118
+ declare class NodeImpl<A> {
119
+ constructor(registry: RegistryImpl, atom: Atom<A>);
120
+ readonly registry: RegistryImpl;
121
+ readonly atom: Atom<A>;
122
+ state: NodeState;
123
+ lifetime: Lifetime<A> | undefined;
124
+ writeContext: WriteContextImpl<A>;
125
+ preserveInitialValueOnBuild: boolean;
126
+ parents: Set<NodeImpl<unknown>>;
127
+ previousParents: Set<NodeImpl<unknown>> | undefined;
128
+ children: Set<NodeImpl<unknown>>;
129
+ listeners: Set<() => void>;
130
+ skipInvalidation: boolean;
131
+ building: boolean;
132
+ invalidatedDuringBuild: boolean;
133
+ currentState(): 'uninitialized' | 'stale' | 'valid' | 'removed';
134
+ get canBeRemoved(): boolean;
135
+ _value: A;
136
+ value(): A;
137
+ valueOption(): Option.Option<A>;
138
+ setInitialValue(value: A): void;
139
+ setValue(value: A): void;
140
+ addParent(parent: NodeImpl<unknown>): void;
141
+ removeChild(child: NodeImpl<unknown>): void;
142
+ invalidate(): void;
143
+ invalidateChildren(): void;
144
+ notify(): void;
145
+ disposeLifetime(): void;
146
+ remove(): void;
147
+ subscribe(listener: () => void): () => void;
148
+ }
149
+ interface Lifetime<A> extends AtomContext {
150
+ isFn: boolean;
151
+ readonly registry: RegistryImpl;
152
+ readonly node: NodeImpl<A>;
153
+ finalizers: (() => void)[] | undefined;
154
+ disposed: boolean;
155
+ readonly dispose: () => void;
156
+ }
157
+ declare class WriteContextImpl<A> implements WriteContext<A> {
158
+ constructor(registry: RegistryImpl, node: NodeImpl<A>);
159
+ readonly registry: RegistryImpl;
160
+ readonly node: NodeImpl<A>;
161
+ get<A>(atom: Atom<A>): A;
162
+ set<R, W>(atom: Writable<R, W>, value: W): void;
163
+ setSelf(value: A): void;
164
+ refreshSelf(): void;
165
+ }
109
166
  declare namespace Registry_d_exports {
110
- export { AtomRegistry, Node, Registry, TypeId, getResult$1 as getResult, isAtomRegistry, layer, layerOptions, make$1 as make, mount$1 as mount, toStream$1 as toStream, toStreamResult$1 as toStreamResult };
167
+ export { AtomRegistry, Node, Registry, RegistryImpl, TypeId, batch$1 as batch, getResult$1 as getResult, isAtomRegistry, layer, layerOptions, make$1 as make, mount$1 as mount, toStream$1 as toStream, toStreamResult$1 as toStreamResult };
111
168
  }
112
169
  /**
113
170
  * The literal type used to identify `AtomRegistry` services and values.
@@ -324,6 +381,55 @@ declare const mount$1: {
324
381
  <A>(atom: Atom<A>): (self: Registry) => Effect.Effect<void, never, Scope.Scope>;
325
382
  <A>(self: Registry, atom: Atom<A>): Effect.Effect<void, never, Scope.Scope>;
326
383
  };
384
+ /**
385
+ * Concrete registry used by the package implementation.
386
+ */
387
+ declare class RegistryImpl implements Registry {
388
+ #private;
389
+ readonly [TypeId]: TypeId;
390
+ readonly timeoutResolution: number;
391
+ readonly defaultIdleTTL: number | undefined;
392
+ readonly scheduler: Scheduler;
393
+ readonly schedulerAsync: Scheduler;
394
+ readonly dispatcher: SchedulerDispatcher;
395
+ readonly now: () => number;
396
+ readonly scheduleTimer: (f: () => void, delayMillis: number) => () => void;
397
+ onNodeAdded?: ((node: Node<unknown>) => void) | undefined;
398
+ onNodeRemoved?: ((node: Node<unknown>) => void) | undefined;
399
+ constructor(initialValues?: Iterable<readonly [Atom<unknown>, unknown]>, scheduleTask?: (cb: () => void) => () => void, timeoutResolution?: number, defaultIdleTTL?: number, now?: () => number, scheduleTimer?: (f: () => void, delayMillis: number) => () => void);
400
+ setInitialValue<A>(atom: Atom<A>, value: A): void;
401
+ readonly nodes: Map<string | Atom<unknown>, NodeImpl<unknown>>;
402
+ readonly preloadedSerializable: Map<string, unknown>;
403
+ readonly timeoutBuckets: Map<number, readonly [nodes: Set<NodeImpl<unknown>>, cancel: () => void]>;
404
+ readonly nodeTimeoutBucket: Map<NodeImpl<unknown>, number>;
405
+ disposed: boolean;
406
+ getNodes(): Map<string | Atom<unknown>, NodeImpl<unknown>>;
407
+ get<A>(atom: Atom<A>): A;
408
+ getRaw<A>(atom: Atom<A>): Option.Option<A>;
409
+ set<R, W>(atom: Writable<R, W>, value: W): void;
410
+ setSerializable(key: string, encoded: unknown): void;
411
+ private applySerializableValue;
412
+ modify<R, W, A>(atom: Writable<R, W>, f: (_: R) => [returnValue: A, nextValue: W]): A;
413
+ update<R, W>(atom: Writable<R, W>, f: (_: R) => W): void;
414
+ refresh: <A>(atom: Atom<A>) => void;
415
+ subscribe<A>(atom: Atom<A>, f: (_: A) => void, options?: {
416
+ readonly immediate?: boolean;
417
+ }): () => void;
418
+ mount<A>(atom: Atom<A>): () => void;
419
+ atomHasTtl(atom: Atom<unknown>): boolean;
420
+ ensureNode<A>(atom: Atom<A>): NodeImpl<A>;
421
+ createNode<A>(atom: Atom<A>): NodeImpl<A>;
422
+ invalidateAtom: <A>(atom: Atom<A>) => void;
423
+ scheduleAtomRemoval(atom: Atom<unknown>): void;
424
+ scheduleNodeRemoval(node: NodeImpl<unknown>): void;
425
+ removeNode(node: NodeImpl<unknown>): void;
426
+ setNodeTimeout(node: NodeImpl<unknown>): void;
427
+ removeNodeTimeout(node: NodeImpl<unknown>): void;
428
+ sweepBucket(bucket: number): void;
429
+ reset(): void;
430
+ dispose(): void;
431
+ }
432
+ declare function batch$1(f: () => void): void;
327
433
  //#endregion
328
434
  //#region src/Browser.d.ts
329
435
  /**
@@ -1284,4 +1390,4 @@ declare const serializable: {
1284
1390
  }): R & Serializable<S>;
1285
1391
  };
1286
1392
  //#endregion
1287
- export { toStreamResult as $, get as A, isAtom as At, modify as B, autoDispose as C, layerOptions as Ct, family as D, toStreamResult$1 as Dt, debounce as E, toStream$1 as Et, kvs as F, writable as Ft, refresh as G, optimistic as H, make as I, set as J, runtime as K, makeRead as L, initialValue as M, readable as Mt, isSerializable as N, setIdleTTL as Nt, fn as O, TypeId$1 as Ot, keepAlive as P, transform as Pt, toStream as Q, map as R, WriteContext as S, layer as St, context as T, mount$1 as Tt, optimisticFn as U, mount as V, pull as W, subscriptionRef as X, setLazy as Y, swr as Z, SharedRuntimeFactory as _, Registry as _t, Atom_d_exports as a, withRefresh as at, WithoutSerializable as b, getResult$1 as bt, Interrupt as c, getServerValue as ct, RegistryRuntimeFactory as d, makeRefreshOnSignal as dt, update as et, Reset as f, refreshOnWindowFocus as ft, SerializableTypeId as g, Node as gt, SerializableJson as h, AtomRegistry as ht, AtomRuntime as i, withReactivity as it, getResult as j, isWritable as jt, fnSync as k, WritableTypeId as kt, PullResult as l, withServerValue as lt, Serializable as m, windowFocusSignal as mt, AtomContext as n, withFallback as nt, Failure as o, ServerValue as ot, RuntimeFactory as p, searchParam as pt, serializable as q, AtomResultFn as r, withLabel as rt, FnContext as s, ServerValueTypeId as st, Atom as t, withEquality as tt, PullSuccess as u, withServerValueInitial as ut, Success as v, Registry_d_exports as vt, batch as w, make$1 as wt, Writable as x, isAtomRegistry as xt, Type as y, TypeId as yt, mapResult as z };
1393
+ export { toStreamResult as $, get as A, TypeId$1 as At, modify as B, autoDispose as C, isAtomRegistry as Ct, family as D, mount$1 as Dt, debounce as E, make$1 as Et, kvs as F, setIdleTTL as Ft, refresh as G, optimistic as H, make as I, transform as It, set as J, runtime as K, makeRead as L, writable as Lt, initialValue as M, isAtom as Mt, isSerializable as N, isWritable as Nt, fn as O, toStream$1 as Ot, keepAlive as P, readable as Pt, toStream as Q, map as R, WriteContext as S, getResult$1 as St, context as T, layerOptions as Tt, optimisticFn as U, mount as V, pull as W, subscriptionRef as X, setLazy as Y, swr as Z, SharedRuntimeFactory as _, Registry as _t, Atom_d_exports as a, withRefresh as at, WithoutSerializable as b, TypeId as bt, Interrupt as c, getServerValue as ct, RegistryRuntimeFactory as d, makeRefreshOnSignal as dt, update as et, Reset as f, refreshOnWindowFocus as ft, SerializableTypeId as g, Node as gt, SerializableJson as h, AtomRegistry as ht, AtomRuntime as i, withReactivity as it, getResult as j, WritableTypeId as jt, fnSync as k, toStreamResult$1 as kt, PullResult as l, withServerValue as lt, Serializable as m, windowFocusSignal as mt, AtomContext as n, withFallback as nt, Failure as o, ServerValue as ot, RuntimeFactory as p, searchParam as pt, serializable as q, AtomResultFn as r, withLabel as rt, FnContext as s, ServerValueTypeId as st, Atom as t, withEquality as tt, PullSuccess as u, withServerValueInitial as ut, Success as v, RegistryImpl as vt, batch as w, layer as wt, Writable as x, batch$1 as xt, Type as y, Registry_d_exports as yt, mapResult as z };
package/dist/Atom.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as toStreamResult, A as get, At as isAtom, B as modify, C as autoDispose, D as family, E as debounce, F as kvs, Ft as writable, G as refresh, H as optimistic, I as make, J as set, K as runtime, L as makeRead, M as initialValue, Mt as readable, N as isSerializable, Nt as setIdleTTL, O as fn, Ot as TypeId, P as keepAlive, Pt as transform, Q as toStream, R as map, S as WriteContext, T as context, U as optimisticFn, V as mount, W as pull, X as subscriptionRef, Y as setLazy, Z as swr, _ as SharedRuntimeFactory, at as withRefresh, b as WithoutSerializable, c as Interrupt, ct as getServerValue, d as RegistryRuntimeFactory, dt as makeRefreshOnSignal, et as update, f as Reset, ft as refreshOnWindowFocus, g as SerializableTypeId, h as SerializableJson, i as AtomRuntime, it as withReactivity, j as getResult, jt as isWritable, k as fnSync, kt as WritableTypeId, l as PullResult, lt as withServerValue, m as Serializable, mt as windowFocusSignal, n as AtomContext, nt as withFallback, o as Failure, ot as ServerValue, p as RuntimeFactory, pt as searchParam, q as serializable, r as AtomResultFn, rt as withLabel, s as FnContext, st as ServerValueTypeId, t as Atom, tt as withEquality, u as PullSuccess, ut as withServerValueInitial, v as Success, w as batch, x as Writable, y as Type, z as mapResult } from "./Atom-BgqgP-Qc.js";
1
+ import { $ as toStreamResult, A as get, At as TypeId, B as modify, C as autoDispose, D as family, E as debounce, F as kvs, Ft as setIdleTTL, G as refresh, H as optimistic, I as make, It as transform, J as set, K as runtime, L as makeRead, Lt as writable, M as initialValue, Mt as isAtom, N as isSerializable, Nt as isWritable, O as fn, P as keepAlive, Pt as readable, Q as toStream, R as map, S as WriteContext, T as context, U as optimisticFn, V as mount, W as pull, X as subscriptionRef, Y as setLazy, Z as swr, _ as SharedRuntimeFactory, at as withRefresh, b as WithoutSerializable, c as Interrupt, ct as getServerValue, d as RegistryRuntimeFactory, dt as makeRefreshOnSignal, et as update, f as Reset, ft as refreshOnWindowFocus, g as SerializableTypeId, h as SerializableJson, i as AtomRuntime, it as withReactivity, j as getResult, jt as WritableTypeId, k as fnSync, l as PullResult, lt as withServerValue, m as Serializable, mt as windowFocusSignal, n as AtomContext, nt as withFallback, o as Failure, ot as ServerValue, p as RuntimeFactory, pt as searchParam, q as serializable, r as AtomResultFn, rt as withLabel, s as FnContext, st as ServerValueTypeId, t as Atom, tt as withEquality, u as PullSuccess, ut as withServerValueInitial, v as Success, w as batch, x as Writable, y as Type, z as mapResult } from "./Atom-Ciqh8CR3.js";
2
2
  export { Atom, AtomContext, AtomResultFn, AtomRuntime, Failure, FnContext, Interrupt, PullResult, PullSuccess, RegistryRuntimeFactory, Reset, RuntimeFactory, Serializable, SerializableJson, SerializableTypeId, type ServerValue, ServerValueTypeId, SharedRuntimeFactory, Success, Type, TypeId, WithoutSerializable, Writable, WritableTypeId, WriteContext, autoDispose, batch, context, debounce, family, fn, fnSync, get, getResult, getServerValue, initialValue, isAtom, isSerializable, isWritable, keepAlive, kvs, make, makeRead, makeRefreshOnSignal, map, mapResult, modify, mount, optimistic, optimisticFn, pull, readable, refresh, refreshOnWindowFocus, runtime, searchParam, serializable, set, setIdleTTL, setLazy, subscriptionRef, swr, toStream, toStreamResult, transform, update, windowFocusSignal, withEquality, withFallback, withLabel, withReactivity, withRefresh, withServerValue, withServerValueInitial, writable };
package/dist/Atom.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as isWritable, A as set, B as withReactivity, C as mount, D as refresh, E as pull, F as toStreamResult, G as withServerValueInitial, H as ServerValueTypeId, I as update, J as searchParam, K as makeRefreshOnSignal, L as withEquality, M as subscriptionRef, N as swr, O as runtime, P as toStream, Q as isAtom, R as withFallback, S as modify, T as optimisticFn, U as getServerValue, V as withRefresh, W as withServerValue, X as TypeId, Y as windowFocusSignal, Z as WritableTypeId, _ as kvs, a as autoDispose, b as map, c as debounce, d as fnSync, et as readable, f as get, g as keepAlive, h as isSerializable, i as SerializableTypeId, j as setLazy, k as serializable, l as family, m as initialValue, n as Interrupt, nt as transform, o as batch, p as getResult, q as refreshOnWindowFocus, r as Reset, rt as writable, s as context, tt as setIdleTTL, u as fn, v as make, w as optimistic, x as mapResult, y as makeRead, z as withLabel } from "./Atom-DVWTGeoV.mjs";
1
+ import { $ as isWritable, A as set, B as withReactivity, C as mount, D as refresh, E as pull, F as toStreamResult, G as withServerValueInitial, H as ServerValueTypeId, I as update, J as searchParam, K as makeRefreshOnSignal, L as withEquality, M as subscriptionRef, N as swr, O as runtime, P as toStream, Q as isAtom, R as withFallback, S as modify, T as optimisticFn, U as getServerValue, V as withRefresh, W as withServerValue, X as TypeId, Y as windowFocusSignal, Z as WritableTypeId, _ as kvs, a as autoDispose, b as map, c as debounce, d as fnSync, et as readable, f as get, g as keepAlive, h as isSerializable, i as SerializableTypeId, j as setLazy, k as serializable, l as family, m as initialValue, n as Interrupt, nt as transform, o as batch, p as getResult, q as refreshOnWindowFocus, r as Reset, rt as writable, s as context, tt as setIdleTTL, u as fn, v as make, w as optimistic, x as mapResult, y as makeRead, z as withLabel } from "./Atom-BdJCLuRj.mjs";
2
2
  export { Interrupt, Reset, SerializableTypeId, ServerValueTypeId, TypeId, WritableTypeId, autoDispose, batch, context, debounce, family, fn, fnSync, get, getResult, getServerValue, initialValue, isAtom, isSerializable, isWritable, keepAlive, kvs, make, makeRead, makeRefreshOnSignal, map, mapResult, modify, mount, optimistic, optimisticFn, pull, readable, refresh, refreshOnWindowFocus, runtime, searchParam, serializable, set, setIdleTTL, setLazy, subscriptionRef, swr, toStream, toStreamResult, transform, update, windowFocusSignal, withEquality, withFallback, withLabel, withReactivity, withRefresh, withServerValue, withServerValueInitial, writable };
@@ -1,5 +1,5 @@
1
- import { i as AtomRuntime, n as AtomContext, p as RuntimeFactory, r as AtomResultFn, t as Atom } from "./Atom-BgqgP-Qc.js";
2
- import { L as Result } from "./Result-BHH-qTvm.js";
1
+ import { i as AtomRuntime, n as AtomContext, p as RuntimeFactory, r as AtomResultFn, t as Atom } from "./Atom-Ciqh8CR3.js";
2
+ import { L as Result } from "./Result-pXS4ZOef.js";
3
3
  import * as Context from "effect/Context";
4
4
  import * as Duration from "effect/Duration";
5
5
  import * as Effect from "effect/Effect";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { O as runtime, g as keepAlive, k as serializable, l as family, tt as setIdleTTL } from "./Atom-DVWTGeoV.mjs";
3
- import { j as schemaCodec } from "./Result-rlUvoHzK.mjs";
2
+ import { O as runtime, g as keepAlive, k as serializable, l as family, tt as setIdleTTL } from "./Atom-BdJCLuRj.mjs";
3
+ import { j as schemaCodec } from "./Result-CBWUo7aQ.mjs";
4
4
  import * as Context from "effect/Context";
5
5
  import * as Duration from "effect/Duration";
6
6
  import * as Effect from "effect/Effect";
package/dist/AtomRpc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as AtomRuntime, l as PullResult, n as AtomContext, p as RuntimeFactory, r as AtomResultFn, t as Atom, x as Writable } from "./Atom-BgqgP-Qc.js";
2
- import { L as Result } from "./Result-BHH-qTvm.js";
1
+ import { i as AtomRuntime, l as PullResult, n as AtomContext, p as RuntimeFactory, r as AtomResultFn, t as Atom, x as Writable } from "./Atom-Ciqh8CR3.js";
2
+ import { L as Result } from "./Result-pXS4ZOef.js";
3
3
  import * as Context from "effect/Context";
4
4
  import * as Duration from "effect/Duration";
5
5
  import * as Effect from "effect/Effect";
package/dist/AtomRpc.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { O as runtime, g as keepAlive, k as serializable, l as family, tt as setIdleTTL } from "./Atom-DVWTGeoV.mjs";
3
- import { j as schemaCodec } from "./Result-rlUvoHzK.mjs";
2
+ import { O as runtime, g as keepAlive, k as serializable, l as family, tt as setIdleTTL } from "./Atom-BdJCLuRj.mjs";
3
+ import { j as schemaCodec } from "./Result-CBWUo7aQ.mjs";
4
4
  import * as Context from "effect/Context";
5
5
  import * as Duration from "effect/Duration";
6
6
  import * as Effect from "effect/Effect";
@@ -1,4 +1,4 @@
1
- import { _t as Registry } from "./Atom-BgqgP-Qc.js";
1
+ import { _t as Registry } from "./Atom-Ciqh8CR3.js";
2
2
  import * as Fiber from "effect/Fiber";
3
3
  declare namespace Hydration_d_exports {
4
4
  export { DehydratedAtom, DehydratedAtomValue, dehydrate, hydrate };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { h as isSerializable, i as SerializableTypeId } from "./Atom-DVWTGeoV.mjs";
3
- import { F as isResult, h as isInitial } from "./Result-rlUvoHzK.mjs";
2
+ import { h as isSerializable, i as SerializableTypeId } from "./Atom-BdJCLuRj.mjs";
3
+ import { F as isResult, h as isInitial } from "./Result-CBWUo7aQ.mjs";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Clock from "effect/Clock";
6
6
  import * as Deferred from "effect/Deferred";
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { F as isResult, T as toExit, _ as isNotInitial, h as isInitial, m as isFailure, v as isSuccess } from "./Result-rlUvoHzK.mjs";
2
+ import { F as isResult, T as toExit, _ as isNotInitial, h as isInitial, m as isFailure, v as isSuccess } from "./Result-CBWUo7aQ.mjs";
3
3
  import * as Context from "effect/Context";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Exit from "effect/Exit";
@@ -13,26 +13,8 @@ import * as Stream from "effect/Stream";
13
13
  import { hasProperty } from "effect/Predicate";
14
14
  import * as Queue from "effect/Queue";
15
15
  import * as Match from "effect/Match";
16
- //#region src/internal/HostTimer.ts
17
- /**
18
- * Host clock and timer primitives for the atom registry.
19
- *
20
- * This module is the named host boundary for wall-clock reads and delayed
21
- * scheduling. It deliberately imports nothing from `effect`: the registry
22
- * itself is a fiber-free store, and consumers who need deterministic idle
23
- * eviction pass their own `now` / `scheduleTimer` to `Registry.make` /
24
- * `Registry.layerOptions`. The defaults here are the plain platform
25
- * implementations.
26
- *
27
- * @since 4.0.0
28
- */
29
- const hostNow = () => Date.now();
30
- const hostScheduleTimer = (f, delayMillis) => {
31
- const id = setTimeout(f, delayMillis);
32
- return () => clearTimeout(id);
33
- };
34
- //#endregion
35
16
  //#region src/internal/NodeLifetime.ts
17
+ /** @internal */
36
18
  const decideNodeFate = (input) => {
37
19
  if (input.keepAlive || input.listenerCount > 0 || input.childCount > 0 || !input.isLive || input.isWaiting) return { _tag: "Alive" };
38
20
  if (input.idleTTL === 0) return { _tag: "RemoveNow" };
@@ -43,7 +25,7 @@ const decideNodeFate = (input) => {
43
25
  };
44
26
  };
45
27
  //#endregion
46
- //#region src/internal/Node.ts
28
+ //#region src/AtomNode.ts
47
29
  const notifyListener = (listener) => {
48
30
  listener();
49
31
  };
@@ -58,7 +40,6 @@ const NodeState = {
58
40
  valid: NodeFlags.alive | NodeFlags.initialized,
59
41
  removed: 0
60
42
  };
61
- /** @internal */
62
43
  var NodeImpl = class {
63
44
  constructor(registry, atom) {
64
45
  this.registry = registry;
@@ -385,21 +366,18 @@ var WriteContextImpl = class {
385
366
  return this.node.invalidate();
386
367
  }
387
368
  };
388
- /** @internal */
389
369
  const BatchPhase = {
390
370
  disabled: 0,
391
371
  collect: 1,
392
372
  commit: 2
393
373
  };
394
- /** @internal */
395
374
  const batchState = {
396
375
  phase: BatchPhase.disabled,
397
376
  depth: 0,
398
377
  stale: [],
399
378
  notify: /* @__PURE__ */ new Set()
400
379
  };
401
- /** @internal */
402
- function batch(f) {
380
+ function runInternalBatch(f) {
403
381
  batchState.phase = BatchPhase.collect;
404
382
  batchState.depth++;
405
383
  try {
@@ -429,6 +407,27 @@ function batchRebuildNode(node) {
429
407
  if (node.state !== NodeState.valid) node.value();
430
408
  }
431
409
  //#endregion
410
+ //#region src/internal/HostTimer.ts
411
+ /**
412
+ * Host clock and timer primitives for the atom registry.
413
+ *
414
+ * This module is the named host boundary for wall-clock reads and delayed
415
+ * scheduling. It deliberately imports nothing from `effect`: the registry
416
+ * itself is a fiber-free store, and consumers who need deterministic idle
417
+ * eviction pass their own `now` / `scheduleTimer` to `Registry.make` /
418
+ * `Registry.layerOptions`. The defaults here are the plain platform
419
+ * implementations.
420
+ *
421
+ * @since 4.0.0
422
+ */
423
+ /** @internal */
424
+ const hostNow = () => Date.now();
425
+ /** @internal */
426
+ const hostScheduleTimer = (f, delayMillis) => {
427
+ const id = setTimeout(f, delayMillis);
428
+ return () => clearTimeout(id);
429
+ };
430
+ //#endregion
432
431
  //#region src/Registry.ts
433
432
  /**
434
433
  * Stores and runs atoms for one reactive runtime.
@@ -443,11 +442,9 @@ function batchRebuildNode(node) {
443
442
  */
444
443
  var Registry_exports = /* @__PURE__ */ __exportAll({
445
444
  AtomRegistry: () => AtomRegistry,
446
- BatchPhase: () => BatchPhase,
447
445
  RegistryImpl: () => RegistryImpl,
448
446
  TypeId: () => TypeId,
449
447
  batch: () => batch,
450
- batchState: () => batchState,
451
448
  getResult: () => getResult,
452
449
  isAtomRegistry: () => isAtomRegistry,
453
450
  layer: () => layer,
@@ -599,7 +596,7 @@ const atomKey = (atom) => isSerializableAtom(atom) ? atom[SerializableTypeId].ke
599
596
  */
600
597
  const isNodeImplFor = (atom, node) => atomKey(node.atom) === atomKey(atom);
601
598
  /**
602
- * @internal
599
+ * Concrete registry used by the package implementation.
603
600
  */
604
601
  var RegistryImpl = class {
605
602
  [TypeId];
@@ -819,5 +816,8 @@ var RegistryImpl = class {
819
816
  this.reset();
820
817
  }
821
818
  };
819
+ function batch(f) {
820
+ runInternalBatch(f);
821
+ }
822
822
  //#endregion
823
- export { getResult as a, layerOptions as c, toStream as d, toStreamResult as f, batchState as h, TypeId as i, make as l, batch as m, RegistryImpl as n, isAtomRegistry as o, BatchPhase as p, Registry_exports as r, layer as s, AtomRegistry as t, mount as u };
823
+ export { batch as a, layer as c, mount as d, toStream as f, TypeId as i, layerOptions as l, RegistryImpl as n, getResult as o, toStreamResult as p, Registry_exports as r, isAtomRegistry as s, AtomRegistry as t, make as u };
@@ -1,2 +1,2 @@
1
- import { Ct as layerOptions, Dt as toStreamResult, Et as toStream, St as layer, Tt as mount, _t as Registry, bt as getResult, gt as Node, ht as AtomRegistry, wt as make, xt as isAtomRegistry, yt as TypeId } from "./Atom-BgqgP-Qc.js";
2
- export { AtomRegistry, Node, Registry, TypeId, getResult, isAtomRegistry, layer, layerOptions, make, mount, toStream, toStreamResult };
1
+ import { Ct as isAtomRegistry, Dt as mount, Et as make, Ot as toStream, St as getResult, Tt as layerOptions, _t as Registry, bt as TypeId, gt as Node, ht as AtomRegistry, kt as toStreamResult, vt as RegistryImpl, wt as layer, xt as batch } from "./Atom-Ciqh8CR3.js";
2
+ export { AtomRegistry, Node, Registry, RegistryImpl, TypeId, batch, getResult, isAtomRegistry, layer, layerOptions, make, mount, toStream, toStreamResult };
package/dist/Registry.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as getResult, c as layerOptions, d as toStream, f as toStreamResult, h as batchState, i as TypeId, l as make, m as batch, n as RegistryImpl, o as isAtomRegistry, p as BatchPhase, s as layer, t as AtomRegistry, u as mount } from "./Registry-BE4aKSZk.mjs";
2
- export { AtomRegistry, BatchPhase, RegistryImpl, TypeId, batch, batchState, getResult, isAtomRegistry, layer, layerOptions, make, mount, toStream, toStreamResult };
1
+ import { a as batch, c as layer, d as mount, f as toStream, i as TypeId, l as layerOptions, n as RegistryImpl, o as getResult, p as toStreamResult, s as isAtomRegistry, t as AtomRegistry, u as make } from "./Registry-Bwb4SHbP.mjs";
2
+ export { AtomRegistry, RegistryImpl, TypeId, batch, getResult, isAtomRegistry, layer, layerOptions, make, mount, toStream, toStreamResult };
@@ -15,7 +15,7 @@ import * as Hash from "effect/Hash";
15
15
  import * as SchemaIssue from "effect/SchemaIssue";
16
16
  import * as SchemaParser from "effect/SchemaParser";
17
17
  import * as SchemaTransformation from "effect/SchemaTransformation";
18
- //#region src/internal/ResultValues.ts
18
+ //#region src/ResultValues.ts
19
19
  const now = () => Effect.runSync(Clock.currentTimeMillis);
20
20
  /**
21
21
  * Runtime identifier attached to `Result` values and used by `isResult`.
@@ -53,6 +53,9 @@ const ResultProto = {
53
53
  return Match.value(this).pipe(Match.tag("Initial", () => tagHash), Match.tag("Success", (s) => Hash.combine(tagHash)(Hash.hash(s.value))), Match.tag("Failure", (f) => Hash.combine(tagHash)(Hash.hash(f.cause))), Match.exhaustive);
54
54
  }
55
55
  };
56
+ const InitialTag = { _tag: "Initial" };
57
+ const SuccessTag = { _tag: "Success" };
58
+ const FailureTag = { _tag: "Failure" };
56
59
  /**
57
60
  * Returns `true` when a value is an `Result`.
58
61
  *
@@ -69,7 +72,7 @@ const isResult = (u) => hasProperty(u, TypeId);
69
72
  const initial = (waiting = false) => {
70
73
  return {
71
74
  ...ResultProto,
72
- _tag: "Initial",
75
+ ...InitialTag,
73
76
  waiting
74
77
  };
75
78
  };
@@ -83,7 +86,7 @@ const initial = (waiting = false) => {
83
86
  const success = (value, options) => {
84
87
  return {
85
88
  ...ResultProto,
86
- _tag: "Success",
89
+ ...SuccessTag,
87
90
  value,
88
91
  waiting: options?.waiting ?? false,
89
92
  timestamp: options?.timestamp ?? now()
@@ -99,14 +102,14 @@ const success = (value, options) => {
99
102
  const failure = (cause, options) => {
100
103
  return {
101
104
  ...ResultProto,
102
- _tag: "Failure",
105
+ ...FailureTag,
103
106
  cause,
104
107
  ...options?.previousSuccess === void 0 ? { previousSuccess: Option.none() } : { previousSuccess: options.previousSuccess },
105
108
  waiting: options?.waiting ?? false
106
109
  };
107
110
  };
108
111
  //#endregion
109
- //#region src/internal/ResultSchema.ts
112
+ //#region src/ResultSchema.ts
110
113
  /**
111
114
  * Creates a schema for `Result` values using optional schemas for success values and failure errors.
112
115
  *
@@ -197,8 +200,6 @@ const Schema = (options) => {
197
200
  };
198
201
  /**
199
202
  * A codec for `Result` values built from the given success and error schemas.
200
- *
201
- * @internal
202
203
  */
203
204
  const schemaCodec = (success, error) => Schema({
204
205
  success,
@@ -6,7 +6,7 @@ import * as Schema_ from "effect/Schema";
6
6
  import { Pipeable } from "effect/Pipeable";
7
7
  import { Predicate, Refinement } from "effect/Predicate";
8
8
  import * as Types from "effect/Types";
9
- //#region src/internal/ResultValues.d.ts
9
+ //#region src/ResultValues.d.ts
10
10
  /**
11
11
  * Type-level identifier used to recognize `Result` values.
12
12
  *
@@ -66,15 +66,21 @@ declare namespace Result {
66
66
  * @since 4.0.0
67
67
  */
68
68
  type Result<A, E = never> = Initial<A, E> | Success<A, E> | Failure<A, E>;
69
+ declare const InitialTag: {
70
+ readonly _tag: 'Initial';
71
+ };
72
+ type InitialTag = typeof InitialTag;
69
73
  /**
70
74
  * Initial `Result` state before a success value or failure cause is available.
71
75
  *
72
76
  * @category models
73
77
  * @since 4.0.0
74
78
  */
75
- interface Initial<A, E = never> extends Result.Proto<A, E> {
76
- readonly _tag: 'Initial';
77
- }
79
+ interface Initial<A, E = never> extends Result.Proto<A, E>, InitialTag {}
80
+ declare const SuccessTag: {
81
+ readonly _tag: 'Success';
82
+ };
83
+ type SuccessTag = typeof SuccessTag;
78
84
  /**
79
85
  * Successful `Result` containing the current value, its timestamp, and the
80
86
  * shared waiting flag.
@@ -82,11 +88,14 @@ interface Initial<A, E = never> extends Result.Proto<A, E> {
82
88
  * @category models
83
89
  * @since 4.0.0
84
90
  */
85
- interface Success<A, E = never> extends Result.Proto<A, E> {
86
- readonly _tag: 'Success';
91
+ interface Success<A, E = never> extends Result.Proto<A, E>, SuccessTag {
87
92
  readonly value: A;
88
93
  readonly timestamp: number;
89
94
  }
95
+ declare const FailureTag: {
96
+ readonly _tag: 'Failure';
97
+ };
98
+ type FailureTag = typeof FailureTag;
90
99
  /**
91
100
  * Failed `Result` containing a failure cause and the latest previous success
92
101
  * when one is available.
@@ -94,8 +103,7 @@ interface Success<A, E = never> extends Result.Proto<A, E> {
94
103
  * @category models
95
104
  * @since 4.0.0
96
105
  */
97
- interface Failure<A, E = never> extends Result.Proto<A, E> {
98
- readonly _tag: 'Failure';
106
+ interface Failure<A, E = never> extends Result.Proto<A, E>, FailureTag {
99
107
  readonly cause: Cause.Cause<E>;
100
108
  readonly previousSuccess: Option.Option<Success<A, E>>;
101
109
  }
@@ -136,7 +144,7 @@ declare const failure: <A, E = never>(cause: Cause.Cause<E>, options?: {
136
144
  readonly waiting?: boolean | undefined;
137
145
  }) => Failure<A, E>;
138
146
  //#endregion
139
- //#region src/internal/ResultSchema.d.ts
147
+ //#region src/ResultSchema.d.ts
140
148
  /**
141
149
  * Schema interface for `Result` values, retaining the schemas used for
142
150
  * success values and failure errors.
package/dist/Result.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as touch, B as failure, C as isWaiting, D as matchWithWaiting, E as matchWithError, F as Failure, H as isResult, I as Initial, L as Result, M as waiting, N as waitingFrom, O as replacePrevious, P as Schema, R as Success, S as isSuccess, T as match, U as success, V as initial, _ as getOrThrow, a as With, b as isInterrupted, c as cause, d as failWithPrevious, f as failureWithPrevious, g as getOrElse, h as fromExitWithPrevious, j as value, k as toExit, l as error, m as fromExit, n as Defect, o as all, p as flatMap, r as Interrupt, s as builder, t as Builder, u as fail, v as isFailure, w as map, x as isNotInitial, y as isInitial, z as TypeId } from "./Result-BHH-qTvm.js";
1
+ import { A as touch, B as failure, C as isWaiting, D as matchWithWaiting, E as matchWithError, F as Failure, H as isResult, I as Initial, L as Result, M as waiting, N as waitingFrom, O as replacePrevious, P as Schema, R as Success, S as isSuccess, T as match, U as success, V as initial, _ as getOrThrow, a as With, b as isInterrupted, c as cause, d as failWithPrevious, f as failureWithPrevious, g as getOrElse, h as fromExitWithPrevious, j as value, k as toExit, l as error, m as fromExit, n as Defect, o as all, p as flatMap, r as Interrupt, s as builder, t as Builder, u as fail, v as isFailure, w as map, x as isNotInitial, y as isInitial, z as TypeId } from "./Result-pXS4ZOef.js";
2
2
  export { Builder, Defect, type Failure, type Initial, Interrupt, type Result, Schema, type Success, TypeId, With, all, builder, cause, error, fail, failWithPrevious, failure, failureWithPrevious, flatMap, fromExit, fromExitWithPrevious, getOrElse, getOrThrow, initial, isResult as isAsyncResult, isResult, isFailure, isInitial, isInterrupted, isNotInitial, isSuccess, isWaiting, map, match, matchWithError, matchWithWaiting, replacePrevious, success, toExit, touch, value, waiting, waitingFrom };
package/dist/Result.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { A as Schema, C as matchWithWaiting, D as value, E as touch, F as isResult, I as success, M as TypeId, N as failure, O as waiting, P as initial, S as matchWithError, T as toExit, _ as isNotInitial, a as error, b as map, c as failureWithPrevious, d as fromExitWithPrevious, f as getOrElse, g as isInterrupted, h as isInitial, i as cause, k as waitingFrom, l as flatMap, m as isFailure, n as all, o as fail, p as getOrThrow, r as builder, s as failWithPrevious, u as fromExit, v as isSuccess, w as replacePrevious, x as match, y as isWaiting } from "./Result-rlUvoHzK.mjs";
1
+ import { A as Schema, C as matchWithWaiting, D as value, E as touch, F as isResult, I as success, M as TypeId, N as failure, O as waiting, P as initial, S as matchWithError, T as toExit, _ as isNotInitial, a as error, b as map, c as failureWithPrevious, d as fromExitWithPrevious, f as getOrElse, g as isInterrupted, h as isInitial, i as cause, k as waitingFrom, l as flatMap, m as isFailure, n as all, o as fail, p as getOrThrow, r as builder, s as failWithPrevious, u as fromExit, v as isSuccess, w as replacePrevious, x as match, y as isWaiting } from "./Result-CBWUo7aQ.mjs";
2
2
  export { Schema, TypeId, all, builder, cause, error, fail, failWithPrevious, failure, failureWithPrevious, flatMap, fromExit, fromExitWithPrevious, getOrElse, getOrThrow, initial, isResult as isAsyncResult, isResult, isFailure, isInitial, isInterrupted, isNotInitial, isSuccess, isWaiting, map, match, matchWithError, matchWithWaiting, replacePrevious, success, toExit, touch, value, waiting, waitingFrom };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as Atom_d_exports, vt as Registry_d_exports } from "./Atom-BgqgP-Qc.js";
2
- import { i as Result_d_exports } from "./Result-BHH-qTvm.js";
1
+ import { a as Atom_d_exports, yt as Registry_d_exports } from "./Atom-Ciqh8CR3.js";
2
+ import { i as Result_d_exports } from "./Result-pXS4ZOef.js";
3
3
  import { t as AtomHttpApi_d_exports } from "./AtomHttpApi.js";
4
4
  import { t as AtomRef_d_exports } from "./AtomRef.js";
5
5
  import { t as AtomRpc_d_exports } from "./AtomRpc.js";
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { t as Atom_exports } from "./Atom-DVWTGeoV.mjs";
2
- import { r as Registry_exports } from "./Registry-BE4aKSZk.mjs";
3
- import { t as Result_exports } from "./Result-rlUvoHzK.mjs";
1
+ import { t as Atom_exports } from "./Atom-BdJCLuRj.mjs";
2
+ import { r as Registry_exports } from "./Registry-Bwb4SHbP.mjs";
3
+ import { t as Result_exports } from "./Result-CBWUo7aQ.mjs";
4
4
  import { t as AtomHttpApi_exports } from "./AtomHttpApi.mjs";
5
5
  import { t as AtomRef_exports } from "./AtomRef.mjs";
6
6
  import { t as AtomRpc_exports } from "./AtomRpc.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/effect-atom",
3
3
  "license": "Apache-2.0",
4
- "version": "2.0.0",
4
+ "version": "3.0.0",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -58,23 +58,23 @@
58
58
  "dist"
59
59
  ],
60
60
  "peerDependencies": {
61
- "effect": "4.0.0-rc.108"
61
+ "effect": "^4.0.0-rc.111"
62
62
  },
63
63
  "devDependencies": {
64
- "@effect/vitest": "4.0.0-rc.108",
64
+ "@effect/vitest": "4.0.0-rc.111",
65
65
  "@systemfsoftware/arethetypeswrong-cli": "^1.1.1",
66
66
  "@types/node": "^24",
67
- "effect": "4.0.0-rc.108",
67
+ "effect": "4.0.0-rc.111",
68
68
  "oxlint": "^1.77.0",
69
69
  "rimraf": "^6.1.3",
70
70
  "tsdown": "^0.22.14",
71
71
  "type-fest": "^5.8.0",
72
72
  "typescript": "^7",
73
73
  "vitest": "^4.1.10",
74
- "@systemfsoftware/effect-gherkin-spec": "^2.0.0",
74
+ "@systemfsoftware/effect-gherkin-spec": "^2.0.1",
75
75
  "@systemfsoftware/oxlint-config": "^0.1.0",
76
- "@systemfsoftware/tsconfig": "^1.3.3",
77
- "@systemfsoftware/vitest-config": "^0.1.0"
76
+ "@systemfsoftware/vitest-config": "^0.1.0",
77
+ "@systemfsoftware/tsconfig": "^1.3.3"
78
78
  },
79
79
  "publishConfig": {
80
80
  "provenance": true