@graphrefly/graphrefly 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/ai-CaR_912Q.d.cts +1033 -0
- package/dist/ai-WlRltJV7.d.ts +1033 -0
- package/dist/audit-ClmqGOCx.d.cts +245 -0
- package/dist/audit-DRlSzBu9.d.ts +245 -0
- package/dist/{chunk-QOWVNWOC.js → chunk-3ZWCKRHX.js} +27 -25
- package/dist/{chunk-QOWVNWOC.js.map → chunk-3ZWCKRHX.js.map} +1 -1
- package/dist/chunk-APFNLIRG.js +62 -0
- package/dist/chunk-APFNLIRG.js.map +1 -0
- package/dist/chunk-AT5LKYNL.js +395 -0
- package/dist/chunk-AT5LKYNL.js.map +1 -0
- package/dist/{chunk-IAHGTNOZ.js → chunk-BQ6RQQFF.js} +351 -2095
- package/dist/chunk-BQ6RQQFF.js.map +1 -0
- package/dist/{chunk-L2GLW2U7.js → chunk-BVZYTZ5H.js} +9 -103
- package/dist/chunk-BVZYTZ5H.js.map +1 -0
- package/dist/{chunk-EVR6UFUV.js → chunk-DST5DKZS.js} +19 -15
- package/dist/{chunk-EVR6UFUV.js.map → chunk-DST5DKZS.js.map} +1 -1
- package/dist/{chunk-TKE3JGOH.js → chunk-GTE6PWRZ.js} +5 -692
- package/dist/chunk-GTE6PWRZ.js.map +1 -0
- package/dist/chunk-HXZEYDUR.js +94 -0
- package/dist/chunk-HXZEYDUR.js.map +1 -0
- package/dist/chunk-J22W6HV3.js +107 -0
- package/dist/chunk-J22W6HV3.js.map +1 -0
- package/dist/{chunk-PY4XCDLR.js → chunk-J2VBW3DZ.js} +6 -95
- package/dist/chunk-J2VBW3DZ.js.map +1 -0
- package/dist/{chunk-HWPIFSW2.js → chunk-JSCT3CR4.js} +6 -4
- package/dist/{chunk-HWPIFSW2.js.map → chunk-JSCT3CR4.js.map} +1 -1
- package/dist/chunk-JWBCY4NC.js +330 -0
- package/dist/chunk-JWBCY4NC.js.map +1 -0
- package/dist/chunk-K2AUJHVP.js +2251 -0
- package/dist/chunk-K2AUJHVP.js.map +1 -0
- package/dist/chunk-MJ2NKQQL.js +119 -0
- package/dist/chunk-MJ2NKQQL.js.map +1 -0
- package/dist/chunk-N6UR7YVY.js +198 -0
- package/dist/chunk-N6UR7YVY.js.map +1 -0
- package/dist/chunk-NC6S43JJ.js +456 -0
- package/dist/chunk-NC6S43JJ.js.map +1 -0
- package/dist/chunk-OFVJBJXR.js +98 -0
- package/dist/chunk-OFVJBJXR.js.map +1 -0
- package/dist/chunk-OHISZPOJ.js +97 -0
- package/dist/chunk-OHISZPOJ.js.map +1 -0
- package/dist/chunk-OU5CQKNW.js +102 -0
- package/dist/chunk-OU5CQKNW.js.map +1 -0
- package/dist/{chunk-XOFWRC73.js → chunk-PF7GRZMW.js} +316 -21
- package/dist/chunk-PF7GRZMW.js.map +1 -0
- package/dist/{chunk-5DJTTKX3.js → chunk-PHOUUNK7.js} +74 -111
- package/dist/chunk-PHOUUNK7.js.map +1 -0
- package/dist/chunk-RNHBMHKA.js +1665 -0
- package/dist/chunk-RNHBMHKA.js.map +1 -0
- package/dist/chunk-SX52TAR4.js +110 -0
- package/dist/chunk-SX52TAR4.js.map +1 -0
- package/dist/{chunk-H4RVA4VE.js → chunk-VYPWMZ6H.js} +2 -2
- package/dist/chunk-WBZOVTYK.js +171 -0
- package/dist/chunk-WBZOVTYK.js.map +1 -0
- package/dist/chunk-WKNUIZOY.js +354 -0
- package/dist/chunk-WKNUIZOY.js.map +1 -0
- package/dist/chunk-X3VMZYBT.js +713 -0
- package/dist/chunk-X3VMZYBT.js.map +1 -0
- package/dist/chunk-X5R3GL6H.js +525 -0
- package/dist/chunk-X5R3GL6H.js.map +1 -0
- package/dist/chunk-XGPU467M.js +136 -0
- package/dist/chunk-XGPU467M.js.map +1 -0
- package/dist/compat/index.cjs +7656 -0
- package/dist/compat/index.cjs.map +1 -0
- package/dist/compat/index.d.cts +18 -0
- package/dist/compat/index.d.ts +18 -0
- package/dist/compat/index.js +50 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/jotai/index.cjs +2048 -0
- package/dist/compat/jotai/index.cjs.map +1 -0
- package/dist/compat/jotai/index.d.cts +2 -0
- package/dist/compat/jotai/index.d.ts +2 -0
- package/dist/compat/jotai/index.js +9 -0
- package/dist/compat/jotai/index.js.map +1 -0
- package/dist/compat/nanostores/index.cjs +2175 -0
- package/dist/compat/nanostores/index.cjs.map +1 -0
- package/dist/compat/nanostores/index.d.cts +2 -0
- package/dist/compat/nanostores/index.d.ts +2 -0
- package/dist/compat/nanostores/index.js +23 -0
- package/dist/compat/nanostores/index.js.map +1 -0
- package/dist/compat/nestjs/index.cjs +350 -16
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +6 -6
- package/dist/compat/nestjs/index.d.ts +6 -6
- package/dist/compat/nestjs/index.js +11 -9
- package/dist/compat/react/index.cjs +141 -0
- package/dist/compat/react/index.cjs.map +1 -0
- package/dist/compat/react/index.d.cts +2 -0
- package/dist/compat/react/index.d.ts +2 -0
- package/dist/compat/react/index.js +12 -0
- package/dist/compat/react/index.js.map +1 -0
- package/dist/compat/solid/index.cjs +128 -0
- package/dist/compat/solid/index.cjs.map +1 -0
- package/dist/compat/solid/index.d.cts +2 -0
- package/dist/compat/solid/index.d.ts +2 -0
- package/dist/compat/solid/index.js +12 -0
- package/dist/compat/solid/index.js.map +1 -0
- package/dist/compat/svelte/index.cjs +131 -0
- package/dist/compat/svelte/index.cjs.map +1 -0
- package/dist/compat/svelte/index.d.cts +2 -0
- package/dist/compat/svelte/index.d.ts +2 -0
- package/dist/compat/svelte/index.js +12 -0
- package/dist/compat/svelte/index.js.map +1 -0
- package/dist/compat/vue/index.cjs +146 -0
- package/dist/compat/vue/index.cjs.map +1 -0
- package/dist/compat/vue/index.d.cts +3 -0
- package/dist/compat/vue/index.d.ts +3 -0
- package/dist/compat/vue/index.js +12 -0
- package/dist/compat/vue/index.js.map +1 -0
- package/dist/compat/zustand/index.cjs +4931 -0
- package/dist/compat/zustand/index.cjs.map +1 -0
- package/dist/compat/zustand/index.d.cts +5 -0
- package/dist/compat/zustand/index.d.ts +5 -0
- package/dist/compat/zustand/index.js +12 -0
- package/dist/compat/zustand/index.js.map +1 -0
- package/dist/composite-C7PcQvcs.d.cts +303 -0
- package/dist/composite-aUCvjZVR.d.ts +303 -0
- package/dist/core/index.cjs +53 -4
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +4 -3
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.js +26 -24
- package/dist/demo-shell-BDkOptd6.d.ts +102 -0
- package/dist/demo-shell-Crid1WdR.d.cts +102 -0
- package/dist/extra/index.cjs +222 -110
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.d.cts +6 -4
- package/dist/extra/index.d.ts +6 -4
- package/dist/extra/index.js +72 -65
- package/dist/extra/sources.cjs +2486 -0
- package/dist/extra/sources.cjs.map +1 -0
- package/dist/extra/sources.d.cts +465 -0
- package/dist/extra/sources.d.ts +465 -0
- package/dist/extra/sources.js +57 -0
- package/dist/extra/sources.js.map +1 -0
- package/dist/graph/index.cjs +408 -14
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +5 -5
- package/dist/graph/index.d.ts +5 -5
- package/dist/graph/index.js +13 -5
- package/dist/{graph-D-3JIQme.d.cts → graph-CCwGKLCm.d.ts} +195 -4
- package/dist/{graph-B6NFqv3z.d.ts → graph-DNCrvZSn.d.cts} +195 -4
- package/dist/index-3lsddbbS.d.ts +86 -0
- package/dist/index-B1tloyhO.d.cts +34 -0
- package/dist/{index-CYkjxu3s.d.ts → index-B6D3QNSA.d.ts} +33 -4
- package/dist/index-B6EhDnjH.d.cts +37 -0
- package/dist/index-B9B7_HEY.d.ts +37 -0
- package/dist/{index-Ds23Wvou.d.ts → index-BHlKbUwO.d.cts} +131 -883
- package/dist/{index-DiobMNwE.d.ts → index-BPVt8kqc.d.ts} +3 -3
- package/dist/index-BaSM3aYt.d.ts +195 -0
- package/dist/index-BuEoe-Qu.d.ts +121 -0
- package/dist/{index-Ch0IpIO0.d.cts → index-BwfLUNw4.d.ts} +131 -883
- package/dist/index-ByQxazQJ.d.cts +86 -0
- package/dist/index-C0svESO4.d.ts +127 -0
- package/dist/{index-OXImXMq6.d.ts → index-C8oil6M6.d.ts} +18 -196
- package/dist/{index-DKE1EATr.d.cts → index-CI3DprxP.d.cts} +18 -196
- package/dist/{index-AMWewNDe.d.cts → index-CO8uBlUh.d.cts} +33 -4
- package/dist/index-CxFrXH4m.d.ts +45 -0
- package/dist/index-D8wS_PeY.d.cts +121 -0
- package/dist/index-DO_6JN9Z.d.cts +127 -0
- package/dist/index-DVGiGFGT.d.cts +195 -0
- package/dist/index-DYme44FM.d.cts +44 -0
- package/dist/{index-J7Kc0oIQ.d.cts → index-DlLp-2Xn.d.cts} +3 -3
- package/dist/index-Dzk2hrlR.d.ts +44 -0
- package/dist/index-VHqptjhu.d.cts +45 -0
- package/dist/index-VdHQMPy1.d.ts +36 -0
- package/dist/index-Xi3u0HCQ.d.cts +36 -0
- package/dist/index-wEn0eFe8.d.ts +34 -0
- package/dist/index.cjs +1780 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +784 -2082
- package/dist/index.d.ts +784 -2082
- package/dist/index.js +955 -4349
- package/dist/index.js.map +1 -1
- package/dist/memory-C6Z2tGpC.d.cts +139 -0
- package/dist/memory-li6FL5RM.d.ts +139 -0
- package/dist/messaging-Gt4LPbyA.d.cts +269 -0
- package/dist/messaging-XDoYablx.d.ts +269 -0
- package/dist/{meta-DWbkoq1s.d.cts → meta-BxCA7rcr.d.cts} +1 -1
- package/dist/{meta-CnkLA_43.d.ts → meta-CbznRPYJ.d.ts} +1 -1
- package/dist/{node-B-f-Lu-k.d.cts → node-BmerH3kS.d.cts} +26 -1
- package/dist/{node-B-f-Lu-k.d.ts → node-BmerH3kS.d.ts} +26 -1
- package/dist/{observable-uP-wy_uK.d.ts → observable-BgGUwcqp.d.ts} +1 -1
- package/dist/{observable-DBnrwcar.d.cts → observable-DJt_AxzQ.d.cts} +1 -1
- package/dist/patterns/ai.cjs +7930 -0
- package/dist/patterns/ai.cjs.map +1 -0
- package/dist/patterns/ai.d.cts +10 -0
- package/dist/patterns/ai.d.ts +10 -0
- package/dist/patterns/ai.js +71 -0
- package/dist/patterns/ai.js.map +1 -0
- package/dist/patterns/audit.cjs +5805 -0
- package/dist/patterns/audit.cjs.map +1 -0
- package/dist/patterns/audit.d.cts +6 -0
- package/dist/patterns/audit.d.ts +6 -0
- package/dist/patterns/audit.js +29 -0
- package/dist/patterns/audit.js.map +1 -0
- package/dist/patterns/demo-shell.cjs +5604 -0
- package/dist/patterns/demo-shell.cjs.map +1 -0
- package/dist/patterns/demo-shell.d.cts +6 -0
- package/dist/patterns/demo-shell.d.ts +6 -0
- package/dist/patterns/demo-shell.js +15 -0
- package/dist/patterns/demo-shell.js.map +1 -0
- package/dist/patterns/memory.cjs +5283 -0
- package/dist/patterns/memory.cjs.map +1 -0
- package/dist/patterns/memory.d.cts +5 -0
- package/dist/patterns/memory.d.ts +5 -0
- package/dist/patterns/memory.js +20 -0
- package/dist/patterns/memory.js.map +1 -0
- package/dist/patterns/reactive-layout/index.cjs +355 -13
- package/dist/patterns/reactive-layout/index.cjs.map +1 -1
- package/dist/patterns/reactive-layout/index.d.cts +6 -5
- package/dist/patterns/reactive-layout/index.d.ts +6 -5
- package/dist/patterns/reactive-layout/index.js +15 -12
- package/dist/reactive-layout-MQP--J3F.d.cts +183 -0
- package/dist/reactive-layout-u5Ulnqag.d.ts +183 -0
- package/dist/{storage-BuTdpCI1.d.cts → storage-CMjUUuxn.d.ts} +10 -2
- package/dist/{storage-F2X1U1x0.d.ts → storage-DdWlZo6U.d.cts} +10 -2
- package/dist/sugar-CCOxXK1e.d.ts +201 -0
- package/dist/sugar-D02n5JjF.d.cts +201 -0
- package/package.json +63 -3
- package/dist/chunk-5DJTTKX3.js.map +0 -1
- package/dist/chunk-IAHGTNOZ.js.map +0 -1
- package/dist/chunk-L2GLW2U7.js.map +0 -1
- package/dist/chunk-MW4VAKAO.js +0 -47
- package/dist/chunk-MW4VAKAO.js.map +0 -1
- package/dist/chunk-PY4XCDLR.js.map +0 -1
- package/dist/chunk-TKE3JGOH.js.map +0 -1
- package/dist/chunk-XOFWRC73.js.map +0 -1
- package/dist/index-BJB7t9gg.d.cts +0 -392
- package/dist/index-C-TXEa7C.d.ts +0 -392
- /package/dist/{chunk-H4RVA4VE.js.map → chunk-VYPWMZ6H.js.map} +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { a as NodeOptions, F as FnCtx, N as Node, t as NodeActions, x as NodeFnCleanup } from './node-BmerH3kS.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sugar constructors over the raw `node()` primitive.
|
|
5
|
+
*
|
|
6
|
+
* Each factory wraps a user-friendly function into the canonical
|
|
7
|
+
* `NodeFn = (data, actions, ctx) => cleanup | void` shape, then calls
|
|
8
|
+
* `node(...)`. This is the only place `actions.emit(...)` is invoked
|
|
9
|
+
* on behalf of the user — if you need finer control (multi-emission,
|
|
10
|
+
* raw `actions.down` / `actions.up`, cleanup return), use the raw
|
|
11
|
+
* `node()` factory from `./node.js` directly.
|
|
12
|
+
*
|
|
13
|
+
* See SESSION-foundation-redesign.md §8.5 + §10.6 for the rewrite.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a manual source node. Drive it with `state.emit(v)` (framed,
|
|
18
|
+
* diamond-safe) or `state.down([[DATA, v]])` (raw compat path).
|
|
19
|
+
*
|
|
20
|
+
* @param initial - Starting cached value. Pass `undefined` or `null`
|
|
21
|
+
* explicitly to cache that value; omit to leave the node in `"sentinel"`.
|
|
22
|
+
* @param opts - Optional {@link NodeOptions} (excluding `initial`).
|
|
23
|
+
*/
|
|
24
|
+
declare function state<T>(initial: T, opts?: Omit<NodeOptions<T>, "initial">): Node<T>;
|
|
25
|
+
/**
|
|
26
|
+
* User-level producer compute: runs once on first-subscriber activation.
|
|
27
|
+
* Receives `actions` for imperative emission and `ctx` for FnCtx (typically
|
|
28
|
+
* only `store` is useful on a producer — no deps means `prevData` and
|
|
29
|
+
* `terminalDeps` are empty).
|
|
30
|
+
*/
|
|
31
|
+
type ProducerFn = (actions: NodeActions, ctx: FnCtx) => NodeFnCleanup | void;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a producer node with no deps; `fn` runs once when the first
|
|
34
|
+
* subscriber connects. Return a cleanup function (`() => void`) or
|
|
35
|
+
* `{ deactivation: () => void }` to register teardown.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const ticker = producer((actions) => {
|
|
40
|
+
* const id = setInterval(() => actions.emit(Date.now()), 1000);
|
|
41
|
+
* return () => clearInterval(id);
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare function producer<T = unknown>(fn: ProducerFn, opts?: NodeOptions<T>): Node<T>;
|
|
46
|
+
/**
|
|
47
|
+
* User-level derived compute: receives the latest DATA from each dep and
|
|
48
|
+
* returns the new value. The sugar wraps it with `actions.emit(fn(...))`
|
|
49
|
+
* so the return value flows through the framed emit pipeline.
|
|
50
|
+
*
|
|
51
|
+
* For derived nodes that need to inspect `ctx.prevData` / `ctx.terminalDeps`
|
|
52
|
+
* / `ctx.store`, accept the optional second parameter.
|
|
53
|
+
*/
|
|
54
|
+
type DerivedFn<T> = (data: readonly unknown[], ctx: FnCtx) => T | undefined | null;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a derived node that computes **one output per wave** from the latest
|
|
57
|
+
* value of each dependency — **snapshot / combine semantics**.
|
|
58
|
+
*
|
|
59
|
+
* `fn` receives one scalar per dep (the last DATA value seen this wave, or the
|
|
60
|
+
* prior-wave value as fallback). It is called once per settled wave and emits
|
|
61
|
+
* a single value via `actions.emit`. The equals check then suppresses the
|
|
62
|
+
* emission as `RESOLVED` if the output has not changed.
|
|
63
|
+
*
|
|
64
|
+
* **Not for streaming one-to-one transforms.** If each DATA value in a batch
|
|
65
|
+
* must produce a corresponding output (e.g. transforming every item emitted by
|
|
66
|
+
* `fromIter` individually), use {@link map} or raw `node()` with full batch
|
|
67
|
+
* iteration instead. `derived` only sees the *last* value per dep when a batch
|
|
68
|
+
* carries multiple DATAs.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const a = state(1);
|
|
73
|
+
* const b = derived([a], ([x]) => (x as number) * 2);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function derived<T = unknown>(deps: readonly Node[], fn: DerivedFn<T>, opts?: NodeOptions<T> & {
|
|
77
|
+
partial?: boolean;
|
|
78
|
+
}): Node<T>;
|
|
79
|
+
/**
|
|
80
|
+
* User-level effect compute: fires when deps settle. Return value is NOT
|
|
81
|
+
* auto-emitted — use `actions.emit(v)` / `actions.down(msgs)` explicitly if
|
|
82
|
+
* the effect also wants to produce downstream messages. Return a cleanup
|
|
83
|
+
* function or `{ deactivation }` to register teardown.
|
|
84
|
+
*/
|
|
85
|
+
type EffectFn = (data: readonly unknown[], actions: NodeActions, ctx: FnCtx) => NodeFnCleanup | void;
|
|
86
|
+
/**
|
|
87
|
+
* Runs a side-effect when deps settle. Return value is not auto-emitted.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* effect([source], ([v]) => {
|
|
92
|
+
* console.log(v);
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function effect(deps: readonly Node[], fn: EffectFn, opts?: NodeOptions<unknown> & {
|
|
97
|
+
partial?: boolean;
|
|
98
|
+
}): Node<unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* Proxy handed to a {@link DynamicFn}. `track(dep)` returns the dep's
|
|
101
|
+
* latest DATA payload, as delivered through the protocol. Reading from
|
|
102
|
+
* `track` does NOT bypass the message protocol — it reads the internal
|
|
103
|
+
* `DepRecord.prevData` (the stable end-of-previous-wave value) that
|
|
104
|
+
* `_onDepMessage` already populated. If a dep has not yet sent DATA,
|
|
105
|
+
* `track` returns `undefined`.
|
|
106
|
+
*/
|
|
107
|
+
type TrackFn = (dep: Node) => unknown;
|
|
108
|
+
/** User-level dynamicNode compute. */
|
|
109
|
+
type DynamicFn<T> = (track: TrackFn, ctx: FnCtx) => T | undefined | null;
|
|
110
|
+
/**
|
|
111
|
+
* Sugar over `derived(...)` that exposes dep values via a `track(dep)`
|
|
112
|
+
* proxy instead of positional `data[i]`. All declared `allDeps` participate
|
|
113
|
+
* in wave tracking, so the first fn run waits for every dep to settle.
|
|
114
|
+
* Unused deps that update just re-run fn; `equals` absorbs unchanged
|
|
115
|
+
* outputs as RESOLVED.
|
|
116
|
+
*
|
|
117
|
+
* P3-compliant: `track(dep)` reads from the framework-managed
|
|
118
|
+
* `DepRecord.prevData` populated by the protocol, never from
|
|
119
|
+
* `dep.cache`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const a = state(1);
|
|
124
|
+
* const b = state(10);
|
|
125
|
+
* const sum = dynamicNode([a, b], (track) => (track(a) as number) + (track(b) as number));
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare function dynamicNode<T = unknown>(allDeps: readonly Node[], fn: DynamicFn<T>, opts?: NodeOptions<T> & {
|
|
129
|
+
partial?: boolean;
|
|
130
|
+
}): Node<T>;
|
|
131
|
+
/**
|
|
132
|
+
* Like {@link dynamicNode} but deps are discovered at runtime via `track()`
|
|
133
|
+
* calls — no upfront `allDeps` array needed. Designed for pull-based compat
|
|
134
|
+
* layers (Jotai atoms, TC39 Signals) where deps are unknown until fn runs.
|
|
135
|
+
*
|
|
136
|
+
* **Two-phase discovery:**
|
|
137
|
+
* 1. fn runs. Each `track(dep)` for an unknown dep: subscribes immediately
|
|
138
|
+
* via `_addDep`, returns `dep.cache` as a stub (P3 boundary exception).
|
|
139
|
+
* Result is discarded (discovery run).
|
|
140
|
+
* 2. New deps settle (DATA from subscribe handshake). Wave machinery
|
|
141
|
+
* re-triggers fn. `track(dep)` now returns protocol-delivered `data[i]`.
|
|
142
|
+
* If MORE unknown deps appear, repeat step 1.
|
|
143
|
+
* 3. Converges when no new deps found → real run → `actions.emit(result)`.
|
|
144
|
+
*
|
|
145
|
+
* P3 violation is limited to discovery runs. Once all deps are known,
|
|
146
|
+
* subsequent waves use protocol-delivered values exclusively.
|
|
147
|
+
*
|
|
148
|
+
* Re-entrance safety: `_addDep` subscribes immediately. If the dep delivers
|
|
149
|
+
* DATA synchronously during fn execution, `_execFn`'s re-entrance guard
|
|
150
|
+
* defers the re-run to after the current fn returns.
|
|
151
|
+
*
|
|
152
|
+
* @param opts - Optional {@link AutoTrackOptions}. Pass `{ partial: true }` to
|
|
153
|
+
* allow fn to run before all known deps have delivered their first value
|
|
154
|
+
* (useful for optional/secondary deps).
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const a = state(1), b = state(2);
|
|
159
|
+
* const sum = autoTrackNode((track) => track(a) + track(b));
|
|
160
|
+
* // deps [a, b] discovered automatically on first run
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* Options for {@link autoTrackNode}.
|
|
165
|
+
*/
|
|
166
|
+
interface AutoTrackOptions<T> extends NodeOptions<T> {
|
|
167
|
+
/**
|
|
168
|
+
* When `true`, fn may run before all known deps have delivered their first
|
|
169
|
+
* DATA. Unknown deps return `undefined` via `track()`, which the fn must
|
|
170
|
+
* handle explicitly. Useful when some deps are "nice-to-have" — e.g. a
|
|
171
|
+
* primary computation should continue while a secondary dep is still
|
|
172
|
+
* initialising.
|
|
173
|
+
*
|
|
174
|
+
* When `false` (default), fn is held until every known dep has delivered at
|
|
175
|
+
* least one DATA value — a RESOLVED is emitted for the wave instead.
|
|
176
|
+
* This matches `derived()` semantics and is the correct default for
|
|
177
|
+
* pull-based compat layers (Signals, Jotai) where all deps must be
|
|
178
|
+
* initialised before the computation is meaningful.
|
|
179
|
+
*
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
partial?: boolean;
|
|
183
|
+
}
|
|
184
|
+
declare function autoTrackNode<T = unknown>(fn: (track: TrackFn, ctx: FnCtx) => T | undefined | null, opts?: AutoTrackOptions<T>): Node<T>;
|
|
185
|
+
/** Unary operator used by {@link pipe}. */
|
|
186
|
+
type PipeOperator = (n: Node) => Node;
|
|
187
|
+
/**
|
|
188
|
+
* Composes unary operators left-to-right; returns the final node.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const out = pipe(
|
|
193
|
+
* source,
|
|
194
|
+
* (n) => map(n, (x) => x + 1),
|
|
195
|
+
* (n) => filter(n, (x) => x > 0),
|
|
196
|
+
* );
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
declare function pipe(source: Node, ...ops: PipeOperator[]): Node;
|
|
200
|
+
|
|
201
|
+
export { type AutoTrackOptions as A, type DerivedFn as D, type EffectFn as E, type PipeOperator as P, type TrackFn as T, type DynamicFn as a, type ProducerFn as b, autoTrackNode as c, derived as d, dynamicNode as e, effect as f, producer as g, pipe as p, state as s };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { a as NodeOptions, F as FnCtx, N as Node, t as NodeActions, x as NodeFnCleanup } from './node-BmerH3kS.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sugar constructors over the raw `node()` primitive.
|
|
5
|
+
*
|
|
6
|
+
* Each factory wraps a user-friendly function into the canonical
|
|
7
|
+
* `NodeFn = (data, actions, ctx) => cleanup | void` shape, then calls
|
|
8
|
+
* `node(...)`. This is the only place `actions.emit(...)` is invoked
|
|
9
|
+
* on behalf of the user — if you need finer control (multi-emission,
|
|
10
|
+
* raw `actions.down` / `actions.up`, cleanup return), use the raw
|
|
11
|
+
* `node()` factory from `./node.js` directly.
|
|
12
|
+
*
|
|
13
|
+
* See SESSION-foundation-redesign.md §8.5 + §10.6 for the rewrite.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a manual source node. Drive it with `state.emit(v)` (framed,
|
|
18
|
+
* diamond-safe) or `state.down([[DATA, v]])` (raw compat path).
|
|
19
|
+
*
|
|
20
|
+
* @param initial - Starting cached value. Pass `undefined` or `null`
|
|
21
|
+
* explicitly to cache that value; omit to leave the node in `"sentinel"`.
|
|
22
|
+
* @param opts - Optional {@link NodeOptions} (excluding `initial`).
|
|
23
|
+
*/
|
|
24
|
+
declare function state<T>(initial: T, opts?: Omit<NodeOptions<T>, "initial">): Node<T>;
|
|
25
|
+
/**
|
|
26
|
+
* User-level producer compute: runs once on first-subscriber activation.
|
|
27
|
+
* Receives `actions` for imperative emission and `ctx` for FnCtx (typically
|
|
28
|
+
* only `store` is useful on a producer — no deps means `prevData` and
|
|
29
|
+
* `terminalDeps` are empty).
|
|
30
|
+
*/
|
|
31
|
+
type ProducerFn = (actions: NodeActions, ctx: FnCtx) => NodeFnCleanup | void;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a producer node with no deps; `fn` runs once when the first
|
|
34
|
+
* subscriber connects. Return a cleanup function (`() => void`) or
|
|
35
|
+
* `{ deactivation: () => void }` to register teardown.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const ticker = producer((actions) => {
|
|
40
|
+
* const id = setInterval(() => actions.emit(Date.now()), 1000);
|
|
41
|
+
* return () => clearInterval(id);
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare function producer<T = unknown>(fn: ProducerFn, opts?: NodeOptions<T>): Node<T>;
|
|
46
|
+
/**
|
|
47
|
+
* User-level derived compute: receives the latest DATA from each dep and
|
|
48
|
+
* returns the new value. The sugar wraps it with `actions.emit(fn(...))`
|
|
49
|
+
* so the return value flows through the framed emit pipeline.
|
|
50
|
+
*
|
|
51
|
+
* For derived nodes that need to inspect `ctx.prevData` / `ctx.terminalDeps`
|
|
52
|
+
* / `ctx.store`, accept the optional second parameter.
|
|
53
|
+
*/
|
|
54
|
+
type DerivedFn<T> = (data: readonly unknown[], ctx: FnCtx) => T | undefined | null;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a derived node that computes **one output per wave** from the latest
|
|
57
|
+
* value of each dependency — **snapshot / combine semantics**.
|
|
58
|
+
*
|
|
59
|
+
* `fn` receives one scalar per dep (the last DATA value seen this wave, or the
|
|
60
|
+
* prior-wave value as fallback). It is called once per settled wave and emits
|
|
61
|
+
* a single value via `actions.emit`. The equals check then suppresses the
|
|
62
|
+
* emission as `RESOLVED` if the output has not changed.
|
|
63
|
+
*
|
|
64
|
+
* **Not for streaming one-to-one transforms.** If each DATA value in a batch
|
|
65
|
+
* must produce a corresponding output (e.g. transforming every item emitted by
|
|
66
|
+
* `fromIter` individually), use {@link map} or raw `node()` with full batch
|
|
67
|
+
* iteration instead. `derived` only sees the *last* value per dep when a batch
|
|
68
|
+
* carries multiple DATAs.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const a = state(1);
|
|
73
|
+
* const b = derived([a], ([x]) => (x as number) * 2);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function derived<T = unknown>(deps: readonly Node[], fn: DerivedFn<T>, opts?: NodeOptions<T> & {
|
|
77
|
+
partial?: boolean;
|
|
78
|
+
}): Node<T>;
|
|
79
|
+
/**
|
|
80
|
+
* User-level effect compute: fires when deps settle. Return value is NOT
|
|
81
|
+
* auto-emitted — use `actions.emit(v)` / `actions.down(msgs)` explicitly if
|
|
82
|
+
* the effect also wants to produce downstream messages. Return a cleanup
|
|
83
|
+
* function or `{ deactivation }` to register teardown.
|
|
84
|
+
*/
|
|
85
|
+
type EffectFn = (data: readonly unknown[], actions: NodeActions, ctx: FnCtx) => NodeFnCleanup | void;
|
|
86
|
+
/**
|
|
87
|
+
* Runs a side-effect when deps settle. Return value is not auto-emitted.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* effect([source], ([v]) => {
|
|
92
|
+
* console.log(v);
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function effect(deps: readonly Node[], fn: EffectFn, opts?: NodeOptions<unknown> & {
|
|
97
|
+
partial?: boolean;
|
|
98
|
+
}): Node<unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* Proxy handed to a {@link DynamicFn}. `track(dep)` returns the dep's
|
|
101
|
+
* latest DATA payload, as delivered through the protocol. Reading from
|
|
102
|
+
* `track` does NOT bypass the message protocol — it reads the internal
|
|
103
|
+
* `DepRecord.prevData` (the stable end-of-previous-wave value) that
|
|
104
|
+
* `_onDepMessage` already populated. If a dep has not yet sent DATA,
|
|
105
|
+
* `track` returns `undefined`.
|
|
106
|
+
*/
|
|
107
|
+
type TrackFn = (dep: Node) => unknown;
|
|
108
|
+
/** User-level dynamicNode compute. */
|
|
109
|
+
type DynamicFn<T> = (track: TrackFn, ctx: FnCtx) => T | undefined | null;
|
|
110
|
+
/**
|
|
111
|
+
* Sugar over `derived(...)` that exposes dep values via a `track(dep)`
|
|
112
|
+
* proxy instead of positional `data[i]`. All declared `allDeps` participate
|
|
113
|
+
* in wave tracking, so the first fn run waits for every dep to settle.
|
|
114
|
+
* Unused deps that update just re-run fn; `equals` absorbs unchanged
|
|
115
|
+
* outputs as RESOLVED.
|
|
116
|
+
*
|
|
117
|
+
* P3-compliant: `track(dep)` reads from the framework-managed
|
|
118
|
+
* `DepRecord.prevData` populated by the protocol, never from
|
|
119
|
+
* `dep.cache`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const a = state(1);
|
|
124
|
+
* const b = state(10);
|
|
125
|
+
* const sum = dynamicNode([a, b], (track) => (track(a) as number) + (track(b) as number));
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
declare function dynamicNode<T = unknown>(allDeps: readonly Node[], fn: DynamicFn<T>, opts?: NodeOptions<T> & {
|
|
129
|
+
partial?: boolean;
|
|
130
|
+
}): Node<T>;
|
|
131
|
+
/**
|
|
132
|
+
* Like {@link dynamicNode} but deps are discovered at runtime via `track()`
|
|
133
|
+
* calls — no upfront `allDeps` array needed. Designed for pull-based compat
|
|
134
|
+
* layers (Jotai atoms, TC39 Signals) where deps are unknown until fn runs.
|
|
135
|
+
*
|
|
136
|
+
* **Two-phase discovery:**
|
|
137
|
+
* 1. fn runs. Each `track(dep)` for an unknown dep: subscribes immediately
|
|
138
|
+
* via `_addDep`, returns `dep.cache` as a stub (P3 boundary exception).
|
|
139
|
+
* Result is discarded (discovery run).
|
|
140
|
+
* 2. New deps settle (DATA from subscribe handshake). Wave machinery
|
|
141
|
+
* re-triggers fn. `track(dep)` now returns protocol-delivered `data[i]`.
|
|
142
|
+
* If MORE unknown deps appear, repeat step 1.
|
|
143
|
+
* 3. Converges when no new deps found → real run → `actions.emit(result)`.
|
|
144
|
+
*
|
|
145
|
+
* P3 violation is limited to discovery runs. Once all deps are known,
|
|
146
|
+
* subsequent waves use protocol-delivered values exclusively.
|
|
147
|
+
*
|
|
148
|
+
* Re-entrance safety: `_addDep` subscribes immediately. If the dep delivers
|
|
149
|
+
* DATA synchronously during fn execution, `_execFn`'s re-entrance guard
|
|
150
|
+
* defers the re-run to after the current fn returns.
|
|
151
|
+
*
|
|
152
|
+
* @param opts - Optional {@link AutoTrackOptions}. Pass `{ partial: true }` to
|
|
153
|
+
* allow fn to run before all known deps have delivered their first value
|
|
154
|
+
* (useful for optional/secondary deps).
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const a = state(1), b = state(2);
|
|
159
|
+
* const sum = autoTrackNode((track) => track(a) + track(b));
|
|
160
|
+
* // deps [a, b] discovered automatically on first run
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* Options for {@link autoTrackNode}.
|
|
165
|
+
*/
|
|
166
|
+
interface AutoTrackOptions<T> extends NodeOptions<T> {
|
|
167
|
+
/**
|
|
168
|
+
* When `true`, fn may run before all known deps have delivered their first
|
|
169
|
+
* DATA. Unknown deps return `undefined` via `track()`, which the fn must
|
|
170
|
+
* handle explicitly. Useful when some deps are "nice-to-have" — e.g. a
|
|
171
|
+
* primary computation should continue while a secondary dep is still
|
|
172
|
+
* initialising.
|
|
173
|
+
*
|
|
174
|
+
* When `false` (default), fn is held until every known dep has delivered at
|
|
175
|
+
* least one DATA value — a RESOLVED is emitted for the wave instead.
|
|
176
|
+
* This matches `derived()` semantics and is the correct default for
|
|
177
|
+
* pull-based compat layers (Signals, Jotai) where all deps must be
|
|
178
|
+
* initialised before the computation is meaningful.
|
|
179
|
+
*
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
partial?: boolean;
|
|
183
|
+
}
|
|
184
|
+
declare function autoTrackNode<T = unknown>(fn: (track: TrackFn, ctx: FnCtx) => T | undefined | null, opts?: AutoTrackOptions<T>): Node<T>;
|
|
185
|
+
/** Unary operator used by {@link pipe}. */
|
|
186
|
+
type PipeOperator = (n: Node) => Node;
|
|
187
|
+
/**
|
|
188
|
+
* Composes unary operators left-to-right; returns the final node.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const out = pipe(
|
|
193
|
+
* source,
|
|
194
|
+
* (n) => map(n, (x) => x + 1),
|
|
195
|
+
* (n) => filter(n, (x) => x > 0),
|
|
196
|
+
* );
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
declare function pipe(source: Node, ...ops: PipeOperator[]): Node;
|
|
200
|
+
|
|
201
|
+
export { type AutoTrackOptions as A, type DerivedFn as D, type EffectFn as E, type PipeOperator as P, type TrackFn as T, type DynamicFn as a, type ProducerFn as b, autoTrackNode as c, derived as d, dynamicNode as e, effect as f, producer as g, pipe as p, state as s };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphrefly/graphrefly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
|
|
5
5
|
"description": "Reactive harness layer for agent workflows. Describe automations in plain language, trace every decision, enforce policies, persist checkpoints. Zero dependencies.",
|
|
6
6
|
"repository": {
|
|
@@ -47,6 +47,16 @@
|
|
|
47
47
|
"default": "./dist/extra/index.cjs"
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
+
"./extra/sources": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/extra/sources.d.ts",
|
|
53
|
+
"default": "./dist/extra/sources.js"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/extra/sources.d.cts",
|
|
57
|
+
"default": "./dist/extra/sources.cjs"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
50
60
|
"./graph": {
|
|
51
61
|
"import": {
|
|
52
62
|
"types": "./dist/graph/index.d.ts",
|
|
@@ -77,6 +87,16 @@
|
|
|
77
87
|
"default": "./dist/compat/jotai/index.cjs"
|
|
78
88
|
}
|
|
79
89
|
},
|
|
90
|
+
"./compat/nanostores": {
|
|
91
|
+
"import": {
|
|
92
|
+
"types": "./dist/compat/nanostores/index.d.ts",
|
|
93
|
+
"default": "./dist/compat/nanostores/index.js"
|
|
94
|
+
},
|
|
95
|
+
"require": {
|
|
96
|
+
"types": "./dist/compat/nanostores/index.d.cts",
|
|
97
|
+
"default": "./dist/compat/nanostores/index.cjs"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
80
100
|
"./compat/zustand": {
|
|
81
101
|
"import": {
|
|
82
102
|
"types": "./dist/compat/zustand/index.d.ts",
|
|
@@ -137,7 +157,7 @@
|
|
|
137
157
|
"default": "./dist/compat/nestjs/index.cjs"
|
|
138
158
|
}
|
|
139
159
|
},
|
|
140
|
-
"./reactive-layout": {
|
|
160
|
+
"./patterns/reactive-layout": {
|
|
141
161
|
"import": {
|
|
142
162
|
"types": "./dist/patterns/reactive-layout/index.d.ts",
|
|
143
163
|
"default": "./dist/patterns/reactive-layout/index.js"
|
|
@@ -146,6 +166,46 @@
|
|
|
146
166
|
"types": "./dist/patterns/reactive-layout/index.d.cts",
|
|
147
167
|
"default": "./dist/patterns/reactive-layout/index.cjs"
|
|
148
168
|
}
|
|
169
|
+
},
|
|
170
|
+
"./patterns/demo-shell": {
|
|
171
|
+
"import": {
|
|
172
|
+
"types": "./dist/patterns/demo-shell.d.ts",
|
|
173
|
+
"default": "./dist/patterns/demo-shell.js"
|
|
174
|
+
},
|
|
175
|
+
"require": {
|
|
176
|
+
"types": "./dist/patterns/demo-shell.d.cts",
|
|
177
|
+
"default": "./dist/patterns/demo-shell.cjs"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"./patterns/memory": {
|
|
181
|
+
"import": {
|
|
182
|
+
"types": "./dist/patterns/memory.d.ts",
|
|
183
|
+
"default": "./dist/patterns/memory.js"
|
|
184
|
+
},
|
|
185
|
+
"require": {
|
|
186
|
+
"types": "./dist/patterns/memory.d.cts",
|
|
187
|
+
"default": "./dist/patterns/memory.cjs"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"./patterns/ai": {
|
|
191
|
+
"import": {
|
|
192
|
+
"types": "./dist/patterns/ai.d.ts",
|
|
193
|
+
"default": "./dist/patterns/ai.js"
|
|
194
|
+
},
|
|
195
|
+
"require": {
|
|
196
|
+
"types": "./dist/patterns/ai.d.cts",
|
|
197
|
+
"default": "./dist/patterns/ai.cjs"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"./patterns/audit": {
|
|
201
|
+
"import": {
|
|
202
|
+
"types": "./dist/patterns/audit.d.ts",
|
|
203
|
+
"default": "./dist/patterns/audit.js"
|
|
204
|
+
},
|
|
205
|
+
"require": {
|
|
206
|
+
"types": "./dist/patterns/audit.d.cts",
|
|
207
|
+
"default": "./dist/patterns/audit.cjs"
|
|
208
|
+
}
|
|
149
209
|
}
|
|
150
210
|
},
|
|
151
211
|
"files": [
|
|
@@ -157,7 +217,7 @@
|
|
|
157
217
|
},
|
|
158
218
|
"scripts": {
|
|
159
219
|
"docs:dev": "pnpm --dir website dev",
|
|
160
|
-
"docs:build": "pnpm --dir website build && pnpm --dir demos/compat-matrix build && pnpm --dir demos/reactive-layout build && cp -r demos/compat-matrix/dist/. website/dist/demos/compat-matrix/ && cp -r demos/reactive-layout/dist/. website/dist/demos/reactive-layout/",
|
|
220
|
+
"docs:build": "pnpm build && pnpm --dir website build && pnpm --dir demos/compat-matrix build && pnpm --dir demos/reactive-layout build && pnpm --dir demos/knowledge-graph build && cp -r demos/compat-matrix/dist/. website/dist/demos/compat-matrix/ && cp -r demos/reactive-layout/dist/. website/dist/demos/reactive-layout/ && cp -r demos/knowledge-graph/dist/. website/dist/demos/knowledge-graph/",
|
|
161
221
|
"docs:preview": "pnpm --dir website preview",
|
|
162
222
|
"build": "tsup",
|
|
163
223
|
"test": "vitest run",
|