react-fine-grained-signals 0.1.0 → 0.2.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-runtime-2jSE9Tz5.js","names":["READABLE_INTEROP_V1","READABLE_INTEROP_V1","READABLE_INTEROP_V1","collector","READABLE_INTEROP_V1"],"sources":["../src/core/execution-owner.ts","../src/core/interop-context.mts","../src/core/foreign-readable-v1.mts","../src/core/interop.ts","../src/core/render-tracking.ts","../src/core/signal-brand.ts","../src/core/alien-derived-runtime-core.mts","../src/core/render-runtime.mts","../src/core/reactive-runtime.ts","../src/core/core-runtime.ts"],"sourcesContent":["declare const untrackedOwnerBrand: unique symbol;\nexport const UNTRACKED_OWNER = Symbol.for(\n \"react-fine-grained-signals.untracked-owner.v2\",\n) as typeof untrackedOwnerBrand;\n\n/** Shared lexical owner for graph, render, and explicitly untracked reads. */\nexport type ExecutionOwnerV2 =\n | GraphExecutionOwnerV2\n | RenderExecutionOwnerV2;\n\nexport type ExecutionContextOwnerV2 = ExecutionOwnerV2 | typeof UNTRACKED_OWNER;\n\nexport interface GraphExecutionOwnerV2 {\n readonly version: 2;\n readonly kind: \"graph\";\n readonly runtimeToken: object;\n add(protocol: ReadableProtocolV1, revision: number): void;\n /**\n * Adopts an effect another copy created while this owner's effect or\n * computed runs: `dispose` is called when that owner next re-runs or is\n * disposed. Optional so an owner without it leaves the effect unowned.\n */\n own?(dispose: () => void): void;\n}\n\nexport interface RenderExecutionOwnerV2 {\n readonly version: 2;\n readonly kind: \"render\";\n readonly scopePolicy?: \"managed\" | \"bare\";\n readonly runtimeToken: object;\n closeScope?(): void;\n add(protocol: ReadableProtocolV1, revision: number): void;\n isSpeculative?(): boolean;\n markSpeculativeDeepRead?(): void;\n /** As on the graph owner: adopts an effect created by a speculative getter. */\n own?(dispose: () => void): void;\n}\n\nexport interface ReadableProtocolV1 {\n readonly version: 1;\n readonly runtimeToken: object;\n getRevision(): number;\n subscribe(listener: (revision: number) => void): {\n unsubscribe(): void;\n revision: number;\n };\n}\n\nexport function isGraphExecutionOwner(\n owner: ExecutionContextOwnerV2 | undefined,\n): owner is GraphExecutionOwnerV2 {\n return typeof owner === \"object\" && owner !== null && owner.kind === \"graph\";\n}\n\nexport function isRenderExecutionOwner(\n owner: ExecutionContextOwnerV2 | undefined,\n): owner is RenderExecutionOwnerV2 {\n return typeof owner === \"object\" && owner !== null && owner.kind === \"render\";\n}\n\ninterface ExecutionContextV2 {\n readonly version: 2;\n owner: ExecutionContextOwnerV2 | undefined;\n frames: Array<{ owner: ExecutionOwnerV2; active: boolean }>;\n}\n\nconst CONTEXT_KEY = Symbol.for(\"react-fine-grained-signals.shared-execution-owner.v2\");\n\nconst globalObject = globalThis as typeof globalThis & Record<symbol, unknown>;\nconst existing = globalObject[CONTEXT_KEY] as ExecutionContextV2 | undefined;\nif (existing !== undefined && existing.version !== 2) {\n throw new Error(\"Incompatible RFSG shared execution owner\");\n}\n\nexport const executionContext: ExecutionContextV2 = existing ?? {\n version: 2,\n owner: undefined,\n frames: [],\n};\nexecutionContext.frames ??= [];\nif (existing === undefined) {\n Object.defineProperty(globalObject, CONTEXT_KEY, {\n value: executionContext,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n}\n\nexport function withExecutionOwner<T>(owner: ExecutionOwnerV2, callback: () => T): T {\n const restore = pushExecutionOwner(owner);\n try {\n return callback();\n } finally {\n restore();\n }\n}\n\n/** Temporarily changes lexical ownership inside one synchronous call. */\nexport function withSynchronousExecutionOwner<T>(\n owner: ExecutionContextOwnerV2,\n callback: () => T,\n): T {\n const previous = executionContext.owner;\n executionContext.owner = owner;\n try {\n return callback();\n } finally {\n executionContext.owner = previous;\n }\n}\n\nexport function pushExecutionOwner(owner: ExecutionOwnerV2): () => void {\n const frame = { owner, active: true };\n executionContext.frames.push(frame);\n executionContext.owner = owner;\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n frame.active = false;\n while (executionContext.frames.at(-1)?.active === false) executionContext.frames.pop();\n executionContext.owner = executionContext.frames.at(-1)?.owner;\n };\n}\n","export const READABLE_INTEROP_V1 = Symbol.for(\"react-fine-grained-signals.readable-interop.v1\");\n","import { READABLE_INTEROP_V1 } from \"./interop-context.mjs\";\nimport { UNTRACKED_OWNER, executionContext, withSynchronousExecutionOwner } from \"./execution-owner.js\";\nimport type { ExecutionContextOwnerV2, ReadableProtocolV1 } from \"./execution-owner.js\";\nimport { isGraphExecutionOwner, isRenderExecutionOwner } from \"./execution-owner.js\";\nimport type { ForeignReadableAdapterOptions, RuntimeNode } from \"./alien-derived-types.js\";\n\ninterface CandidateReadable {\n readonly value: unknown;\n}\n\n/** A render owner records another copy's read under its protocol object itself. */\nexport function isReadableProtocol(value: unknown): value is ReadableProtocolV1 {\n return typeof value === \"object\" && value !== null\n && Reflect.get(value, \"version\") === 1\n && typeof Reflect.get(value, \"getRevision\") === \"function\"\n && typeof Reflect.get(value, \"subscribe\") === \"function\";\n}\n\nfunction observeRevision(node: RuntimeNode): number {\n return node.renderRevision ??= 0;\n}\n\n// Owns the cross-copy readable protocol and its bridge nodes. Graph scheduling,\n// linking, and propagation remain in the single Alien-derived graph core.\nexport function createForeignReadableAdapter({\n runtimeToken,\n makeNode,\n mutableFlag,\n dirtyFlag,\n getActiveSubscriber,\n link,\n propagate,\n shallowPropagate,\n flush,\n isRunning,\n isBatching,\n effect,\n own,\n}: ForeignReadableAdapterOptions) {\n const readableNodes = new WeakMap<object, RuntimeNode>();\n const foreignNodes = new WeakMap<ReadableProtocolV1, RuntimeNode>();\n const localReadable = Symbol(\"localReadable\");\n type LocalReadableProtocol = ReadableProtocolV1 & { readonly [localReadable]: CandidateReadable };\n\n function getLocalReadableRevision(this: LocalReadableProtocol): number {\n const readable = this[localReadable];\n const node = readableNodes.get(readable)!;\n try { withSynchronousExecutionOwner(UNTRACKED_OWNER, () => readable.value); }\n catch { /* Revisions remain observable while computed read errors are cached. */ }\n return observeRevision(node);\n }\n\n function subscribeLocalReadable(this: LocalReadableProtocol, listener: (revision: number) => void) {\n const readable = this[localReadable];\n const node = readableNodes.get(readable)!;\n const revision = observeRevision(node);\n let initial = true;\n const unsubscribe = effect(() => {\n try { readable.value; } catch { /* Keep errored computed boundaries observed. */ }\n if (initial) initial = false;\n else listener(observeRevision(node));\n });\n return { unsubscribe, revision };\n }\n\n // A bridge is a source whose value is the other copy's revision. Like a\n // source write, every newly learned revision -- pushed, read, or polled --\n // marks it Dirty and propagates to its subscribers, so `pendingRevision`\n // never advances past a revision its subscribers were not told about (a\n // silent advance would make the later push look stale and drop it).\n function advance(node: RuntimeNode, revision: number): boolean {\n if (revision === node.pendingRevision) return false;\n node.pendingRevision = revision;\n node.flags = mutableFlag | dirtyFlag;\n if (node.subs !== undefined) propagate(node.subs, isRunning());\n return true;\n }\n\n // A revision this copy learns by reading rather than by push: advance, then\n // settle at once, as a source read settles a pending write, so the reader\n // and later checks see a committed bridge instead of a change they already\n // observed. Effects it queues run when the push (or the next flush) arrives.\n function observeForeignRevision(node: RuntimeNode, revision: number): void {\n if (advance(node, revision)) {\n node.revision = revision;\n node.flags = mutableFlag;\n if (node.subs !== undefined) shallowPropagate(node.subs);\n }\n }\n\n function ensureForeignNode(protocol: ReadableProtocolV1, observedRevision: number): RuntimeNode {\n let node = foreignNodes.get(protocol);\n if (node === undefined) {\n node = makeNode(\"external\", mutableFlag, {\n protocol,\n revision: observedRevision,\n pendingRevision: observedRevision,\n unsubscribe: undefined,\n });\n foreignNodes.set(protocol, node);\n }\n // Before linking, so the reader itself is not invalidated by what it read.\n observeForeignRevision(node, observedRevision);\n const subscriber = getActiveSubscriber();\n if (subscriber?.kind === \"computed\") subscriber.foreignDependent = true;\n if (subscriber !== undefined) link(node, subscriber);\n // A handshake that finds the source already past the revision this effect\n // just read marks it stale (bit 128), so its first run is retried once it\n // finishes; see `effect()` in alien-derived-runtime-core.mts.\n if (subscriber?.kind === \"effect\" && activateForeignNode(node)) subscriber.flags |= 128;\n return node;\n }\n\n // Returns true when the subscription reports a revision newer than the one\n // this copy last observed.\n function activateForeignNode(node: RuntimeNode): boolean | undefined {\n if (node.unsubscribe === undefined) {\n const protocol = node.protocol;\n const subscription = protocol!.subscribe((revision) => {\n if (revision !== node.revision) advance(node, revision);\n // Flush even for a revision a read already learned: that read only\n // queued the bridge's effects.\n if (!isBatching()) flush();\n });\n node.unsubscribe = subscription.unsubscribe;\n if (advance(node, subscription.revision)) {\n if (!isBatching()) flush();\n return true;\n }\n }\n }\n\n const graphOwner = {\n version: 2 as const,\n kind: \"graph\" as const,\n runtimeToken,\n add(protocol: ReadableProtocolV1, revision: number) { ensureForeignNode(protocol, revision); },\n own,\n };\n\n function withGraphOwner<T>(callback: () => T): T {\n const owner = executionContext.owner;\n if (isGraphExecutionOwner(owner) && owner.runtimeToken === runtimeToken) return callback();\n return withSynchronousExecutionOwner(graphOwner, callback);\n }\n\n function publishForeignReadable(readable: object, node: RuntimeNode, owner: ExecutionContextOwnerV2 | undefined): void {\n if (owner === UNTRACKED_OWNER || ((isGraphExecutionOwner(owner) || isRenderExecutionOwner(owner)) && owner.runtimeToken === runtimeToken)) return;\n const protocol = node.readableProtocol;\n if (protocol !== undefined) {\n if (isGraphExecutionOwner(owner) || isRenderExecutionOwner(owner)) owner.add(protocol, observeRevision(node));\n }\n }\n\n function attachProtocol(readable: CandidateReadable, node: RuntimeNode): void {\n readableNodes.set(readable, node);\n const protocol: LocalReadableProtocol = {\n version: 1 as const,\n runtimeToken,\n [localReadable]: readable,\n getRevision: getLocalReadableRevision,\n subscribe: subscribeLocalReadable,\n };\n node.readableProtocol = protocol;\n Object.defineProperty(readable, READABLE_INTEROP_V1, {\n value: protocol,\n enumerable: false,\n writable: false,\n configurable: false,\n });\n }\n\n function getReadableRevision(readable: object): number {\n const node = readableNodes.get(readable);\n if (node !== undefined) return observeRevision(node);\n const protocolValue: unknown = Reflect.get(readable, READABLE_INTEROP_V1);\n if (isReadableProtocol(protocolValue)) return protocolValue.getRevision();\n throw new TypeError(\"Unknown candidate readable\");\n }\n\n return {\n attachProtocol,\n ensureForeignNode,\n activateForeignNode,\n observeForeignRevision,\n getNodeForReadable: (value: object) => readableNodes.get(value),\n getReadableRevision,\n observeRevision,\n publishForeignReadable,\n graphOwner,\n withGraphOwner,\n };\n}\n","/** Internal, same-global communication for independently instantiated runtimes. */\nexport interface ReadableInteropV1 {\n readonly version: 1;\n readonly runtimeToken: object;\n getRevision(): number;\n subscribe(listener: (revision: number) => void): {\n unsubscribe(): void;\n revision: number;\n };\n}\n\nexport interface InteropGraphCollectorV1 {\n readonly runtimeToken: object;\n add(protocol: ReadableInteropV1, observedRevision: number): void;\n}\n\nexport interface InteropRenderCollectorV1 {\n add(protocol: ReadableInteropV1, observedRevision: number): void;\n}\n\nexport interface InteropRenderScopeV1 {\n readonly token: object;\n readonly managed: boolean;\n isActive(): boolean;\n finish(): void;\n}\n\nexport interface SharedInteropContextV1 {\n readonly version: 1;\n graphCollector?: InteropGraphCollectorV1 | undefined;\n renderCollector?: InteropRenderCollectorV1 | undefined;\n renderScope?: InteropRenderScopeV1 | undefined;\n speculativeDepth: number;\n speculativeDeepReadEpoch: number;\n}\n\nexport const READABLE_INTEROP_V1 = Symbol.for(\n \"react-fine-grained-signals.readable-interop.v1\",\n);\n\nconst SHARED_CONTEXT_V1 = Symbol.for(\n \"react-fine-grained-signals.shared-interop-context.v1\",\n);\n\nlet cachedContext: SharedInteropContextV1 | undefined;\n\n/** Resolve the tiny same-global context shared by duplicate module copies. */\nexport function getSharedInteropContext(): SharedInteropContextV1 {\n if (cachedContext !== undefined) return cachedContext;\n\n const globalObject = globalThis as typeof globalThis & Record<symbol, unknown>;\n const existing = globalObject[SHARED_CONTEXT_V1] as SharedInteropContextV1 | undefined;\n if (existing !== undefined) {\n if (existing.version !== 1 || typeof existing.speculativeDepth !== \"number\") {\n throw new Error(\"Incompatible react-fine-grained-signals interop context\");\n }\n cachedContext = existing;\n return existing;\n }\n\n const context: SharedInteropContextV1 = {\n version: 1,\n speculativeDepth: 0,\n speculativeDeepReadEpoch: 0,\n };\n Object.defineProperty(globalObject, SHARED_CONTEXT_V1, {\n value: context,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n cachedContext = context;\n return context;\n}\n\nexport function getReadableInterop(readable: object): ReadableInteropV1 | undefined {\n const protocol = (readable as Record<PropertyKey, unknown>)[READABLE_INTEROP_V1];\n if (protocol === undefined || typeof protocol !== \"object\" || protocol === null) {\n return undefined;\n }\n const candidate = protocol as Partial<ReadableInteropV1>;\n return candidate.version === 1 &&\n typeof candidate.getRevision === \"function\" &&\n typeof candidate.subscribe === \"function\" &&\n typeof candidate.runtimeToken === \"object\" && candidate.runtimeToken !== null\n ? candidate as ReadableInteropV1\n : undefined;\n}\n\nexport function attachReadableInterop(\n readable: object,\n protocol: ReadableInteropV1,\n): void {\n Object.defineProperty(readable, READABLE_INTEROP_V1, {\n value: protocol,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n}\n\nexport function withInteropGraphCollector<T>(\n collector: InteropGraphCollectorV1,\n callback: () => T,\n): T {\n const context = getSharedInteropContext();\n const previous = context.graphCollector;\n context.graphCollector = collector;\n try {\n return callback();\n } finally {\n context.graphCollector = previous;\n }\n}\n\nexport function withoutInteropGraphCollector<T>(callback: () => T): T {\n const context = getSharedInteropContext();\n const previous = context.graphCollector;\n context.graphCollector = undefined;\n try {\n return callback();\n } finally {\n context.graphCollector = previous;\n }\n}\n\nexport function publishInteropGraphRead(\n protocol: ReadableInteropV1,\n observedRevision: number,\n): void {\n const collector = getSharedInteropContext().graphCollector;\n if (collector !== undefined && collector.runtimeToken !== protocol.runtimeToken) {\n collector.add(protocol, observedRevision);\n }\n}\n\nexport function withInteropRenderCollector<T>(\n collector: InteropRenderCollectorV1 | undefined,\n callback: () => T,\n): T {\n const context = getSharedInteropContext();\n const previous = context.renderCollector;\n context.renderCollector = collector;\n try {\n return callback();\n } finally {\n context.renderCollector = previous;\n }\n}\n\n/** Push a render boundary and restore only a still-active parent boundary. */\nexport function pushInteropRenderScope(\n scope: InteropRenderScopeV1,\n collector: InteropRenderCollectorV1,\n): () => void {\n const context = getSharedInteropContext();\n const previousScope = context.renderScope;\n const previousCollector = context.renderCollector;\n context.renderScope = scope;\n context.renderCollector = collector;\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n if (context.renderScope !== scope) return;\n const restoreScope = previousScope?.isActive() ? previousScope : undefined;\n context.renderScope = restoreScope;\n context.renderCollector = restoreScope === undefined ? undefined : previousCollector;\n };\n}\n\nexport function withoutInteropRenderCollector<T>(callback: () => T): T {\n return withInteropRenderCollector(undefined, callback);\n}\n\nexport function publishInteropRenderRead(\n protocol: ReadableInteropV1,\n observedRevision: number,\n): void {\n getSharedInteropContext().renderCollector?.add(protocol, observedRevision);\n}\n\nexport function withInteropSpeculativeMode<T>(callback: () => T): T {\n const context = getSharedInteropContext();\n context.speculativeDepth += 1;\n try {\n return callback();\n } finally {\n context.speculativeDepth -= 1;\n }\n}\n\n/** Run durable graph work without inheriting an outer speculative callback. */\nexport function withoutInteropSpeculativeMode<T>(callback: () => T): T {\n const context = getSharedInteropContext();\n const previousDepth = context.speculativeDepth;\n context.speculativeDepth = 0;\n try {\n return callback();\n } finally {\n context.speculativeDepth = previousDepth;\n }\n}\n\nexport function isInteropSpeculative(): boolean {\n return getSharedInteropContext().speculativeDepth > 0;\n}\n\n/** Marks speculative deep reads whose per-key dependencies were not collected. */\nexport function markInteropSpeculativeDeepRead(): void {\n const context = getSharedInteropContext();\n context.speculativeDeepReadEpoch = (context.speculativeDeepReadEpoch ?? 0) + 1;\n}\n","import {\n getReadableInterop,\n withoutInteropRenderCollector,\n type ReadableInteropV1,\n} from \"./interop.js\";\nimport { UNTRACKED_OWNER, executionContext, withSynchronousExecutionOwner } from \"./execution-owner.js\";\n\n/** Internal dependency contract used by the React render collector. */\nexport interface RenderDependency {\n getRenderVersion(): number;\n subscribeRender(listener: () => void): () => void;\n}\n\nexport interface RenderCollector {\n add(dependency: RenderDependency, observedVersion: number): void;\n}\n\nconst foreignRenderDependencies = new WeakMap<ReadableInteropV1, RenderDependency>();\n\nclass ForeignRenderDependency implements RenderDependency {\n constructor(readonly protocol: ReadableInteropV1) {}\n\n getRenderVersion(): number {\n return this.protocol.getRevision();\n }\n\n subscribeRender(listener: () => void): () => void {\n const subscription = this.protocol.subscribe(() => listener());\n return () => subscription.unsubscribe();\n }\n}\n\n/** Reuse one render adapter for each foreign readable protocol. */\nexport function getForeignRenderDependency(protocol: ReadableInteropV1): RenderDependency {\n let dependency = foreignRenderDependencies.get(protocol);\n if (dependency === undefined) {\n dependency = new ForeignRenderDependency(protocol);\n foreignRenderDependencies.set(protocol, dependency);\n }\n return dependency;\n}\n\n/** Resolve the private protocol attached to a foreign candidate readable. */\nexport function getForeignReadableRenderDependency(readable: object): RenderDependency | undefined {\n const protocol = getReadableInterop(readable);\n return protocol === undefined ? undefined : getForeignRenderDependency(protocol);\n}\n\nexport let activeRenderCollector: RenderCollector | undefined;\n\n/** Returns whether a React render is currently collecting signal reads. */\nexport function hasActiveRenderCollector(): boolean {\n return activeRenderCollector !== undefined;\n}\n\n/** Replaces the current render collector and returns the previous collector. */\nexport function setActiveRenderCollector(\n collector?: RenderCollector,\n): RenderCollector | undefined {\n const previous = activeRenderCollector;\n activeRenderCollector = collector;\n return previous;\n}\n\n/** Records a dependency and reports whether render collection was active. */\nexport function trackRenderDependency(\n dependency: RenderDependency,\n observedVersion?: number,\n): boolean {\n if (activeRenderCollector === undefined) return false;\n activeRenderCollector.add(dependency, observedVersion ?? dependency.getRenderVersion());\n return true;\n}\n\n/** Runs a callback without adding its reads to the active React render. */\nexport function untrackedRender<T>(callback: () => T): T {\n const previous = setActiveRenderCollector();\n try {\n const owner = executionContext.owner;\n const run = () => withoutInteropRenderCollector(callback);\n // A render-only pause must keep an enclosing graph subscriber active.\n if (owner !== undefined && typeof owner !== \"symbol\" && owner.kind === \"graph\") {\n return run();\n }\n return withSynchronousExecutionOwner(UNTRACKED_OWNER, run);\n } finally {\n setActiveRenderCollector(previous);\n }\n}\n\n/** A small versioned subscription surface shared by signals and computeds. */\nexport class RenderSubscription implements RenderDependency {\n // Written slots, not absent ones: the hooks are `undefined` whenever the\n // constructor is called without them, and `#listeners` is cleared back to\n // `undefined` to release the Set once the last listener unsubscribes.\n readonly #onFirstSubscriber?: (() => void) | undefined;\n readonly #onLastSubscriber?: (() => void) | undefined;\n #listeners?: Set<() => void> | undefined;\n #version = 0;\n\n constructor(\n onFirstSubscriber?: () => void,\n onLastSubscriber?: () => void,\n ) {\n this.#onFirstSubscriber = onFirstSubscriber;\n this.#onLastSubscriber = onLastSubscriber;\n }\n\n getRenderVersion(): number {\n return this.#version;\n }\n\n subscribeRender(listener: () => void): () => void {\n const listeners = (this.#listeners ??= new Set());\n const wasEmpty = listeners.size === 0;\n listeners.add(listener);\n if (wasEmpty) this.#onFirstSubscriber?.();\n\n return () => {\n const currentListeners = this.#listeners;\n if (currentListeners === undefined || !currentListeners.delete(listener)) {\n return;\n }\n if (currentListeners.size === 0) {\n this.#listeners = undefined;\n this.#onLastSubscriber?.();\n }\n };\n }\n\n track(): boolean {\n return trackRenderDependency(this);\n }\n\n /**\n * Whether anything is currently subscribed on the React side. Used by\n * `deepSignal`'s metadata pruning to tell a genuinely dead per-key version\n * signal from one a mounted component still depends on — dropping the\n * latter would strand that subscriber on a `RenderSubscription` the\n * property map no longer reaches, so it would never be notified again.\n */\n hasListeners(): boolean {\n return this.#listeners !== undefined && this.#listeners.size !== 0;\n }\n\n bumpVersion(): void {\n this.#version = (this.#version + 1) | 0;\n }\n\n notify(): void {\n this.bumpVersion();\n const listeners = this.#listeners;\n if (listeners === undefined) return;\n // Snapshot before iterating: a listener may (un)subscribe synchronously.\n // oxlint-disable-next-line unicorn/no-useless-spread\n for (const listener of [...listeners]) notifyListener(listener);\n }\n}\n\n/**\n * Invokes one subscription listener, keeping its failure from cancelling the\n * listeners queued behind it. Without this, a single throwing subscriber\n * aborts the rest of the notify cycle, so unrelated components silently miss\n * the update that was being delivered. Reported the same way as the other\n * background-callback failures in this codebase (`readBoundSignal` in\n * src/runtime/jsx.ts): `console.error(message, { cause })`.\n */\nexport function notifyListener(listener: () => void): void {\n try {\n listener();\n } catch (error) {\n console.error(\n \"react-fine-grained-signals: a render-subscription listener threw; continuing with the remaining listeners.\",\n { cause: error },\n );\n }\n}\n","/**\n * Package-wide identity marker shared by public signal wrappers and deep proxies.\n *\n * The key names a *generation* of the cross-copy contract; the number stored\n * under it is that generation's minor version. A minor version only ever widens\n * the contract, so anything from the minimum upwards is trusted; a change that\n * an older copy could not honour takes a new key instead.\n *\n * v0.1.x used `react-fine-grained-signals.signal` and trusted every version\n * from 1 upwards. A v0.2 signal is only reactive under the v2 shared execution\n * owner and the ReadableInterop V1 protocol, neither of which a v0.1.x copy\n * knows, so reusing that key with a larger number would have let v0.1.x\n * recognize v0.2 signals (and v0.2 recognize v0.1.x ones) and then silently\n * never update. A separate key makes each generation reject the other's\n * signals outright: JSX and `isSignal` fail loudly instead of going stale.\n */\nexport const SIGNAL_BRAND: unique symbol = Symbol.for(\"react-fine-grained-signals.signal.v2\");\nexport const SIGNAL_BRAND_VERSION = 1;\nexport const SIGNAL_BRAND_MIN_VERSION = 1;\n\n/** The v0.1.x key, kept only to report an incompatible signal clearly. */\nexport const LEGACY_SIGNAL_BRAND_V1 = Symbol.for(\"react-fine-grained-signals.signal\");\n","/* Production-shaped Alien-derived graph, adapted from Alien Signals 3.2.1.\n * Source: https://github.com/stackblitz/alien-signals/tree/8734d386d925025d0e99419bd9161c17b112c5ee\n * Copyright (c) 2024-present Johnson Chu. See the repository license notice.\n * Imports only alien-signals/system; RFSG APIs and adapters remain local.\n */\nimport { createReactiveSystem } from \"alien-signals/system\";\nimport type { Link, ReactiveFlags, ReactiveNode } from \"alien-signals/system\";\nimport { UNTRACKED_OWNER, executionContext, isGraphExecutionOwner, isRenderExecutionOwner, withSynchronousExecutionOwner } from \"./execution-owner.js\";\nimport { createForeignReadableAdapter, isReadableProtocol } from \"./foreign-readable-v1.mjs\";\nimport { READABLE_INTEROP_V1 } from \"./interop-context.mjs\";\nimport type { ExecutionContextOwnerV2, ExecutionOwnerV2, ReadableProtocolV1 } from \"./execution-owner.js\";\nimport { activeRenderCollector, trackRenderDependency } from \"./render-tracking.js\";\nimport { SIGNAL_BRAND, SIGNAL_BRAND_MIN_VERSION, SIGNAL_BRAND_VERSION } from \"./signal-brand.js\";\nimport type { AlienDerivedGraphRuntime, RenderAdapterForCore, RenderAttempt, RuntimeNode, RuntimeSource, RuntimeComputed, RuntimeEffect, RuntimeReadable, RuntimeWritable, SpeculativeComputedEntry } from \"./alien-derived-types.js\";\n\n// These mirror `ReactiveFlags` in alien-signals/system 3.2.1 bit for bit; the\n// exact dependency pin in package.json is what keeps them valid.\nconst None = 0 as ReactiveFlags;\nconst Mutable = 1 as ReactiveFlags;\nconst Watching = 2 as ReactiveFlags;\nconst RecursedCheck = 4 as ReactiveFlags;\nconst Recursed = 8 as ReactiveFlags;\nconst Dirty = 16 as ReactiveFlags;\nconst Pending = 32 as ReactiveFlags;\n// Alien 3.2.1's high-level `HasChildEffect`: set on an effect or computed that\n// created an effect while running, so its next run disposes those children.\nconst HasChildEffect = 64 as ReactiveFlags;\n\nexport function createAlienDerivedRuntime(): AlienDerivedGraphRuntime {\nconst runtimeToken = {};\nlet renderAdapter: RenderAdapterForCore | undefined;\nlet activeRenderAttempt: RenderAttempt | undefined;\n\nlet activeSub: RuntimeNode | undefined;\n// Disposers of effects created by the speculative getter now running.\nlet speculativeChildren: Array<() => void> | undefined;\nlet cycle = 0;\nlet runDepth = 0;\nlet batchDepth = 0;\nlet flushIndex = 0;\nlet queuedLength = 0;\nconst queue: Array<RuntimeNode | undefined> = [];\n\nconst system = createReactiveSystem({\n update(rawNode: ReactiveNode) {\n const node = rawNode as RuntimeNode;\n if (node.kind === \"external\") {\n // Commit only what was propagated; see `advance` in foreign-readable-v1.\n const changed = node.revision !== node.pendingRevision;\n node.revision = node.pendingRevision;\n node.flags = Mutable;\n return changed;\n }\n if (node.kind === \"computed\") return updateComputed(node as RuntimeComputed);\n if (node.kind === \"source\") return updateSource(node);\n node.flags = Mutable;\n return true;\n },\n notify(rawEffect: ReactiveNode) {\n let current: RuntimeNode | undefined = rawEffect as RuntimeNode;\n let insertIndex = queuedLength;\n const firstInsertedIndex = insertIndex;\n do {\n const effect = current!;\n queue[insertIndex++] = effect;\n effect.flags &= ~Watching;\n current = effect.subs?.sub as RuntimeNode | undefined;\n if (current === undefined || !(current.flags & Watching)) break;\n // This queue walk intentionally advances until its linked-list sentinel.\n // oxlint-disable-next-line no-constant-condition\n } while (true);\n queuedLength = insertIndex;\n let leftIndex = firstInsertedIndex;\n while (leftIndex < --insertIndex) {\n const left = queue[leftIndex]!;\n queue[leftIndex++] = queue[insertIndex]!;\n queue[insertIndex] = left;\n }\n },\n unwatched(rawNode: ReactiveNode) {\n const node = rawNode as RuntimeNode;\n if (node.kind === \"external\") {\n node.unsubscribe?.();\n node.unsubscribe = undefined;\n } else if (node.kind === \"computed\") {\n if (node.depsTail !== undefined) {\n node.flags = Mutable | Dirty;\n disposeDeps(node);\n }\n } else if (node.kind === \"effect\") {\n disposeEffect(node as RuntimeEffect);\n }\n },\n});\nconst { link: alienLink, unlink: alienUnlink, propagate, checkDirty, shallowPropagate } = system;\n\nfunction linkNode(dependency: RuntimeNode, subscriber: RuntimeNode, version: number): void {\n alienLink(dependency as unknown as ReactiveNode, subscriber as unknown as ReactiveNode, version);\n}\n\nfunction unlinkNode(linkage: Link, subscriber: RuntimeNode): Link | undefined {\n return alienUnlink(linkage, subscriber as unknown as ReactiveNode);\n}\n\nfunction makeNode(kind: RuntimeNode[\"kind\"], flags: number, fields: Partial<RuntimeNode> = {}): RuntimeNode {\n return { kind, flags: flags as ReactiveFlags, deps: undefined, depsTail: undefined, subs: undefined, subsTail: undefined, renderRevision: 0, ...fields } as RuntimeNode;\n}\n\nconst foreignAdapter = createForeignReadableAdapter({\n runtimeToken,\n makeNode,\n mutableFlag: Mutable,\n dirtyFlag: Dirty,\n getActiveSubscriber: () => activeSub,\n link: (node: RuntimeNode, subscriber: RuntimeNode) => linkNode(node, subscriber, cycle),\n propagate,\n shallowPropagate,\n flush: () => flush(),\n isRunning: () => !!runDepth,\n isBatching: () => !!batchDepth,\n effect: (callback: () => unknown) => detachedEffect(callback),\n own: adopt,\n});\nconst renderDependencies = new WeakMap<object, RuntimeNode>();\nconst deepSignalNodes = new WeakSet<RuntimeNode>();\nconst deepWatchedNodes = new WeakSet<RuntimeNode>();\n\nfunction getRenderDependency(readable: { value: unknown }, node: RuntimeNode) {\n if (!renderDependencies.has(readable)) {\n node.getRenderVersion = () => foreignAdapter.observeRevision(node);\n node.subscribeRender = (listener: () => void) => {\n let initial = true;\n let version = foreignAdapter.observeRevision(node);\n return detachedEffect(() => {\n try { readable.value; } catch { /* Keep erroring boundaries subscribed. */ }\n const nextVersion = foreignAdapter.observeRevision(node);\n if (initial) initial = false;\n else if (nextVersion !== version) listener();\n version = nextVersion;\n });\n };\n renderDependencies.set(readable, node);\n }\n return renderDependencies.get(readable)!;\n}\n\nfunction readSource(source: RuntimeNode): unknown {\n if (source.flags & Dirty && updateSource(source)) {\n if (source.subs !== undefined) shallowPropagate(source.subs);\n }\n if (activeSub !== undefined) linkNode(source, activeSub, cycle);\n return source.currentValue;\n}\n\n// The read half of `readSource` without linking. Another copy's `untracked()`\n// clears only its own subscriber, so a read under the shared UNTRACKED_OWNER\n// must not link to whichever subscriber this copy happens to be running.\nfunction readSourceUntracked(source: RuntimeNode): unknown {\n if (source.flags & Dirty && updateSource(source)) {\n if (source.subs !== undefined) shallowPropagate(source.subs);\n }\n return source.currentValue;\n}\n\n// Another copy's graph or render owner is reading. That copy records the read\n// through `publishForeignReadable`; this copy's `activeSub` may still be an\n// outer frame (B effect -> A computed -> B signal) that never read the value,\n// so such a read must not link to it.\nfunction isForeignOwner(owner: ExecutionContextOwnerV2 | undefined): owner is ExecutionOwnerV2 {\n return (isGraphExecutionOwner(owner) || isRenderExecutionOwner(owner)) && owner.runtimeToken !== runtimeToken;\n}\n\nconst attachProtocol = foreignAdapter.attachProtocol;\nconst ensureForeignNode = foreignAdapter.ensureForeignNode;\nconst graphOwner = foreignAdapter.graphOwner;\n// User callbacks (computed getters, effect bodies) are called as `() => T`:\n// no arguments and no `this`, as in v0.1.1.\nfunction withGraphOwner<T>(callback: () => T): T {\n const owner = executionContext.owner;\n const previousAttempt = activeRenderAttempt;\n const alreadyOwned = isGraphExecutionOwner(owner) && owner.runtimeToken === runtimeToken;\n if (previousAttempt === undefined && alreadyOwned) return callback();\n activeRenderAttempt = undefined;\n if (!alreadyOwned) executionContext.owner = graphOwner;\n try { return callback(); }\n finally {\n if (!alreadyOwned) executionContext.owner = owner;\n activeRenderAttempt = previousAttempt;\n }\n}\n\nfunction configureRenderAdapter(adapter: RenderAdapterForCore): void {\n renderAdapter = adapter;\n}\n\nfunction withRenderAttempt<T>(attempt: RenderAttempt | undefined, callback: () => T): T {\n const restore = pushRenderAttempt(attempt);\n try { return callback(); }\n finally { restore(); }\n}\n\nfunction pushRenderAttempt(attempt: RenderAttempt | undefined): () => void {\n const previous = activeRenderAttempt;\n activeRenderAttempt = attempt;\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n if (activeRenderAttempt === attempt) activeRenderAttempt = previous;\n };\n}\n\nfunction getActiveRenderAttempt() { return activeRenderAttempt; }\nconst getNodeForReadable = foreignAdapter.getNodeForReadable;\nconst getReadableRevision = foreignAdapter.getReadableRevision;\nfunction isComputedClean(node: RuntimeNode): boolean {\n // A foreign revision this copy has not been told about yet still dirties it.\n if (node.foreignDependent) refreshForeignDependencies(node as RuntimeComputed, new Set());\n return node.initialized === true && !(node.flags & (Dirty | Pending));\n}\n\n// A speculative dependency is keyed either by a readable (this copy's, or one\n// carrying another copy's protocol) or, for a read another copy published to\n// the render owner, by that copy's protocol object itself.\nfunction getDependencyRevision(dependency: object): number {\n return isReadableProtocol(dependency) ? dependency.getRevision() : getReadableRevision(dependency);\n}\n\nfunction promoteComputed(readable: object, node: RuntimeNode, entry: SpeculativeComputedEntry): boolean {\n // Already initialized, by a real read or another attempt's promotion: both\n // advance `renderRevision`, so `settleRenderAttempt` compares this attempt's\n // value with the node's rather than trusting the revision it recorded.\n if (node.initialized) return true;\n const computed = node as RuntimeComputed;\n const hadForeignDependencies = computed.foreignDependent;\n // Another copy's protocol, with the revision the render read it at, or a\n // local node (whose revision slot is unused).\n const dependencies: Array<RuntimeNode | ReadableProtocolV1> = [];\n const revisions: number[] = [];\n for (const [dependency, revision] of entry.dependencies) {\n let protocol: unknown = dependency;\n if (!isReadableProtocol(dependency)) {\n if (getReadableRevision(dependency) !== revision) return false;\n const dependencyNode = foreignAdapter.getNodeForReadable(dependency);\n if (dependencyNode !== undefined) {\n // Link a dependency only in the state the speculative read observed. A\n // computed's revision moves only when it re-evaluates, so one a later\n // write left Dirty or Pending fails here, as it does on cache reuse.\n if (dependencyNode.kind === \"computed\" && !isComputedClean(dependencyNode)) return false;\n // The render read a source's pending value without settling it. Settle it\n // before linking, as Alien's own signal read does, or a later write back\n // to the stale committed value compares equal and never reaches us.\n if (dependencyNode.kind === \"source\") readSourceUntracked(dependencyNode);\n dependencies.push(dependencyNode);\n revisions.push(revision);\n continue;\n }\n protocol = Reflect.get(dependency, READABLE_INTEROP_V1);\n if (!isReadableProtocol(protocol)) return false;\n } else if (dependency.getRevision() !== revision) {\n return false;\n }\n dependencies.push(protocol as ReadableProtocolV1);\n revisions.push(revision);\n }\n disposeDeps(computed);\n computed.depsTail = undefined;\n const previousSub = activeSub;\n activeSub = computed;\n cycle += 1;\n try {\n for (let index = 0; index < dependencies.length; index += 1) {\n const dependency = dependencies[index]!;\n if ((dependency as RuntimeNode).kind === undefined) ensureForeignNode(dependency as ReadableProtocolV1, revisions[index]!);\n else linkNode(dependency as RuntimeNode, computed, cycle);\n }\n } finally { activeSub = previousSub; }\n recomputeForeignDependencies(computed);\n if (hadForeignDependencies !== computed.foreignDependent) updateForeignDependencyAncestors(computed);\n computed.value = entry.value;\n computed.error = entry.error;\n computed.hasError = entry.hasError;\n computed.initialized = true;\n computed.flags = Mutable;\n // Initialization is a value change, as in `updateComputed`, so any other\n // attempt that read this computed before it existed re-checks its value.\n computed.renderRevision = (computed.renderRevision + 1) | 0;\n return true;\n}\n\nfunction hasSubscribers(readable: object): boolean {\n return foreignAdapter.getNodeForReadable(readable)?.subs !== undefined;\n}\nfunction hasActiveSubscriber(): boolean { return activeSub !== undefined; }\nfunction getBatchDepth(): number { return batchDepth; }\n\nfunction updateSource(source: RuntimeNode): boolean {\n source.flags = Mutable;\n const changed = !Object.is(source.currentValue, source.currentValue = source.pendingValue);\n return changed;\n}\n\nfunction readComputed(computed: RuntimeComputed, track = true): unknown {\n // Bridge pushes cannot be relied on at read time: an inactive bridge gets\n // none, and an active one hears of a write only when the other copy's flush\n // reaches it, which can be after this copy has re-run on another of that\n // write's consequences (or after the other copy's batch). Poll them here.\n if (computed.foreignDependent) {\n refreshForeignDependencies(computed, new Set());\n }\n // RecursedCheck is only set on a computed while its own getter is on the\n // stack, so any read of it here -- direct or through other computeds -- is\n // a cycle that would otherwise silently return a stale intermediate value.\n if (computed.flags & RecursedCheck) {\n throw new Error(\"Computed cycle detected\");\n }\n const flags = computed.flags;\n if (flags & Dirty || (flags & Pending && ((computed.deps !== undefined && checkDirty(computed.deps, computed as unknown as ReactiveNode)) || (computed.flags = flags & ~Pending, false)))) {\n if (updateComputed(computed) && computed.subs !== undefined) shallowPropagate(computed.subs);\n } else if (!flags) {\n updateComputed(computed);\n }\n if (track && activeSub !== undefined) {\n linkNode(computed, activeSub, cycle);\n if (activeSub.kind === \"computed\" && computed.foreignDependent) activeSub.foreignDependent = true;\n if (activeSub.kind === \"effect\" && computed.foreignDependent) activateForeignDependencies(computed, new Set());\n }\n if (computed.hasError) throw computed.error;\n return computed.value;\n}\n\n// A newer revision invalidates the bridge's subscribers through the graph\n// itself (see `observeForeignRevision`), so this computed and everything\n// between it and the bridge re-check, and the bridge's other subscribers do\n// too instead of later comparing against an already-advanced revision.\nfunction refreshForeignDependencies(node: RuntimeComputed, visited: Set<RuntimeNode>): void {\n if (visited.has(node)) return;\n visited.add(node);\n for (let dependency = node.deps; dependency !== undefined; dependency = dependency.nextDep) {\n const dep = dependency.dep as RuntimeNode;\n if (dep.kind === \"external\") foreignAdapter.observeForeignRevision(dep, dep.protocol!.getRevision());\n else if (dep.kind === \"computed\" && dep.foreignDependent) refreshForeignDependencies(dep as RuntimeComputed, visited);\n }\n}\n\nfunction activateForeignDependencies(node: RuntimeComputed, visited: Set<RuntimeNode>): void {\n if (visited.has(node)) return;\n visited.add(node);\n let dependency = node.deps;\n while (dependency !== undefined) {\n const dep = dependency.dep as RuntimeNode;\n if (dep.kind === \"external\") foreignAdapter.activateForeignNode(dep);\n else if (dep.kind === \"computed\") activateForeignDependencies(dep as RuntimeComputed, visited);\n dependency = dependency.nextDep;\n }\n}\n\nfunction updateComputed(computed: RuntimeComputed): boolean {\n if (computed.flags & HasChildEffect) disposeChildEffects(computed);\n computed.depsTail = undefined;\n computed.flags = Mutable | RecursedCheck;\n const previous = activeSub;\n activeSub = computed;\n let changed = !computed.initialized;\n const hadError = computed.hasError;\n const hadForeignDependencies = computed.foreignDependent;\n const previousValue = computed.value;\n computed.foreignDependent = false;\n try {\n cycle += 1;\n try {\n computed.value = withGraphOwner(computed.getter);\n computed.error = undefined;\n computed.hasError = false;\n } catch (error) {\n computed.value = undefined;\n computed.error = error;\n computed.hasError = true;\n }\n computed.initialized = true;\n changed = changed || hadError || computed.hasError || !Object.is(previousValue, computed.value);\n if (changed && computed.renderRevision !== undefined) computed.renderRevision = (computed.renderRevision + 1) | 0;\n return changed;\n } finally {\n activeSub = previous;\n computed.flags &= ~RecursedCheck;\n purgeDeps(computed);\n recomputeForeignDependencies(computed);\n if (hadForeignDependencies !== computed.foreignDependent) updateForeignDependencyAncestors(computed);\n // A recomputation reached through an effect's dirty check (rather than a\n // direct read by that effect) can link a new foreign bridge whose value\n // does not change this computed's result yet, so the effect never re-reads\n // it and never activates it. Activate here whenever an effect watches us.\n if (computed.foreignDependent && computed.subs !== undefined && isWatchedByEffect(computed, new Set())) {\n activateForeignDependencies(computed, new Set());\n }\n }\n}\n\n// A computed's subscribers are effects and other computeds only.\nfunction isWatchedByEffect(node: RuntimeNode, visited: Set<RuntimeNode>): boolean {\n if (visited.has(node)) return false;\n visited.add(node);\n for (let link = node.subs; link !== undefined; link = link.nextSub) {\n const subscriber = link.sub as RuntimeNode;\n if (subscriber.kind === \"effect\" ? subscriber.flags !== None : isWatchedByEffect(subscriber, visited)) return true;\n }\n return false;\n}\n\n// Alien 3.2.1's child-effect disposal: an effect created while `sub` ran is\n// linked as one of `sub`'s dependencies; unlinking it before `sub` runs again\n// leaves it with no subscriber, which disposes it through `unwatched`.\nfunction disposeChildEffects(sub: RuntimeNode): void {\n let link = sub.depsTail;\n while (link !== undefined) {\n const previous = link.prevDep;\n if ((link.dep as RuntimeNode).kind === \"effect\") unlinkNode(link, sub);\n link = previous;\n }\n}\n\nfunction recomputeForeignDependencies(computed: RuntimeComputed): void {\n let dependency = computed.deps;\n let foreignDependent = false;\n while (dependency !== undefined) {\n const dep = dependency.dep as RuntimeNode;\n if (dep.kind === \"external\" || (dep.kind === \"computed\" && (dep as RuntimeComputed).foreignDependent)) {\n foreignDependent = true;\n break;\n }\n dependency = dependency.nextDep;\n }\n computed.foreignDependent = foreignDependent;\n}\n\nfunction updateForeignDependencyAncestors(computed: RuntimeComputed): void {\n let link = computed.subs;\n while (link !== undefined) {\n const subscriber = link.sub as RuntimeNode;\n if (subscriber.kind === \"computed\") {\n const computedSubscriber = subscriber as RuntimeComputed;\n const wasForeignDependent = computedSubscriber.foreignDependent;\n recomputeForeignDependencies(computedSubscriber);\n if (wasForeignDependent !== computedSubscriber.foreignDependent) updateForeignDependencyAncestors(computedSubscriber);\n }\n link = link.nextSub;\n }\n}\n\nfunction runEffect(effect: RuntimeEffect): void {\n const flags = effect.flags;\n if (flags & Dirty || (flags & Pending && effect.deps !== undefined && checkDirty(effect.deps, effect as unknown as ReactiveNode))) {\n if (flags & HasChildEffect) disposeChildEffects(effect);\n if (effect.cleanup !== undefined) {\n try {\n runCleanup(effect);\n } catch (error) {\n reportFailure(error);\n }\n if (!effect.flags) return;\n }\n effect.depsTail = undefined;\n effect.flags = Watching | RecursedCheck;\n const previous = activeSub;\n activeSub = effect;\n try {\n cycle += 1;\n runDepth += 1;\n const cleanup: unknown = withGraphOwner(effect.fn);\n effect.cleanup = typeof cleanup === \"function\" ? cleanup as () => unknown : undefined;\n if (!effect.flags && effect.cleanup !== undefined) runCleanup(effect);\n } finally {\n runDepth -= 1;\n activeSub = previous;\n effect.flags &= ~RecursedCheck;\n settleDeps(effect);\n }\n } else if (effect.deps !== undefined) {\n effect.flags = Watching | (flags & HasChildEffect);\n }\n}\n\n// After a run: drop the dependencies this run stopped reading. An effect that\n// disposed itself mid-run has to drop every link instead -- both the previous\n// run's (its disposer only saw this run's prefix, since a run starts from an\n// empty `depsTail`) and any its reads after the disposer re-created -- rather\n// than keep a dead closure subscribed for the lifetime of those sources.\nfunction settleDeps(effect: RuntimeNode): void {\n // With no tail, `purgeDeps` drops every link from the head.\n if (effect.flags === None) effect.depsTail = undefined;\n purgeDeps(effect);\n}\n\nfunction flush() {\n try {\n while (flushIndex < queuedLength) {\n const effect = queue[flushIndex]!;\n queue[flushIndex++] = undefined;\n try {\n runEffect(effect as RuntimeEffect);\n } catch (error) {\n reportFailure(error);\n }\n }\n } finally {\n while (flushIndex < queuedLength) {\n const effect = queue[flushIndex]!;\n queue[flushIndex++] = undefined;\n effect!.flags |= Watching | Recursed;\n }\n flushIndex = 0;\n queuedLength = 0;\n }\n}\n\nfunction reportFailure(error: unknown): void {\n try {\n console.error(\"react-fine-grained-signals: an effect() callback threw; the error is contained and reported here so this flush can finish.\", { cause: error });\n } catch { /* Reporting must not interrupt scheduler progress. */ }\n try {\n const report = globalThis.reportError;\n if (typeof report === \"function\") report.call(globalThis, error);\n } catch { /* Keep a failing host reporter from escaping the runtime. */ }\n}\n\nfunction disposeDeps(sub: RuntimeNode): void {\n let depLink = sub.depsTail;\n while (depLink !== undefined) {\n const previous = depLink.prevDep;\n unlinkNode(depLink, sub);\n depLink = previous;\n }\n}\n\nfunction purgeDeps(sub: RuntimeNode): void {\n const tail = sub.depsTail;\n let depLink = tail === undefined ? sub.deps : tail.nextDep;\n while (depLink !== undefined) depLink = unlinkNode(depLink, sub);\n}\n\nfunction runCleanup(effect: RuntimeEffect): unknown {\n const cleanup = effect.cleanup;\n effect.cleanup = undefined;\n const previous = activeSub;\n activeSub = undefined;\n try {\n return withSynchronousExecutionOwner(UNTRACKED_OWNER, cleanup!);\n } finally { activeSub = previous; }\n}\n\nfunction disposeEffect(effect: RuntimeEffect): void {\n effect.flags = None;\n disposeDeps(effect);\n // An owned child also leaves its parent's dependency list, so the parent\n // stops holding a link to a disposed effect.\n const ownerLink = effect.subs;\n if (ownerLink !== undefined) unlinkNode(ownerLink, ownerLink.sub as RuntimeNode);\n if (effect.cleanup !== undefined) {\n try { runCleanup(effect); }\n catch (error) { reportFailure(error); }\n }\n}\n\n// Library-internal subscriptions (render stores, direct DOM bindings, the\n// cross-copy protocol) must never become owned by whichever user effect is\n// running when React or another copy happens to create them synchronously.\nfunction detachedEffect(fn: () => unknown): () => void {\n return effect(fn, true);\n}\n\nfunction effect(fn: () => unknown, detached?: boolean): () => void {\n const node = makeNode(\"effect\", Watching | RecursedCheck, { fn, cleanup: undefined });\n const dispose = () => disposeEffect(node as RuntimeEffect);\n const previous = activeSub;\n // As in Alien 3.2.1 (and v0.1.x, which used it), an effect created while\n // another effect or computed runs (the only kinds that become `activeSub`)\n // is owned by it: the owner's next run or its disposal disposes the child.\n // That owner may belong to another copy, which this copy reaches only\n // through the shared owner; a speculative getter has no owner (see `adopt`).\n if (!detached) {\n const owner = executionContext.owner;\n if (previous === undefined && speculativeChildren === undefined && (isGraphExecutionOwner(owner) || isRenderExecutionOwner(owner)) && owner.runtimeToken !== runtimeToken) owner.own?.(dispose);\n else adopt(dispose, node);\n }\n try {\n activeSub = node;\n runDepth += 1;\n try {\n const cleanup: unknown = withGraphOwner(fn);\n node.cleanup = typeof cleanup === \"function\" ? cleanup as () => unknown : undefined;\n } catch (error) {\n node.cleanup = undefined;\n reportFailure(error);\n } finally {\n runDepth -= 1;\n activeSub = previous;\n node.flags &= ~RecursedCheck;\n purgeDeps(node);\n }\n } catch (error) {\n // Keep setup failures from escaping even if bookkeeping itself fails.\n reportFailure(error);\n }\n if (!runDepth && !batchDepth) {\n // Only the stale-read bit (128, RFSG-only; set by the foreign adapter's\n // subscription handshake, cleared by the next run's `flags` assignment)\n // re-runs a new effect. A write its first run made to its own dependencies\n // -- directly, or through effects it flushed -- leaves Recursed/Pending\n // instead and, as in Alien 3.2.1 and v0.1.1, does not. The bit is a literal\n // rather than a named constant to keep the signal-only bundle in budget.\n if (node.flags & 128) runEffect(node as RuntimeEffect);\n if (queuedLength) flush();\n }\n return dispose;\n}\n\n// Makes an effect a child of the running effect or computed, whose next run or\n// disposal unlinks it and so disposes it. Also the shared owners' `own`, for an\n// effect another copy created: a childless stand-in effect takes its place in\n// the dependency list and disposes it on cleanup, so only the disposer crosses\n// the copy boundary. With no running subscriber, a speculative getter's\n// effects are collected for `evaluateSpeculatively` to dispose.\nfunction adopt(disposeChild: () => void, child = makeNode(\"effect\", Watching, { cleanup: disposeChild })): void {\n if (activeSub !== undefined) {\n linkNode(child, activeSub, 0);\n activeSub.flags |= HasChildEffect;\n } else speculativeChildren?.push(disposeChild);\n}\n\n// A speculative render evaluation has no subscriber to own the effects its\n// getter creates and may never be promoted, so they are disposed as soon as\n// it returns. Returns whether there were any: such a result is not promoted,\n// so the committed computed runs its getter (and creates them) for real.\nfunction evaluateSpeculatively(computed: RuntimeComputed, entry: SpeculativeComputedEntry): boolean {\n const previousSub = activeSub;\n const previousChildren = speculativeChildren;\n const children: Array<() => void> = [];\n const getter = computed.getter;\n activeSub = undefined;\n speculativeChildren = children;\n try {\n entry.value = getter();\n } catch (error) {\n entry.error = error;\n entry.hasError = true;\n } finally {\n activeSub = previousSub;\n speculativeChildren = previousChildren;\n for (const disposeChild of children) disposeChild();\n }\n return children.length > 0;\n}\n\n\nfunction batch<T>(fn: () => T): T {\n batchDepth += 1;\n try {\n return fn();\n } finally {\n batchDepth -= 1;\n if (!batchDepth) flush();\n }\n}\n\nfunction untracked<T>(fn: () => T): T {\n const previous = activeSub;\n const previousAttempt = activeRenderAttempt;\n activeSub = undefined;\n activeRenderAttempt = undefined;\n try { return withSynchronousExecutionOwner(UNTRACKED_OWNER, fn); }\n finally {\n activeRenderAttempt = previousAttempt;\n activeSub = previous;\n }\n}\n\n// Public API/brand candidates. Each public object is the readable class\n// instance itself; no outer wrapper, interop protocol, or per-instance methods.\nconst brandDescriptor = () => ({ value: SIGNAL_BRAND_VERSION, enumerable: false, writable: false, configurable: false });\nfunction registerHelperBrand(value: object): void {\n Object.defineProperty(value, SIGNAL_BRAND, brandDescriptor());\n}\n\nfunction inlineWrite(node: RuntimeSource, value: unknown): void {\n if (!Object.is(node.pendingValue, node.pendingValue = value)) {\n if (node.renderRevision !== undefined) node.renderRevision = (node.renderRevision + 1) | 0;\n node.flags = Mutable | Dirty;\n const subscribers = node.subs;\n if (subscribers !== undefined) {\n propagate(subscribers, !!runDepth);\n if (!batchDepth) flush();\n }\n }\n}\n\nfunction inlineDeepSignalWrite(node: RuntimeSource, value: unknown): void {\n // DeepSignal version sources use this specialized entry point so liveness\n // bookkeeping stays exact without classifying every ordinary source write.\n deepWatchedNodes.delete(node);\n inlineWrite(node, value);\n}\n\nclass HelperBrandSignal<T = unknown> {\n #node: RuntimeSource;\n constructor(node: RuntimeSource, branded = true) { this.#node = node; if (branded) registerHelperBrand(this); attachProtocol(this, node); }\n get value(): T {\n const node = this.#node;\n const currentOwner = executionContext.owner;\n // A render attempt is installed with its render owner. Ordinary owner-free\n // reads can skip speculative-render dispatch while preserving collection.\n if (currentOwner === undefined) {\n const value = readSource(node);\n const collector = activeRenderCollector;\n if (collector !== undefined) {\n trackRenderDependency(getRenderDependency(this, node) as import(\"./alien-derived-types.js\").RenderReadableDependency);\n }\n return value as T;\n }\n // Reads inside this copy's own effects and computeds: no render attempt is\n // installed (`withGraphOwner` clears it), nothing is untracked or foreign.\n if (currentOwner === graphOwner) return readSource(node) as T;\n const attempt = activeRenderAttempt;\n if (attempt !== undefined && isRenderExecutionOwner(currentOwner) && currentOwner.runtimeToken === runtimeToken && renderAdapter !== undefined) {\n foreignAdapter.observeRevision(node);\n return renderAdapter.readSource(this, node, attempt) as T;\n }\n if (currentOwner === UNTRACKED_OWNER) return readSourceUntracked(node) as T;\n if (isForeignOwner(currentOwner)) {\n const value = readSourceUntracked(node);\n foreignAdapter.publishForeignReadable(this, node, currentOwner);\n return value as T;\n }\n return readSource(node) as T;\n }\n set value(value: T) { inlineWrite(this.#node, value); }\n peek(): T { return this.#node.pendingValue as T; }\n}\n\n/** Internal DeepSignal root and per-property version sources have a distinct\n * write entry point because their liveness markers must be cleared before any\n * write, including an Object.is-equal write. Ordinary branded signals never\n * pay that bookkeeping cost. */\nclass DeepSignalRuntimeSource<T = unknown> {\n #node: RuntimeSource;\n constructor(node: RuntimeSource) { this.#node = node; attachProtocol(this, node); }\n get value(): T {\n const node = this.#node;\n const currentOwner = executionContext.owner;\n if (currentOwner === undefined) {\n const value = readSource(node);\n const collector = activeRenderCollector;\n if (collector !== undefined) {\n trackRenderDependency(getRenderDependency(this, node) as import(\"./alien-derived-types.js\").RenderReadableDependency);\n }\n return value as T;\n }\n // Reads inside this copy's own effects and computeds: no render attempt is\n // installed (`withGraphOwner` clears it), nothing is untracked or foreign.\n if (currentOwner === graphOwner) return readSource(node) as T;\n const attempt = activeRenderAttempt;\n if (attempt !== undefined && isRenderExecutionOwner(currentOwner) && currentOwner.runtimeToken === runtimeToken && renderAdapter !== undefined) {\n foreignAdapter.observeRevision(node);\n return renderAdapter.readSource(this, node, attempt) as T;\n }\n if (currentOwner === UNTRACKED_OWNER) return readSourceUntracked(node) as T;\n if (isForeignOwner(currentOwner)) {\n const value = readSourceUntracked(node);\n foreignAdapter.publishForeignReadable(this, node, currentOwner);\n return value as T;\n }\n return readSource(node) as T;\n }\n set value(value: T) { inlineDeepSignalWrite(this.#node, value); }\n peek(): T { return this.#node.pendingValue as T; }\n}\nfunction createBrandedSignal<T>(makeReadable: new (node: RuntimeSource) => RuntimeWritable<T>, initialValue: T): RuntimeWritable<T> {\n const node = makeNode(\"source\", Mutable, { currentValue: initialValue, pendingValue: initialValue });\n return new makeReadable(node as RuntimeSource);\n}\nconst signalClassBrandHelper = <T,>(initialValue: T): RuntimeWritable<T> => createBrandedSignal(HelperBrandSignal<T>, initialValue);\n\nclass HelperBrandComputed<T = unknown> {\n #node: RuntimeComputed;\n constructor(node: RuntimeComputed, branded = true) { this.#node = node; if (branded) registerHelperBrand(this); attachProtocol(this, node); }\n get value(): T {\n const node = this.#node;\n const currentOwner = executionContext.owner;\n // See the source getter: this copy's own graph scope needs no other check.\n if (currentOwner === graphOwner) return readComputed(node) as T;\n const attempt = activeRenderAttempt;\n if (attempt !== undefined && isRenderExecutionOwner(currentOwner) && currentOwner.runtimeToken === runtimeToken && renderAdapter !== undefined) {\n foreignAdapter.observeRevision(node);\n return renderAdapter.readComputed(this, node, attempt) as T;\n }\n const owner = currentOwner;\n // A foreign owner records this read itself (from `finally`, so an erroring\n // computed stays observable); it must not link to this copy's `activeSub`.\n const foreign = owner !== undefined && isForeignOwner(owner);\n try {\n return readComputed(node, owner !== UNTRACKED_OWNER && !foreign) as T;\n } finally {\n if (owner === undefined) {\n if (activeRenderCollector !== undefined) trackRenderDependency(getRenderDependency(this, node) as import(\"./alien-derived-types.js\").RenderReadableDependency);\n } else if (foreign) {\n foreignAdapter.publishForeignReadable(this, node, owner);\n }\n }\n }\n peek(): T { return untracked(() => readComputed(this.#node) as T); }\n}\nfunction createBrandedComputed<T>(makeReadable: new (node: RuntimeComputed) => RuntimeReadable<T>, getter: () => T): RuntimeReadable<T> {\n const node = makeNode(\"computed\", None, { getter, value: undefined, error: undefined, hasError: false, initialized: false });\n return new makeReadable(node as RuntimeComputed);\n}\nconst computedClassBrandHelper = <T,>(getter: () => T): RuntimeReadable<T> => createBrandedComputed(HelperBrandComputed<T>, getter);\n\nfunction hasBrandAndPeek(value: unknown): value is { peek(): unknown } & object {\n if (typeof value !== \"object\" || value === null) return false;\n const version = Reflect.get(value, SIGNAL_BRAND);\n return typeof version === \"number\" && version >= SIGNAL_BRAND_MIN_VERSION && typeof Reflect.get(value, \"peek\") === \"function\";\n}\nconst isSignalBrandHelper = hasBrandAndPeek;\nfunction createDeepSignal<T>(initialValue: T): RuntimeWritable<T> {\n const node = makeNode(\"source\", Mutable, { currentValue: initialValue, pendingValue: initialValue });\n const readable = new DeepSignalRuntimeSource<T>(node as RuntimeSource);\n deepSignalNodes.add(node);\n return readable;\n}\nfunction createDeepSignalVersion<T>(initialValue: T): RuntimeWritable<T> {\n const node = makeNode(\"source\", Mutable, { currentValue: initialValue, pendingValue: initialValue });\n const readable = new DeepSignalRuntimeSource<T>(node as RuntimeSource);\n deepSignalNodes.add(node);\n return readable;\n}\nfunction markDeepSignalWatched(readable: object): void {\n const node = foreignAdapter.getNodeForReadable(readable);\n if (node !== undefined) deepWatchedNodes.add(node);\n }\nfunction hasDeepSignalSubscribers(readable: object): boolean {\n const node = foreignAdapter.getNodeForReadable(readable);\n return node !== undefined && (\n deepWatchedNodes.has(node) || (deepSignalNodes.has(node) && hasSubscribers(readable))\n );\n }\nfunction getRenderVersion(readable: object): number {\n return foreignAdapter.getReadableRevision(readable);\n }\nfunction subscribeReadables(readables: readonly RuntimeReadable[], notify: () => void): () => void {\n let initial = true;\n return detachedEffect(() => {\n for (const readable of readables) {\n try { readable.value; } catch { /* Keep errored computed boundaries observed. */ }\n }\n if (initial) initial = false;\n else notify();\n });\n }\n\n return {\n runtimeToken, graphOwner, configureRenderAdapter, withRenderAttempt, pushRenderAttempt,\n getActiveRenderAttempt, getNodeForReadable, getReadableRevision, getDependencyRevision, isComputedClean,\n promoteComputed, evaluateSpeculatively, adopt, hasSubscribers, hasActiveSubscriber, getBatchDepth,\n signal: signalClassBrandHelper, computed: computedClassBrandHelper,\n effect, detachedEffect, batch, untracked, SIGNAL_BRAND, isSignal: isSignalBrandHelper,\n createDeepSignal, createDeepSignalVersion, markDeepSignalWatched, hasDeepSignalSubscribers,\n getRenderVersion, subscribeReadables,\n };\n}\n","/* Attempt-local render and speculative adapter for the production graph. */\nimport { executionContext, isGraphExecutionOwner, isRenderExecutionOwner, pushExecutionOwner, UNTRACKED_OWNER } from \"./execution-owner.js\";\nimport type { RenderExecutionOwnerV2 } from \"./execution-owner.js\";\nimport { activeRenderCollector, setActiveRenderCollector } from \"./render-tracking.js\";\nimport { isReadableProtocol } from \"./foreign-readable-v1.mjs\";\nimport { READABLE_INTEROP_V1 } from \"./interop-context.mjs\";\nimport type { RenderCollector } from \"./render-tracking.js\";\nimport type { AlienDerivedGraphRuntime, RenderAttempt, RenderReadableDependency, RuntimeComputed, RuntimeNode, RuntimeReadable, RuntimeSource, SpeculativeComputedEntry } from \"./alien-derived-types.js\";\n\nexport function createAlienDerivedRenderAdapter(core: AlienDerivedGraphRuntime) {\nlet activeSpeculativeComputed: SpeculativeComputedEntry | undefined;\nconst readablesByNode = new WeakMap<RuntimeNode, object>();\nconst collectorFrames: Array<{ collector: RenderCollector; active: boolean }> = [];\nlet baseRenderCollector: RenderCollector | undefined;\n\nfunction addDependency(attempt: RenderAttempt, dependency: object, revision: number): void {\n const node = core.getNodeForReadable(dependency);\n if (node !== undefined) readablesByNode.set(node, dependency);\n if (activeSpeculativeComputed !== undefined) {\n activeSpeculativeComputed.dependencies.set(dependency, revision);\n } else {\n attempt.add(dependency, revision);\n }\n}\n\nfunction readSource(readable: object, node: RuntimeSource, attempt: RenderAttempt): unknown {\n addDependency(attempt, readable, node.renderRevision);\n return node.pendingValue;\n}\n\nfunction readComputed(readable: object, node: RuntimeComputed, attempt: RenderAttempt): unknown {\n if (activeSpeculativeComputed !== undefined) {\n const restoreAttempt = core.pushRenderAttempt(undefined);\n try { return (readable as RuntimeReadable).value; }\n finally {\n addDependency(attempt, readable, node.renderRevision);\n restoreAttempt();\n }\n }\n addDependency(attempt, readable, node.renderRevision);\n const cache = attempt.computedCache;\n let entry = cache.get(node);\n // A speculative result is only reusable while every dependency it read is\n // still at the revision it saw. An attempt can outlive its render (a bare\n // scope stays open until commit or a microtask, and on the server nothing\n // ever commits), so this is what keeps \"read, write, read again\" from\n // returning the old value. Checked here, on reuse, so writes pay nothing.\n if (entry !== undefined && isEntryCurrent(entry)) {\n if (entry.hasError) throw entry.error;\n return entry.value;\n }\n if (core.isComputedClean(node)) {\n if (node.hasError) throw node.error;\n return node.value;\n }\n\n entry = {\n dependencies: new Map(),\n value: undefined,\n error: undefined,\n hasError: false,\n canPromote: false,\n };\n cache.set(node, entry);\n const previous = activeSpeculativeComputed;\n activeSpeculativeComputed = entry;\n const deepReadEpoch = attempt.speculativeDeepReadEpoch;\n let createdEffects = false;\n try {\n createdEffects = core.evaluateSpeculatively(node, entry);\n } finally {\n activeSpeculativeComputed = previous;\n entry.canPromote = !createdEffects && deepReadEpoch === attempt.speculativeDeepReadEpoch;\n }\n if (entry.hasError) throw entry.error;\n return entry.value;\n}\n\n// Sources bump their revision on every value-changing write. A computed's\n// revision only moves when it re-evaluates, so it also has to be clean (a\n// write upstream marks even an unwatched computed dirty or pending, since\n// computeds stay linked to their sources). Foreign protocols report their own.\nfunction isEntryCurrent(entry: SpeculativeComputedEntry): boolean {\n for (const [dependency, revision] of entry.dependencies) {\n const node = core.getNodeForReadable(dependency);\n if (node === undefined) {\n if (core.getDependencyRevision(dependency) !== revision) return false;\n } else if (node.renderRevision !== revision || (node.kind === \"computed\" && !core.isComputedClean(node))) {\n return false;\n }\n }\n return true;\n}\n\ncore.configureRenderAdapter({ readSource, readComputed });\n\nfunction createRenderAttempt(): RenderAttempt {\n return {\n dependencies: new Map(),\n computedCache: new Map(),\n speculativeDeepReadEpoch: 0,\n add(dependency, revision) {\n if (!this.dependencies.has(dependency)) this.dependencies.set(dependency, revision);\n },\n markSpeculativeDeepRead() { this.speculativeDeepReadEpoch += 1; },\n };\n}\n\nfunction createRenderOwner(attempt: RenderAttempt, scopePolicy: \"managed\" | \"bare\" = \"managed\"): RenderExecutionOwnerV2 {\n return {\n version: 2 as const,\n kind: \"render\" as const,\n scopePolicy,\n runtimeToken: core.runtimeToken,\n add(protocol, revision) { addDependency(attempt, protocol, revision); },\n isSpeculative() { return activeSpeculativeComputed !== undefined; },\n markSpeculativeDeepRead() { attempt.markSpeculativeDeepRead(); },\n own: core.adopt,\n };\n}\n\nfunction pushRenderScope(attempt: RenderAttempt, scopePolicy: \"managed\" | \"bare\" = \"managed\"): () => void {\n const parent = executionContext.owner;\n if (isRenderExecutionOwner(parent) && !(parent.scopePolicy === \"managed\" && scopePolicy === \"managed\")) {\n parent.closeScope?.();\n }\n const restoreAttempt = core.pushRenderAttempt(attempt);\n const owner = createRenderOwner(attempt, scopePolicy);\n const restoreOwner = pushExecutionOwner(owner);\n const collector: RenderCollector = { add(dependency: RenderReadableDependency, revision: number) { addDependency(attempt, dependency, revision); } };\n if (collectorFrames.length === 0) baseRenderCollector = activeRenderCollector;\n const frame = { collector, active: true };\n collectorFrames.push(frame);\n setActiveRenderCollector(collector);\n let active = true;\n const restoreScope = () => {\n if (!active) return;\n active = false;\n frame.active = false;\n while (collectorFrames.at(-1)?.active === false) collectorFrames.pop();\n setActiveRenderCollector(collectorFrames.at(-1)?.collector ?? baseRenderCollector);\n if (collectorFrames.length === 0) baseRenderCollector = undefined;\n restoreAttempt();\n restoreOwner();\n };\n owner.closeScope = restoreScope;\n return restoreScope;\n}\n\nfunction withRenderScope<T>(attempt: RenderAttempt, callback: () => T, scopePolicy: \"managed\" | \"bare\" = \"managed\"): T {\n const restore = pushRenderScope(attempt, scopePolicy);\n try { return callback(); }\n finally { restore(); }\n}\n\nfunction promoteRenderAttempt(attempt: RenderAttempt): boolean {\n for (const [node, entry] of attempt.computedCache) {\n if (!entry.canPromote) continue;\n const readable = readablesByNode.get(node);\n if (readable === undefined || !core.promoteComputed(readable, node, entry)) return false;\n }\n return true;\n}\n\nfunction settleRenderAttempt(attempt: RenderAttempt): boolean {\n let stable = true;\n for (const [dependency, revision] of attempt.dependencies) {\n const currentRevision = getRenderVersion(dependency);\n if (currentRevision === revision) continue;\n const node = core.getNodeForReadable(dependency);\n const entry = node === undefined ? undefined : attempt.computedCache.get(node);\n if (node === undefined || entry === undefined || node.initialized !== true || entry.hasError !== node.hasError ||\n (!entry.hasError && !Object.is(entry.value, node.value))) {\n stable = false;\n continue;\n }\n attempt.dependencies.set(dependency, currentRevision);\n }\n return stable;\n}\n\nfunction getRenderVersion(readable: object): number {\n if (isReadableProtocol(readable) || core.getNodeForReadable(readable) !== undefined || Reflect.get(readable, READABLE_INTEROP_V1) !== undefined) {\n return core.getDependencyRevision(readable);\n }\n const getVersion = Reflect.get(readable, \"getRenderVersion\");\n if (typeof getVersion === \"function\") return getVersion.call(readable) as number;\n throw new TypeError(\"Unknown render dependency\");\n}\nfunction hasActiveRenderOwner(): boolean { return isRenderExecutionOwner(executionContext.owner); }\nfunction isSpeculative() {\n const owner = executionContext.owner;\n if (isGraphExecutionOwner(owner) || owner === UNTRACKED_OWNER) return false;\n return isRenderExecutionOwner(owner)\n && (owner.isSpeculative?.() === true || activeSpeculativeComputed !== undefined);\n}\nfunction markSpeculativeDeepRead(): void {\n const attempt = core.getActiveRenderAttempt();\n if (attempt !== undefined) attempt.markSpeculativeDeepRead();\n else if (isRenderExecutionOwner(executionContext.owner)) executionContext.owner.markSpeculativeDeepRead?.();\n}\n\nfunction subscribeReadables(readables: readonly RuntimeReadable[], notify: () => void): () => void {\n let initial = true;\n return core.detachedEffect(() => {\n for (const readable of readables) {\n try { readable.value; } catch { /* Keep errored computed boundaries observed. */ }\n }\n if (initial) initial = false;\n else notify();\n });\n}\n\nfunction captureRenderSnapshot(readable: RuntimeReadable): { value: unknown; dependencies: Map<object, number>; attempt: RenderAttempt } {\n const attempt = createRenderAttempt();\n let value: unknown;\n withRenderScope(attempt, () => { value = readable.value; });\n return { value, dependencies: attempt.dependencies, attempt };\n}\n\nfunction getExecutionOwner() { return executionContext.owner; }\n return {\n createRenderAttempt, createRenderOwner, pushRenderScope, withRenderScope,\n promoteRenderAttempt, settleRenderAttempt, getRenderVersion, hasActiveRenderOwner, isSpeculative,\n markSpeculativeDeepRead, subscribeReadables, captureRenderSnapshot,\n getExecutionOwner,\n };\n}\n","import { createAlienDerivedRuntime } from \"./alien-derived-runtime-core.mjs\";\nimport { createAlienDerivedRenderAdapter } from \"./render-runtime.mjs\";\nimport type { AlienDerivedRenderAdapter, RuntimeNode } from \"./alien-derived-types.js\";\n\nexport interface RuntimeReadonlySignal<T> {\n readonly value: T;\n peek(): T;\n}\n\nexport interface RuntimeSignal<T> extends RuntimeReadonlySignal<T> {\n value: T;\n}\n\nexport interface ReactiveRuntime {\n readonly runtimeToken: object;\n readonly graphOwner: {\n readonly kind: \"graph\";\n readonly runtimeToken: object;\n add(protocol: object, revision: number): void;\n };\n getNodeForReadable(readable: RuntimeReadonlySignal<unknown>): RuntimeNode | undefined;\n readonly renderAdapter: AlienDerivedRenderAdapter;\n signal<T>(value: T): RuntimeSignal<T>;\n computed<T>(getter: () => T): RuntimeReadonlySignal<T>;\n effect(fn: () => void | (() => void)): () => void;\n detachedEffect(fn: () => void | (() => void)): () => void;\n batch<T>(fn: () => T): T;\n untracked<T>(fn: () => T): T;\n hasSubscribers(readable: RuntimeReadonlySignal<unknown>): boolean;\n hasActiveSubscriber(): boolean;\n getBatchDepth(): number;\n createDeepSignal<T>(initialValue: T): RuntimeSignal<T>;\n createDeepSignalVersion<T>(initialValue: T): RuntimeSignal<T>;\n markDeepSignalWatched(readable: RuntimeReadonlySignal<unknown>): void;\n hasDeepSignalSubscribers(readable: RuntimeReadonlySignal<unknown>): boolean;\n isSpeculative(): boolean;\n markSpeculativeDeepRead(): void;\n}\n\n/** Builds one Alien-derived graph and its separate owner/render adapters. */\nexport function createReactiveRuntime(): ReactiveRuntime {\n const graph = createAlienDerivedRuntime();\n const render = createAlienDerivedRenderAdapter(graph);\n\n return {\n runtimeToken: graph.runtimeToken,\n graphOwner: graph.graphOwner,\n getNodeForReadable: graph.getNodeForReadable,\n renderAdapter: render,\n signal: graph.signal,\n computed: graph.computed,\n effect: graph.effect,\n detachedEffect: graph.detachedEffect,\n batch: graph.batch,\n untracked: graph.untracked,\n hasSubscribers: graph.hasSubscribers,\n hasActiveSubscriber: graph.hasActiveSubscriber,\n getBatchDepth: graph.getBatchDepth,\n createDeepSignal: graph.createDeepSignal,\n createDeepSignalVersion: graph.createDeepSignalVersion,\n markDeepSignalWatched: graph.markDeepSignalWatched,\n hasDeepSignalSubscribers: graph.hasDeepSignalSubscribers,\n isSpeculative: render.isSpeculative,\n markSpeculativeDeepRead: render.markSpeculativeDeepRead,\n };\n}\n","import { createReactiveRuntime } from \"./reactive-runtime.js\";\n\n/** The single graph used by this package's public signal APIs. */\nexport const coreRuntime = createReactiveRuntime();\n"],"mappings":";;AACA,MAAa,kBAAkB,OAAO,IACpC,+CACF;AA6CA,SAAgB,sBACd,OACgC;CAChC,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,SAAS;AACvE;AAEA,SAAgB,uBACd,OACiC;CACjC,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,SAAS;AACvE;AAQA,MAAM,cAAc,OAAO,IAAI,sDAAsD;AAErF,MAAM,eAAe;AACrB,MAAM,WAAW,aAAa;AAC9B,IAAI,aAAa,KAAA,KAAa,SAAS,YAAY,GACjD,MAAM,IAAI,MAAM,0CAA0C;AAG5D,MAAa,mBAAuC,YAAY;CAC9D,SAAS;CACT,OAAO,KAAA;CACP,QAAQ,CAAC;AACX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AgB,MAAM;EACtB,OAAO,MAAM;EACb,WAAW,MAAM;EACjB,gBAAgB,MAAM;EACtB,qBAAqB,MAAM;EAC3B,eAAe,MAAM;EACrB,kBAAkB,MAAM;EACxB,yBAAyB,MAAM;EAC/B,uBAAuB,MAAM;EAC7B,0BAA0B,MAAM;EAChC,eAAe,OAAO;EACtB,yBAAyB,OAAO;CAClC;AACF;;;;AC9DA,MAAa,cAAc,sBAAsB"}
package/dist/index.d.ts CHANGED
@@ -1,27 +1,18 @@
1
1
  import { a as effect, c as untracked, i as computed, n as Signal, o as isSignal, r as batch, s as signal, t as ReadonlySignal } from "./base-Bx5ahfW2.js";
