signalium 3.0.3 → 4.0.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/cjs/development/{component-shared-DzjqSRY-.js → component-shared-CU7qN_Ks.js} +2 -2
  3. package/dist/cjs/development/{component-shared-DzjqSRY-.js.map → component-shared-CU7qN_Ks.js.map} +1 -1
  4. package/dist/cjs/development/config-D6wyrhrW.js +58 -0
  5. package/dist/cjs/development/config-D6wyrhrW.js.map +1 -0
  6. package/dist/cjs/development/config.js +1 -1
  7. package/dist/cjs/development/{debug-CDy1L3Id.js → debug-BS6RdX4D.js} +252 -32
  8. package/dist/cjs/development/debug-BS6RdX4D.js.map +1 -0
  9. package/dist/cjs/development/debug.js +3 -1
  10. package/dist/cjs/development/debug.js.map +1 -1
  11. package/dist/cjs/development/index.js +3 -2
  12. package/dist/cjs/development/index.js.map +1 -1
  13. package/dist/cjs/development/react/index.js +399 -52
  14. package/dist/cjs/development/react/index.js.map +1 -1
  15. package/dist/cjs/development/react/index.server.js +2 -2
  16. package/dist/cjs/development/react/index.server.js.map +1 -1
  17. package/dist/cjs/development/react/server.js +1 -1
  18. package/dist/cjs/development/{snapshot-D8Ydfj9E.js → snapshot-BLa9mv8h.js} +4 -2
  19. package/dist/cjs/development/snapshot-BLa9mv8h.js.map +1 -0
  20. package/dist/cjs/development/transform/index.js +5 -2
  21. package/dist/cjs/development/transform/index.js.map +1 -1
  22. package/dist/cjs/development/utils.js +34 -2
  23. package/dist/cjs/development/utils.js.map +1 -1
  24. package/dist/cjs/production/{component-shared-BuDl2V-v.js → component-shared-BrbkxFeg.js} +2 -2
  25. package/dist/cjs/production/{component-shared-BuDl2V-v.js.map → component-shared-BrbkxFeg.js.map} +1 -1
  26. package/dist/cjs/production/config-BHvmcsLQ.js +52 -0
  27. package/dist/cjs/production/config-BHvmcsLQ.js.map +1 -0
  28. package/dist/cjs/production/config.js +1 -1
  29. package/dist/cjs/production/{contexts-CMvA-Ae9.js → contexts-Bkwv59kH.js} +252 -32
  30. package/dist/cjs/production/contexts-Bkwv59kH.js.map +1 -0
  31. package/dist/cjs/production/debug.js +3 -1
  32. package/dist/cjs/production/debug.js.map +1 -1
  33. package/dist/cjs/production/index.js +3 -2
  34. package/dist/cjs/production/index.js.map +1 -1
  35. package/dist/cjs/production/react/index.js +399 -52
  36. package/dist/cjs/production/react/index.js.map +1 -1
  37. package/dist/cjs/production/react/index.server.js +2 -2
  38. package/dist/cjs/production/react/index.server.js.map +1 -1
  39. package/dist/cjs/production/react/server.js +1 -1
  40. package/dist/cjs/production/{snapshot-I8W4cb8t.js → snapshot-gv-aZDmB.js} +4 -2
  41. package/dist/cjs/production/snapshot-gv-aZDmB.js.map +1 -0
  42. package/dist/cjs/production/transform/index.js +5 -2
  43. package/dist/cjs/production/transform/index.js.map +1 -1
  44. package/dist/cjs/production/utils.js +34 -2
  45. package/dist/cjs/production/utils.js.map +1 -1
  46. package/dist/esm/config.d.ts +1 -1
  47. package/dist/esm/config.d.ts.map +1 -1
  48. package/dist/esm/debug.d.ts +1 -0
  49. package/dist/esm/debug.d.ts.map +1 -1
  50. package/dist/esm/development/{component-shared-D_i2IMKF.js → component-shared-C6HefNX-.js} +2 -2
  51. package/dist/esm/development/{component-shared-D_i2IMKF.js.map → component-shared-C6HefNX-.js.map} +1 -1
  52. package/dist/esm/development/config-CQLKpPRj.js +59 -0
  53. package/dist/esm/development/config-CQLKpPRj.js.map +1 -0
  54. package/dist/esm/development/config.js +2 -2
  55. package/dist/esm/development/{debug-DCgp_XPm.js → debug-D7mtRqCt.js} +280 -60
  56. package/dist/esm/development/debug-D7mtRqCt.js.map +1 -0
  57. package/dist/esm/development/debug.js +12 -10
  58. package/dist/esm/development/index.js +18 -17
  59. package/dist/esm/development/react/index.js +400 -53
  60. package/dist/esm/development/react/index.js.map +1 -1
  61. package/dist/esm/development/react/index.server.js +2 -2
  62. package/dist/esm/development/react/index.server.js.map +1 -1
  63. package/dist/esm/development/react/server.js +1 -1
  64. package/dist/esm/development/{snapshot-D19Mgcgz.js → snapshot-CMsut-I_.js} +7 -5
  65. package/dist/esm/development/snapshot-CMsut-I_.js.map +1 -0
  66. package/dist/esm/development/transform/index.js +5 -2
  67. package/dist/esm/development/transform/index.js.map +1 -1
  68. package/dist/esm/development/utils.js +38 -6
  69. package/dist/esm/development/utils.js.map +1 -1
  70. package/dist/esm/index.d.ts +1 -1
  71. package/dist/esm/index.d.ts.map +1 -1
  72. package/dist/esm/internals/async.d.ts.map +1 -1
  73. package/dist/esm/internals/config.d.ts +40 -0
  74. package/dist/esm/internals/config.d.ts.map +1 -1
  75. package/dist/esm/internals/lease.d.ts +30 -0
  76. package/dist/esm/internals/lease.d.ts.map +1 -0
  77. package/dist/esm/internals/reactive.d.ts +18 -1
  78. package/dist/esm/internals/reactive.d.ts.map +1 -1
  79. package/dist/esm/internals/utils/hash.d.ts +7 -0
  80. package/dist/esm/internals/utils/hash.d.ts.map +1 -1
  81. package/dist/esm/internals/utils/snapshot.d.ts +2 -0
  82. package/dist/esm/internals/utils/snapshot.d.ts.map +1 -1
  83. package/dist/esm/production/{component-shared-XZnx53QZ.js → component-shared-DzYWFipC.js} +2 -2
  84. package/dist/esm/production/{component-shared-XZnx53QZ.js.map → component-shared-DzYWFipC.js.map} +1 -1
  85. package/dist/esm/production/config-BhtwQYAN.js +53 -0
  86. package/dist/esm/production/config-BhtwQYAN.js.map +1 -0
  87. package/dist/esm/production/config.js +2 -2
  88. package/dist/esm/production/{contexts-Cpo7QZDe.js → contexts-D2PPNujL.js} +283 -63
  89. package/dist/esm/production/contexts-D2PPNujL.js.map +1 -0
  90. package/dist/esm/production/debug.js +3 -1
  91. package/dist/esm/production/index.js +19 -18
  92. package/dist/esm/production/react/index.js +400 -53
  93. package/dist/esm/production/react/index.js.map +1 -1
  94. package/dist/esm/production/react/index.server.js +2 -2
  95. package/dist/esm/production/react/index.server.js.map +1 -1
  96. package/dist/esm/production/react/server.js +1 -1
  97. package/dist/esm/production/{snapshot-CZTu3qTo.js → snapshot-Bx73RooF.js} +7 -5
  98. package/dist/esm/production/snapshot-Bx73RooF.js.map +1 -0
  99. package/dist/esm/production/transform/index.js +5 -2
  100. package/dist/esm/production/transform/index.js.map +1 -1
  101. package/dist/esm/production/utils.js +39 -7
  102. package/dist/esm/production/utils.js.map +1 -1
  103. package/dist/esm/react/async-component.d.ts +10 -2
  104. package/dist/esm/react/async-component.d.ts.map +1 -1
  105. package/dist/esm/react/component-server.d.ts +6 -2
  106. package/dist/esm/react/component-server.d.ts.map +1 -1
  107. package/dist/esm/react/component.d.ts +5 -2
  108. package/dist/esm/react/component.d.ts.map +1 -1
  109. package/dist/esm/react/delivery.d.ts +107 -0
  110. package/dist/esm/react/delivery.d.ts.map +1 -0
  111. package/dist/esm/react/index.d.ts +3 -2
  112. package/dist/esm/react/index.d.ts.map +1 -1
  113. package/dist/esm/react/pause-signals-context.d.ts +16 -2
  114. package/dist/esm/react/pause-signals-context.d.ts.map +1 -1
  115. package/dist/esm/react/props-hash.d.ts +20 -0
  116. package/dist/esm/react/props-hash.d.ts.map +1 -0
  117. package/dist/esm/react/use-reactive.d.ts +6 -3
  118. package/dist/esm/react/use-reactive.d.ts.map +1 -1
  119. package/dist/esm/transform/async.d.ts.map +1 -1
  120. package/dist/esm/transform/callback.d.ts.map +1 -1
  121. package/dist/esm/transform/promise.d.ts.map +1 -1
  122. package/dist/esm/transform/use-reactive.d.ts.map +1 -1
  123. package/dist/esm/transform/utils.d.ts +1 -1
  124. package/dist/esm/transform/utils.d.ts.map +1 -1
  125. package/dist/esm/utils.d.ts +17 -1
  126. package/dist/esm/utils.d.ts.map +1 -1
  127. package/package.json +1 -1
  128. package/dist/cjs/development/config-B0MtLBgx.js +0 -21
  129. package/dist/cjs/development/config-B0MtLBgx.js.map +0 -1
  130. package/dist/cjs/development/debug-CDy1L3Id.js.map +0 -1
  131. package/dist/cjs/development/snapshot-D8Ydfj9E.js.map +0 -1
  132. package/dist/cjs/production/config-B0MtLBgx.js +0 -21
  133. package/dist/cjs/production/config-B0MtLBgx.js.map +0 -1
  134. package/dist/cjs/production/contexts-CMvA-Ae9.js.map +0 -1
  135. package/dist/cjs/production/snapshot-I8W4cb8t.js.map +0 -1
  136. package/dist/esm/development/config-CPQL7hX-.js +0 -22
  137. package/dist/esm/development/config-CPQL7hX-.js.map +0 -1
  138. package/dist/esm/development/debug-DCgp_XPm.js.map +0 -1
  139. package/dist/esm/development/snapshot-D19Mgcgz.js.map +0 -1
  140. package/dist/esm/production/config-CPQL7hX-.js +0 -22
  141. package/dist/esm/production/config-CPQL7hX-.js.map +0 -1
  142. package/dist/esm/production/contexts-Cpo7QZDe.js.map +0 -1
  143. package/dist/esm/production/snapshot-CZTu3qTo.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../.tsc-out/react/context.js","../../../../.tsc-out/react/provider.js","../../../../.tsc-out/react/pause-signals-context.js","../../../../.tsc-out/react/async-component.js","../../../../.tsc-out/react/component.js","../../../../.tsc-out/react/use-signal.js","../../../../.tsc-out/react/use-reactive.js"],"sourcesContent":["import { createContext, useContext as useReactContext } from 'react';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nexport const ScopeContext = createContext(undefined);\nexport function useScope() {\n return useReactContext(ScopeContext);\n}\nexport function useContext(context) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scope = getCurrentConsumer()?.scope ?? useScope();\n if (!scope) {\n throw new Error('useContext must be used within a signal hook, a withContext, or a component');\n }\n return scope.getContext(context) ?? context.defaultValue;\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useContext, useMemo } from 'react';\nimport { ScopeContext } from './context.js';\nimport { getGlobalScope, SignalScope } from '../internals/contexts.js';\nimport { hashValue } from '../internals/utils/hash.js';\nexport function ContextProvider({ children, contexts = [], inherit = true, }) {\n const parentScope = useContext(ScopeContext) ?? getGlobalScope();\n const scope = useMemo(() => new SignalScope(contexts, inherit ? parentScope : undefined), \n // eslint-disable-next-line react-hooks/exhaustive-deps\n [parentScope, inherit, hashValue(contexts)]);\n return _jsx(ScopeContext.Provider, { value: scope, children: children });\n}\n","import React, { createContext, useContext, useEffect, useRef } from 'react';\nimport { watchSignal, unwatchSignal } from '../internals/watch.js';\nimport { schedulePull } from '../internals/scheduling.js';\nclass PauseSignalsManager {\n signals = new Set();\n _paused;\n constructor(initialPaused) {\n this._paused = initialPaused;\n }\n get paused() {\n return this._paused;\n }\n register(signal) {\n this.signals.add(signal);\n }\n unregister(signal) {\n this.signals.delete(signal);\n }\n setPaused(value) {\n if (value === this._paused)\n return;\n this._paused = value;\n for (const signal of this.signals) {\n if (value) {\n unwatchSignal(signal, { isPausing: true });\n }\n else {\n watchSignal(signal);\n schedulePull(signal);\n }\n }\n }\n}\nconst PauseSignalsManagerContext = createContext(null);\nexport function PauseSignalsProvider({ value, children }) {\n const managerRef = useRef(null);\n if (managerRef.current === null) {\n managerRef.current = new PauseSignalsManager(value);\n }\n const manager = managerRef.current;\n useEffect(() => {\n manager.setPaused(value);\n }, [manager, value]);\n return React.createElement(PauseSignalsManagerContext.Provider, { value: manager }, children);\n}\nexport function usePauseSignalsManager() {\n return useContext(PauseSignalsManagerContext);\n}\n","import React, { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport { getCurrentConsumer, setCurrentConsumer } from '../internals/consumer.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { runSignal } from '../internals/get.js';\nimport { isReactivePromise } from '../internals/async.js';\nimport { hashValue } from '../internals/utils/hash.js';\nimport { isPromise, isThennable } from '../internals/utils/type-utils.js';\nimport { useScope } from './context.js';\nimport { usePauseSignalsManager } from './pause-signals-context.js';\n/**\n * Remembers settled outcomes for yielded thenables so synchronous replay can inject\n * `next(value)` on later attempts without throwing the same fulfilled promise again (which\n * can strand Suspense). Identity must be stable across replays for a given logical await.\n */\nconst thenableOutcome = new WeakMap();\nfunction adoptYieldedThenable(thenable) {\n const expanded = thenable;\n if (expanded.status === 'fulfilled') {\n return expanded.value;\n }\n if (expanded.status === 'rejected') {\n throw expanded.reason;\n }\n if (expanded.status === 'pending') {\n throw thenable;\n }\n const hit = thenableOutcome.get(thenable);\n if (hit !== undefined) {\n if (hit.kind === 'rejected') {\n throw hit.reason;\n }\n return hit.value;\n }\n thenable.then(v => {\n thenableOutcome.set(thenable, { kind: 'fulfilled', value: v });\n }, e => {\n thenableOutcome.set(thenable, { kind: 'rejected', reason: e });\n });\n throw thenable;\n}\n/** Marked on the outer wrapper returned by `component()` for async (generator) definitions. */\nexport const SIGNALIUM_ASYNC_COMPONENT = Symbol.for('signalium.asyncComponent');\n/**\n * Call from wrappers around `use()` if you might receive a Signalium async component by mistake.\n * React's `use()` does not support Signalium async `component()` wrappers — render them under\n * `<Suspense>` and use `await` inside the component (after the async transform) instead.\n */\nexport function throwIfSignaliumAsyncComponentPassedToUse(resource) {\n if (typeof resource === 'function' &&\n resource[SIGNALIUM_ASYNC_COMPONENT] === true) {\n throw new Error('use() with a Signalium async `component()` is not supported. Render the component under <Suspense> and use await inside the component (compiled from async/await by the Signalium preset) instead.');\n }\n}\nexport { isGeneratorFunction, isAsyncFunctionWithoutTransform } from './component-shared.js';\n/**\n * Synchronous replay driver for async `component()` (authoring: `async`/`await`; Babel rewrites to a generator).\n *\n * Each React render starts a **new** iterator and walks it in a tight loop. Each `yield` (from\n * the compiled generator, originally `await`) is treated like `use(promise)` / Suspense: pending\n * thenables **throw** (interrupting the render); settled `ReactivePromise` values are injected via\n * `next(value)` and the loop continues in the same turn.\n *\n * **Hooks after a suspending `await`:** Same family as React `use()` — the throw aborts before\n * later code runs; the next attempt replays from the top. Do not use conditional hooks without\n * Suspense on paths that skip them.\n *\n * **Plain `Promise` / other thenables:** First time pending, **throw** for Suspense and register\n * the outcome in a `WeakMap` keyed by thenable identity. After settlement, the **same** object\n * replays inject the value (or throw the rejection) synchronously. Keep **stable thenable\n * identity** across replays (e.g. store in a ref). Thenables may expose React `use()`-style\n * `status` / `value` / `reason` for synchronous reads when present.\n *\n * **Generator `let` / `const`:** Reset every replay; durable state should use React hooks, refs, or\n * Signalium signals.\n *\n * `ownerSignal` is set as `CURRENT_CONSUMER` so reads inside the generator participate in the\n * reactive graph like `compute` in `runSignal`.\n */\nexport function runSyncReplayAsyncComponent(fn, props, ownerSignal) {\n const prevConsumer = getCurrentConsumer();\n try {\n setCurrentConsumer(ownerSignal);\n const iter = fn(props);\n let sent = undefined;\n for (;;) {\n const step = iter.next(sent);\n if (step.done) {\n return step.value;\n }\n const yielded = step.value;\n if (yielded !== null && typeof yielded === 'object' && isReactivePromise(yielded)) {\n const rp = yielded;\n if (rp.isRejected) {\n throw rp.error;\n }\n if (!rp.isReady) {\n const native = rp._promise;\n throw native !== undefined ? native : rp;\n }\n sent = rp.value;\n continue;\n }\n if (yielded !== null && typeof yielded === 'object' && (isPromise(yielded) || isThennable(yielded))) {\n sent = adoptYieldedThenable(yielded);\n continue;\n }\n sent = yielded;\n }\n }\n finally {\n setCurrentConsumer(prevConsumer);\n }\n}\n/**\n * Async Signalium `component()`: one lazy reactive signal per **instance** (same as sync\n * `component()`), outer `useMemo` keyed by `hashValue(props)`. No definition-scoped props map.\n */\nexport function createAsyncComponentWrapper(fn) {\n const Inner = (props) => {\n const scope = useScope();\n const manager = usePauseSignalsManager();\n const fnSignalRef = useRef(undefined);\n const propsRef = useRef(props);\n propsRef.current = props;\n let sig = fnSignalRef.current;\n if (sig === undefined) {\n let owned;\n owned = createReactiveSignal({\n compute: () => runSyncReplayAsyncComponent(fn, propsRef.current, owned),\n equals: () => false,\n isRelay: false,\n tracer: undefined,\n }, [], undefined, scope);\n owned._isLazy = true;\n fnSignalRef.current = sig = owned;\n }\n const watch = !manager?.paused;\n manager?.register(sig);\n useEffect(() => {\n return () => manager?.unregister(sig);\n }, [manager, sig]);\n useSyncExternalStore(sig.addListenerLazy(watch), () => sig.updatedCount, () => sig.updatedCount);\n runSignal(sig);\n return sig.value;\n };\n const Outer = (props) => {\n const hash = hashValue(props);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => React.createElement(Inner, props), [hash]);\n };\n Object.defineProperty(Outer, SIGNALIUM_ASYNC_COMPONENT, { value: true, enumerable: false });\n return Outer;\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport * as React from 'react';\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport { useScope } from './context.js';\nimport { usePauseSignalsManager } from './pause-signals-context.js';\nimport { setRequestScopeGetter, SignalScope } from '../internals/contexts.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { runSignal } from '../internals/get.js';\nimport { hashValue } from '../internals/utils/hash.js';\nimport { createAsyncComponentWrapper } from './async-component.js';\nimport { isAsyncFunctionWithoutTransform, isGeneratorFunction, createServerAsyncComponentWrapper, } from './component-shared.js';\nexport { isAsyncFunctionWithoutTransform, runSyncReplayAsyncComponent, SIGNALIUM_ASYNC_COMPONENT, throwIfSignaliumAsyncComponentPassedToUse, } from './async-component.js';\n/**\n * Auto-install per-request scoping for SSR of client components.\n *\n * `setupRscRequestScope()` only affects the RSC bundle; Next.js (and similar frameworks) render\n * client components in a separate SSR module graph. This ensures the SSR bundle also gets a\n * fresh {@link SignalScope} per render via `React.cache` (React 19+).\n */\nlet _ssrScopeInitialized = false;\nfunction ensureSsrScope() {\n if (_ssrScopeInitialized || typeof window !== 'undefined')\n return;\n _ssrScopeInitialized = true;\n const cache = React.cache;\n if (typeof cache === 'function') {\n const getScope = cache(() => new SignalScope([]));\n setRequestScopeGetter(() => getScope());\n }\n}\nexport default function component(fn) {\n ensureSsrScope();\n if (isAsyncFunctionWithoutTransform(fn)) {\n throw new Error('signalium: `component(async (props) => { await ... })` requires the Signalium Babel preset (async transform).');\n }\n if (isGeneratorFunction(fn)) {\n if (typeof window === 'undefined') {\n return createServerAsyncComponentWrapper(fn);\n }\n return createAsyncComponentWrapper(fn);\n }\n // Async `component(async () => { await ... })` is rewritten to a generator by the Babel preset.\n // Remaining callers are synchronous render functions only (see Promise overload for TS authoring).\n const syncFn = fn;\n const Component = (props) => {\n const scope = useScope();\n const manager = usePauseSignalsManager();\n const fnSignalRef = useRef(undefined);\n const propsRef = useRef(props);\n propsRef.current = props;\n let signal = fnSignalRef.current;\n if (signal === undefined) {\n const created = createReactiveSignal({\n compute: () => syncFn(propsRef.current),\n equals: () => false,\n isRelay: false,\n tracer: undefined,\n }, [], undefined, scope);\n created._isLazy = true;\n fnSignalRef.current = signal = created;\n }\n const watch = !manager?.paused;\n manager?.register(signal);\n useEffect(() => {\n return () => manager?.unregister(signal);\n }, [manager, signal]);\n useSyncExternalStore(signal.addListenerLazy(watch), () => signal.updatedCount, () => signal.updatedCount);\n runSignal(signal);\n return signal.value;\n };\n return (props) => {\n const hash = hashValue(props);\n // Renders Comp only when hash changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => _jsx(Component, { ...props }), [hash]);\n };\n}\n","import { useRef } from 'react';\nimport { signal } from '../index.js';\nexport function useSignal(value, opts) {\n const ref = useRef(undefined);\n if (!ref.current) {\n ref.current = signal(value, opts);\n }\n return ref.current;\n}\n","import { useEffect, useRef, useSyncExternalStore } from 'react';\nimport { getReactiveFnAndDefinition, reactiveSignal } from '../internals/core-api.js';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nimport { snapshot } from '../internals/utils/snapshot.js';\nimport { useScope } from './context.js';\nimport { usePauseSignalsManager } from './pause-signals-context.js';\nimport { getGlobalScope } from '../internals/contexts.js';\nfunction useSignalWithSuspension(signal) {\n const manager = usePauseSignalsManager();\n const watch = !manager?.paused;\n manager?.register(signal);\n useEffect(() => {\n return () => manager?.unregister(signal);\n }, [manager, signal]);\n return useSyncExternalStore(signal.addListenerLazy(watch), () => signal.value, () => signal.value);\n}\n/**\n * Subscribe to a reactive thunk without structural cloning. The thunk's\n * `ReactiveDefinition` is memoized by fn identity in a `WeakMap`, so a\n * memoized thunk (via `useCallback` or the Signalium Babel preset) reuses the\n * same scope-cached signal across renders.\n *\n * This is a minimal wrapper: the returned value is whatever the thunk\n * returned, by reference. In particular, when the thunk returns a\n * `ReactivePromise`, re-renders only fire when the underlying signal itself\n * re-evaluates (e.g. a new promise replaces the old one) — not when the\n * existing promise transitions from pending to resolved. If you need promise\n * state transitions to drive React, read its fields inside the thunk (e.g.\n * `useReactiveShallow(() => { const p = fetchThing(); return { value: p.value,\n * isPending: p.isPending }; })`) or use {@link useReactive} for the\n * structurally-shared snapshot that handles this automatically.\n */\nexport function useReactiveShallow(fn) {\n if (IS_DEV && getCurrentConsumer()) {\n throw new Error('signalium: `useReactiveShallow` cannot be called inside a reactive function. ' +\n 'Call your reactive function directly instead — it already participates in the signal graph.');\n }\n const [, def] = getReactiveFnAndDefinition(fn);\n const scope = useScope() ?? getGlobalScope();\n const signal = scope.get(def, []);\n return useSignalWithSuspension(signal);\n}\n/**\n * Subscribe to a reactive thunk and return a structurally-shared snapshot of\n * its value. Nested objects/arrays/Maps/Sets are deep-cloned; unchanged\n * subtrees keep the same reference, so React's referential equality works as\n * expected. ReactivePromise values are flattened to plain objects.\n *\n * This is the default hook for reading reactive values inside a React\n * component — it gives you safe equality semantics at the React boundary.\n * Use {@link useReactiveShallow} if you know you don't need structural\n * sharing.\n */\nexport function useReactive(fn) {\n if (IS_DEV && getCurrentConsumer()) {\n throw new Error('signalium: `useReactive` cannot be called inside a reactive function. ' +\n 'Call your reactive function directly instead — it already participates in the signal graph.');\n }\n const manager = usePauseSignalsManager();\n const watch = !manager?.paused;\n const scope = useScope() ?? getGlobalScope();\n const innerSignalRef = useRef(undefined);\n const cloneSignalRef = useRef(undefined);\n const valueRef = useRef(undefined);\n const [, def] = getReactiveFnAndDefinition(fn);\n const signal = scope.get(def, []);\n if (innerSignalRef.current !== signal) {\n innerSignalRef.current = signal;\n valueRef.current = undefined;\n cloneSignalRef.current = reactiveSignal(() => {\n const next = snapshot(signal.value, valueRef.current);\n valueRef.current = next;\n return next;\n });\n }\n const cloneSignal = cloneSignalRef.current;\n manager?.register(cloneSignal);\n useEffect(() => {\n return () => manager?.unregister(cloneSignal);\n }, [manager, cloneSignal]);\n return useSyncExternalStore(cloneSignal.addListenerLazy(watch), () => cloneSignal.value, () => cloneSignal.value);\n}\n/**\n * @deprecated Use {@link useReactive} instead. `useReactive` is now\n * deep-by-default; `useReactiveDeep` is a thin alias kept for back-compat and\n * will be removed in a future major release.\n */\nexport function useReactiveDeep(fn) {\n if (IS_DEV) {\n warnUseReactiveDeepOnce();\n }\n return useReactive(fn);\n}\nlet _useReactiveDeepWarned = false;\nfunction warnUseReactiveDeepOnce() {\n if (_useReactiveDeepWarned)\n return;\n _useReactiveDeepWarned = true;\n console.warn('[signalium] `useReactiveDeep` is deprecated; use `useReactive` instead. ' +\n '`useReactive` is now deep-by-default. Use `useReactiveShallow` to opt out of structural snapshots.');\n}\n"],"names":["createContext","useReactContext","getCurrentConsumer","useContext","getGlobalScope","useMemo","SignalScope","hashValue","_jsx","unwatchSignal","watchSignal","schedulePull","useRef","useEffect","setCurrentConsumer","isReactivePromise","isPromise","isThennable","createReactiveSignal","useSyncExternalStore","runSignal","React","setRequestScopeGetter","isAsyncFunctionWithoutTransform","isGeneratorFunction","createServerAsyncComponentWrapper","signal","getReactiveFnAndDefinition","reactiveSignal","snapshot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,eAAeA,MAAAA,cAAc,MAAS;AAC5C,SAAS,WAAW;AACvB,SAAOC,MAAAA,WAAgB,YAAY;AACvC;AACO,SAAS,WAAW,SAAS;AAEhC,QAAM,QAAQC,MAAAA,sBAAsB,SAAS,SAAQ;AACrD,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,6EAA6E;AAAA,EACjG;AACA,SAAO,MAAM,WAAW,OAAO,KAAK,QAAQ;AAChD;ACRO,SAAS,gBAAgB,EAAE,UAAU,WAAW,CAAA,GAAI,UAAU,QAAS;AAC1E,QAAM,cAAcC,MAAA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,SAAO,wBAAwB,MAAM;AACzC;AAYO,SAAS,YAAY,IAAI;AAC5B,MAAcF,MAAAA,sBAAsB;AAChC,UAAM,IAAI,MAAM,mKACiF;AAAA,EACrG;AACA,QAAM,UAAU,uBAAA;AAChB,QAAM,QAAQ,CAAC,SAAS;AACxB,QAAM,QAAQ,SAAA,KAAcE,qBAAA;AAC5B,QAAM,iBAAiBQ,MAAAA,OAAO,MAAS;AACvC,QAAM,iBAAiBA,MAAAA,OAAO,MAAS;AACvC,QAAM,WAAWA,MAAAA,OAAO,MAAS;AACjC,QAAM,GAAG,GAAG,IAAIe,SAAAA,2BAA2B,EAAE;AAC7C,QAAM,SAAS,MAAM,IAAI,KAAK,CAAA,CAAE;AAChC,MAAI,eAAe,YAAY,QAAQ;AACnC,mBAAe,UAAU;AACzB,aAAS,UAAU;AACnB,mBAAe,UAAUC,SAAAA,eAAe,MAAM;AAC1C,YAAM,OAAOC,SAAAA,SAAS,OAAO,OAAO,SAAS,OAAO;AACpD,eAAS,UAAU;AACnB,aAAO;AAAA,IACX,CAAC;AAAA,EACL;AACA,QAAM,cAAc,eAAe;AACnC,WAAS,SAAS,WAAW;AAC7BhB,QAAAA,UAAU,MAAM;AACZ,WAAO,MAAM,SAAS,WAAW,WAAW;AAAA,EAChD,GAAG,CAAC,SAAS,WAAW,CAAC;AACzB,SAAOM,MAAAA,qBAAqB,YAAY,gBAAgB,KAAK,GAAG,MAAM,YAAY,OAAO,MAAM,YAAY,KAAK;AACpH;AAMO,SAAS,gBAAgB,IAAI;AACpB;AACR,4BAAA;AAAA,EACJ;AACA,SAAO,YAAY,EAAE;AACzB;AACA,IAAI,yBAAyB;AAC7B,SAAS,0BAA0B;AAC/B,MAAI;AACA;AACJ,2BAAyB;AACzB,UAAQ,KAAK,4KAC2F;AAC5G;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../.tsc-out/react/context.js","../../../../.tsc-out/react/provider.js","../../../../.tsc-out/react/pause-signals-context.js","../../../../.tsc-out/react/props-hash.js","../../../../.tsc-out/react/delivery.js","../../../../.tsc-out/react/async-component.js","../../../../.tsc-out/react/component.js","../../../../.tsc-out/react/use-signal.js","../../../../.tsc-out/react/use-reactive.js"],"sourcesContent":["import { createContext, useContext as useReactContext } from 'react';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nexport const ScopeContext = createContext(undefined);\nexport function useScope() {\n return useReactContext(ScopeContext);\n}\nexport function useContext(context) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scope = getCurrentConsumer()?.scope ?? useScope();\n if (!scope) {\n throw new Error('useContext must be used within a signal hook, a withContext, or a component');\n }\n return scope.getContext(context) ?? context.defaultValue;\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useContext, useMemo } from 'react';\nimport { ScopeContext } from './context.js';\nimport { getGlobalScope, SignalScope } from '../internals/contexts.js';\nimport { hashValue } from '../internals/utils/hash.js';\nexport function ContextProvider({ children, contexts = [], inherit = true, }) {\n const parentScope = useContext(ScopeContext) ?? getGlobalScope();\n const scope = useMemo(() => new SignalScope(contexts, inherit ? parentScope : undefined), \n // eslint-disable-next-line react-hooks/exhaustive-deps\n [parentScope, inherit, hashValue(contexts)]);\n return _jsx(ScopeContext.Provider, { value: scope, children: children });\n}\n","import React, { createContext, useContext, useEffect, useRef, useSyncExternalStore } from 'react';\nexport class PauseSignalsManager {\n /**\n * Readers per registered signal. Scope-cached signals can be shared across providers, so pausing\n * counts readers on the signal instead of pausing it outright.\n */\n signals = new Map();\n /** Unclaimed render leases taken under this provider (e.g. a suspended mount). Pruned lazily. */\n leases = new Set();\n pruneLeasesAt = 64;\n _paused;\n constructor(initialPaused) {\n this._paused = initialPaused;\n }\n get paused() {\n return this._paused;\n }\n trackLease(signal) {\n const leases = this.leases;\n leases.add(signal);\n if (leases.size >= this.pruneLeasesAt) {\n for (const leased of leases) {\n if (!leased._isLeased)\n leases.delete(leased);\n }\n this.pruneLeasesAt = Math.max(64, leases.size * 2);\n }\n }\n /** Call before the reader subscribes, so a paused reader never takes the watch. */\n register(signal) {\n this.signals.set(signal, (this.signals.get(signal) ?? 0) + 1);\n this.leases.delete(signal);\n if (this._paused) {\n signal._addPausedReaders(1);\n }\n }\n unregister(signal) {\n const count = this.signals.get(signal);\n if (count === undefined)\n return;\n if (count > 1) {\n this.signals.set(signal, count - 1);\n }\n else {\n this.signals.delete(signal);\n }\n if (this._paused) {\n // The reader may still be subscribed; reconciling now could briefly re-watch.\n signal._addPausedReaders(-1, true);\n }\n }\n setPaused(value) {\n if (value === this._paused)\n return;\n this._paused = value;\n for (const [signal, count] of this.signals) {\n signal._addPausedReaders(value ? count : -count);\n }\n for (const signal of this.leases) {\n if (!signal._isLeased) {\n this.leases.delete(signal);\n }\n else if (value) {\n signal._pauseWatch();\n }\n else {\n signal._resumeWatch();\n }\n }\n }\n}\nconst PauseSignalsManagerContext = createContext(null);\nexport function PauseSignalsProvider({ value, children }) {\n const managerRef = useRef(null);\n if (managerRef.current === null) {\n managerRef.current = new PauseSignalsManager(value);\n }\n const manager = managerRef.current;\n useEffect(() => {\n manager.setPaused(value);\n }, [manager, value]);\n return React.createElement(PauseSignalsManagerContext.Provider, { value: manager }, children);\n}\nexport function usePauseSignalsManager() {\n return useContext(PauseSignalsManagerContext);\n}\n/** `addListenerLazy`, tracking the lease so pausing reaches it if the render never commits. */\nexport function addRenderListener(signal, manager) {\n const subscribe = signal.addListenerLazy(!manager?.paused);\n if (manager !== null && signal._isLeased) {\n manager.trackLease(signal);\n }\n return subscribe;\n}\n/** `useSyncExternalStore`, registering the reader with `manager` before it subscribes. */\nexport function usePausableStore(manager, signal, subscribe, getSnapshot) {\n useEffect(() => {\n if (manager === null)\n return;\n manager.register(signal);\n return () => manager.unregister(signal);\n }, [manager, signal]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import { useRef } from 'react';\nimport { ARRAY_SEED, finalizeHash, getObjectHash, hashObjectKeys, hashValue, mixHash, } from '../internals/utils/hash.js';\nconst { imul } = Math;\nconst { getPrototypeOf, keys: objectKeys } = Object;\nconst EMPTY_PROPS_HASH = hashValue({});\n/**\n * React elements are plain object literals, so `hashValue` hashes them\n * structurally: it walks `props` and recurses through the entire children tree.\n * For a component taking `children`, that walk dominates every render. An\n * element is opaque — nothing reads through it — so hash it by identity. Every\n * other prop keeps its structural hash, so a new-but-equivalent object or array\n * still reuses the memo.\n *\n * The value may be a proxy, whose traps can throw or subscribe the renderer to\n * whatever they touch. So `$$typeof` is only read when it is an own enumerable\n * key, which the structural hash reads anyway, and the keys are reused for it.\n */\nfunction hashPropValue(value, seen) {\n if (typeof value === 'object' && value !== null) {\n const proto = getPrototypeOf(value);\n if (proto === Object.prototype) {\n const keys = objectKeys(value);\n if (keys.includes('$$typeof') && typeof value.$$typeof === 'symbol') {\n return getObjectHash(value);\n }\n seen.push(value);\n const h = hashObjectKeys(value, keys, seen);\n seen.pop();\n return h;\n }\n // Plain arrays only: an `Array` subclass hashes like any other class instance\n // in `hashValue`, by its `registerCustomHash` function or else by identity.\n if (proto === Array.prototype) {\n // `children` is commonly an array, and elements inside it need the same\n // treatment. Order-sensitive, so a reorder still changes the hash.\n if (seen.includes(value))\n return 0;\n seen.push(value);\n const array = value;\n let h = ARRAY_SEED;\n for (let i = 0; i < array.length; i++) {\n h = mixHash(h, hashPropValue(array[i], seen));\n }\n seen.pop();\n return finalizeHash(h, array.length);\n }\n }\n return hashValue(value, seen);\n}\n/** `hashValue(props)`, except React elements are hashed by identity. */\nexport function hashProps(props) {\n const keyMultiplier = 0x9e3779b9; // 2^32 / golden ratio, as in `hashObjectKeys`\n const seen = [];\n let sum = EMPTY_PROPS_HASH;\n for (const key of objectKeys(props)) {\n sum += imul(hashValue(key), keyMultiplier) ^ hashPropValue(props[key], seen);\n }\n return sum >>> 0;\n}\n/**\n * True when `next` has exactly the same keys as `prev` and every value is the same by `Object.is`.\n * Iterates with `for...in` (props are plain objects with no enumerable inherited keys) so the check\n * allocates nothing.\n */\nfunction shallowIdentical(prev, next) {\n let count = 0;\n for (const key in next) {\n if (!Object.is(prev[key], next[key]) || !(key in prev))\n return false;\n count++;\n }\n for (const _key in prev) {\n count--;\n }\n return count === 0;\n}\nclass PropsHashCache {\n props;\n hash;\n constructor(props, hash) {\n this.props = props;\n this.hash = hash;\n }\n}\n/**\n * `hashProps(props)` for a component wrapper, skipping the hash when every prop is identical (by\n * `Object.is`) to the previous render's. A parent that re-renders without changing any prop —\n * by far the common case — then costs one shallow comparison instead of a structural hash.\n *\n * Props are treated as immutable, the same contract as `React.memo` and the React Compiler: a\n * plain object, array, `Map`, `Set` or `Date` prop mutated in place and passed again under the\n * same identity keeps its previous hash, so the memoized element is reused and the component\n * does not re-render for it. (Structural hashing used to notice such mutations, because those\n * values are hashed by content; reference-hashed values — class instances, functions, elements —\n * never could.) Pass a new object, or read the changing data from a signal inside the\n * component, instead of mutating a prop in place.\n *\n * The cache holds only the props a render already hashed, so a render React discards can at most\n * leave a correct (props → hash) pair behind.\n */\nexport function usePropsHash(props) {\n const ref = useRef(null);\n const cache = ref.current;\n if (cache !== null) {\n if (cache.props === props ||\n shallowIdentical(cache.props, props)) {\n return cache.hash;\n }\n const hash = hashProps(props);\n cache.props = props;\n cache.hash = hash;\n return hash;\n }\n const hash = hashProps(props);\n ref.current = new PropsHashCache(props, hash);\n return hash;\n}\n","import { useEffect, useInsertionEffect, useLayoutEffect, useReducer, useRef, useState } from 'react';\nimport { checkSignal } from '../internals/get.js';\nimport { getReactDelivery, runBatch, scheduleReactDelivery } from '../internals/config.js';\n/**\n * Resolves a reader's delivery mode once per mounted instance. The mode decides which hooks the\n * reader calls, so it must not change for the lifetime of the instance; a global config change\n * applies to readers that mount afterwards.\n */\nexport function useDeliveryMode(override) {\n const ref = useRef(undefined);\n return (ref.current ??= override ?? getReactDelivery());\n}\n// Layout effects subscribe as close to the commit as possible. On the server neither effect runs;\n// the plain `useEffect` keeps older React versions from warning about `useLayoutEffect` in SSR.\nconst useCommitEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\nconst increment = (n) => n + 1;\n/**\n * State-delivery bookkeeping for one mounted reader. `committed` is the signal version (its\n * `updatedCount`) the last commit rendered; a notification only turns into a `setState` when the\n * signal has moved past it.\n */\nexport class StateDelivery {\n signal;\n committed;\n forceUpdate;\n /** In the pending-delivery queue. */\n queued = false;\n /** A `setState` was delivered and its render has not committed yet. */\n awaitingCommit = false;\n /** Visible: between the subscription layout effect's setup and cleanup. Only visible readers get deliveries. */\n mounted = false;\n /**\n * Set by every render, cleared by its commit. Still set when Suspense hides the reader, it means\n * the reader's own render suspended, so it stays live: a change may no longer need what it\n * suspended on.\n */\n rendering = false;\n /** The subscription layout effect has run before: its next run is a reveal, not a first mount. */\n connected = false;\n /**\n * A commit included the reader without connecting it: it was committed hidden (prerendered in a\n * hidden `<Activity>`, or mounted into a Suspense-hidden tree), so its first connect is a reveal.\n */\n committedHidden = false;\n /** The subscription currently held, the subscribe function it was made with, and its signal and pause manager. */\n subscribedWith = null;\n subscribedSignal = null;\n pauseManager = null;\n unsubscribe = null;\n listener;\n constructor(signal, version, forceUpdate) {\n this.signal = signal;\n this.committed = version;\n this.forceUpdate = forceUpdate;\n this.listener = () => this.check();\n }\n check() {\n if (this.queued || this.awaitingCommit || !this.mounted)\n return;\n if (this.signal.updatedCount !== this.committed) {\n enqueueDelivery(this);\n }\n }\n /**\n * Brings the signal up to date the way a read would, and reports whether it moved past the\n * committed version. A signal nobody watched (the reader was hidden, or its render lease expired\n * before the commit) is not recomputed when its dependencies change, so its `updatedCount` alone\n * can be stale.\n */\n pull() {\n try {\n checkSignal(this.signal);\n }\n catch {\n return 2 /* PullResult.Threw */;\n }\n return this.signal.updatedCount !== this.committed ? 1 /* PullResult.Changed */ : 0 /* PullResult.Current */;\n }\n subscribe(subscribe, manager) {\n if (this.subscribedWith === subscribe && this.pauseManager === manager)\n return;\n this.release();\n // Register before subscribing, so a paused reader never takes the watch.\n manager?.register(this.signal);\n this.subscribedSignal = this.signal;\n this.pauseManager = manager;\n this.unsubscribe = subscribe(this.listener);\n this.subscribedWith = subscribe;\n }\n release() {\n if (this.unsubscribe === null)\n return;\n this.unsubscribe();\n this.pauseManager?.unregister(this.subscribedSignal);\n this.unsubscribe = null;\n this.subscribedWith = null;\n this.subscribedSignal = null;\n this.pauseManager = null;\n }\n}\nlet PENDING_DELIVERIES = [];\nlet deliveryScheduled = false;\nfunction enqueueDelivery(delivery) {\n delivery.queued = true;\n PENDING_DELIVERIES.push(delivery);\n if (!deliveryScheduled) {\n deliveryScheduled = true;\n scheduleReactDelivery(flushDeliveries);\n }\n}\nfunction flushDeliveries() {\n deliveryScheduled = false;\n const deliveries = PENDING_DELIVERIES;\n PENDING_DELIVERIES = [];\n runBatch(() => {\n for (const delivery of deliveries) {\n delivery.queued = false;\n // Re-check: the reader may have unmounted, or re-rendered for another reason and already\n // committed the latest version, since it was queued.\n if (delivery.mounted && delivery.signal.updatedCount !== delivery.committed) {\n delivery.awaitingCommit = true;\n delivery.forceUpdate();\n }\n }\n });\n}\n/**\n * A `'state'` reader's bookkeeping, for {@link useStateDelivery}. Call before the render reads\n * `signal`, which may suspend.\n */\nexport function useStateDeliveryState(signal) {\n const [, forceUpdate] = useReducer(increment, 0);\n const [delivery] = useState(() => new StateDelivery(signal, signal.updatedCount, forceUpdate));\n delivery.rendering = true;\n return delivery;\n}\n/**\n * Drives a reader with `setState` instead of `useSyncExternalStore` (`delivery: 'state'`).\n *\n * The render reads the signal directly (so a render that happens for any other reason sees fresh\n * data) and passes the version it rendered. On commit the reader subscribes, claiming the render\n * lease that `subscribe` (the signal's `addListenerLazy` result) represents, pulls the signal and\n * compares the version it rendered with the signal's current one, so a change that landed between\n * render and subscribe is never lost. Notifications are coalesced per reader and flushed together,\n * in one `runBatch`, on `scheduleReactDelivery`. The `setState` runs outside any transition, at\n * React's default priority, which waits for an in-progress transition rather than restarting it.\n *\n * Revealing. When the subscription layout effect connects a reader that was hidden after it\n * rendered, the reader pulls the signal and, if it moved since that render, updates with a\n * `setState` from the layout effect. React renders that synchronously, before the revealing commit\n * paints, so revealed content never shows a stale value; the cost is one SyncLane render of that\n * reader, only when something changed, and nothing when nothing did. A reveal is a reconnect (the\n * content was shown, then hidden) or the first connect of a reader that a commit included while\n * hidden: content prerendered inside a hidden `<Activity>`, which mounts no effects until it is\n * revealed. A first mount is not a reveal: a change between its render and its commit is\n * delivered at default priority like any other, so a screen mounting while data ticks does not\n * pay a second, synchronous render of every reader before it paints.\n *\n * Hiding. A Suspense boundary that hides already-revealed content (react-freeze) disconnects layout\n * effects but not passive ones; `<Activity mode=\"hidden\">` disconnects both. Deliveries follow the\n * layout effect, so a hidden reader is not rendered, unless its own render is what suspended; the\n * subscription follows the passive effect, so it lives exactly as long as a `useSyncExternalStore`\n * subscription would: a Suspense hide keeps the signal watched (relays stay active), `<Activity>`\n * and unmount release it. When the layout effect reconnects, the reader catches up as above, so\n * revealed content never shows a value that changed while it was hidden.\n */\nexport function useStateDelivery(delivery, signal, subscribe, version, manager) {\n // Every commit records what it rendered, then re-checks: a change that arrived while a delivered\n // update was rendering (and was therefore not queued again) is picked up here.\n useCommitEffect(() => {\n delivery.signal = signal;\n delivery.committed = version;\n delivery.awaitingCommit = false;\n delivery.rendering = false;\n delivery.check();\n });\n // Insertion effects run in every commit that includes the reader, hidden or not; layout effects\n // only in visible ones. A visible mount runs both in the same synchronous commit, so a reader\n // still unconnected once that commit's work is done was committed hidden.\n useInsertionEffect(() => {\n if (delivery.connected)\n return;\n queueMicrotask(() => {\n if (!delivery.connected)\n delivery.committedHidden = true;\n });\n }, [delivery]);\n useCommitEffect(() => {\n // Runs when the reader becomes visible: its first mount, a reveal, StrictMode's effect replay,\n // or a new signal (whose render may have happened while hidden).\n const revealing = delivery.connected || delivery.committedHidden;\n delivery.connected = true;\n delivery.committedHidden = false;\n delivery.mounted = true;\n delivery.subscribe(subscribe, manager);\n const pulled = delivery.pull();\n if (pulled === 2 /* PullResult.Threw */ || (pulled === 1 /* PullResult.Changed */ && revealing)) {\n // Render now, before this commit paints; a computation that threw rethrows from the render\n // to the nearest error boundary.\n delivery.awaitingCommit = true;\n delivery.forceUpdate();\n }\n else if (pulled === 1 /* PullResult.Changed */) {\n // A first mount: deliver a change between its render and this commit at default priority.\n delivery.check();\n }\n return () => {\n if (delivery.rendering) {\n // Hidden because its own render suspended: that render won't commit, so let the next\n // change through.\n delivery.awaitingCommit = false;\n }\n else {\n delivery.mounted = false;\n }\n };\n }, [subscribe, manager]);\n // Releases the subscription on unmount and on `<Activity mode=\"hidden\">`, but not on a Suspense\n // hide, which leaves passive effects connected.\n useEffect(() => () => delivery.release(), [delivery]);\n}\n","import React, { useMemo, useRef } from 'react';\nimport { getCurrentConsumer, setCurrentConsumer } from '../internals/consumer.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { runSignal } from '../internals/get.js';\nimport { isReactivePromise } from '../internals/async.js';\nimport { usePropsHash } from './props-hash.js';\nimport { useDeliveryMode, useStateDelivery, useStateDeliveryState } from './delivery.js';\nimport { isPromise, isThennable } from '../internals/utils/type-utils.js';\nimport { useScope } from './context.js';\nimport { addRenderListener, usePausableStore, usePauseSignalsManager } from './pause-signals-context.js';\nimport { holdLeaseUntilSettled, holdSuspendedLease, releaseAbandonedAttempt } from '../internals/lease.js';\n/** Inner element props to the user's element props, which survive React retrying a suspended mount. */\nconst elementPropsByInnerProps = new WeakMap();\n/** Per user element, suspended mount attempts still holding a pinned lease. */\nconst suspendedAttemptsByElement = new WeakMap();\nexport function createComponentElement(Inner, props) {\n const element = React.createElement(Inner, props);\n elementPropsByInnerProps.set(element.props, props);\n return element;\n}\n/**\n * React 19's `use()` throws an opaque `SuspenseException`, recognisable only by its message (or\n * error code when minified).\n */\nfunction isReactSuspenseException(error) {\n if (!(error instanceof Error))\n return false;\n const { message } = error;\n return message.startsWith('Suspense Exception') || /^Minified React error #(460|542)\\b/.test(message);\n}\n/**\n * Computes a `component()` signal during render. A suspended render pins its lease, so the relays\n * it reads stay active until React retries it. A later attempt at the same element releases\n * earlier attempts' pins once it has leased its own.\n */\nexport function readComponentSignal(signal, props) {\n const element = elementPropsByInnerProps.get(props);\n let attempts = element === undefined ? undefined : suspendedAttemptsByElement.get(element);\n try {\n runSignal(signal);\n const value = signal.value;\n attempts?.delete(signal);\n return value;\n }\n catch (error) {\n let pinned = true;\n if (error !== null && typeof error === 'object' && isThennable(error)) {\n holdLeaseUntilSettled(signal, error);\n }\n else if (isReactSuspenseException(error)) {\n holdSuspendedLease(signal);\n }\n else {\n pinned = false;\n }\n if (pinned && element !== undefined && signal._isLeased) {\n if (attempts === undefined) {\n attempts = new Set();\n suspendedAttemptsByElement.set(element, attempts);\n }\n attempts.add(signal);\n }\n throw error;\n }\n finally {\n if (attempts !== undefined) {\n for (const attempt of attempts) {\n if (attempt !== signal) {\n releaseAbandonedAttempt(attempt);\n attempts.delete(attempt);\n }\n }\n }\n }\n}\n/**\n * Remembers settled outcomes for yielded thenables so synchronous replay can inject\n * `next(value)` on later attempts without throwing the same fulfilled promise again (which\n * can strand Suspense). Identity must be stable across replays for a given logical await.\n */\nconst thenableOutcome = new WeakMap();\nfunction adoptYieldedThenable(thenable) {\n const expanded = thenable;\n if (expanded.status === 'fulfilled') {\n return expanded.value;\n }\n if (expanded.status === 'rejected') {\n throw expanded.reason;\n }\n if (expanded.status === 'pending') {\n throw thenable;\n }\n const hit = thenableOutcome.get(thenable);\n if (hit !== undefined) {\n if (hit.kind === 'rejected') {\n throw hit.reason;\n }\n return hit.value;\n }\n thenable.then(v => {\n thenableOutcome.set(thenable, { kind: 'fulfilled', value: v });\n }, e => {\n thenableOutcome.set(thenable, { kind: 'rejected', reason: e });\n });\n throw thenable;\n}\n/** Marked on the outer wrapper returned by `component()` for async (generator) definitions. */\nexport const SIGNALIUM_ASYNC_COMPONENT = Symbol.for('signalium.asyncComponent');\n/**\n * Call from wrappers around `use()` if you might receive a Signalium async component by mistake.\n * React's `use()` does not support Signalium async `component()` wrappers — render them under\n * `<Suspense>` and use `await` inside the component (after the async transform) instead.\n */\nexport function throwIfSignaliumAsyncComponentPassedToUse(resource) {\n if (typeof resource === 'function' &&\n resource[SIGNALIUM_ASYNC_COMPONENT] === true) {\n throw new Error('use() with a Signalium async `component()` is not supported. Render the component under <Suspense> and use await inside the component (compiled from async/await by the Signalium preset) instead.');\n }\n}\nexport { isGeneratorFunction, isAsyncFunctionWithoutTransform } from './component-shared.js';\n/**\n * Synchronous replay driver for async `component()` (authoring: `async`/`await`; Babel rewrites to a generator).\n *\n * Each React render starts a **new** iterator and walks it in a tight loop. Each `yield` (from\n * the compiled generator, originally `await`) is treated like `use(promise)` / Suspense: pending\n * thenables **throw** (interrupting the render); settled `ReactivePromise` values are injected via\n * `next(value)` and the loop continues in the same turn.\n *\n * **Hooks after a suspending `await`:** Same family as React `use()` — the throw aborts before\n * later code runs; the next attempt replays from the top. Do not use conditional hooks without\n * Suspense on paths that skip them.\n *\n * **Plain `Promise` / other thenables:** First time pending, **throw** for Suspense and register\n * the outcome in a `WeakMap` keyed by thenable identity. After settlement, the **same** object\n * replays inject the value (or throw the rejection) synchronously. Keep **stable thenable\n * identity** across replays (e.g. store in a ref). Thenables may expose React `use()`-style\n * `status` / `value` / `reason` for synchronous reads when present.\n *\n * **Generator `let` / `const`:** Reset every replay; durable state should use React hooks, refs, or\n * Signalium signals.\n *\n * `ownerSignal` is set as `CURRENT_CONSUMER` so reads inside the generator participate in the\n * reactive graph like `compute` in `runSignal`.\n */\nexport function runSyncReplayAsyncComponent(fn, props, ownerSignal) {\n const prevConsumer = getCurrentConsumer();\n try {\n setCurrentConsumer(ownerSignal);\n const iter = fn(props);\n let sent = undefined;\n for (;;) {\n const step = iter.next(sent);\n if (step.done) {\n return step.value;\n }\n const yielded = step.value;\n if (yielded !== null && typeof yielded === 'object' && isReactivePromise(yielded)) {\n const rp = yielded;\n if (rp.isRejected) {\n throw rp.error;\n }\n if (!rp.isReady) {\n const native = rp._promise;\n throw native !== undefined ? native : rp;\n }\n sent = rp.value;\n continue;\n }\n if (yielded !== null && typeof yielded === 'object' && (isPromise(yielded) || isThennable(yielded))) {\n sent = adoptYieldedThenable(yielded);\n continue;\n }\n sent = yielded;\n }\n }\n finally {\n setCurrentConsumer(prevConsumer);\n }\n}\n/**\n * Async Signalium `component()`: one lazy reactive signal per **instance** (same as sync\n * `component()`), outer `useMemo` keyed by `hashProps(props)`. No definition-scoped props map.\n */\nexport function createAsyncComponentWrapper(fn, options) {\n const deliveryOverride = options?.delivery;\n const Inner = (props) => {\n const scope = useScope();\n const manager = usePauseSignalsManager();\n const delivery = useDeliveryMode(deliveryOverride);\n const fnSignalRef = useRef(undefined);\n const propsRef = useRef(props);\n propsRef.current = props;\n let sig = fnSignalRef.current;\n if (sig === undefined) {\n let owned;\n owned = createReactiveSignal({\n compute: () => runSyncReplayAsyncComponent(fn, propsRef.current, owned),\n equals: () => false,\n isRelay: false,\n tracer: undefined,\n }, [], undefined, scope);\n owned._isLazy = true;\n fnSignalRef.current = sig = owned;\n }\n // Same ordering as sync `component()`: watch before computing (so relays read during the\n // computation activate), and compute + settle the signal before the snapshot is read so the\n // mount render's snapshot is stable (no forced re-render / sync redo).\n const subscribe = addRenderListener(sig, manager);\n // The delivery mode is fixed for the lifetime of the instance, so the hook order is stable.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const stateDelivery = delivery === 'state' ? useStateDeliveryState(sig) : null;\n const value = readComponentSignal(sig, props);\n if (stateDelivery !== null) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStateDelivery(stateDelivery, sig, subscribe, sig.updatedCount, manager);\n }\n else {\n const getSnapshot = () => sig.updatedCount;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n usePausableStore(manager, sig, subscribe, getSnapshot);\n }\n return value;\n };\n const Outer = (props) => {\n const hash = usePropsHash(props);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => createComponentElement(Inner, props), [hash]);\n };\n Object.defineProperty(Outer, SIGNALIUM_ASYNC_COMPONENT, { value: true, enumerable: false });\n return Outer;\n}\n","import * as React from 'react';\nimport { useMemo, useRef } from 'react';\nimport { useScope } from './context.js';\nimport { addRenderListener, usePausableStore, usePauseSignalsManager } from './pause-signals-context.js';\nimport { setRequestScopeGetter, SignalScope } from '../internals/contexts.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { usePropsHash } from './props-hash.js';\nimport { useDeliveryMode, useStateDelivery, useStateDeliveryState } from './delivery.js';\nimport { createAsyncComponentWrapper, createComponentElement, readComponentSignal } from './async-component.js';\nimport { isAsyncFunctionWithoutTransform, isGeneratorFunction, createServerAsyncComponentWrapper, } from './component-shared.js';\nexport { isAsyncFunctionWithoutTransform, runSyncReplayAsyncComponent, SIGNALIUM_ASYNC_COMPONENT, throwIfSignaliumAsyncComponentPassedToUse, } from './async-component.js';\n/**\n * Auto-install per-request scoping for SSR of client components.\n *\n * `setupRscRequestScope()` only affects the RSC bundle; Next.js (and similar frameworks) render\n * client components in a separate SSR module graph. This ensures the SSR bundle also gets a\n * fresh {@link SignalScope} per render via `React.cache` (React 19+).\n */\nlet _ssrScopeInitialized = false;\nfunction ensureSsrScope() {\n if (_ssrScopeInitialized || typeof window !== 'undefined')\n return;\n _ssrScopeInitialized = true;\n const cache = React.cache;\n if (typeof cache === 'function') {\n const getScope = cache(() => new SignalScope([]));\n setRequestScopeGetter(() => getScope());\n }\n}\nexport default function component(fn, options) {\n ensureSsrScope();\n if (isAsyncFunctionWithoutTransform(fn)) {\n throw new Error('signalium: `component(async (props) => { await ... })` requires the Signalium Babel preset (async transform).');\n }\n if (isGeneratorFunction(fn)) {\n if (typeof window === 'undefined') {\n return createServerAsyncComponentWrapper(fn);\n }\n return createAsyncComponentWrapper(fn, options);\n }\n // Async `component(async () => { await ... })` is rewritten to a generator by the Babel preset.\n // Remaining callers are synchronous render functions only (see Promise overload for TS authoring).\n const syncFn = fn;\n const deliveryOverride = options?.delivery;\n const Component = (props) => {\n const scope = useScope();\n const manager = usePauseSignalsManager();\n const delivery = useDeliveryMode(deliveryOverride);\n const fnSignalRef = useRef(undefined);\n const propsRef = useRef(props);\n propsRef.current = props;\n let signal = fnSignalRef.current;\n if (signal === undefined) {\n const created = createReactiveSignal({\n compute: () => syncFn(propsRef.current),\n equals: () => false,\n isRelay: false,\n tracer: undefined,\n }, [], undefined, scope);\n created._isLazy = true;\n fnSignalRef.current = signal = created;\n }\n // Mark the signal as a listener (and watch it unless paused) before computing, so relays read\n // during the computation are activated.\n const subscribe = addRenderListener(signal, manager);\n // The delivery mode is fixed for the lifetime of the instance, so the hook order is stable.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const stateDelivery = delivery === 'state' ? useStateDeliveryState(signal) : null;\n // Compute and settle the signal BEFORE `useSyncExternalStore` reads the snapshot. Reading\n // `value` runs `checkSignal`, which bumps `updatedCount` when the lazy signal was dirty (always\n // the case on mount). If the snapshot were read first, React would see it change after render\n // and re-render: synchronously after every mount, and as a sync redo of mounts inside a\n // transition.\n const value = readComponentSignal(signal, props);\n if (stateDelivery !== null) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStateDelivery(stateDelivery, signal, subscribe, signal.updatedCount, manager);\n }\n else {\n const getSnapshot = () => signal.updatedCount;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n usePausableStore(manager, signal, subscribe, getSnapshot);\n }\n return value;\n };\n return (props) => {\n const hash = usePropsHash(props);\n // Renders Comp only when hash changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => createComponentElement(Component, props), [hash]);\n };\n}\n","import { useRef } from 'react';\nimport { signal } from '../index.js';\nexport function useSignal(value, opts) {\n const ref = useRef(undefined);\n if (!ref.current) {\n ref.current = signal(value, opts);\n }\n return ref.current;\n}\n","import { useRef } from 'react';\nimport { getReactiveFnAndDefinition, reactiveSignal } from '../internals/core-api.js';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nimport { snapshot } from '../internals/utils/snapshot.js';\nimport { useScope } from './context.js';\nimport { addRenderListener, usePausableStore, usePauseSignalsManager } from './pause-signals-context.js';\nimport { getGlobalScope } from '../internals/contexts.js';\nimport { useDeliveryMode, useStateDelivery, useStateDeliveryState } from './delivery.js';\nfunction useSignalWithSuspension(signal, options) {\n const manager = usePauseSignalsManager();\n const delivery = useDeliveryMode(options?.delivery);\n const subscribe = addRenderListener(signal, manager);\n // The delivery mode is fixed for the lifetime of the instance, so the hook order is stable.\n if (delivery === 'state') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const stateDelivery = useStateDeliveryState(signal);\n const value = signal.value;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStateDelivery(stateDelivery, signal, subscribe, signal.updatedCount, manager);\n return value;\n }\n const getSnapshot = () => signal.value;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return usePausableStore(manager, signal, subscribe, getSnapshot);\n}\n/**\n * Subscribe to a reactive thunk without structural cloning. The thunk's\n * `ReactiveDefinition` is memoized by fn identity in a `WeakMap`, so a\n * memoized thunk (via `useCallback` or the Signalium Babel preset) reuses the\n * same scope-cached signal across renders.\n *\n * This is a minimal wrapper: the returned value is whatever the thunk\n * returned, by reference. In particular, when the thunk returns a\n * `ReactivePromise`, re-renders only fire when the underlying signal itself\n * re-evaluates (e.g. a new promise replaces the old one) — not when the\n * existing promise transitions from pending to resolved. If you need promise\n * state transitions to drive React, read its fields inside the thunk (e.g.\n * `useReactiveShallow(() => { const p = fetchThing(); return { value: p.value,\n * isPending: p.isPending }; })`) or use {@link useReactive} for the\n * structurally-shared snapshot that handles this automatically.\n */\nexport function useReactiveShallow(fn, options) {\n if (IS_DEV && getCurrentConsumer()) {\n throw new Error('signalium: `useReactiveShallow` cannot be called inside a reactive function. ' +\n 'Call your reactive function directly instead — it already participates in the signal graph.');\n }\n const [, def] = getReactiveFnAndDefinition(fn);\n const scope = useScope() ?? getGlobalScope();\n const signal = scope.get(def, []);\n return useSignalWithSuspension(signal, options);\n}\n/**\n * Subscribe to a reactive thunk and return a structurally-shared snapshot of\n * its value. Nested objects/arrays/Maps/Sets are deep-cloned; unchanged\n * subtrees keep the same reference, so React's referential equality works as\n * expected. ReactivePromise values are flattened to plain objects.\n *\n * This is the default hook for reading reactive values inside a React\n * component — it gives you safe equality semantics at the React boundary.\n * Use {@link useReactiveShallow} if you know you don't need structural\n * sharing.\n */\nexport function useReactive(fn, options) {\n if (IS_DEV && getCurrentConsumer()) {\n throw new Error('signalium: `useReactive` cannot be called inside a reactive function. ' +\n 'Call your reactive function directly instead — it already participates in the signal graph.');\n }\n const manager = usePauseSignalsManager();\n const delivery = useDeliveryMode(options?.delivery);\n const scope = useScope() ?? getGlobalScope();\n const innerSignalRef = useRef(undefined);\n const cloneSignalRef = useRef(undefined);\n const valueRef = useRef(undefined);\n const [, def] = getReactiveFnAndDefinition(fn);\n const signal = scope.get(def, []);\n if (innerSignalRef.current !== signal) {\n innerSignalRef.current = signal;\n valueRef.current = undefined;\n cloneSignalRef.current = reactiveSignal(() => {\n const next = snapshot(signal.value, valueRef.current);\n valueRef.current = next;\n return next;\n });\n }\n const cloneSignal = cloneSignalRef.current;\n const subscribe = addRenderListener(cloneSignal, manager);\n // The delivery mode is fixed for the lifetime of the instance, so the hook order is stable.\n if (delivery === 'state') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const stateDelivery = useStateDeliveryState(cloneSignal);\n const value = cloneSignal.value;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStateDelivery(stateDelivery, cloneSignal, subscribe, cloneSignal.updatedCount, manager);\n return value;\n }\n const getSnapshot = () => cloneSignal.value;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return usePausableStore(manager, cloneSignal, subscribe, getSnapshot);\n}\n/**\n * @deprecated Use {@link useReactive} instead. `useReactive` is now\n * deep-by-default; `useReactiveDeep` is a thin alias kept for back-compat and\n * will be removed in a future major release.\n */\nexport function useReactiveDeep(fn, options) {\n if (IS_DEV) {\n warnUseReactiveDeepOnce();\n }\n return useReactive(fn, options);\n}\nlet _useReactiveDeepWarned = false;\nfunction warnUseReactiveDeepOnce() {\n if (_useReactiveDeepWarned)\n return;\n _useReactiveDeepWarned = true;\n console.warn('[signalium] `useReactiveDeep` is deprecated; use `useReactive` instead. ' +\n '`useReactive` is now deep-by-default. Use `useReactiveShallow` to opt out of structural snapshots.');\n}\n"],"names":["createContext","useReactContext","getCurrentConsumer","useContext","getGlobalScope","useMemo","SignalScope","hashValue","_jsx","useRef","useEffect","useSyncExternalStore","getObjectHash","hashObjectKeys","ARRAY_SEED","mixHash","finalizeHash","hash","getReactDelivery","useLayoutEffect","checkSignal","scheduleReactDelivery","runBatch","useReducer","useState","useInsertionEffect","runSignal","isThennable","holdLeaseUntilSettled","holdSuspendedLease","releaseAbandonedAttempt","setCurrentConsumer","isReactivePromise","isPromise","createReactiveSignal","React","setRequestScopeGetter","isAsyncFunctionWithoutTransform","isGeneratorFunction","createServerAsyncComponentWrapper","signal","getReactiveFnAndDefinition","reactiveSignal","snapshot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,eAAeA,MAAAA,cAAc,MAAS;AAC5C,SAAS,WAAW;AACvB,SAAOC,MAAAA,WAAgB,YAAY;AACvC;AACO,SAAS,WAAW,SAAS;AAEhC,QAAM,QAAQC,MAAAA,sBAAsB,SAAS,SAAQ;AACrD,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,6EAA6E;AAAA,EACjG;AACA,SAAO,MAAM,WAAW,OAAO,KAAK,QAAQ;AAChD;ACRO,SAAS,gBAAgB,EAAE,UAAU,WAAW,CAAA,GAAI,UAAU,QAAS;AAC1E,QAAM,cAAcC,MAAAA,WAAW,YAAY,KAAKC,MAAAA,eAAc;AAC9D,QAAM,QAAQC,MAAAA;AAAAA,IAAQ,MAAM,IAAIC,MAAAA,YAAY,UAAU,UAAU,cAAc,MAAS;AAAA;AAAA,IAEvF,CAAC,aAAa,SAASC,gBAAU,QAAQ,CAAC;AAAA,EAAC;AAC3C,SAAOC,WAAAA,IAAK,aAAa,UAAU,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AAY,IAAI,OAAO;AAClC;AACA,IAAI,yBAAyB;AAC7B,SAAS,0BAA0B;AAC/B,MAAI;AACA;AACJ,2BAAyB;AACzB,UAAQ,KAAK,4KAC2F;AAC5G;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const componentShared = require("../component-shared-DzjqSRY-.js");
4
- function component(fn) {
3
+ const componentShared = require("../component-shared-CU7qN_Ks.js");
4
+ function component(fn, _options) {
5
5
  if (componentShared.isAsyncFunctionWithoutTransform(fn)) {
6
6
  throw new Error("signalium: `component(async (props) => { await ... })` requires the Signalium Babel preset (async transform).");
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.js","sources":["../../../../.tsc-out/react/component-server.js"],"sourcesContent":["import { isGeneratorFunction, isAsyncFunctionWithoutTransform, createServerAsyncComponentWrapper, createServerSyncComponentWrapper, } from './component-shared.js';\nexport default function component(fn) {\n if (isAsyncFunctionWithoutTransform(fn)) {\n throw new Error('signalium: `component(async (props) => { await ... })` requires the Signalium Babel preset (async transform).');\n }\n if (isGeneratorFunction(fn)) {\n return createServerAsyncComponentWrapper(fn);\n }\n return createServerSyncComponentWrapper(fn);\n}\n"],"names":["isAsyncFunctionWithoutTransform","isGeneratorFunction","createServerAsyncComponentWrapper","createServerSyncComponentWrapper"],"mappings":";;;AACe,SAAS,UAAU,IAAI;AAClC,MAAIA,gBAAAA,gCAAgC,EAAE,GAAG;AACrC,UAAM,IAAI,MAAM,+GAA+G;AAAA,EACnI;AACA,MAAIC,gBAAAA,oBAAoB,EAAE,GAAG;AACzB,WAAOC,gBAAAA,kCAAkC,EAAE;AAAA,EAC/C;AACA,SAAOC,gBAAAA,iCAAiC,EAAE;AAC9C;;"}
1
+ {"version":3,"file":"index.server.js","sources":["../../../../.tsc-out/react/component-server.js"],"sourcesContent":["import { isGeneratorFunction, isAsyncFunctionWithoutTransform, createServerAsyncComponentWrapper, createServerSyncComponentWrapper, } from './component-shared.js';\nexport default function component(fn, _options) {\n if (isAsyncFunctionWithoutTransform(fn)) {\n throw new Error('signalium: `component(async (props) => { await ... })` requires the Signalium Babel preset (async transform).');\n }\n if (isGeneratorFunction(fn)) {\n return createServerAsyncComponentWrapper(fn);\n }\n return createServerSyncComponentWrapper(fn);\n}\n"],"names":["isAsyncFunctionWithoutTransform","isGeneratorFunction","createServerAsyncComponentWrapper","createServerSyncComponentWrapper"],"mappings":";;;AACe,SAAS,UAAU,IAAI,UAAU;AAC5C,MAAIA,gBAAAA,gCAAgC,EAAE,GAAG;AACrC,UAAM,IAAI,MAAM,+GAA+G;AAAA,EACnI;AACA,MAAIC,gBAAAA,oBAAoB,EAAE,GAAG;AACzB,WAAOC,gBAAAA,kCAAkC,EAAE;AAAA,EAC/C;AACA,SAAOC,gBAAAA,iCAAiC,EAAE;AAC9C;;"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
- const debug = require("../debug-CDy1L3Id.js");
4
+ const debug = require("../debug-BS6RdX4D.js");
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
7
  if (e) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const debug = require("./debug-CDy1L3Id.js");
2
+ const debug = require("./debug-BS6RdX4D.js");
3
3
  const DERIVED_DEFINITION_MAP = /* @__PURE__ */ new WeakMap();
4
4
  function getReactiveFnAndDefinition(fn, opts) {
5
5
  let fnAndDef = DERIVED_DEFINITION_MAP.get(fn);
@@ -153,6 +153,8 @@ exports.reactiveSignal = reactiveSignal;
153
153
  exports.registerCustomSnapshot = registerCustomSnapshot;
154
154
  exports.relay = relay;
155
155
  exports.snapshot = snapshot;
156
+ exports.snapshotArray = snapshotArray;
157
+ exports.snapshotPlainObject = snapshotPlainObject;
156
158
  exports.task = task;
157
159
  exports.watcher = watcher;
158
- //# sourceMappingURL=snapshot-D8Ydfj9E.js.map
160
+ //# sourceMappingURL=snapshot-BLa9mv8h.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-BLa9mv8h.js","sources":["../../../.tsc-out/internals/core-api.js","../../../.tsc-out/internals/utils/snapshot.js"],"sourcesContent":["import { getCurrentScope, getScopeOwner, SignalScope } from './contexts.js';\nimport { createReactiveDefinition, createReactiveSignal, } from './reactive.js';\nimport { createRelay, createTask } from './async.js';\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const DERIVED_DEFINITION_MAP = new WeakMap();\nexport function getReactiveFnAndDefinition(fn, opts) {\n let fnAndDef = DERIVED_DEFINITION_MAP.get(fn);\n if (!fnAndDef) {\n const def = createReactiveDefinition(opts?.id, opts?.desc, fn, opts?.equals, false, opts?.paramKey, undefined);\n const defScope = getCurrentScope();\n const reactiveFn = (...args) => {\n const scope = getCurrentScope(defScope);\n const signal = scope.get(def, args);\n return signal.value;\n };\n fnAndDef = [reactiveFn, def];\n DERIVED_DEFINITION_MAP.set(fn, fnAndDef);\n }\n return fnAndDef;\n}\nexport function reactive(fn, opts) {\n return getReactiveFnAndDefinition(fn, opts)[0];\n}\nexport const reactiveMethod = (owner, fn, opts) => {\n const def = createReactiveDefinition(opts?.id, opts?.desc, fn, opts?.equals, false, opts?.paramKey, undefined);\n const reactiveFn = (...args) => {\n return getScopeOwner(owner).get(def, args).value;\n };\n DERIVED_DEFINITION_MAP.set(reactiveFn, [reactiveFn, def]);\n return reactiveFn;\n};\nexport function relay(activate, opts) {\n const scope = getCurrentScope();\n return createRelay(activate, scope, opts);\n}\nexport const task = (fn, opts) => {\n const scope = getCurrentScope();\n return createTask(fn, scope, opts);\n};\nexport function watcher(fn, opts) {\n const def = createReactiveDefinition(opts?.id, opts?.desc, fn, opts?.equals, false, undefined, opts?.tracer);\n const scope = opts?.isolate ? new SignalScope([]) : getCurrentScope();\n return createReactiveSignal(def, undefined, undefined, scope);\n}\n/**\n * Creates a reactive signal from a compute function. This is useful for when you\n * want to create a signal that does not receive parameters, but is still reactive.\n *\n * @param compute\n * @param opts\n * @returns\n */\nexport const reactiveSignal = (compute, opts) => {\n const def = createReactiveDefinition(opts?.id, opts?.desc, compute, opts?.equals, false, undefined, undefined);\n const scope = opts?.isolate ? new SignalScope([]) : getCurrentScope();\n return createReactiveSignal(def, undefined, undefined, scope);\n};\n","import { isReactivePromise } from '../async.js';\nconst getProto = Object.getPrototypeOf;\nexport function snapshotArray(current, prev, snap) {\n const prevArr = Array.isArray(prev) ? prev : undefined;\n let changed = !prevArr || prevArr.length !== current.length;\n const result = new Array(current.length);\n for (let i = 0; i < current.length; i++) {\n result[i] = snap(current[i], prevArr?.[i]);\n if (!changed && result[i] !== prevArr[i]) {\n changed = true;\n }\n }\n return changed ? result : prevArr;\n}\nexport function snapshotPlainObject(current, prev, snap) {\n const prevObj = prev !== null && prev !== undefined && typeof prev === 'object' && !Array.isArray(prev)\n ? prev\n : undefined;\n const keys = Object.keys(current);\n let changed = !prevObj || Object.keys(prevObj).length !== keys.length;\n const result = {};\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n result[key] = snap(current[key], prevObj?.[key]);\n if (!changed && result[key] !== prevObj[key]) {\n changed = true;\n }\n }\n return changed ? result : prevObj;\n}\nfunction snapshotReactivePromise(current, prev, snap) {\n const prevObj = prev !== null && prev !== undefined && typeof prev === 'object' ? prev : undefined;\n const value = snap(current.value, prevObj?.value);\n const error = current.error;\n const isPending = current.isPending;\n const isRejected = current.isRejected;\n const isResolved = current.isResolved;\n const isReady = current.isReady;\n const isSettled = current.isSettled;\n // `run` is set once in the task constructor and never mutated, so its identity\n // is stable for the lifetime of the underlying ReactivePromiseImpl. Carrying\n // it on the snapshot lets consumers (e.g. React components reading a task via\n // `useReactive`) invoke `result.run(...)` against the live task. For non-task\n // promises this is `undefined`; we still assign the slot so the resulting\n // object's hidden class is stable across task and non-task snapshots.\n const run = current.run;\n if (prevObj &&\n value === prevObj.value &&\n error === prevObj.error &&\n isPending === prevObj.isPending &&\n isRejected === prevObj.isRejected &&\n isResolved === prevObj.isResolved &&\n isReady === prevObj.isReady &&\n isSettled === prevObj.isSettled &&\n run === prevObj.run) {\n return prevObj;\n }\n return { value, error, isPending, isRejected, isResolved, isReady, isSettled, run };\n}\nfunction snapshotMap(current, prev, snap) {\n const prevMap = prev instanceof Map ? prev : undefined;\n let changed = !prevMap || prevMap.size !== current.size;\n const result = new Map();\n for (const [key, val] of current) {\n const snapped = snap(val, prevMap?.get(key));\n result.set(key, snapped);\n if (!changed && snapped !== prevMap.get(key)) {\n changed = true;\n }\n }\n return changed ? result : prevMap;\n}\nfunction snapshotSet(current, prev, _snap) {\n const prevSet = prev instanceof Set ? prev : undefined;\n let changed = !prevSet || prevSet.size !== current.size;\n const result = new Set();\n for (const val of current) {\n const snapped = snapshot(val, prevSet?.has(val) ? val : undefined);\n result.add(snapped);\n if (!changed && !prevSet.has(snapped)) {\n changed = true;\n }\n }\n return changed ? result : prevSet;\n}\n/**\n * Built-in handlers for plain structural types. Matched by exact prototype\n * only — subclasses of `Object` / `Array` / `Map` / `Set` are NOT routed\n * through these handlers (they fall through and, if no custom ancestor is\n * registered, are returned as-is). We use a Map here rather than installing\n * a symbol property on the built-in prototypes, because mutating built-in\n * prototypes (even with a symbol key) changes their hidden class and\n * invalidates V8's fast-path inline caches for every plain object / array\n * in the program.\n */\nconst BUILTIN_PROTO_TO_SNAPSHOT = new Map([\n [Object.prototype, snapshotPlainObject],\n [Array.prototype, snapshotArray],\n [Map.prototype, snapshotMap],\n [Set.prototype, snapshotSet],\n [null, snapshotPlainObject],\n]);\n/**\n * Custom registrations are stored as a non-enumerable symbol property on the\n * class prototype. JS prototype lookup walks the chain natively, so subclass\n * inheritance and override-by-redefinition are free — no resolver, no cache,\n * no invalidation. The symbol is module-private (created with `Symbol()`,\n * not `Symbol.for()`), so it cannot collide with anything else and cannot\n * be addressed by user code.\n */\nconst SNAPSHOT_HANDLER = Symbol('signalium.snapshot.handler');\n/**\n * Register a custom snapshot function for instances of a class.\n * The function receives the current value, the previous snapshot (or undefined),\n * and the recursive `snapshot` function for snapshotting nested values.\n *\n * Subclasses inherit the handler automatically via prototype lookup, so\n * registering once on a base class applies to all descendants. A descendant\n * can override by registering its own handler.\n *\n * Return `prev` when nothing has changed to preserve reference stability.\n *\n * @example\n * ```ts\n * registerCustomSnapshot(MyEntity, (current, prev, snapshot) => {\n * const name = snapshot(current.name, prev?.name);\n * const age = current.age;\n * if (prev && name === prev.name && age === prev.age) return prev;\n * return { name, age };\n * });\n * ```\n */\nexport const registerCustomSnapshot = (ctor, snapshotFn) => {\n // Use defineProperty so the handler is non-enumerable (it shouldn't show up\n // in `Reflect.ownKeys` walks any more than necessary) and so re-registration\n // overwrites cleanly even if a subclass has shadowed it.\n Object.defineProperty(ctor.prototype, SNAPSHOT_HANDLER, {\n value: snapshotFn,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n};\n/**\n * Recursively snapshot a value with structural sharing.\n *\n * - Plain objects and arrays are deep-cloned; unchanged subtrees keep the same reference.\n * - ReactivePromise instances are read (establishing deps) and flattened to a plain object.\n * - Class instances are returned as-is unless a custom handler is registered\n * for the class or any of its ancestors via `registerCustomSnapshot`.\n * - Primitives are returned directly.\n */\nexport function snapshot(currentValue, prevValue) {\n if (currentValue === null || typeof currentValue !== 'object') {\n return currentValue;\n }\n if (isReactivePromise(currentValue)) {\n return snapshotReactivePromise(currentValue, prevValue, snapshot);\n }\n // Custom registrations check first: native prototype lookup walks the chain\n // for us, so subclasses inherit their ancestor's handler with no extra work.\n const customHandler = currentValue[SNAPSHOT_HANDLER];\n if (customHandler !== undefined) {\n return customHandler(currentValue, prevValue, snapshot);\n }\n // Built-in handlers are looked up by exact prototype only.\n const builtIn = BUILTIN_PROTO_TO_SNAPSHOT.get(getProto(currentValue));\n if (builtIn !== undefined) {\n return builtIn(currentValue, prevValue, snapshot);\n }\n return currentValue;\n}\n"],"names":["createReactiveDef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YAAY,CAAC;AACpE,MAAI,YAAY,QAAW;AACvB,WAAO,QAAQ,cAAc,WAAW,QAAQ;AAAA,EACpD;AACA,SAAO;AACX;;;;;;;;;;;;"}
@@ -29,6 +29,7 @@ function createSignaliumAsyncTransform(api, opts) {
29
29
  ["relay", ["signalium"]],
30
30
  ["task", ["signalium"]],
31
31
  ["watcher", ["signalium"]],
32
+ ["retain", ["signalium", "signalium/utils"]],
32
33
  ["useReactive", ["signalium/react"]],
33
34
  ["useReactiveShallow", ["signalium/react"]],
34
35
  ["useReactiveDeep", ["signalium/react"]]
@@ -119,6 +120,7 @@ function createSignaliumCallbackTransform(api, opts) {
119
120
  ["relay", ["signalium"]],
120
121
  ["task", ["signalium"]],
121
122
  ["watcher", ["signalium"]],
123
+ ["retain", ["signalium", "signalium/utils"]],
122
124
  ["useReactive", ["signalium/react"]],
123
125
  ["useReactiveShallow", ["signalium/react"]],
124
126
  ["useReactiveDeep", ["signalium/react"]]
@@ -436,7 +438,8 @@ function createSignaliumPromiseMethodsTransform(api, opts) {
436
438
  ["reactiveMethod", ["signalium"]],
437
439
  ["relay", ["signalium"]],
438
440
  ["task", ["signalium"]],
439
- ["watcher", ["signalium"]]
441
+ ["watcher", ["signalium"]],
442
+ ["retain", ["signalium", "signalium/utils"]]
440
443
  ], opts?.transformedImports, opts?.importPaths);
441
444
  const t = api.types;
442
445
  const promiseImportPath = opts?.promiseImportPath ?? "signalium";
@@ -675,7 +678,7 @@ function createSignaliumUseReactiveTransform(api, opts) {
675
678
  if (!isTargetCall(callPath))
676
679
  return;
677
680
  const args = callPath.get("arguments");
678
- if (args.length !== 1)
681
+ if (args.length === 0)
679
682
  return;
680
683
  let fnPath = args[0];
681
684
  while (fnPath.isTSAsExpression() || fnPath.isTSSatisfiesExpression?.() || fnPath.isTSNonNullExpression() || fnPath.isTSInstantiationExpression?.()) {