@graphrefly/ts 0.1.0 → 0.1.1
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 +5 -7
- package/dist/{actions-types-DfRob139.d.cts → actions-types-BYzAurt6.d.cts} +1 -1
- package/dist/{actions-types-DcDaBRTC.d.ts → actions-types-CFJILlFn.d.ts} +1 -1
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +5 -5
- package/dist/adapters/index.d.ts +5 -5
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/nestjs/microservices.d.cts +1 -1
- package/dist/adapters/nestjs/microservices.d.ts +1 -1
- package/dist/adapters/nestjs/native.d.cts +2 -2
- package/dist/adapters/nestjs/native.d.ts +2 -2
- package/dist/adapters/nestjs/native.js +2 -2
- package/dist/adapters/nestjs/websockets.d.cts +1 -1
- package/dist/adapters/nestjs/websockets.d.ts +1 -1
- package/dist/adapters/nestjs.d.cts +1 -1
- package/dist/adapters/nestjs.d.ts +1 -1
- package/dist/adapters/observe-storage.d.cts +1 -1
- package/dist/adapters/observe-storage.d.ts +1 -1
- package/dist/adapters/react.cjs.map +1 -1
- package/dist/adapters/react.d.cts +1 -1
- package/dist/adapters/react.d.ts +1 -1
- package/dist/adapters/react.js +1 -1
- package/dist/adapters/solid.cjs.map +1 -1
- package/dist/adapters/solid.d.cts +1 -1
- package/dist/adapters/solid.d.ts +1 -1
- package/dist/adapters/solid.js +1 -1
- package/dist/adapters/svelte.cjs.map +1 -1
- package/dist/adapters/svelte.d.cts +1 -1
- package/dist/adapters/svelte.d.ts +1 -1
- package/dist/adapters/svelte.js +1 -1
- package/dist/adapters/vue.cjs.map +1 -1
- package/dist/adapters/vue.d.cts +1 -1
- package/dist/adapters/vue.d.ts +1 -1
- package/dist/adapters/vue.js +1 -1
- package/dist/{agent-runtime-types-tool-CTZx51kE.d.cts → agent-runtime-types-tool-DSzCWLK4.d.cts} +1 -1
- package/dist/{agent-runtime-types-tool-B0jR0euI.d.ts → agent-runtime-types-tool-DUZUxrl5.d.ts} +1 -1
- package/dist/{capability-admission-CGmtVzfS.d.ts → capability-admission--qmB5qYW.d.ts} +1 -1
- package/dist/{capability-admission-BwmsThnQ.d.cts → capability-admission-BbiUMnpF.d.cts} +1 -1
- package/dist/{chunk-BIGKAHSX.js → chunk-2U4G3PEU.js} +8 -8
- package/dist/{chunk-FLUPPSIP.js → chunk-3KYPNNBH.js} +1 -1
- package/dist/chunk-3KYPNNBH.js.map +1 -0
- package/dist/{chunk-AVPXWVRL.js → chunk-BOWKPNXS.js} +2 -2
- package/dist/{chunk-LRYGIKWY.js → chunk-G3J4KZLK.js} +5 -5
- package/dist/{chunk-32WGWBYO.js → chunk-HFPPLLLQ.js} +2 -2
- package/dist/{chunk-VYAEEKZ3.js → chunk-IISXKNWE.js} +1 -1
- package/dist/chunk-IISXKNWE.js.map +1 -0
- package/dist/{chunk-DXBOAAPS.js → chunk-KTJ5LEOL.js} +1 -1
- package/dist/chunk-KTJ5LEOL.js.map +1 -0
- package/dist/{chunk-HT5R7S47.js → chunk-LPC42V2E.js} +3 -3
- package/dist/{chunk-STLRNFU7.js → chunk-T3YMFLRH.js} +3 -3
- package/dist/chunk-T3YMFLRH.js.map +1 -0
- package/dist/{chunk-V3MSIDUQ.js → chunk-TWOPVCGK.js} +2 -2
- package/dist/{chunk-ND43YDGK.js → chunk-V3YEGWSH.js} +1 -1
- package/dist/chunk-V3YEGWSH.js.map +1 -0
- package/dist/{chunk-2BIF6BQ7.js → chunk-W4ATMMTH.js} +2 -2
- package/dist/{committed-fact-log-backend-Cjhgia-O.d.ts → committed-fact-log-backend-B_h6A6cN.d.ts} +1 -1
- package/dist/{committed-fact-log-backend-BE3Fx5Zv.d.cts → committed-fact-log-backend-CIhiKL-Q.d.cts} +1 -1
- package/dist/composition/index.cjs.map +1 -1
- package/dist/composition/index.d.cts +1 -1
- package/dist/composition/index.d.ts +1 -1
- package/dist/composition/index.js +2 -2
- package/dist/cqrs/index.d.cts +1 -1
- package/dist/cqrs/index.d.ts +1 -1
- package/dist/cqrs/messaging.d.cts +1 -1
- package/dist/cqrs/messaging.d.ts +1 -1
- package/dist/cqrs/work-queue.d.cts +1 -1
- package/dist/cqrs/work-queue.d.ts +1 -1
- package/dist/data-structures/index.cjs.map +1 -1
- package/dist/data-structures/index.d.cts +5 -5
- package/dist/data-structures/index.d.ts +5 -5
- package/dist/data-structures/index.js +3 -3
- package/dist/executors/tool-provider-adapters.d.cts +3 -3
- package/dist/executors/tool-provider-adapters.d.ts +3 -3
- package/dist/executors/tool-provider-adapters.js +4 -4
- package/dist/executors/tool-provider-runtime.d.cts +4 -4
- package/dist/executors/tool-provider-runtime.d.ts +4 -4
- package/dist/executors/tool-provider.d.cts +3 -3
- package/dist/executors/tool-provider.d.ts +3 -3
- package/dist/executors/tool-provider.js +3 -3
- package/dist/executors/work-queue.d.cts +1 -1
- package/dist/executors/work-queue.d.ts +1 -1
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +4 -4
- package/dist/graph/index.d.ts +4 -4
- package/dist/graph/index.js +7 -7
- package/dist/{graph-D7DgoW4r.d.ts → graph-BYcUX6Y-.d.ts} +1 -1
- package/dist/{graph-BpVjXE3p.d.cts → graph-DpUhfPg-.d.cts} +1 -1
- package/dist/{index-NxEHWqYL.d.ts → index-CBXYou1z.d.ts} +1 -1
- package/dist/{index-Df4kax8O.d.cts → index-sxZ52y0d.d.cts} +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +15 -15
- package/dist/inspection/boundary.d.cts +2 -2
- package/dist/inspection/boundary.d.ts +2 -2
- package/dist/{measurements-CIGHDnsE.d.ts → measurements-ByXwo0t6.d.ts} +2 -2
- package/dist/{measurements-BwkzVaf4.d.cts → measurements-CQONT7Qg.d.cts} +2 -2
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/semantic/index.d.cts +1 -1
- package/dist/memory/semantic/index.d.ts +1 -1
- package/dist/messaging/index.d.cts +1 -1
- package/dist/messaging/index.d.ts +1 -1
- package/dist/operators/index.cjs.map +1 -1
- package/dist/operators/index.d.cts +5 -5
- package/dist/operators/index.d.ts +5 -5
- package/dist/operators/index.js +3 -3
- package/dist/orchestration/index.cjs.map +1 -1
- package/dist/orchestration/index.d.cts +5 -5
- package/dist/orchestration/index.d.ts +5 -5
- package/dist/orchestration/index.js +4 -4
- package/dist/orchestration/messaging.d.cts +1 -1
- package/dist/orchestration/messaging.d.ts +1 -1
- package/dist/orchestration/work-queue.d.cts +2 -2
- package/dist/orchestration/work-queue.d.ts +2 -2
- package/dist/patterns/event-flow.d.cts +1 -1
- package/dist/patterns/event-flow.d.ts +1 -1
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.d.cts +2 -2
- package/dist/patterns/index.d.ts +2 -2
- package/dist/patterns/index.js +1 -1
- package/dist/{reactive-collection-yjdqrWkb.d.cts → reactive-collection-Bt5117qe.d.cts} +1 -1
- package/dist/{reactive-collection-BTdjAVpJ.d.ts → reactive-collection-CZGtOhEp.d.ts} +1 -1
- package/dist/{reactive-collection-storage-C1YIW_q2.d.cts → reactive-collection-storage-BzhzmEpP.d.cts} +3 -3
- package/dist/{reactive-collection-storage-BZozONHw.d.ts → reactive-collection-storage-NKUpbyyK.d.ts} +3 -3
- package/dist/{reactive-map-c-l8bYrl.d.cts → reactive-map-Cf9_oTOT.d.cts} +1 -1
- package/dist/{reactive-map-B6sA6p5U.d.ts → reactive-map-DQeA7ThE.d.ts} +1 -1
- package/dist/{scheduled-readiness-Batwa3Fm.d.ts → scheduled-readiness-BQdebv1Q.d.ts} +1 -1
- package/dist/{scheduled-readiness-BtUBoaGJ.d.cts → scheduled-readiness-D5qPFnZF.d.cts} +1 -1
- package/dist/solutions/agentic-memory/browser.d.cts +2 -2
- package/dist/solutions/agentic-memory/browser.d.ts +2 -2
- package/dist/solutions/agentic-memory/index.d.cts +3 -3
- package/dist/solutions/agentic-memory/index.d.ts +3 -3
- package/dist/solutions/agentic-memory/node.d.cts +2 -2
- package/dist/solutions/agentic-memory/node.d.ts +2 -2
- package/dist/solutions/agentic-work-item-memory/index.d.cts +1 -1
- package/dist/solutions/agentic-work-item-memory/index.d.ts +1 -1
- package/dist/solutions/agentic-work-item-memory-application/index.d.cts +1 -1
- package/dist/solutions/agentic-work-item-memory-application/index.d.ts +1 -1
- package/dist/solutions/index.d.cts +6 -6
- package/dist/solutions/index.d.ts +6 -6
- package/dist/solutions/reactive-layout/browser/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/browser/index.d.ts +2 -2
- package/dist/solutions/reactive-layout/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/node-canvas/index.d.ts +2 -2
- package/dist/solutions/reactive-layout/react-native/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/react-native/index.d.ts +2 -2
- package/dist/solutions/reactive-layout/skia/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/skia/index.d.ts +2 -2
- package/dist/solutions/work-item/actions.d.cts +5 -5
- package/dist/solutions/work-item/actions.d.ts +5 -5
- package/dist/solutions/work-item/index.d.cts +4 -4
- package/dist/solutions/work-item/index.d.ts +4 -4
- package/dist/solutions/work-item/scheduling.d.cts +4 -4
- package/dist/solutions/work-item/scheduling.d.ts +4 -4
- package/dist/solutions/work-item/work-queue.d.cts +1 -1
- package/dist/solutions/work-item/work-queue.d.ts +1 -1
- package/dist/sources/browser.cjs.map +1 -1
- package/dist/sources/browser.d.cts +2 -2
- package/dist/sources/browser.d.ts +2 -2
- package/dist/sources/browser.js +2 -2
- package/dist/sources/index.cjs.map +1 -1
- package/dist/sources/index.d.cts +2 -2
- package/dist/sources/index.d.ts +2 -2
- package/dist/sources/index.js +2 -2
- package/dist/sources/node.d.cts +1 -1
- package/dist/sources/node.d.ts +1 -1
- package/dist/storage/index.d.cts +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/{store-BnjczOv3.d.cts → store-Rxycbh-H.d.cts} +5 -5
- package/dist/{store-DEQq1IUZ.d.ts → store-piaqo-AU.d.ts} +5 -5
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{types-CjoOI5fY.d.cts → types-084NQr4q.d.cts} +1 -1
- package/dist/{types-C_rZAUfY.d.ts → types-CIYYkmqF.d.ts} +1 -1
- package/dist/work-queue/index.d.cts +1 -1
- package/dist/work-queue/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/chunk-DXBOAAPS.js.map +0 -1
- package/dist/chunk-FLUPPSIP.js.map +0 -1
- package/dist/chunk-ND43YDGK.js.map +0 -1
- package/dist/chunk-STLRNFU7.js.map +0 -1
- package/dist/chunk-VYAEEKZ3.js.map +0 -1
- /package/dist/{chunk-BIGKAHSX.js.map → chunk-2U4G3PEU.js.map} +0 -0
- /package/dist/{chunk-AVPXWVRL.js.map → chunk-BOWKPNXS.js.map} +0 -0
- /package/dist/{chunk-LRYGIKWY.js.map → chunk-G3J4KZLK.js.map} +0 -0
- /package/dist/{chunk-32WGWBYO.js.map → chunk-HFPPLLLQ.js.map} +0 -0
- /package/dist/{chunk-HT5R7S47.js.map → chunk-LPC42V2E.js.map} +0 -0
- /package/dist/{chunk-V3MSIDUQ.js.map → chunk-TWOPVCGK.js.map} +0 -0
- /package/dist/{chunk-2BIF6BQ7.js.map → chunk-W4ATMMTH.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/store.ts"],"sourcesContent":["/**\n * Framework-neutral store adapters.\n *\n * Focused framework bindings build on this tiny Node-facing layer without\n * importing framework packages into the dependency-free adapters barrel\n * (D125/D238).\n */\n\nimport type { DeliveryMeta, Sink } from \"../ctx/types.js\";\nimport type { Node } from \"../node/node.js\";\n\n/** A minimal readable store contract shared by Svelte/Nanostores-style adapters. */\nexport interface ReadableStore<T> {\n\tget(): T | undefined;\n\tsubscribe(run: (value: T | undefined) => void): () => void;\n}\n\n/** A minimal writable store contract over a clean-slate writable node. */\nexport interface WritableStore<T> extends ReadableStore<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\n/** React `useSyncExternalStore`-compatible shape, without importing React. */\nexport interface ExternalStore<T> {\n\tgetSnapshot(): T | undefined;\n\tgetServerSnapshot(): T | undefined;\n\tsubscribe(onStoreChange: () => void): () => void;\n}\n\n/** Object-of-nodes factory used by record subscription adapters. */\nexport type NodeRecordFactory<K extends string, R extends Record<string, unknown>> = (key: K) => {\n\t[P in keyof R]: Node<R[P]>;\n};\n\n/** Zustand-compatible store API over a caller-owned clean-slate state node. */\nexport interface ZustandStoreApi<T extends object> {\n\tgetState(): T;\n\tsetState(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean): void;\n\tgetInitialState(): T;\n\tsubscribe(listener: (state: T, prevState: T) => void): () => void;\n\tdestroy(): void;\n}\n\n/** Jotai-style atom facade over a caller-owned node. */\nexport interface JotaiAtom<T> {\n\tget(): T | undefined;\n\tsubscribe(callback: (value: T | undefined) => void): () => void;\n\treadonly _node: Node<T>;\n}\n\n/** Writable Jotai-style atom facade over a caller-owned writable node. */\nexport interface WritableJotaiAtom<T> extends JotaiAtom<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\n/** Nanostores-style atom facade over a caller-owned node. */\nexport interface NanoAtom<T> {\n\tget(): T | undefined;\n\tsubscribe(callback: (value: T | undefined) => void): () => void;\n\tlisten(callback: (value: T | undefined) => void): () => void;\n\treadonly _node: Node<T>;\n}\n\n/** Writable Nanostores-style atom facade over a caller-owned writable node. */\nexport interface WritableNanoAtom<T> extends NanoAtom<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\n/** TC39-Signals-style facade over a caller-owned node. */\nexport interface SignalLike<T> {\n\tget(): T | undefined;\n\tsubscribe(callback: (value: T | undefined) => void): () => void;\n\treadonly _node: Node<T>;\n}\n\n/** Writable TC39-Signals-style facade over a caller-owned writable node. */\nexport interface WritableSignalLike<T> extends SignalLike<T> {\n\tset(value: T): void;\n\tupdate(fn: (value: T | undefined) => T): void;\n}\n\nexport interface SubscribeValuesOptions<T> {\n\t/** Emit the current cache snapshot immediately. `undefined` means SENTINEL/no DATA. */\n\timmediate?: boolean;\n\t/** Suppress synchronous push-on-subscribe/replay DATA. Useful for change-only store listeners. */\n\tchangesOnly?: boolean;\n\tonError?: (error: unknown) => void;\n\tonComplete?: () => void;\n\t/** Custom cache reader for wrappers that keep their own snapshot object. */\n\tgetSnapshot?: () => T | undefined;\n}\n\nexport interface WritableNode<T> extends Node<T> {\n\tset(value: T): void;\n}\n\nexport interface WritableStoreOptions<T> extends SubscribeValuesOptions<T> {\n\t/** Override writes for adapters that need a framework-owned reducer. */\n\twrite?: (node: WritableNode<T>, value: T) => void;\n}\n\n/** Read a node cache without activating it.\n * @param node - Node to observe, adapt, or connect.\n * @returns A `T | undefined` value.\n * @category adapters\n * @example\n * ```ts\n * import { nodeSnapshot } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function nodeSnapshot<T>(node: Node<T>): T | undefined {\n\treturn node.cache as T | undefined;\n}\n\n/**\n * Subscribe to DATA values from a Node. Protocol internals stay below the adapter boundary:\n * DATA drives value listeners, ERROR/COMPLETE route to optional lifecycle callbacks.\n * @param node - Node to observe, adapt, or connect.\n * @param run - run value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns A `() => void` value.\n * @category adapters\n * @example\n * ```ts\n * import { subscribeNodeValues } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function subscribeNodeValues<T>(\n\tnode: Node<T>,\n\trun: (value: T | undefined) => void,\n\topts: SubscribeValuesOptions<T> = {},\n): () => void {\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\tif (opts.immediate) run(read());\n\n\tlet subscribing = true;\n\tconst skipSynchronousHandshakeData = opts.changesOnly || opts.immediate;\n\tconst sink: Sink = (msg, delivery?: DeliveryMeta) => {\n\t\tswitch (msg[0]) {\n\t\t\tcase \"DATA\":\n\t\t\t\tif (skipSynchronousHandshakeData && subscribing && delivery === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trun(msg[1] as T);\n\t\t\t\treturn;\n\t\t\tcase \"ERROR\":\n\t\t\t\topts.onError?.(msg[1]);\n\t\t\t\treturn;\n\t\t\tcase \"COMPLETE\":\n\t\t\t\topts.onComplete?.();\n\t\t\t\treturn;\n\t\t}\n\t};\n\tconst unsubscribe = node.subscribe(sink);\n\tsubscribing = false;\n\treturn unsubscribe;\n}\n\n/** Build a Svelte/Nanostores-style readable store from a clean-slate Node.\n * @param node - Node to observe, adapt, or connect.\n * @param opts - Options that configure the helper.\n * @returns A `ReadableStore<T>` value.\n * @category adapters\n * @example\n * ```ts\n * import { readableStore } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function readableStore<T>(\n\tnode: Node<T>,\n\topts: SubscribeValuesOptions<T> = {},\n): ReadableStore<T> {\n\treturn {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (run) => subscribeNodeValues(node, run, { immediate: true, ...opts }),\n\t};\n}\n\nfunction hasWritableSet<T>(node: Node<T>): node is WritableNode<T> {\n\treturn typeof (node as { set?: unknown }).set === \"function\";\n}\n\nfunction defaultWrite<T>(node: WritableNode<T>, value: T): void {\n\tnode.set(value);\n}\n\n/** Build a writable store over a StateNode or compatible clean-slate writable Node. */\nexport function writableStore<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableStore<T>;\n\n/**\n * Creates a writable store.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The writable store result.\n * @category adapters\n * @example\n * ```ts\n * import { writableStore } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function writableStore<T>(\n\tnode: Node<T>,\n\topts: WritableStoreOptions<T> & { write: (node: WritableNode<T>, value: T) => void },\n): WritableStore<T>;\n\n/**\n * Creates a writable store.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The writable store result.\n * @category adapters\n * @example\n * ```ts\n * import { writableStore } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function writableStore<T>(\n\tnode: Node<T>,\n\topts: WritableStoreOptions<T> = {},\n): WritableStore<T> {\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\tconst write = opts.write ?? (hasWritableSet(node) ? defaultWrite : undefined);\n\tif (!write) {\n\t\tthrow new TypeError(\"writableStore: node must expose set(value) or opts.write\");\n\t}\n\tconst writable = node as WritableNode<T>;\n\treturn {\n\t\tget: read,\n\t\tsubscribe: (run) => subscribeNodeValues(node, run, { immediate: true, ...opts }),\n\t\tset: (value) => write(writable, value),\n\t\tupdate: (fn) => write(writable, fn(read())),\n\t};\n}\n\n/** Build the tiny shape React's `useSyncExternalStore` expects, without importing React.\n * @param node - Node to observe, adapt, or connect.\n * @param opts - Options that configure the helper.\n * @returns A `ExternalStore<T>` value.\n * @category adapters\n * @example\n * ```ts\n * import { externalStore } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function externalStore<T>(\n\tnode: Node<T>,\n\topts: Pick<SubscribeValuesOptions<T>, \"getSnapshot\" | \"onError\" | \"onComplete\"> = {},\n): ExternalStore<T> {\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\treturn {\n\t\tgetSnapshot: read,\n\t\tgetServerSnapshot: read,\n\t\tsubscribe: (onStoreChange) =>\n\t\t\tsubscribeNodeValues(node, () => onStoreChange(), {\n\t\t\t\tchangesOnly: true,\n\t\t\t\tonError: opts.onError,\n\t\t\t\tonComplete: opts.onComplete,\n\t\t\t}),\n\t};\n}\n\n/** Build a framework-neutral keyed record store for focused framework record bindings.\n * @param keysNode - keys node value used by the helper.\n * @param factory - factory value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns A `ReadableStore<Record<K, R>>` value.\n * @category adapters\n * @example\n * ```ts\n * import { recordReadableStore } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function recordReadableStore<K extends string, R extends Record<string, unknown>>(\n\tkeysNode: Node<readonly K[]>,\n\tfactory: NodeRecordFactory<K, R>,\n\topts: SubscribeValuesOptions<Record<K, R>> = {},\n): ReadableStore<Record<K, R>> {\n\tconst read = () => {\n\t\tconst keys = keysNode.cache ?? [];\n\t\tconst out = {} as Record<K, R>;\n\t\tfor (const key of keys) {\n\t\t\tconst nodes = factory(key);\n\t\t\tconst values = {} as R;\n\t\t\tfor (const field of Object.keys(nodes) as Array<keyof R>) {\n\t\t\t\tvalues[field] = nodes[field].cache as R[keyof R];\n\t\t\t}\n\t\t\tout[key] = values;\n\t\t}\n\t\treturn out;\n\t};\n\n\treturn {\n\t\tget: read,\n\t\tsubscribe(run) {\n\t\t\tconst entryUnsubs: Array<() => void> = [];\n\t\t\tconst cleanupEntries = () => {\n\t\t\t\tfor (const unsub of entryUnsubs.splice(0)) unsub();\n\t\t\t};\n\t\t\tconst sync = () => {\n\t\t\t\tcleanupEntries();\n\t\t\t\tfor (const key of keysNode.cache ?? []) {\n\t\t\t\t\tconst nodes = factory(key);\n\t\t\t\t\tfor (const field of Object.keys(nodes) as Array<keyof R>) {\n\t\t\t\t\t\tentryUnsubs.push(\n\t\t\t\t\t\t\tsubscribeNodeValues(nodes[field], () => run(read()), {\n\t\t\t\t\t\t\t\tchangesOnly: true,\n\t\t\t\t\t\t\t\tonError: opts.onError,\n\t\t\t\t\t\t\t\tonComplete: opts.onComplete,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trun(read());\n\t\t\t};\n\t\t\tconst keysUnsub = subscribeNodeValues(keysNode, sync, {\n\t\t\t\tchangesOnly: true,\n\t\t\t\tonError: opts.onError,\n\t\t\t\tonComplete: opts.onComplete,\n\t\t\t});\n\t\t\tsync();\n\t\t\treturn () => {\n\t\t\t\tkeysUnsub();\n\t\t\t\tcleanupEntries();\n\t\t\t};\n\t\t},\n\t};\n}\n\n/** Build a Zustand-compatible StoreApi over a caller-owned clean-slate state node. */\nexport function zustandStore<T extends object>(\n\tnode: WritableNode<T>,\n\tinitialState?: T,\n\topts?: WritableStoreOptions<T>,\n): ZustandStoreApi<T>;\n\n/**\n * Creates a zustand store.\n *\n * @param node - node value used by the helper.\n * @param initialState - initial state value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The zustand store result.\n * @category adapters\n * @example\n * ```ts\n * import { zustandStore } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function zustandStore<T extends object>(\n\tnode: Node<T>,\n\tinitialState: T | undefined,\n\topts: WritableStoreOptions<T> & { write: (node: WritableNode<T>, value: T) => void },\n): ZustandStoreApi<T>;\n\n/**\n * Creates a zustand store.\n *\n * @param node - node value used by the helper.\n * @param initialState - initial state value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The zustand store result.\n * @category adapters\n * @example\n * ```ts\n * import { zustandStore } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function zustandStore<T extends object>(\n\tnode: Node<T>,\n\tinitialState: T = nodeSnapshot(node) as T,\n\topts: WritableStoreOptions<T> = {},\n): ZustandStoreApi<T> {\n\tconst listeners = new Set<() => void>();\n\tconst read = opts.getSnapshot ?? (() => nodeSnapshot(node));\n\tconst write = opts.write ?? (hasWritableSet(node) ? defaultWrite : undefined);\n\tif (!write) {\n\t\tthrow new TypeError(\"zustandStore: node must expose set(value) or opts.write\");\n\t}\n\tconst writable = node as WritableNode<T>;\n\tconst api: ZustandStoreApi<T> = {\n\t\tgetState: () => read() as T,\n\t\tsetState(partial, replace) {\n\t\t\tconst prev = api.getState();\n\t\t\tconst next = typeof partial === \"function\" ? partial(prev) : partial;\n\t\t\twrite(writable, replace ? (next as T) : ({ ...prev, ...next } as T));\n\t\t},\n\t\tgetInitialState: () => initialState,\n\t\tsubscribe(listener) {\n\t\t\tlet prev = api.getState();\n\t\t\tconst unsub = subscribeNodeValues(\n\t\t\t\tnode,\n\t\t\t\t() => {\n\t\t\t\t\tconst next = api.getState();\n\t\t\t\t\tlistener(next, prev);\n\t\t\t\t\tprev = next;\n\t\t\t\t},\n\t\t\t\t{ changesOnly: true, onError: opts.onError, onComplete: opts.onComplete },\n\t\t\t);\n\t\t\tlisteners.add(unsub);\n\t\t\treturn () => {\n\t\t\t\tif (!listeners.delete(unsub)) return;\n\t\t\t\tunsub();\n\t\t\t};\n\t\t},\n\t\tdestroy() {\n\t\t\tfor (const unsub of [...listeners]) {\n\t\t\t\tlisteners.delete(unsub);\n\t\t\t\tunsub();\n\t\t\t}\n\t\t},\n\t};\n\treturn api;\n}\n\n/** Build a Jotai-style atom facade over a caller-owned node. */\nexport function jotaiAtom<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableJotaiAtom<T>;\n\n/**\n * Creates a jotai atom.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The jotai atom result.\n * @category adapters\n * @example\n * ```ts\n * import { jotaiAtom } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function jotaiAtom<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): JotaiAtom<T>;\n\n/**\n * Creates a jotai atom.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The jotai atom result.\n * @category adapters\n * @example\n * ```ts\n * import { jotaiAtom } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function jotaiAtom<T>(\n\tnode: Node<T> | WritableNode<T>,\n\topts: SubscribeValuesOptions<T> | WritableStoreOptions<T> = {},\n): JotaiAtom<T> | WritableJotaiAtom<T> {\n\tconst base: JotaiAtom<T> = {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (callback) => subscribeNodeValues(node, callback, { changesOnly: true, ...opts }),\n\t\t_node: node,\n\t};\n\tif (hasWritableSet(node) || typeof (opts as WritableStoreOptions<T>).write === \"function\") {\n\t\tconst writable = writableStore(\n\t\t\tnode,\n\t\t\topts as WritableStoreOptions<T> & {\n\t\t\t\twrite: (node: WritableNode<T>, value: T) => void;\n\t\t\t},\n\t\t);\n\t\treturn { ...base, set: writable.set, update: writable.update };\n\t}\n\treturn base;\n}\n\n/** Build a Nanostores-style atom facade over a caller-owned node. */\nexport function nanoAtom<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableNanoAtom<T>;\n\n/**\n * Creates a nano atom.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The nano atom result.\n * @category adapters\n * @example\n * ```ts\n * import { nanoAtom } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function nanoAtom<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): NanoAtom<T>;\n\n/**\n * Creates a nano atom.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The nano atom result.\n * @category adapters\n * @example\n * ```ts\n * import { nanoAtom } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function nanoAtom<T>(\n\tnode: Node<T> | WritableNode<T>,\n\topts: SubscribeValuesOptions<T> | WritableStoreOptions<T> = {},\n): NanoAtom<T> | WritableNanoAtom<T> {\n\tconst base: NanoAtom<T> = {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (callback) => subscribeNodeValues(node, callback, { immediate: true, ...opts }),\n\t\tlisten: (callback) => subscribeNodeValues(node, callback, { changesOnly: true, ...opts }),\n\t\t_node: node,\n\t};\n\tif (hasWritableSet(node) || typeof (opts as WritableStoreOptions<T>).write === \"function\") {\n\t\tconst writable = writableStore(\n\t\t\tnode,\n\t\t\topts as WritableStoreOptions<T> & {\n\t\t\t\twrite: (node: WritableNode<T>, value: T) => void;\n\t\t\t},\n\t\t);\n\t\treturn { ...base, set: writable.set, update: writable.update };\n\t}\n\treturn base;\n}\n\n/** Build a TC39-Signals-style facade over a caller-owned node. */\nexport function signalFromNode<T>(\n\tnode: WritableNode<T>,\n\topts?: WritableStoreOptions<T>,\n): WritableSignalLike<T>;\n\n/**\n * Creates a signal from node.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The signal from node result.\n * @category adapters\n * @example\n * ```ts\n * import { signalFromNode } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function signalFromNode<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): SignalLike<T>;\n\n/**\n * Creates a signal from node.\n *\n * @param node - node value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns The signal from node result.\n * @category adapters\n * @example\n * ```ts\n * import { signalFromNode } from \"@graphrefly/ts/adapters\";\n * ```\n */\nexport function signalFromNode<T>(\n\tnode: Node<T> | WritableNode<T>,\n\topts: SubscribeValuesOptions<T> | WritableStoreOptions<T> = {},\n): SignalLike<T> | WritableSignalLike<T> {\n\tconst base: SignalLike<T> = {\n\t\tget: () => (opts.getSnapshot ?? (() => nodeSnapshot(node)))(),\n\t\tsubscribe: (callback) => subscribeNodeValues(node, callback, { changesOnly: true, ...opts }),\n\t\t_node: node,\n\t};\n\tif (hasWritableSet(node) || typeof (opts as WritableStoreOptions<T>).write === \"function\") {\n\t\tconst writable = writableStore(\n\t\t\tnode,\n\t\t\topts as WritableStoreOptions<T> & {\n\t\t\t\twrite: (node: WritableNode<T>, value: T) => void;\n\t\t\t},\n\t\t);\n\t\treturn { ...base, set: writable.set, update: writable.update };\n\t}\n\treturn base;\n}\n"],"mappings":";AAiHO,SAAS,aAAgB,MAA8B;AAC7D,SAAO,KAAK;AACb;AAeO,SAAS,oBACf,MACA,KACA,OAAkC,CAAC,GACtB;AACb,QAAM,OAAO,KAAK,gBAAgB,MAAM,aAAa,IAAI;AACzD,MAAI,KAAK,UAAW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BAAoB,MAAM,UAAU,EAAE,aAAa,MAAM,GAAG,KAAK,CAAC;AAAA,IAC3F,OAAO;AAAA,EACR;AACA,MAAI,eAAe,IAAI,KAAK,OAAQ,KAAiC,UAAU,YAAY;AAC1F,UAAM,WAAW;AAAA,MAChB;AAAA,MACA;AAAA,IAGD;AACA,WAAO,EAAE,GAAG,MAAM,KAAK,SAAS,KAAK,QAAQ,SAAS,OAAO;AAAA,EAC9D;AACA,SAAO;AACR;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|