2
- import { r as useSignals } from "./use-signals-CBDbbAbV.js";
2
+ import { a as deepSignal, i as NotDeepSignal, n as createSignalAwareElement, r as DeepSignal } from "./jsx-BQGrTir3.js";
3
+ import { r as useSignalTracking } from "./use-signals-CJYcdFdL.js";
3
4
  import { DependencyList } from "react";
4
- //#region src/core/deep-signal.d.ts
5
- /** A signal whose plain-object and array values are reactive by property. */
6
- interface DeepSignal<T extends object> extends Signal<T> {}
7
- /**
8
- * Creates a signal that lazily tracks nested plain-object and array properties.
9
- * Mutations must go through `.value`; changes made through the original raw
10
- * object are intentionally not observable.
11
- */
12
- declare function deepSignal<T extends object>(initialValue: T): DeepSignal<T>;
13
- //#endregion
14
5
  //#region src/react/hooks.d.ts
15
6
  /** An immutable value that React can safely compare as an external-store snapshot. */
16
7
  type SignalSnapshot = string | number | boolean | bigint | symbol | null | undefined;
17
8
  /** Creates a signal whose identity is stable for the lifetime of this component. */
18
- declare function useSignal<T>(initialValue: T): Signal<T>;
9
+ export declare function useSignal<T>(initialValue: T): Signal<T>;
19
10
  /**
20
11
  * Creates a deep signal whose identity is stable for the component lifetime.
21
12
  * A factory is evaluated only while initializing a mounted component instance;
22
13
  * it must remain pure because React Strict Mode may replay initial rendering.
23
14
  */
