@systemfsoftware/effect-atom 1.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 +112 -0
- package/dist/{Atom-DVWTGeoV.mjs → Atom-BdJCLuRj.mjs} +3 -7
- package/dist/{Atom-BgqgP-Qc.d.ts → Atom-Ciqh8CR3.d.ts} +112 -6
- package/dist/Atom.d.ts +1 -1
- package/dist/Atom.mjs +1 -1
- package/dist/AtomHttpApi.d.ts +2 -2
- package/dist/AtomHttpApi.mjs +2 -2
- package/dist/AtomRpc.d.ts +2 -2
- package/dist/AtomRpc.mjs +2 -2
- package/dist/Hydration.d.ts +1 -1
- package/dist/Hydration.mjs +2 -2
- package/dist/{Registry-BE4aKSZk.mjs → Registry-Bwb4SHbP.mjs} +30 -30
- package/dist/Registry.d.ts +2 -2
- package/dist/Registry.mjs +2 -2
- package/dist/{Result-rlUvoHzK.mjs → Result-CBWUo7aQ.mjs} +8 -7
- package/dist/{Result-BHH-qTvm.d.ts → Result-pXS4ZOef.d.ts} +17 -9
- package/dist/Result.d.ts +1 -1
- package/dist/Result.mjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +3 -3
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,117 @@
|
|
|
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
|
+
|
|
15
|
+
## 2.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- The `result` member is removed from the `DehydratedAtomValue` type returned by `dehydrate`.
|
|
20
|
+
|
|
21
|
+
- `DehydratedAtomValue.result` was a `Deferred` that completed when an initially-loading atom reached a real value. It never survived serialization, so it could not work across the process boundary the dehydrated state exists for; reading it after transport failed at runtime.
|
|
22
|
+
- The pending-update behaviour is unchanged: entries created with `encodeInitialAs: 'deferred'` still settle the target registry once `hydrate` applies them and the source atom resolves.
|
|
23
|
+
- Wait for all pending updates by joining the fiber that `hydrate` returns, as before.
|
|
24
|
+
- Code that read `entry.result` directly no longer compiles; drop that access — there is no replacement field.
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- `Registry.make` and `Registry.layerOptions` accept `now` and `scheduleTimer`, so every time-dependent atom can be driven without waiting in real time.
|
|
29
|
+
|
|
30
|
+
- `now?: () => number` supplies the clock.
|
|
31
|
+
- `scheduleTimer?: (f: () => void, delayMillis: number) => () => void` arms a delayed callback and returns its canceller.
|
|
32
|
+
|
|
33
|
+
Both default to the platform's wall clock and timer, so existing callers are unaffected. One substitution now drives all three time-dependent behaviours together: idle-TTL eviction, `Atom.debounce`, and `Atom.swr` staleness. Previously each read the clock and armed timers itself, so testing any of them meant real elapsed time.
|
|
34
|
+
|
|
35
|
+
`Registry` exposes `now` and `scheduleTimer` as members, alongside `scheduler` and `schedulerAsync`.
|
|
36
|
+
|
|
37
|
+
- Atoms built from a runtime keep the last good answer again, and four read paths that lost or overwrote a value are fixed.
|
|
38
|
+
|
|
39
|
+
- A stream-backed atom that emitted values and then completed reported an empty stream and failed with `NoSuchElementError`. It now settles with the value the stream emitted last.
|
|
40
|
+
- A failing refresh, retry or reload no longer clears the value already on screen. The previous success is carried across effect, stream, pull, `subscriptionRef` and `fn` atoms, so `Result.previousSuccess` is populated while waiting and after a failure, as documented.
|
|
41
|
+
- Reading a `subscriptionRef` atom whose runtime layer failed threw `Result.getOrThrow: no value found` instead of reporting the failure. It now reports the layer's failure like every other atom on that runtime.
|
|
42
|
+
- `Atom.kvs` without `mode: 'async'` wrote `defaultValue()` into the store on first read, overwriting a value the store had not finished loading. The fallback is now shown without writing, and the default is stored only once the store reports the key absent.
|
|
43
|
+
|
|
44
|
+
Surface changes:
|
|
45
|
+
|
|
46
|
+
- `AtomContext.self` takes the value type as a parameter: `get.self<MyResult>()` returns `Option<MyResult>` where it previously returned `Option<unknown>`.
|
|
47
|
+
- `AtomRuntime.subscriptionRef` declares `Cause.NoSuchElementError` in its error channel, which its implementation always could produce.
|
|
48
|
+
- The HTTP API client's `mutation` and `query` bound their `Group` and `Endpoint` type parameters to any group and any endpoint. Each is now bound to the group and endpoint its identifier arguments select, so a call that passed one of them explicitly and disagreed with the identifiers no longer compiles.
|
|
49
|
+
- `Result.builder` renders a typed value. `orElse` returns the accumulated value or the fallback, `orNull` and `render` add `null`, and `exhaustive` returns the value alone, where all four previously returned `unknown`. Code that relied on assigning a rendered result anywhere now needs the value's real type.
|
|
50
|
+
- `Atom.mapResult` reports the mapped value with the source atom's error type, where it previously reported a union that included an untyped result. Mapping a mapped atom now gives the second mapper the real value type instead of `unknown`; an annotation written against the old union needs updating.
|
|
51
|
+
|
|
52
|
+
- Harden the v4 fork: Effect-native hydration, zero `as any` casts, browser-mode tests.
|
|
53
|
+
|
|
54
|
+
Breaking changes:
|
|
55
|
+
|
|
56
|
+
- `Hydration.DehydratedAtomValue.resultPromise?: Promise<unknown>` is now `result?: Deferred<unknown>` — the pending-value channel is Effect-native, and `hydrate` returns a `Fiber<void, never>` that completes once every pending result has been applied (join it for deterministic SSR flushes and tests).
|
|
57
|
+
- `Hydration.dehydrate`'s `encodeInitialAs: 'promise'` is now `'deferred'`, `dehydrate` returns `Array<DehydratedAtomValue>` directly, and `Hydration.toValues` is removed.
|
|
58
|
+
- `Registry.setSerializable` now applies to an already-materialized node as well as preloading absent ones.
|
|
59
|
+
- `ScopedAtom.Context` is typed `React.Context<A | undefined>` to match runtime.
|
|
60
|
+
- `useAtom`/`useAtomSet` `mode: 'promise'` and `mode: 'promiseExit'` are gone; the single `mode: 'effect'` returns a lazy `(value) => Effect<A, E>` instead of an eager `Promise`, so callers run the result with `Effect.runPromise`/`yield*` and no raw `Promise` remains on the public surface.
|
|
61
|
+
|
|
62
|
+
Additions:
|
|
63
|
+
|
|
64
|
+
- `Registry.setInitialValue(atom, value)` — typed initial-value seeding (also used by `useAtomInitialValues`).
|
|
65
|
+
- `Result.Schema` now carries a `toArbitrary` hook, so `Schema.toArbitrary` works for property tests; its generated space is the wire-representable subset (no `undefined` defects, which the JSON codec cannot carry).
|
|
66
|
+
|
|
67
|
+
Internal:
|
|
68
|
+
|
|
69
|
+
- Every `as any` / `as unknown as` cast removed from both packages' `src` (Registry, Result, Atom, AtomRef, AtomRpc, AtomHttpApi, Hooks, RegistryContext, ScopedAtom); oxlint `correctness` and `perf` categories now gate as errors.
|
|
70
|
+
- `atom-react` tests run in Vitest browser mode (playwright chromium) with `expect.element` assertions; jest-dom and jsdom are gone. Consumers running these tests need `playwright install chromium`.
|
|
71
|
+
- Fixed a zombie-notification defect: an item removed from an `AtomRef.collection` no longer notifies the collection when mutated.
|
|
72
|
+
|
|
73
|
+
- Port both packages onto the effect v4 release candidate (`effect@4.0.0-rc.108`,
|
|
74
|
+
resolved from the `effect4` catalog). The `src/` is now the v4 reactivity API:
|
|
75
|
+
absorbed packages (`@effect/experimental`, `@effect/platform`, `@effect/rpc`)
|
|
76
|
+
are gone — their modules now live under `effect/unstable/*` and the core `effect`
|
|
77
|
+
barrel — and every removed/renamed v3 symbol is replaced (`Effect.async`→
|
|
78
|
+
`callback`, `Context.Tag`→`Context.Service`, `Runtime<R>`→`Runtime`, `Cause`
|
|
79
|
+
error renames, `Schema.decodeEither`→`decodeExit`, the `Mailbox`/`Subscribable`/
|
|
80
|
+
`GlobalValue`/`FiberId` modules). **Breaking:** the `effect` peer dependency is
|
|
81
|
+
now `4.0.0-rc.x`; consumers must move to effect v4.
|
|
82
|
+
|
|
83
|
+
Breaking changes:
|
|
84
|
+
|
|
85
|
+
- `Registry.isRegistry` is renamed `isAtomRegistry`.
|
|
86
|
+
- The read-context type `Atom.Context` is renamed `Atom.AtomContext`; `defaultMemoMap` and `KvsError` are removed.
|
|
87
|
+
- `Result.toExitAsEffect`, `Result.schemaFromSelf`, `Result.PartialEncoded`, and `Result.Encoded` are removed (use `Result.toExit` + `Effect.exit` and `Result.Schema`).
|
|
88
|
+
- `Atom.make(stream)`/`Atom.fn(stream)` widen the atom's error channel with `Cause.NoSuchElementError`.
|
|
89
|
+
- `Registry.make`/`Registry.layerOptions` and `RegistryProvider` take a changed `scheduleTask` option signature.
|
|
90
|
+
- `@systemfsoftware/effect-atom-react` no longer re-exports the atom package's namespaces (`Atom`, `Registry`, `Result`, `AtomRef`, `AtomHttpApi`, `AtomRpc`, `Hydration`, `ScopedAtom`) from its root — those modules are not browser-safe, and the react entry is browser-tested. Import them from `@systemfsoftware/effect-atom` directly.
|
|
91
|
+
- Runtime type markers `Atom.TypeId`/`WritableTypeId`/`AtomRef.TypeId` moved to `~effect/reactivity/*`; the wire `SerializableTypeId` (`~effect-atom/atom/Atom/Serializable`) is unchanged, so `Hydration` payload keys are stable.
|
|
92
|
+
|
|
93
|
+
- cut over to effect v4 (4.0.0-rc.108): public surface derives from effect types; peers flip effect ^3→^4
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- Array types are spelled one way. `Array<T>` and `ReadonlyArray<T>` in emitted
|
|
98
|
+
declarations become `T[]` and `readonly T[]`, which the type checker cannot tell
|
|
99
|
+
apart: no exported type changes, only how it is written.
|
|
100
|
+
|
|
101
|
+
- A serialised successful result now requires its timestamp to be a finite number.
|
|
102
|
+
It previously accepted `NaN` and `Infinity`, so a corrupted timestamp could decode
|
|
103
|
+
without complaint and reach code that compares it.
|
|
104
|
+
|
|
105
|
+
- New version is published through npm trusted publishing, so it carries a provenance attestation you can verify.
|
|
106
|
+
|
|
107
|
+
- The `atom` packages publish their own author rather than crediting an upstream they are not downstream of, and `stryker-plugins` no longer pulls Node's ambient types into a package that has no runtime dependency on them.
|
|
108
|
+
|
|
109
|
+
- Each of these packages now has a README, so its registry page says what the package is, how
|
|
110
|
+
to install it, and what to import or register — previously the page was blank. The lint
|
|
111
|
+
plugins show the configuration line that enables what they recommend.
|
|
112
|
+
|
|
113
|
+
`@systemfsoftware/stryker-js-mutation-report` also carries its licence text
|
|
114
|
+
|
|
3
115
|
## 1.0.0
|
|
4
116
|
|
|
5
117
|
### Major Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { a as
|
|
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-
|
|
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/
|
|
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-
|
|
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/
|
|
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,
|
|
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
|
|
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-
|
|
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 };
|
package/dist/AtomHttpApi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as AtomRuntime, n as AtomContext, p as RuntimeFactory, r as AtomResultFn, t as Atom } from "./Atom-
|
|
2
|
-
import { L as Result } from "./Result-
|
|
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";
|
package/dist/AtomHttpApi.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-
|
|
3
|
-
import { j as schemaCodec } from "./Result-
|
|
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-
|
|
2
|
-
import { L as Result } from "./Result-
|
|
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-
|
|
3
|
-
import { j as schemaCodec } from "./Result-
|
|
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/Hydration.d.ts
CHANGED
package/dist/Hydration.mjs
CHANGED
|
@@ -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-
|
|
3
|
-
import { F as isResult, h as isInitial } from "./Result-
|
|
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-
|
|
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/
|
|
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
|
-
|
|
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
|
-
*
|
|
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 {
|
|
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 };
|
package/dist/Registry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Ct as
|
|
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
|
|
2
|
-
export { AtomRegistry,
|
|
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/
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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/
|
|
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/
|
|
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
|
-
|
|
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/
|
|
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-
|
|
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-
|
|
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,
|
|
2
|
-
import { i as Result_d_exports } from "./Result-
|
|
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-
|
|
2
|
-
import { r as Registry_exports } from "./Registry-
|
|
3
|
-
import { t as Result_exports } from "./Result-
|
|
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,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/effect-atom",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/systemfsoftware/systemfsoftware.git",
|
|
9
|
-
"directory": "packages/effect
|
|
9
|
+
"directory": "packages/core/effect/atom/atom"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://github.com/systemfsoftware/systemfsoftware/tree/main/packages/effect
|
|
11
|
+
"homepage": "https://github.com/systemfsoftware/systemfsoftware/tree/main/packages/core/effect/atom/atom#readme",
|
|
12
12
|
"bugs": "https://github.com/systemfsoftware/systemfsoftware/issues",
|
|
13
13
|
"description": "Reactive toolkit for Effect — forked under systemfsoftware from tim-smart/effect-atom.",
|
|
14
14
|
"keywords": [
|
|
@@ -58,23 +58,23 @@
|
|
|
58
58
|
"dist"
|
|
59
59
|
],
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"effect": "4.0.0-rc.
|
|
61
|
+
"effect": "^4.0.0-rc.111"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@effect/vitest": "4.0.0-rc.
|
|
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.
|
|
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": "^
|
|
74
|
+
"@systemfsoftware/effect-gherkin-spec": "^2.0.1",
|
|
75
75
|
"@systemfsoftware/oxlint-config": "^0.1.0",
|
|
76
76
|
"@systemfsoftware/vitest-config": "^0.1.0",
|
|
77
|
-
"@systemfsoftware/tsconfig": "^1.3.
|
|
77
|
+
"@systemfsoftware/tsconfig": "^1.3.3"
|
|
78
78
|
},
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"provenance": true
|