24
- declare function useDeepSignal<T extends object>(initialValue: T | (() => T)): DeepSignal<T>;
15
+ export declare function useDeepSignal<T extends object>(initialValue: T | (() => T)): DeepSignal<T>;
25
16
  /**
26
17
  * Selects a property-level primitive snapshot from a deep signal.
27
18
  *
@@ -36,7 +27,7 @@ declare function useDeepSignal<T extends object>(initialValue: T | (() => T)): D
36
27
  * "changed size between renders" dev warning, mirroring `useComputed`'s
37
28
  * dependency-mode-switch guard.
38
29
  */
39
- declare function useDeepSignalValue<T extends object, S extends SignalSnapshot>(source: DeepSignal<T>, selector: (value: T) => S, dependencies: DependencyList): S;
30
+ export declare function useDeepSignalValue<T extends object, S extends SignalSnapshot>(source: DeepSignal<T>, selector: (value: T) => S, dependencies: DependencyList): S;
40
31
  /**
41
32
  * Creates a computed signal with a stable identity.
42
33
  *
@@ -51,7 +42,7 @@ declare function useDeepSignalValue<T extends object, S extends SignalSnapshot>(
51
42
  * closure used by the previously committed computed. Choose one mode for a
52
43
  * component's lifetime.
53
44
  */
54
- declare function useComputed<T>(getValue: () => T, dependencies?: DependencyList): ReadonlySignal<T>;
45
+ export declare function useComputed<T>(getValue: () => T, dependencies?: DependencyList): ReadonlySignal<T>;
55
46
  /**
56
47
  * Runs a reactive effect after this component has committed, disposing it when
57
48
  * the component unmounts (and during React Strict Mode's development replay).
@@ -64,17 +55,21 @@ declare function useComputed<T>(getValue: () => T, dependencies?: DependencyList
64
55
  * all of those values in `dependencies`. The effect is then reconnected after
65
56
  * those dependencies change. Choose one mode for a component's lifetime.
66
57
  */
67
- declare function useSignalEffect(callback: () => void | (() => void), dependencies?: DependencyList): void;
58
+ export declare function useSignalEffect(callback: () => void | (() => void), dependencies?: DependencyList): void;
68
59
  /**
69
- * Reads a signal and subscribes the component to subsequent changes.
60
+ * Reads a signal and subscribes the component to subsequent changes through
61
+ * ReadableInterop V1 when available.
62
+ *
63
+ * `useSyncExternalStore` owns the initial consistency check after subscribing.
64
+ * For V1 readables, its watcher tracks revisions without an EffectNode. A
65
+ * read that throws (a computed whose cached error `.value` rethrows) remains
66
+ * for the render-time `getSnapshot` to surface to an Error Boundary; only the
67
+ * structural-readable fallback needs an effect to contain background errors.
70
68
  *
71
- * The immediate run made by the public `effect` API establishes dependency
72
- * tracking only. It intentionally does not notify React: `useSyncExternalStore`
73
- * owns the initial consistency check after subscribing. See `createSignalStore`
74
- * for the shared subscribe/notify wiring, including why a read that throws
75
- * (a computed whose cached error `.value` rethrows) is swallowed in the
76
- * background effect and left for `getSnapshot` to rethrow instead.
69
+ * A `deepSignal` is rejected at compile time: this subscribes to root
70
+ * replacement only, so nested mutations would never re-render. Read deep state
71
+ * with `useDeepSignalValue` or inside a tracked component instead.
77
72
  */
78
- declare function useSignalValue<T>(source: ReadonlySignal<T>): T;
73
+ export declare function useSignalValue<T>(source: ReadonlySignal<T> & NotDeepSignal): T;
79
74
  //#endregion
80
- export { type DeepSignal, type ReadonlySignal, type Signal, type SignalSnapshot, batch, computed, deepSignal, effect, isSignal, signal, untracked, useComputed, useDeepSignal, useDeepSignalValue, useSignal, useSignalEffect, useSignalValue, useSignals };
75
+ export { type DeepSignal, type ReadonlySignal, type Signal, type SignalSnapshot, batch, computed, createSignalAwareElement as createElement, deepSignal, effect, isSignal, signal, untracked, useSignalTracking };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as effect, c as signal, i as computed, l as untracked, o as isSignal, r as batch } from "./base-BZTnpU8U.js";
2
- import { a as useSignalEffect, i as useSignal, n as useDeepSignal, o as useSignalValue, r as useDeepSignalValue, s as deepSignal, t as useComputed } from "./hooks-BFIWh7AD.js";
3
- import { n as useSignals } from "./use-signals-8i2B-94o.js";
4
- export { batch, computed, deepSignal, effect, isSignal, signal, untracked, useComputed, useDeepSignal, useDeepSignalValue, useSignal, useSignalEffect, useSignalValue, useSignals };
1
+ import { a as isSignal, c as untracked, i as effect, n as computed, s as signal, t as batch } from "./base-WD_74mfC.js";
2
+ import { a as useDeepSignalValue, c as useSignalValue, i as useDeepSignal, l as deepSignal, n as createSignalAwareElement, o as useSignal, r as useComputed, s as useSignalEffect } from "./jsx-P6volZdr.js";
3
+ import { n as useSignalTracking } from "./use-signals-C1K8-vJX.js";
4
+ export { batch, computed, createSignalAwareElement as createElement, deepSignal, effect, isSignal, signal, untracked, useComputed, useDeepSignal, useDeepSignalValue, useSignal, useSignalEffect, useSignalTracking, useSignalValue };
@@ -1,13 +1,47 @@
1
- import { t as ReadonlySignal } from "./base-Bx5ahfW2.js";
1
+ import { n as Signal, t as ReadonlySignal } from "./base-Bx5ahfW2.js";
2
2
  import * as React from "react";
3
+ //#region src/core/deep-signal.d.ts
4
+ declare const deepSignalBrand: unique symbol;
5
+ /** A signal whose plain-object and array values are reactive by property. */
6
+ interface DeepSignal<T extends object> extends Signal<T> {
7
+ /**
8
+ * Type-only marker; never present at runtime. It lets positions that only
9
+ * observe a signal's root value reject a deep signal at compile time,
10
+ * because they would not re-render on nested mutations.
11
+ */
12
+ readonly [deepSignalBrand]: true;
13
+ }
14
+ /**
15
+ * Package-internal: intersected with `ReadonlySignal<T>` where only root
16
+ * replacement is observed (`useSignalValue`, JSX children and host props), so
17
+ * passing a `DeepSignal` there is a type error instead of a silently stale UI.
18
+ */
19
+ type NotDeepSignal = {
20
+ readonly [deepSignalBrand]?: never;
21
+ };
22
+ /**
23
+ * Creates a signal that lazily tracks nested plain-object and array properties.
24
+ * Mutations must go through `.value`; changes made through the original raw
25
+ * object are intentionally not observable.
26
+ */
27
+ declare function deepSignal<T extends object>(initialValue: T): DeepSignal<T>;
28
+ //#endregion
3
29
  //#region src/runtime/jsx.d.ts
4
30
  declare const SVG_ELEMENTS: readonly ["svg", "animate", "animateMotion", "animateTransform", "circle", "clipPath", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "set", "stop", "switch", "symbol", "text", "textPath", "tspan", "use", "view"];
5
31
  type SvgElement = (typeof SVG_ELEMENTS)[number];
6
32
  declare const MATHML_ELEMENTS: readonly ["annotation", "annotation-xml", "maction", "math", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"];
7
33
  type MathMlElement = (typeof MATHML_ELEMENTS)[number];
8
34
  type NonHtmlHostElement = SvgElement | MathMlElement;
9
- type SignalChild = React.ReactNode | ReadonlySignal<SignalChild> | readonly SignalChild[];
10
- type Signalable<T> = T | ReadonlySignal<T>;
35
+ type SignalChild = React.ReactNode | (ReadonlySignal<SignalChild> & NotDeepSignal) | readonly SignalChild[];
36
+ /**
37
+ * The classic-runtime `createElement` that the automatic runtime falls back to
38
+ * for `<div {...props} key="k" />` — TypeScript, Babel and Oxc all import it
39
+ * from the package root of `jsxImportSource`. It applies the same host-prop
40
+ * bindings and child normalization as `jsx`, and leaves `key` (and `ref`) in
41
+ * the config for React's own `createElement` to extract.
42
+ */
43
+ declare function createSignalAwareElement(type: React.ElementType, config?: Record<string, unknown> | null, ...children: unknown[]): React.ReactElement;
44
+ type Signalable<T> = T | (ReadonlySignal<T> & NotDeepSignal);
11
45
  type DirectSignalPropName = "title" | "id" | "className" | "hidden" | "disabled" | "style" | "value" | "checked";
12
46
  type AriaPropName = `aria-${string}`;
13
47
  type AddSignalChildren<P> = Omit<P, "children"> & {
@@ -27,7 +61,8 @@ declare namespace JSX {
27
61
  type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
28
62
  interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
29
63
  interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
30
- type IntrinsicElements = { [Tag in keyof React.JSX.IntrinsicElements]: Tag extends NonHtmlHostElement ? AddSignalChildren<React.JSX.IntrinsicElements[Tag]> : AddHtmlSignalProps<React.JSX.IntrinsicElements[Tag]>; };
64
+ interface IntrinsicElements extends SignalIntrinsicElements {}
31
65
  }
66
+ type SignalIntrinsicElements = { [Tag in keyof React.JSX.IntrinsicElements]: Tag extends NonHtmlHostElement ? AddSignalChildren<React.JSX.IntrinsicElements[Tag]> : AddHtmlSignalProps<React.JSX.IntrinsicElements[Tag]>; };
32
67
  //#endregion
33
- export { JSX as t };
68
+ export { deepSignal as a, NotDeepSignal as i, createSignalAwareElement as n, DeepSignal as r, JSX as t };