signalium 3.0.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/dist/cjs/development/{component-shared-Cug2Y5YZ.js → component-shared-BjwFh5Jq.js} +2 -2
- package/dist/cjs/development/{component-shared-Cug2Y5YZ.js.map → component-shared-BjwFh5Jq.js.map} +1 -1
- package/dist/cjs/development/config-D6wyrhrW.js +58 -0
- package/dist/cjs/development/config-D6wyrhrW.js.map +1 -0
- package/dist/cjs/development/config.js +1 -1
- package/dist/cjs/development/{debug-C46WDxhL.js → debug-CbAX7VeM.js} +260 -43
- package/dist/cjs/development/debug-CbAX7VeM.js.map +1 -0
- package/dist/cjs/development/debug.js +3 -1
- package/dist/cjs/development/debug.js.map +1 -1
- package/dist/cjs/development/index.js +3 -2
- package/dist/cjs/development/index.js.map +1 -1
- package/dist/cjs/development/react/index.js +399 -52
- package/dist/cjs/development/react/index.js.map +1 -1
- package/dist/cjs/development/react/index.server.js +2 -2
- package/dist/cjs/development/react/index.server.js.map +1 -1
- package/dist/cjs/development/react/server.js +1 -1
- package/dist/cjs/development/{snapshot-CbZ6IH3B.js → snapshot-BTMVSd8Y.js} +4 -2
- package/dist/cjs/development/snapshot-BTMVSd8Y.js.map +1 -0
- package/dist/cjs/development/transform/index.js +5 -2
- package/dist/cjs/development/transform/index.js.map +1 -1
- package/dist/cjs/development/utils.js +34 -2
- package/dist/cjs/development/utils.js.map +1 -1
- package/dist/cjs/production/{component-shared-D0J85PUi.js → component-shared-CcxyLg4p.js} +2 -2
- package/dist/cjs/production/{component-shared-D0J85PUi.js.map → component-shared-CcxyLg4p.js.map} +1 -1
- package/dist/cjs/production/config-BHvmcsLQ.js +52 -0
- package/dist/cjs/production/config-BHvmcsLQ.js.map +1 -0
- package/dist/cjs/production/config.js +1 -1
- package/dist/cjs/production/{contexts-CM3QLfV8.js → contexts-waczQzHZ.js} +260 -43
- package/dist/cjs/production/contexts-waczQzHZ.js.map +1 -0
- package/dist/cjs/production/debug.js +3 -1
- package/dist/cjs/production/debug.js.map +1 -1
- package/dist/cjs/production/index.js +3 -2
- package/dist/cjs/production/index.js.map +1 -1
- package/dist/cjs/production/react/index.js +399 -52
- package/dist/cjs/production/react/index.js.map +1 -1
- package/dist/cjs/production/react/index.server.js +2 -2
- package/dist/cjs/production/react/index.server.js.map +1 -1
- package/dist/cjs/production/react/server.js +1 -1
- package/dist/cjs/production/{snapshot-DWwH7_9y.js → snapshot-7264bWj1.js} +4 -2
- package/dist/cjs/production/snapshot-7264bWj1.js.map +1 -0
- package/dist/cjs/production/transform/index.js +5 -2
- package/dist/cjs/production/transform/index.js.map +1 -1
- package/dist/cjs/production/utils.js +34 -2
- package/dist/cjs/production/utils.js.map +1 -1
- package/dist/esm/config.d.ts +1 -1
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/debug.d.ts +1 -0
- package/dist/esm/debug.d.ts.map +1 -1
- package/dist/esm/development/{component-shared-CLSmdnGU.js → component-shared-B3Q6mIzY.js} +2 -2
- package/dist/esm/development/{component-shared-CLSmdnGU.js.map → component-shared-B3Q6mIzY.js.map} +1 -1
- package/dist/esm/development/config-CQLKpPRj.js +59 -0
- package/dist/esm/development/config-CQLKpPRj.js.map +1 -0
- package/dist/esm/development/config.js +2 -2
- package/dist/esm/development/{debug-BTLbgTPK.js → debug-C3HD8WcT.js} +288 -71
- package/dist/esm/development/debug-C3HD8WcT.js.map +1 -0
- package/dist/esm/development/debug.js +12 -10
- package/dist/esm/development/index.js +18 -17
- package/dist/esm/development/react/index.js +400 -53
- package/dist/esm/development/react/index.js.map +1 -1
- package/dist/esm/development/react/index.server.js +2 -2
- package/dist/esm/development/react/index.server.js.map +1 -1
- package/dist/esm/development/react/server.js +1 -1
- package/dist/esm/development/{snapshot-CkndI4Hh.js → snapshot-CCKlBy-y.js} +7 -5
- package/dist/esm/development/snapshot-CCKlBy-y.js.map +1 -0
- package/dist/esm/development/transform/index.js +5 -2
- package/dist/esm/development/transform/index.js.map +1 -1
- package/dist/esm/development/utils.js +38 -6
- package/dist/esm/development/utils.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/async.d.ts.map +1 -1
- package/dist/esm/internals/config.d.ts +40 -0
- package/dist/esm/internals/config.d.ts.map +1 -1
- package/dist/esm/internals/lease.d.ts +30 -0
- package/dist/esm/internals/lease.d.ts.map +1 -0
- package/dist/esm/internals/reactive.d.ts +18 -1
- package/dist/esm/internals/reactive.d.ts.map +1 -1
- package/dist/esm/internals/scheduling.d.ts +2 -1
- package/dist/esm/internals/scheduling.d.ts.map +1 -1
- package/dist/esm/internals/utils/hash.d.ts +7 -0
- package/dist/esm/internals/utils/hash.d.ts.map +1 -1
- package/dist/esm/internals/utils/snapshot.d.ts +2 -0
- package/dist/esm/internals/utils/snapshot.d.ts.map +1 -1
- package/dist/esm/internals/watch.d.ts +3 -2
- package/dist/esm/internals/watch.d.ts.map +1 -1
- package/dist/esm/production/{component-shared-Dva0S5e3.js → component-shared-CycOXiis.js} +2 -2
- package/dist/esm/production/{component-shared-Dva0S5e3.js.map → component-shared-CycOXiis.js.map} +1 -1
- package/dist/esm/production/config-BhtwQYAN.js +53 -0
- package/dist/esm/production/config-BhtwQYAN.js.map +1 -0
- package/dist/esm/production/config.js +2 -2
- package/dist/esm/production/{contexts-FxCndlvf.js → contexts-ry5lvNSx.js} +291 -74
- package/dist/esm/production/contexts-ry5lvNSx.js.map +1 -0
- package/dist/esm/production/debug.js +3 -1
- package/dist/esm/production/index.js +19 -18
- package/dist/esm/production/react/index.js +400 -53
- package/dist/esm/production/react/index.js.map +1 -1
- package/dist/esm/production/react/index.server.js +2 -2
- package/dist/esm/production/react/index.server.js.map +1 -1
- package/dist/esm/production/react/server.js +1 -1
- package/dist/esm/production/{snapshot-CdCaJJ0L.js → snapshot-1d_HVP3L.js} +7 -5
- package/dist/esm/production/snapshot-1d_HVP3L.js.map +1 -0
- package/dist/esm/production/transform/index.js +5 -2
- package/dist/esm/production/transform/index.js.map +1 -1
- package/dist/esm/production/utils.js +39 -7
- package/dist/esm/production/utils.js.map +1 -1
- package/dist/esm/react/async-component.d.ts +10 -2
- package/dist/esm/react/async-component.d.ts.map +1 -1
- package/dist/esm/react/component-server.d.ts +6 -2
- package/dist/esm/react/component-server.d.ts.map +1 -1
- package/dist/esm/react/component.d.ts +5 -2
- package/dist/esm/react/component.d.ts.map +1 -1
- package/dist/esm/react/delivery.d.ts +107 -0
- package/dist/esm/react/delivery.d.ts.map +1 -0
- package/dist/esm/react/index.d.ts +3 -2
- package/dist/esm/react/index.d.ts.map +1 -1
- package/dist/esm/react/pause-signals-context.d.ts +16 -2
- package/dist/esm/react/pause-signals-context.d.ts.map +1 -1
- package/dist/esm/react/props-hash.d.ts +20 -0
- package/dist/esm/react/props-hash.d.ts.map +1 -0
- package/dist/esm/react/use-reactive.d.ts +6 -3
- package/dist/esm/react/use-reactive.d.ts.map +1 -1
- package/dist/esm/transform/async.d.ts.map +1 -1
- package/dist/esm/transform/callback.d.ts.map +1 -1
- package/dist/esm/transform/promise.d.ts.map +1 -1
- package/dist/esm/transform/use-reactive.d.ts.map +1 -1
- package/dist/esm/transform/utils.d.ts +1 -1
- package/dist/esm/transform/utils.d.ts.map +1 -1
- package/dist/esm/types.d.ts +20 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils.d.ts +17 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/development/config-B0MtLBgx.js +0 -21
- package/dist/cjs/development/config-B0MtLBgx.js.map +0 -1
- package/dist/cjs/development/debug-C46WDxhL.js.map +0 -1
- package/dist/cjs/development/snapshot-CbZ6IH3B.js.map +0 -1
- package/dist/cjs/production/config-B0MtLBgx.js +0 -21
- package/dist/cjs/production/config-B0MtLBgx.js.map +0 -1
- package/dist/cjs/production/contexts-CM3QLfV8.js.map +0 -1
- package/dist/cjs/production/snapshot-DWwH7_9y.js.map +0 -1
- package/dist/esm/development/config-CPQL7hX-.js +0 -22
- package/dist/esm/development/config-CPQL7hX-.js.map +0 -1
- package/dist/esm/development/debug-BTLbgTPK.js.map +0 -1
- package/dist/esm/development/snapshot-CkndI4Hh.js.map +0 -1
- package/dist/esm/production/config-CPQL7hX-.js +0 -22
- package/dist/esm/production/config-CPQL7hX-.js.map +0 -1
- package/dist/esm/production/contexts-FxCndlvf.js.map +0 -1
- package/dist/esm/production/snapshot-CdCaJJ0L.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../.tsc-out/transform/utils.js","../../../../.tsc-out/transform/async.js","../../../../.tsc-out/transform/callback.js","../../../../.tsc-out/transform/promise.js","../../../../.tsc-out/transform/use-reactive.js","../../../../.tsc-out/transform/preset.js"],"sourcesContent":["export const isBabelApi = (value) => !!value && typeof value === 'object' && 'types' in value;\nexport const createTransformedImports = (defaultImports, additionalImports, globalImportPaths) => {\n if (globalImportPaths) {\n defaultImports.forEach(([name, paths]) => {\n paths.push(...globalImportPaths);\n });\n }\n const transformedImports = new Map(defaultImports);\n if (additionalImports && additionalImports.length > 0) {\n for (const [name, path] of additionalImports) {\n const existing = transformedImports.get(name);\n if (existing) {\n existing.push(path);\n }\n else {\n transformedImports.set(name, [path]);\n }\n }\n }\n return transformedImports;\n};\n","import { createTransformedImports, isBabelApi } from './utils.js';\nfunction createSignaliumAsyncTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['callback', ['signalium']],\n ['component', ['signalium/react']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isReactiveCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n const isWithinTrackedCall = (path) => {\n let current = path.parentPath;\n while (current) {\n if (current.isCallExpression() && isReactiveCall(current))\n return true;\n current = current.parentPath;\n }\n return false;\n };\n function convertReactiveToGenerator(path) {\n if (!isWithinTrackedCall(path))\n return;\n if (!path.node.async)\n return;\n path.traverse({\n AwaitExpression(awaitPath) {\n const funcParent = awaitPath.getFunctionParent();\n if (funcParent?.node !== path.node)\n return;\n awaitPath.replaceWith(t.yieldExpression(awaitPath.node.argument));\n },\n });\n path.node.async = false;\n if (t.isArrowFunctionExpression(path.node)) {\n let hasThis = false;\n path.traverse({\n ThisExpression() {\n hasThis = true;\n },\n });\n const functionBody = t.isBlockStatement(path.node.body)\n ? path.node.body\n : t.blockStatement([t.returnStatement(path.node.body)]);\n const newFunction = t.functionExpression(null, path.node.params, functionBody, true, false);\n if (hasThis) {\n path.replaceWith(t.callExpression(t.memberExpression(newFunction, t.identifier('bind')), [t.thisExpression()]));\n }\n else {\n path.replaceWith(newFunction);\n }\n }\n else {\n path.node.generator = true;\n }\n }\n return {\n name: 'signalium-transform-reactive-async',\n visitor: {\n FunctionExpression: convertReactiveToGenerator,\n ArrowFunctionExpression: convertReactiveToGenerator,\n },\n };\n}\nexport function signaliumAsyncTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumAsyncTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumAsyncTransform(api, apiOrOpts);\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\nfunction createSignaliumCallbackTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['component', ['signalium/react']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const callbackImportPath = opts?.callbackImportPath ?? 'signalium';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n const matches = importPaths.find(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n return matches ? (typeof matches === 'string' ? matches : importDecl.source.value) : false;\n };\n const isTargetWrapperCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return !!isTrackedImport(callee.name, path);\n };\n function isIdentifierInTypePosition(refPath) {\n // Walk up ancestors and detect if the identifier is within TS type-only constructs\n // Allow identifiers inside the expression arm of TS* expression wrappers\n let current = refPath.parentPath;\n let child = refPath;\n while (current) {\n const nodeType = current.node.type;\n if (nodeType && nodeType.startsWith('TS')) {\n if (current.isTSAsExpression() ||\n current.isTSSatisfiesExpression?.() ||\n current.isTSNonNullExpression() ||\n current.isTSInstantiationExpression?.()) {\n // If we reached this TS* expression via its 'expression' arm, it's runtime, not type-only\n if (child.key === 'expression')\n return false;\n return true;\n }\n return true;\n }\n child = current;\n current = current.parentPath;\n }\n return false;\n }\n function lookupCallbackIdentifier(programPath) {\n // Find an existing direct import: import { callback as X } from 'signalium'\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== callbackImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type === 'ImportSpecifier') {\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'callback') {\n return ispec.local.name;\n }\n }\n }\n }\n return undefined;\n }\n function ensureCallbackIdentifier(programPath) {\n const existing = lookupCallbackIdentifier(programPath);\n if (existing !== undefined)\n return existing;\n // Try to augment an existing import from 'signalium'\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== callbackImportPath)\n continue;\n // Skip `import type` declarations — adding a value specifier there would\n // make it type-only at runtime.\n if (node.importKind === 'type')\n continue;\n const localName = programPath.scope.generateUidIdentifier('callback').name;\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('callback')));\n return localName;\n }\n // Otherwise, insert a new import from 'signalium'\n const localName = 'callback';\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('callback'))], t.stringLiteral(callbackImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n function collectDeps(innerFn) {\n const depNames = new Set();\n const innerScope = innerFn.scope;\n const innerNode = innerFn.node;\n innerFn.traverse({\n ReferencedIdentifier(refPath) {\n // Only consider refs whose nearest function parent is the inner function\n const nearestFn = refPath.getFunctionParent();\n if (!nearestFn || nearestFn.node !== innerNode)\n return;\n const name = refPath.node.name;\n const binding = refPath.scope.getBinding(name);\n if (!binding)\n return;\n // Ignore identifiers that appear only in type positions\n if (isIdentifierInTypePosition(refPath))\n return;\n // Exclude module scope\n if (binding.scope.path.isProgram())\n return;\n // Exclude identifiers declared within the inner function itself or any nested scope inside it\n let declScope = binding.scope;\n while (declScope) {\n if (declScope === innerScope)\n return;\n declScope = declScope.parent;\n }\n // Exclude only the inner function's own parameters\n if (binding.kind === 'param' && binding.scope === innerScope)\n return;\n depNames.add(name);\n },\n });\n return depNames;\n }\n return {\n name: 'signalium-transform-callback-wrapping',\n visitor: {\n CallExpression(callPath) {\n if (!isTargetWrapperCall(callPath))\n return;\n const arg0 = callPath.get('arguments')[0];\n if (!arg0)\n return;\n if (!(arg0.isFunctionExpression() || arg0.isArrowFunctionExpression()))\n return;\n const outerFn = arg0;\n const programPath = callPath.findParent((p) => p.isProgram());\n // Lazily resolve the `callback` import local name so we don't add a\n // dead `import { callback } from 'signalium'` when the outer fn has no\n // inner callbacks to wrap.\n const getCallbackName = () => ensureCallbackIdentifier(programPath);\n // For the \"skip if already wrapped in callback()\" check: consult the\n // existing imports without forcing one to be added.\n const peekCallbackName = () => lookupCallbackIdentifier(programPath);\n // Maintain per-function counters\n const counters = new WeakMap();\n counters.set(outerFn.node, 0);\n const getNextIndexFor = (fnNode) => {\n const current = counters.get(fnNode) ?? 0;\n counters.set(fnNode, current + 1);\n return current;\n };\n outerFn.traverse({\n // Initialize counters for any function-like node when first seen\n FunctionExpression: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerFnPath) {\n if (innerFnPath.node === outerFn.node)\n return;\n // Skip converting when the function is passed directly as a callback\n // to a tracked call AND that call is nested within another tracked call.\n const immediateParent = innerFnPath.parentPath;\n if (immediateParent && immediateParent.isCallExpression()) {\n const callee = immediateParent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (isTrackedImport(calleeId.name, immediateParent)) {\n let current = immediateParent.parentPath;\n while (current) {\n if (current.isCallExpression()) {\n const parentCallee = current.node.callee;\n if (t.isIdentifier(parentCallee)) {\n const parentCalleeId = parentCallee;\n if (isTrackedImport(parentCalleeId.name, current)) {\n return; // nested direct callback – skip\n }\n }\n }\n current = current.parentPath;\n }\n }\n }\n }\n // Skip if already wrapped in callback()\n const parent = innerFnPath.parentPath;\n if (parent && parent.isCallExpression()) {\n const callee = parent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (calleeId.name === peekCallbackName()) {\n return;\n }\n }\n }\n const deps = Array.from(collectDeps(innerFnPath));\n // Determine parent function to index against\n const parentFn = (innerFnPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [innerFnPath.node, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n innerFnPath.replaceWith(wrapped);\n innerFnPath.skip();\n },\n },\n ArrowFunctionExpression: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerFnPath) {\n if (innerFnPath.node === outerFn.node)\n return;\n // Skip converting when the function is passed directly as a callback\n // to a tracked call AND that call is nested within another tracked call.\n const immediateParent = innerFnPath.parentPath;\n if (immediateParent && immediateParent.isCallExpression()) {\n const callee = immediateParent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (isTrackedImport(calleeId.name, immediateParent)) {\n let current = immediateParent.parentPath;\n while (current) {\n if (current.isCallExpression()) {\n const parentCallee = current.node.callee;\n if (t.isIdentifier(parentCallee)) {\n const parentCalleeId = parentCallee;\n if (isTrackedImport(parentCalleeId.name, current)) {\n return; // nested direct callback – skip\n }\n }\n }\n current = current.parentPath;\n }\n }\n }\n }\n // Skip if already wrapped in callback()\n const parent = innerFnPath.parentPath;\n if (parent && parent.isCallExpression()) {\n const callee = parent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (calleeId.name === peekCallbackName()) {\n return;\n }\n }\n }\n const deps = Array.from(collectDeps(innerFnPath));\n const parentFn = (innerFnPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [innerFnPath.node, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n innerFnPath.replaceWith(wrapped);\n innerFnPath.skip();\n },\n },\n FunctionDeclaration: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerDeclPath) {\n const id = innerDeclPath.node.id;\n if (!id)\n return;\n const fnExpr = t.functionExpression(id, innerDeclPath.node.params, innerDeclPath.node.body, innerDeclPath.node.generator, innerDeclPath.node.async);\n const deps = Array.from(collectDeps(innerDeclPath));\n const parentFn = (innerDeclPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [fnExpr, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n const constDecl = t.variableDeclaration('const', [t.variableDeclarator(id, wrapped)]);\n innerDeclPath.replaceWith(constDecl);\n innerDeclPath.skip();\n },\n },\n ObjectMethod: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerMethodPath) {\n if (innerMethodPath.node.kind !== 'method')\n return;\n const fnExpr = t.functionExpression(null, innerMethodPath.node.params, innerMethodPath.node.body, innerMethodPath.node.generator, innerMethodPath.node.async);\n const deps = Array.from(collectDeps(innerMethodPath));\n const parentFn = (innerMethodPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [fnExpr, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n const key = innerMethodPath.node.key;\n const computed = innerMethodPath.node.computed || false;\n const prop = t.objectProperty(key, wrapped, computed);\n innerMethodPath.replaceWith(prop);\n innerMethodPath.skip();\n },\n },\n });\n },\n },\n };\n}\nexport function signaliumCallbackTransform(apiOrOpts, opts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumCallbackTransform(apiOrOpts, opts);\n }\n else {\n return (api) => createSignaliumCallbackTransform(api, apiOrOpts);\n }\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\nconst PROMISE_STATIC_METHODS = new Set(['all', 'race', 'any', 'allSettled', 'resolve', 'reject', 'withResolvers']);\nfunction createSignaliumPromiseMethodsTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['callback', ['signalium']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const promiseImportPath = opts?.promiseImportPath ?? 'signalium';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isReactiveCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n const isWithinTrackedCall = (path) => {\n let current = path.parentPath;\n while (current) {\n if (current.isCallExpression() && isReactiveCall(current))\n return true;\n current = current.parentPath;\n }\n return false;\n };\n function ensureReactivePromiseIdentifier(programPath) {\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== promiseImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type === 'ImportSpecifier') {\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'ReactivePromise') {\n return ispec.local.name;\n }\n }\n }\n }\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== promiseImportPath)\n continue;\n const localName = 'ReactivePromise';\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('ReactivePromise')));\n return localName;\n }\n const localName = 'ReactivePromise';\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('ReactivePromise'))], t.stringLiteral(promiseImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n return {\n name: 'signalium-transform-reactive-promise-methods',\n visitor: {\n CallExpression(callPath) {\n if (!isWithinTrackedCall(callPath))\n return;\n const callee = callPath.node.callee;\n if (!t.isMemberExpression(callee))\n return;\n if (callee.computed)\n return;\n const object = callee.object;\n const property = callee.property;\n if (!t.isIdentifier(object, { name: 'Promise' }))\n return;\n if (callPath.scope.getBinding('Promise'))\n return;\n if (!t.isIdentifier(property))\n return;\n const methodName = property.name;\n if (!PROMISE_STATIC_METHODS.has(methodName))\n return;\n const programPath = callPath.findParent((p) => p.isProgram());\n const reactivePromiseId = ensureReactivePromiseIdentifier(programPath);\n const newCallee = t.memberExpression(t.identifier(reactivePromiseId), t.identifier(methodName));\n callPath.node.callee = newCallee;\n },\n },\n };\n}\nexport function signaliumPromiseMethodsTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumPromiseMethodsTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumPromiseMethodsTransform(api, apiOrOpts);\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\n/**\n * Wraps the thunk argument of `useReactive` / `useReactiveDeep` in\n * `React.useCallback(fn, [deps])`. The captured identifiers are collected from\n * the thunk body the same way the `callback` transform does for `reactive()`\n * callbacks, giving the hook a stable identity across renders when captures are\n * equal. This lets the runtime reuse the underlying `ReactiveSignal`.\n *\n * Runs after the async and callback transforms so the inner function has\n * already been rewritten (e.g. `async` → `function*`).\n */\nfunction createSignaliumUseReactiveTransform(api, opts) {\n // Only forward user-provided `transformedImports` entries that target the\n // hook names we care about. The shared `transformedImports` preset option is\n // also used by the callback/async transforms to retarget arbitrary identifiers\n // like `reactive`/`task`/`relay`; we must not accidentally pick those up here\n // or we'd wrap inner arrows with `useCallback` in non-React code paths.\n const trackedNames = new Set(['useReactive', 'useReactiveShallow', 'useReactiveDeep']);\n const filteredAdditional = opts?.transformedImports?.filter(([name]) => trackedNames.has(name));\n const transformedImports = createTransformedImports([\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], filteredAdditional, opts?.importPaths);\n const t = api.types;\n const reactImportPath = opts?.reactImportPath ?? 'react';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isTargetCall = (path) => {\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n function isIdentifierInTypePosition(refPath) {\n let current = refPath.parentPath;\n let child = refPath;\n while (current) {\n const nodeType = current.node.type;\n if (nodeType && nodeType.startsWith('TS')) {\n if (current.isTSAsExpression() ||\n current.isTSSatisfiesExpression?.() ||\n current.isTSNonNullExpression() ||\n current.isTSInstantiationExpression?.()) {\n if (child.key === 'expression')\n return false;\n return true;\n }\n return true;\n }\n child = current;\n current = current.parentPath;\n }\n return false;\n }\n function ensureUseCallbackIdentifier(programPath) {\n // Find an existing `import { useCallback as X } from 'react'`\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== reactImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type !== 'ImportSpecifier')\n continue;\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'useCallback') {\n return ispec.local.name;\n }\n }\n }\n // Augment an existing `import ... from 'react'`\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== reactImportPath)\n continue;\n const localName = programPath.scope.generateUidIdentifier('useCallback').name;\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('useCallback')));\n return localName;\n }\n // Otherwise, insert a new import\n const localName = programPath.scope.generateUidIdentifier('useCallback').name;\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('useCallback'))], t.stringLiteral(reactImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n function collectDeps(innerFn) {\n const depNames = new Set();\n const innerScope = innerFn.scope;\n const innerNode = innerFn.node;\n innerFn.traverse({\n ReferencedIdentifier(refPath) {\n const nearestFn = refPath.getFunctionParent();\n if (!nearestFn || nearestFn.node !== innerNode)\n return;\n const name = refPath.node.name;\n const binding = refPath.scope.getBinding(name);\n if (!binding)\n return;\n if (isIdentifierInTypePosition(refPath))\n return;\n if (binding.scope.path.isProgram())\n return;\n let declScope = binding.scope;\n while (declScope) {\n if (declScope === innerScope)\n return;\n declScope = declScope.parent;\n }\n if (binding.kind === 'param' && binding.scope === innerScope)\n return;\n depNames.add(name);\n },\n });\n return Array.from(depNames);\n }\n function isAlreadyMemoized(argPath) {\n if (!argPath.isCallExpression())\n return false;\n const callee = argPath.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n const name = callee.name;\n // Heuristic: any identifier ending in `useCallback` or `useMemo` is treated\n // as already-memoized. Avoids double-wrapping and supports aliased imports.\n return name === 'useCallback' || name === 'useMemo' || /useCallback$/.test(name);\n }\n return {\n name: 'signalium-transform-use-reactive',\n visitor: {\n CallExpression(callPath) {\n if (!isTargetCall(callPath))\n return;\n const args = callPath.get('arguments');\n // Only the thunk form: exactly one argument and it is a function.\n if (args.length !== 1)\n return;\n let fnPath = args[0];\n // Unwrap TS expression wrappers (`as`, `satisfies`, `!`, etc.) so the\n // user can still write `useReactive((async () => ...) as X)`.\n while (fnPath.isTSAsExpression() ||\n fnPath.isTSSatisfiesExpression?.() ||\n fnPath.isTSNonNullExpression() ||\n fnPath.isTSInstantiationExpression?.()) {\n fnPath = fnPath.get('expression');\n }\n if (!(fnPath.isArrowFunctionExpression() || fnPath.isFunctionExpression()))\n return;\n if (isAlreadyMemoized(fnPath))\n return;\n const programPath = callPath.findParent((p) => p.isProgram());\n const useCallbackName = ensureUseCallbackIdentifier(programPath);\n const innerFn = fnPath;\n const deps = collectDeps(innerFn);\n const wrapped = t.callExpression(t.identifier(useCallbackName), [\n innerFn.node,\n t.arrayExpression(deps.map(n => t.identifier(n))),\n ]);\n fnPath.replaceWith(wrapped);\n fnPath.skip();\n },\n },\n };\n}\nexport function signaliumUseReactiveTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumUseReactiveTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumUseReactiveTransform(api, apiOrOpts);\n}\n","import { signaliumAsyncTransform } from './async.js';\nimport { signaliumCallbackTransform } from './callback.js';\nimport { signaliumPromiseMethodsTransform } from './promise.js';\nimport { signaliumUseReactiveTransform } from './use-reactive.js';\nimport { isBabelApi } from './utils.js';\n// Babel preset that sequences the two plugins just like separate entries\n// Usage in babel config: presets: [[require('signalium/transform').signaliumPreset(options)]\nfunction createSignaliumPreset(api, opts) {\n return {\n plugins: [\n signaliumCallbackTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n callbackImportPath: opts?.callbackImportPath,\n }),\n signaliumAsyncTransform({ transformedImports: opts?.transformedImports ?? [], importPaths: opts?.importPaths }),\n signaliumUseReactiveTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n reactImportPath: opts?.reactImportPath,\n }),\n signaliumPromiseMethodsTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n promiseImportPath: opts?.promiseImportPath,\n }),\n ],\n };\n}\nexport function signaliumPreset(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumPreset(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumPreset(api, apiOrOpts);\n}\n"],"names":["localName","importDecl"],"mappings":"AAAO,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW;AACjF,MAAM,2BAA2B,CAAC,gBAAgB,mBAAmB,sBAAsB;AAC9F,MAAI,mBAAmB;AACnB,mBAAe,QAAQ,CAAC,CAAC,MAAM,KAAK,MAAM;AACtC,YAAM,KAAK,GAAG,iBAAiB;AAAA,IACnC,CAAC;AAAA,EACL;AACA,QAAM,qBAAqB,IAAI,IAAI,cAAc;AACjD,MAAI,qBAAqB,kBAAkB,SAAS,GAAG;AACnD,eAAW,CAAC,MAAM,IAAI,KAAK,mBAAmB;AAC1C,YAAM,WAAW,mBAAmB,IAAI,IAAI;AAC5C,UAAI,UAAU;AACV,iBAAS,KAAK,IAAI;AAAA,MACtB,OACK;AACD,2BAAmB,IAAI,MAAM,CAAC,IAAI,CAAC;AAAA,MACvC;AAAA,IACJ;AAAA,EACJ;AACA,SAAO;AACX;ACnBA,SAAS,8BAA8B,KAAK,MAAM;AAC9C,QAAM,qBAAqB,yBAAyB;AAAA,IAChD,CAAC,YAAY,CAAC,WAAW,CAAC;AAAA,IAC1B,CAAC,aAAa,CAAC,iBAAiB,CAAC;AAAA,IACjC,CAAC,YAAY,CAAC,WAAW,CAAC;AAAA,IAC1B,CAAC,kBAAkB,CAAC,WAAW,CAAC;AAAA,IAChC,CA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,MAAM;AAAA,MACzC,CAAa;AAAA,IACb;AAAA,EACA;AACA;AACO,SAAS,gBAAgB,WAAW,WAAW;AAClD,MAAI,WAAW,SAAS,GAAG;AACvB,WAAO,sBAAsB,WAAW,SAAS;AAAA,EACrD;AACA,SAAO,CAAC,QAAQ,sBAAsB,KAAK,SAAS;AACxD;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../.tsc-out/transform/utils.js","../../../../.tsc-out/transform/async.js","../../../../.tsc-out/transform/callback.js","../../../../.tsc-out/transform/promise.js","../../../../.tsc-out/transform/use-reactive.js","../../../../.tsc-out/transform/preset.js"],"sourcesContent":["export const isBabelApi = (value) => !!value && typeof value === 'object' && 'types' in value;\nexport const createTransformedImports = (defaultImports, additionalImports, globalImportPaths) => {\n if (globalImportPaths) {\n defaultImports.forEach(([name, paths]) => {\n paths.push(...globalImportPaths);\n });\n }\n const transformedImports = new Map(defaultImports);\n if (additionalImports && additionalImports.length > 0) {\n for (const [name, path] of additionalImports) {\n const existing = transformedImports.get(name);\n if (existing) {\n existing.push(path);\n }\n else {\n transformedImports.set(name, [path]);\n }\n }\n }\n return transformedImports;\n};\n","import { createTransformedImports, isBabelApi } from './utils.js';\nfunction createSignaliumAsyncTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['callback', ['signalium']],\n ['component', ['signalium/react']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['retain', ['signalium', 'signalium/utils']],\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isReactiveCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n const isWithinTrackedCall = (path) => {\n let current = path.parentPath;\n while (current) {\n if (current.isCallExpression() && isReactiveCall(current))\n return true;\n current = current.parentPath;\n }\n return false;\n };\n function convertReactiveToGenerator(path) {\n if (!isWithinTrackedCall(path))\n return;\n if (!path.node.async)\n return;\n path.traverse({\n AwaitExpression(awaitPath) {\n const funcParent = awaitPath.getFunctionParent();\n if (funcParent?.node !== path.node)\n return;\n awaitPath.replaceWith(t.yieldExpression(awaitPath.node.argument));\n },\n });\n path.node.async = false;\n if (t.isArrowFunctionExpression(path.node)) {\n let hasThis = false;\n path.traverse({\n ThisExpression() {\n hasThis = true;\n },\n });\n const functionBody = t.isBlockStatement(path.node.body)\n ? path.node.body\n : t.blockStatement([t.returnStatement(path.node.body)]);\n const newFunction = t.functionExpression(null, path.node.params, functionBody, true, false);\n if (hasThis) {\n path.replaceWith(t.callExpression(t.memberExpression(newFunction, t.identifier('bind')), [t.thisExpression()]));\n }\n else {\n path.replaceWith(newFunction);\n }\n }\n else {\n path.node.generator = true;\n }\n }\n return {\n name: 'signalium-transform-reactive-async',\n visitor: {\n FunctionExpression: convertReactiveToGenerator,\n ArrowFunctionExpression: convertReactiveToGenerator,\n },\n };\n}\nexport function signaliumAsyncTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumAsyncTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumAsyncTransform(api, apiOrOpts);\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\nfunction createSignaliumCallbackTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['component', ['signalium/react']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['retain', ['signalium', 'signalium/utils']],\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const callbackImportPath = opts?.callbackImportPath ?? 'signalium';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n const matches = importPaths.find(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n return matches ? (typeof matches === 'string' ? matches : importDecl.source.value) : false;\n };\n const isTargetWrapperCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return !!isTrackedImport(callee.name, path);\n };\n function isIdentifierInTypePosition(refPath) {\n // Walk up ancestors and detect if the identifier is within TS type-only constructs\n // Allow identifiers inside the expression arm of TS* expression wrappers\n let current = refPath.parentPath;\n let child = refPath;\n while (current) {\n const nodeType = current.node.type;\n if (nodeType && nodeType.startsWith('TS')) {\n if (current.isTSAsExpression() ||\n current.isTSSatisfiesExpression?.() ||\n current.isTSNonNullExpression() ||\n current.isTSInstantiationExpression?.()) {\n // If we reached this TS* expression via its 'expression' arm, it's runtime, not type-only\n if (child.key === 'expression')\n return false;\n return true;\n }\n return true;\n }\n child = current;\n current = current.parentPath;\n }\n return false;\n }\n function lookupCallbackIdentifier(programPath) {\n // Find an existing direct import: import { callback as X } from 'signalium'\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== callbackImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type === 'ImportSpecifier') {\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'callback') {\n return ispec.local.name;\n }\n }\n }\n }\n return undefined;\n }\n function ensureCallbackIdentifier(programPath) {\n const existing = lookupCallbackIdentifier(programPath);\n if (existing !== undefined)\n return existing;\n // Try to augment an existing import from 'signalium'\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== callbackImportPath)\n continue;\n // Skip `import type` declarations — adding a value specifier there would\n // make it type-only at runtime.\n if (node.importKind === 'type')\n continue;\n const localName = programPath.scope.generateUidIdentifier('callback').name;\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('callback')));\n return localName;\n }\n // Otherwise, insert a new import from 'signalium'\n const localName = 'callback';\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('callback'))], t.stringLiteral(callbackImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n function collectDeps(innerFn) {\n const depNames = new Set();\n const innerScope = innerFn.scope;\n const innerNode = innerFn.node;\n innerFn.traverse({\n ReferencedIdentifier(refPath) {\n // Only consider refs whose nearest function parent is the inner function\n const nearestFn = refPath.getFunctionParent();\n if (!nearestFn || nearestFn.node !== innerNode)\n return;\n const name = refPath.node.name;\n const binding = refPath.scope.getBinding(name);\n if (!binding)\n return;\n // Ignore identifiers that appear only in type positions\n if (isIdentifierInTypePosition(refPath))\n return;\n // Exclude module scope\n if (binding.scope.path.isProgram())\n return;\n // Exclude identifiers declared within the inner function itself or any nested scope inside it\n let declScope = binding.scope;\n while (declScope) {\n if (declScope === innerScope)\n return;\n declScope = declScope.parent;\n }\n // Exclude only the inner function's own parameters\n if (binding.kind === 'param' && binding.scope === innerScope)\n return;\n depNames.add(name);\n },\n });\n return depNames;\n }\n return {\n name: 'signalium-transform-callback-wrapping',\n visitor: {\n CallExpression(callPath) {\n if (!isTargetWrapperCall(callPath))\n return;\n const arg0 = callPath.get('arguments')[0];\n if (!arg0)\n return;\n if (!(arg0.isFunctionExpression() || arg0.isArrowFunctionExpression()))\n return;\n const outerFn = arg0;\n const programPath = callPath.findParent((p) => p.isProgram());\n // Lazily resolve the `callback` import local name so we don't add a\n // dead `import { callback } from 'signalium'` when the outer fn has no\n // inner callbacks to wrap.\n const getCallbackName = () => ensureCallbackIdentifier(programPath);\n // For the \"skip if already wrapped in callback()\" check: consult the\n // existing imports without forcing one to be added.\n const peekCallbackName = () => lookupCallbackIdentifier(programPath);\n // Maintain per-function counters\n const counters = new WeakMap();\n counters.set(outerFn.node, 0);\n const getNextIndexFor = (fnNode) => {\n const current = counters.get(fnNode) ?? 0;\n counters.set(fnNode, current + 1);\n return current;\n };\n outerFn.traverse({\n // Initialize counters for any function-like node when first seen\n FunctionExpression: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerFnPath) {\n if (innerFnPath.node === outerFn.node)\n return;\n // Skip converting when the function is passed directly as a callback\n // to a tracked call AND that call is nested within another tracked call.\n const immediateParent = innerFnPath.parentPath;\n if (immediateParent && immediateParent.isCallExpression()) {\n const callee = immediateParent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (isTrackedImport(calleeId.name, immediateParent)) {\n let current = immediateParent.parentPath;\n while (current) {\n if (current.isCallExpression()) {\n const parentCallee = current.node.callee;\n if (t.isIdentifier(parentCallee)) {\n const parentCalleeId = parentCallee;\n if (isTrackedImport(parentCalleeId.name, current)) {\n return; // nested direct callback – skip\n }\n }\n }\n current = current.parentPath;\n }\n }\n }\n }\n // Skip if already wrapped in callback()\n const parent = innerFnPath.parentPath;\n if (parent && parent.isCallExpression()) {\n const callee = parent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (calleeId.name === peekCallbackName()) {\n return;\n }\n }\n }\n const deps = Array.from(collectDeps(innerFnPath));\n // Determine parent function to index against\n const parentFn = (innerFnPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [innerFnPath.node, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n innerFnPath.replaceWith(wrapped);\n innerFnPath.skip();\n },\n },\n ArrowFunctionExpression: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerFnPath) {\n if (innerFnPath.node === outerFn.node)\n return;\n // Skip converting when the function is passed directly as a callback\n // to a tracked call AND that call is nested within another tracked call.\n const immediateParent = innerFnPath.parentPath;\n if (immediateParent && immediateParent.isCallExpression()) {\n const callee = immediateParent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (isTrackedImport(calleeId.name, immediateParent)) {\n let current = immediateParent.parentPath;\n while (current) {\n if (current.isCallExpression()) {\n const parentCallee = current.node.callee;\n if (t.isIdentifier(parentCallee)) {\n const parentCalleeId = parentCallee;\n if (isTrackedImport(parentCalleeId.name, current)) {\n return; // nested direct callback – skip\n }\n }\n }\n current = current.parentPath;\n }\n }\n }\n }\n // Skip if already wrapped in callback()\n const parent = innerFnPath.parentPath;\n if (parent && parent.isCallExpression()) {\n const callee = parent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (calleeId.name === peekCallbackName()) {\n return;\n }\n }\n }\n const deps = Array.from(collectDeps(innerFnPath));\n const parentFn = (innerFnPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [innerFnPath.node, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n innerFnPath.replaceWith(wrapped);\n innerFnPath.skip();\n },\n },\n FunctionDeclaration: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerDeclPath) {\n const id = innerDeclPath.node.id;\n if (!id)\n return;\n const fnExpr = t.functionExpression(id, innerDeclPath.node.params, innerDeclPath.node.body, innerDeclPath.node.generator, innerDeclPath.node.async);\n const deps = Array.from(collectDeps(innerDeclPath));\n const parentFn = (innerDeclPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [fnExpr, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n const constDecl = t.variableDeclaration('const', [t.variableDeclarator(id, wrapped)]);\n innerDeclPath.replaceWith(constDecl);\n innerDeclPath.skip();\n },\n },\n ObjectMethod: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerMethodPath) {\n if (innerMethodPath.node.kind !== 'method')\n return;\n const fnExpr = t.functionExpression(null, innerMethodPath.node.params, innerMethodPath.node.body, innerMethodPath.node.generator, innerMethodPath.node.async);\n const deps = Array.from(collectDeps(innerMethodPath));\n const parentFn = (innerMethodPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [fnExpr, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n const key = innerMethodPath.node.key;\n const computed = innerMethodPath.node.computed || false;\n const prop = t.objectProperty(key, wrapped, computed);\n innerMethodPath.replaceWith(prop);\n innerMethodPath.skip();\n },\n },\n });\n },\n },\n };\n}\nexport function signaliumCallbackTransform(apiOrOpts, opts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumCallbackTransform(apiOrOpts, opts);\n }\n else {\n return (api) => createSignaliumCallbackTransform(api, apiOrOpts);\n }\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\nconst PROMISE_STATIC_METHODS = new Set(['all', 'race', 'any', 'allSettled', 'resolve', 'reject', 'withResolvers']);\nfunction createSignaliumPromiseMethodsTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['callback', ['signalium']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['retain', ['signalium', 'signalium/utils']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const promiseImportPath = opts?.promiseImportPath ?? 'signalium';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isReactiveCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n const isWithinTrackedCall = (path) => {\n let current = path.parentPath;\n while (current) {\n if (current.isCallExpression() && isReactiveCall(current))\n return true;\n current = current.parentPath;\n }\n return false;\n };\n function ensureReactivePromiseIdentifier(programPath) {\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== promiseImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type === 'ImportSpecifier') {\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'ReactivePromise') {\n return ispec.local.name;\n }\n }\n }\n }\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== promiseImportPath)\n continue;\n const localName = 'ReactivePromise';\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('ReactivePromise')));\n return localName;\n }\n const localName = 'ReactivePromise';\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('ReactivePromise'))], t.stringLiteral(promiseImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n return {\n name: 'signalium-transform-reactive-promise-methods',\n visitor: {\n CallExpression(callPath) {\n if (!isWithinTrackedCall(callPath))\n return;\n const callee = callPath.node.callee;\n if (!t.isMemberExpression(callee))\n return;\n if (callee.computed)\n return;\n const object = callee.object;\n const property = callee.property;\n if (!t.isIdentifier(object, { name: 'Promise' }))\n return;\n if (callPath.scope.getBinding('Promise'))\n return;\n if (!t.isIdentifier(property))\n return;\n const methodName = property.name;\n if (!PROMISE_STATIC_METHODS.has(methodName))\n return;\n const programPath = callPath.findParent((p) => p.isProgram());\n const reactivePromiseId = ensureReactivePromiseIdentifier(programPath);\n const newCallee = t.memberExpression(t.identifier(reactivePromiseId), t.identifier(methodName));\n callPath.node.callee = newCallee;\n },\n },\n };\n}\nexport function signaliumPromiseMethodsTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumPromiseMethodsTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumPromiseMethodsTransform(api, apiOrOpts);\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\n/**\n * Wraps the thunk argument of `useReactive` / `useReactiveShallow` / `useReactiveDeep` in\n * `React.useCallback(fn, [deps])`, leaving any later arguments (the options object) untouched.\n * The captured identifiers are collected from the thunk body the same way the `callback`\n * transform does for `reactive()` callbacks, giving the hook a stable identity across renders\n * when captures are equal. This lets the runtime reuse the underlying `ReactiveSignal`.\n *\n * Runs after the async and callback transforms so the inner function has\n * already been rewritten (e.g. `async` → `function*`).\n */\nfunction createSignaliumUseReactiveTransform(api, opts) {\n // Only forward user-provided `transformedImports` entries that target the\n // hook names we care about. The shared `transformedImports` preset option is\n // also used by the callback/async transforms to retarget arbitrary identifiers\n // like `reactive`/`task`/`relay`; we must not accidentally pick those up here\n // or we'd wrap inner arrows with `useCallback` in non-React code paths.\n const trackedNames = new Set(['useReactive', 'useReactiveShallow', 'useReactiveDeep']);\n const filteredAdditional = opts?.transformedImports?.filter(([name]) => trackedNames.has(name));\n const transformedImports = createTransformedImports([\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], filteredAdditional, opts?.importPaths);\n const t = api.types;\n const reactImportPath = opts?.reactImportPath ?? 'react';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isTargetCall = (path) => {\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n function isIdentifierInTypePosition(refPath) {\n let current = refPath.parentPath;\n let child = refPath;\n while (current) {\n const nodeType = current.node.type;\n if (nodeType && nodeType.startsWith('TS')) {\n if (current.isTSAsExpression() ||\n current.isTSSatisfiesExpression?.() ||\n current.isTSNonNullExpression() ||\n current.isTSInstantiationExpression?.()) {\n if (child.key === 'expression')\n return false;\n return true;\n }\n return true;\n }\n child = current;\n current = current.parentPath;\n }\n return false;\n }\n function ensureUseCallbackIdentifier(programPath) {\n // Find an existing `import { useCallback as X } from 'react'`\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== reactImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type !== 'ImportSpecifier')\n continue;\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'useCallback') {\n return ispec.local.name;\n }\n }\n }\n // Augment an existing `import ... from 'react'`\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== reactImportPath)\n continue;\n const localName = programPath.scope.generateUidIdentifier('useCallback').name;\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('useCallback')));\n return localName;\n }\n // Otherwise, insert a new import\n const localName = programPath.scope.generateUidIdentifier('useCallback').name;\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('useCallback'))], t.stringLiteral(reactImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n function collectDeps(innerFn) {\n const depNames = new Set();\n const innerScope = innerFn.scope;\n const innerNode = innerFn.node;\n innerFn.traverse({\n ReferencedIdentifier(refPath) {\n const nearestFn = refPath.getFunctionParent();\n if (!nearestFn || nearestFn.node !== innerNode)\n return;\n const name = refPath.node.name;\n const binding = refPath.scope.getBinding(name);\n if (!binding)\n return;\n if (isIdentifierInTypePosition(refPath))\n return;\n if (binding.scope.path.isProgram())\n return;\n let declScope = binding.scope;\n while (declScope) {\n if (declScope === innerScope)\n return;\n declScope = declScope.parent;\n }\n if (binding.kind === 'param' && binding.scope === innerScope)\n return;\n depNames.add(name);\n },\n });\n return Array.from(depNames);\n }\n function isAlreadyMemoized(argPath) {\n if (!argPath.isCallExpression())\n return false;\n const callee = argPath.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n const name = callee.name;\n // Heuristic: any identifier ending in `useCallback` or `useMemo` is treated\n // as already-memoized. Avoids double-wrapping and supports aliased imports.\n return name === 'useCallback' || name === 'useMemo' || /useCallback$/.test(name);\n }\n return {\n name: 'signalium-transform-use-reactive',\n visitor: {\n CallExpression(callPath) {\n if (!isTargetCall(callPath))\n return;\n const args = callPath.get('arguments');\n // The thunk is the first argument. Any further arguments (the `{ delivery }` options\n // object) are left as they are: they are read once per render, not used as a cache key.\n if (args.length === 0)\n return;\n let fnPath = args[0];\n // Unwrap TS expression wrappers (`as`, `satisfies`, `!`, etc.) so the\n // user can still write `useReactive((async () => ...) as X)`.\n while (fnPath.isTSAsExpression() ||\n fnPath.isTSSatisfiesExpression?.() ||\n fnPath.isTSNonNullExpression() ||\n fnPath.isTSInstantiationExpression?.()) {\n fnPath = fnPath.get('expression');\n }\n if (!(fnPath.isArrowFunctionExpression() || fnPath.isFunctionExpression()))\n return;\n if (isAlreadyMemoized(fnPath))\n return;\n const programPath = callPath.findParent((p) => p.isProgram());\n const useCallbackName = ensureUseCallbackIdentifier(programPath);\n const innerFn = fnPath;\n const deps = collectDeps(innerFn);\n const wrapped = t.callExpression(t.identifier(useCallbackName), [\n innerFn.node,\n t.arrayExpression(deps.map(n => t.identifier(n))),\n ]);\n fnPath.replaceWith(wrapped);\n fnPath.skip();\n },\n },\n };\n}\nexport function signaliumUseReactiveTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumUseReactiveTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumUseReactiveTransform(api, apiOrOpts);\n}\n","import { signaliumAsyncTransform } from './async.js';\nimport { signaliumCallbackTransform } from './callback.js';\nimport { signaliumPromiseMethodsTransform } from './promise.js';\nimport { signaliumUseReactiveTransform } from './use-reactive.js';\nimport { isBabelApi } from './utils.js';\n// Babel preset that sequences the two plugins just like separate entries\n// Usage in babel config: presets: [[require('signalium/transform').signaliumPreset(options)]\nfunction createSignaliumPreset(api, opts) {\n return {\n plugins: [\n signaliumCallbackTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n callbackImportPath: opts?.callbackImportPath,\n }),\n signaliumAsyncTransform({ transformedImports: opts?.transformedImports ?? [], importPaths: opts?.importPaths }),\n signaliumUseReactiveTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n reactImportPath: opts?.reactImportPath,\n }),\n signaliumPromiseMethodsTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n promiseImportPath: opts?.promiseImportPath,\n }),\n ],\n };\n}\nexport function signaliumPreset(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumPreset(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumPreset(api, apiOrOpts);\n}\n"],"names":["localName","importDecl"],"mappings":"AAAO,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW;AACjF,MAAM,2BAA2B,CAAC,gBAAgB,mBAAmB,sBAAsB;AAC9F,MAAI,mBAAmB;AACnB,mBAAe,QAAQ,CAAC,CAAC,MAAM,KAAK,MAAM;AACtC,YAAM,KAAK,GAAG,iBAAiB;AAAA,IACnC,CAAC;AAAA,EACL;AACA,QAAM,qBAAqB,IAAI,IAAI,cAAc;AACjD,MAAI,qBAAqB,kBAAkB,SAAS,GAAG;AACnD,eAAW,CAAC,MAAM,IAAI,KAAK,mBAAmB;AAC1C,YAAM,WAAW,mBAAmB,IAAI,IAAI;AAC5C,UAAI,UAAU;AACV,iBAAS,KAAK,IAAI;AAAA,MACtB,OACK;AACD,2BAAmB,IAAI,MAAM,CAAC,IAAI,CAAC;AAAA,MACvC;AAAA,IACJ;AAAA,EACJ;AACA,SAAO;AACX;ACnBA,SAAS,8BAA8B,KAAK,MAAM;AAC9C,QAAM,qBAAqB,yBAAyB;AAAA,IAChD,CAAC,YAAY,CAAC,WAAW,CAAC;AAAA,IAC1B,CAAC,aAAa,CAAC,iBAAiB,CAAC;AAAA,IACjC,CAAC,YAAY,CAAC,WAAW,CAAC;AAAA,IAC1B,CAAC,kBAAkB,CAAC,WAAW,CAAC;AAAA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ChD,aAAa,MAAM;AAAA,QACnB,iBAAiB,MAAM;AAAA,MACvC,CAAa;AAAA,MACD,iCAAiC;AAAA,QAC7B,oBAAoB,MAAM,sBAAsB,CAAA;AAAA,QAChD,aAAa,MAAM;AAAA,QACnB,mBAAmB,MAAM;AAAA,MACzC,CAAa;AAAA,IACb;AAAA,EACA;AACA;AACO,SAAS,gBAAgB,WAAW,WAAW;AAClD,MAAI,WAAW,SAAS,GAAG;AACvB,WAAO,sBAAsB,WAAW,SAAS;AAAA,EACrD;AACA,SAAO,CAAC,QAAQ,sBAAsB,KAAK,SAAS;AACxD;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { w as watcher } from "./snapshot-
|
|
2
|
-
import { a, s } from "./snapshot-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { w as watcher } from "./snapshot-1d_HVP3L.js";
|
|
2
|
+
import { a, s, b, c } from "./snapshot-1d_HVP3L.js";
|
|
3
|
+
import { D as watchSignal, E as getSignal, l as isReactivePromise, v as isPromise, F as unwatchSignal } from "./contexts-ry5lvNSx.js";
|
|
4
|
+
import { n, G, H } from "./contexts-ry5lvNSx.js";
|
|
5
|
+
import { M as MAX_TIMEOUT } from "./config-BhtwQYAN.js";
|
|
5
6
|
function watchOnce(fn) {
|
|
6
7
|
const signal = watcher(fn);
|
|
7
8
|
try {
|
|
@@ -20,6 +21,34 @@ function watchOnce(fn) {
|
|
|
20
21
|
throw error;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
function retain(fn, opts) {
|
|
25
|
+
const ttl = opts?.ttl;
|
|
26
|
+
if (ttl !== void 0 && (typeof ttl !== "number" || Number.isNaN(ttl) || ttl < 0)) {
|
|
27
|
+
throw new RangeError(`signalium: retain() ttl must be a non-negative number of milliseconds, got ${String(ttl)}`);
|
|
28
|
+
}
|
|
29
|
+
const signal = watcher(fn);
|
|
30
|
+
const unsubscribe = signal.addListener(noop);
|
|
31
|
+
let timer;
|
|
32
|
+
const release = () => {
|
|
33
|
+
if (timer !== void 0) {
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
timer = void 0;
|
|
36
|
+
}
|
|
37
|
+
unsubscribe();
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
getSignal(signal);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
release();
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
if (ttl !== void 0 && ttl !== Infinity) {
|
|
46
|
+
timer = setTimeout(release, Math.min(ttl, MAX_TIMEOUT));
|
|
47
|
+
}
|
|
48
|
+
return release;
|
|
49
|
+
}
|
|
50
|
+
const noop = () => {
|
|
51
|
+
};
|
|
23
52
|
function forwardRelay(state, sourceRelay) {
|
|
24
53
|
if (!isReactivePromise(sourceRelay)) {
|
|
25
54
|
throw new Error("forwardRelay: sourceRelay must be a ReactivePromise");
|
|
@@ -44,11 +73,14 @@ function forwardRelay(state, sourceRelay) {
|
|
|
44
73
|
}
|
|
45
74
|
export {
|
|
46
75
|
forwardRelay,
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
n as hashValue,
|
|
77
|
+
G as registerCustomHash,
|
|
49
78
|
a as registerCustomSnapshot,
|
|
50
|
-
|
|
79
|
+
retain,
|
|
80
|
+
H as setReactivePromise,
|
|
51
81
|
s as snapshot,
|
|
82
|
+
b as snapshotArray,
|
|
83
|
+
c as snapshotPlainObject,
|
|
52
84
|
watchOnce
|
|
53
85
|
};
|
|
54
86
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns A promise that resolves with the function's return value\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n try {\n // Watch the signal to activate any relays\n watchSignal(signal);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (isReactivePromise(result) || isPromise(result)) {\n result = result.finally(() => {\n unwatchSignal(signal);\n });\n }\n else {\n unwatchSignal(signal);\n }\n return result;\n }\n catch (error) {\n unwatchSignal(signal);\n throw error;\n }\n}\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns A promise that resolves with the function's return value\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n try {\n // Watch the signal to activate any relays\n watchSignal(signal);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (isReactivePromise(result) || isPromise(result)) {\n result = result.finally(() => {\n unwatchSignal(signal);\n });\n }\n else {\n unwatchSignal(signal);\n }\n return result;\n }\n catch (error) {\n unwatchSignal(signal);\n throw error;\n }\n}\n/**\n * Keeps `fn`'s dependencies (relays, queries) watched until `ttl` ms pass or the returned\n * `release` is called. Without a `ttl`, or with `Infinity`, it lasts until released. A `ttl` above\n * 2^31 - 1 ms is clamped; a negative or `NaN` one throws a `RangeError`.\n *\n * Use it to keep data warm without rendering it, e.g. prefetching a likely next screen. `fn` runs\n * now, in the current scope, and again when its dependencies change.\n *\n * @example\n * ```ts\n * const release = retain(() => fetchTokenDetail(id), { ttl: 30_000 });\n * ```\n */\nexport function retain(fn, opts) {\n const ttl = opts?.ttl;\n if (ttl !== undefined && (typeof ttl !== 'number' || Number.isNaN(ttl) || ttl < 0)) {\n throw new RangeError(`signalium: retain() ttl must be a non-negative number of milliseconds, got ${String(ttl)}`);\n }\n const signal = watcher(fn);\n const unsubscribe = signal.addListener(noop);\n let timer;\n const release = () => {\n if (timer !== undefined) {\n clearTimeout(timer);\n timer = undefined;\n }\n unsubscribe();\n };\n try {\n // Run now so relays activate immediately, not on the next flush.\n getSignal(signal);\n }\n catch (error) {\n release();\n throw error;\n }\n // `setTimeout` fires immediately for delays above MAX_TIMEOUT.\n if (ttl !== undefined && ttl !== Infinity) {\n timer = setTimeout(release, Math.min(ttl, MAX_TIMEOUT));\n }\n return release;\n}\nconst noop = () => { };\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AA8BO,SAAS,UAAU,IAAI;AAE1B,QAAM,SAAS,QAAQ,EAAE;AACzB,MAAI;AAEA,gBAAY,MAAM;AAElB,QAAI,SAAS,UAAU,MAAM;AAC7B,QAAI,kBAAkB,MAAM,KAAK,UAAU,MAAM,GAAG;AAChD,eAAS,OAAO,QAAQ,MAAM;AAC1B,sBAAc,MAAM;AAAA,MACxB,CAAC;AAAA,IACL,OACK;AACD,oBAAc,MAAM;AAAA,IACxB;AACA,WAAO;AAAA,EACX,SACO,OAAO;AACV,kBAAc,MAAM;AACpB,UAAM;AAAA,EACV;AACJ;AAcO,SAAS,OAAO,IAAI,MAAM;AAC7B,QAAM,MAAM,MAAM;AAClB,MAAI,QAAQ,WAAc,OAAO,QAAQ,YAAY,OAAO,MAAM,GAAG,KAAK,MAAM,IAAI;AAChF,UAAM,IAAI,WAAW,8EAA8E,OAAO,GAAG,CAAC,EAAE;AAAA,EACpH;AACA,QAAM,SAAS,QAAQ,EAAE;AACzB,QAAM,cAAc,OAAO,YAAY,IAAI;AAC3C,MAAI;AACJ,QAAM,UAAU,MAAM;AAClB,QAAI,UAAU,QAAW;AACrB,mBAAa,KAAK;AAClB,cAAQ;AAAA,IACZ;AACA,gBAAW;AAAA,EACf;AACA,MAAI;AAEA,cAAU,MAAM;AAAA,EACpB,SACO,OAAO;AACV,YAAO;AACP,UAAM;AAAA,EACV;AAEA,MAAI,QAAQ,UAAa,QAAQ,UAAU;AACvC,YAAQ,WAAW,SAAS,KAAK,IAAI,KAAK,WAAW,CAAC;AAAA,EAC1D;AACA,SAAO;AACX;AACA,MAAM,OAAO,MAAM;AAAE;AAgCd,SAAS,aAAa,OAAO,aAAa;AAE7C,MAAI,CAAC,kBAAkB,WAAW,GAAG;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACzE;AAIA,MAAI,YAAY,WAAW;AAGvB,UAAM,SAAS;AACf,UAAM,UAAU,OAAO,UAAU;AACjC,QAAI,SAAS;AACT,YAAM,WAAW,OAAO;AAAA,IAC5B;AAAA,EACJ,WACS,YAAY,YAAY;AAE7B,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,SAAS,KAAK;AAAA,IACxB;AAAA,EACJ,WACS,YAAY,cAAc,YAAY,SAAS;AAEpD,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,QAAQ;AAAA,IAClB;AAAA,EACJ;AACJ;"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type * as ReactTypes from 'react';
|
|
2
2
|
import { ReactiveSignal } from '../internals/reactive.js';
|
|
3
|
+
import { type ReactReaderOptions } from './delivery.js';
|
|
4
|
+
export declare function createComponentElement<P extends object>(Inner: (props: P) => ReactTypes.ReactNode, props: P): ReactTypes.ReactElement;
|
|
5
|
+
/**
|
|
6
|
+
* Computes a `component()` signal during render. A suspended render pins its lease, so the relays
|
|
7
|
+
* it reads stay active until React retries it. A later attempt at the same element releases
|
|
8
|
+
* earlier attempts' pins once it has leased its own.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readComponentSignal<T>(signal: ReactiveSignal<T, []>, props: object): T;
|
|
3
11
|
/** Marked on the outer wrapper returned by `component()` for async (generator) definitions. */
|
|
4
12
|
export declare const SIGNALIUM_ASYNC_COMPONENT: unique symbol;
|
|
5
13
|
/**
|
|
@@ -36,7 +44,7 @@ export { isGeneratorFunction, isAsyncFunctionWithoutTransform } from './componen
|
|
|
36
44
|
export declare function runSyncReplayAsyncComponent<P extends object>(fn: (props: P) => Generator<any, ReactTypes.ReactNode | ReactTypes.ReactNode[] | null, unknown>, props: P, ownerSignal: ReactiveSignal<ReactTypes.ReactNode | ReactTypes.ReactNode[] | null, []>): ReactTypes.ReactNode | ReactTypes.ReactNode[] | null;
|
|
37
45
|
/**
|
|
38
46
|
* Async Signalium `component()`: one lazy reactive signal per **instance** (same as sync
|
|
39
|
-
* `component()`), outer `useMemo` keyed by `
|
|
47
|
+
* `component()`), outer `useMemo` keyed by `hashProps(props)`. No definition-scoped props map.
|
|
40
48
|
*/
|
|
41
|
-
export declare function createAsyncComponentWrapper<P extends object>(fn: (props: P) => Generator<any, ReactTypes.ReactNode | ReactTypes.ReactNode[] | null, unknown
|
|
49
|
+
export declare function createAsyncComponentWrapper<P extends object>(fn: (props: P) => Generator<any, ReactTypes.ReactNode | ReactTypes.ReactNode[] | null, unknown>, options?: ReactReaderOptions): (props: P) => ReactTypes.ReactNode;
|
|
42
50
|
//# sourceMappingURL=async-component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-component.d.ts","sourceRoot":"","sources":["../../../src/react/async-component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,UAAU,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAwB,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"async-component.d.ts","sourceRoot":"","sources":["../../../src/react/async-component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,UAAU,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAw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S,EAAE,GAAG,IAAI,EAAE,OAAO,CAAC,EAC/F,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,KAAK,EAAE,CAAC,KAAK,UAAU,CAAC,SAAS,CAgEpC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type ComponentRender } from './component-shared.js';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
/** Options for `component()`. Client-only (delivery modes); accepted and ignored on the server. */
|
|
3
|
+
export interface ComponentOptions {
|
|
4
|
+
delivery?: 'sync' | 'state';
|
|
5
|
+
}
|
|
6
|
+
export default function component<Props extends object>(fn: (props: Props) => Promise<ComponentRender>, options?: ComponentOptions): (props: Props) => Promise<ComponentRender>;
|
|
7
|
+
export default function component<Props extends object>(fn: (props: Props) => ComponentRender, options?: ComponentOptions): (props: Props) => ComponentRender;
|
|
4
8
|
//# sourceMappingURL=component-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-server.d.ts","sourceRoot":"","sources":["../../../src/react/component-server.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,SAAS,MAAM,EACpD,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"component-server.d.ts","sourceRoot":"","sources":["../../../src/react/component-server.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,uBAAuB,CAAC;AAE/B,mGAAmG;AACnG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,SAAS,MAAM,EACpD,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,eAAe,CAAC,EAC9C,OAAO,CAAC,EAAE,gBAAgB,GACzB,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAC9C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,SAAS,MAAM,EACpD,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,eAAe,EACrC,OAAO,CAAC,EAAE,gBAAgB,GACzB,CAAC,KAAK,EAAE,KAAK,KAAK,eAAe,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import { type ReactReaderOptions } from './delivery.js';
|
|
2
3
|
import { type ComponentRender } from './component-shared.js';
|
|
3
4
|
export { isAsyncFunctionWithoutTransform, runSyncReplayAsyncComponent, SIGNALIUM_ASYNC_COMPONENT, throwIfSignaliumAsyncComponentPassedToUse, } from './async-component.js';
|
|
4
|
-
|
|
5
|
-
export
|
|
5
|
+
/** Options for `component()`. */
|
|
6
|
+
export type ComponentOptions = ReactReaderOptions;
|
|
7
|
+
export default function component<Props extends object>(fn: (props: Props) => Promise<ComponentRender>, options?: ComponentOptions): (props: Props) => ReactNode;
|
|
8
|
+
export default function component<Props extends object>(fn: (props: Props) => ComponentRender, options?: ComponentOptions): (props: Props) => ReactNode;
|
|
6
9
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/react/component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/react/component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,OAAO,EAA4D,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElH,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,yBAAyB,EACzB,yCAAyC,GAC1C,MAAM,sBAAsB,CAAC;AAuB9B,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,SAAS,MAAM,EACpD,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,eAAe,CAAC,EAC9C,OAAO,CAAC,EAAE,gBAAgB,GACzB,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;AAC/B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,SAAS,MAAM,EACpD,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,eAAe,EACrC,OAAO,CAAC,EAAE,gBAAgB,GACzB,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ReactiveSignal } from '../internals/reactive.js';
|
|
2
|
+
import { type ReactDelivery } from '../internals/config.js';
|
|
3
|
+
import type { PauseSignalsManager } from './pause-signals-context.js';
|
|
4
|
+
export type { ReactDelivery };
|
|
5
|
+
/** Per-call options accepted by `component()`, `useReactive` and `useReactiveShallow`. */
|
|
6
|
+
export interface ReactReaderOptions {
|
|
7
|
+
/**
|
|
8
|
+
* How this reader learns about changes; overrides `setConfig({ reactDelivery })`. Use `'sync'`
|
|
9
|
+
* for readers whose values must stay correlated with other readers in every commit, and
|
|
10
|
+
* `'state'` for live-data leaves that should not hold up transitions. See {@link ReactDelivery}.
|
|
11
|
+
*/
|
|
12
|
+
delivery?: ReactDelivery;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a reader's delivery mode once per mounted instance. The mode decides which hooks the
|
|
16
|
+
* reader calls, so it must not change for the lifetime of the instance; a global config change
|
|
17
|
+
* applies to readers that mount afterwards.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useDeliveryMode(override: ReactDelivery | undefined): ReactDelivery;
|
|
20
|
+
declare const enum PullResult {
|
|
21
|
+
Current = 0,
|
|
22
|
+
Changed = 1,
|
|
23
|
+
Threw = 2
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* State-delivery bookkeeping for one mounted reader. `committed` is the signal version (its
|
|
27
|
+
* `updatedCount`) the last commit rendered; a notification only turns into a `setState` when the
|
|
28
|
+
* signal has moved past it.
|
|
29
|
+
*/
|
|
30
|
+
export declare class StateDelivery {
|
|
31
|
+
signal: ReactiveSignal<any, any>;
|
|
32
|
+
committed: number;
|
|
33
|
+
forceUpdate: () => void;
|
|
34
|
+
/** In the pending-delivery queue. */
|
|
35
|
+
queued: boolean;
|
|
36
|
+
/** A `setState` was delivered and its render has not committed yet. */
|
|
37
|
+
awaitingCommit: boolean;
|
|
38
|
+
/** Visible: between the subscription layout effect's setup and cleanup. Only visible readers get deliveries. */
|
|
39
|
+
mounted: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Set by every render, cleared by its commit. Still set when Suspense hides the reader, it means
|
|
42
|
+
* the reader's own render suspended, so it stays live: a change may no longer need what it
|
|
43
|
+
* suspended on.
|
|
44
|
+
*/
|
|
45
|
+
rendering: boolean;
|
|
46
|
+
/** The subscription layout effect has run before: its next run is a reveal, not a first mount. */
|
|
47
|
+
connected: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* A commit included the reader without connecting it: it was committed hidden (prerendered in a
|
|
50
|
+
* hidden `<Activity>`, or mounted into a Suspense-hidden tree), so its first connect is a reveal.
|
|
51
|
+
*/
|
|
52
|
+
committedHidden: boolean;
|
|
53
|
+
/** The subscription currently held, the subscribe function it was made with, and its signal and pause manager. */
|
|
54
|
+
subscribedWith: ((listener: () => void) => () => void) | null;
|
|
55
|
+
subscribedSignal: ReactiveSignal<any, any> | null;
|
|
56
|
+
pauseManager: PauseSignalsManager | null;
|
|
57
|
+
unsubscribe: (() => void) | null;
|
|
58
|
+
listener: () => void;
|
|
59
|
+
constructor(signal: ReactiveSignal<any, any>, version: number, forceUpdate: () => void);
|
|
60
|
+
check(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Brings the signal up to date the way a read would, and reports whether it moved past the
|
|
63
|
+
* committed version. A signal nobody watched (the reader was hidden, or its render lease expired
|
|
64
|
+
* before the commit) is not recomputed when its dependencies change, so its `updatedCount` alone
|
|
65
|
+
* can be stale.
|
|
66
|
+
*/
|
|
67
|
+
pull(): PullResult;
|
|
68
|
+
subscribe(subscribe: (listener: () => void) => () => void, manager: PauseSignalsManager | null): void;
|
|
69
|
+
release(): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A `'state'` reader's bookkeeping, for {@link useStateDelivery}. Call before the render reads
|
|
73
|
+
* `signal`, which may suspend.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useStateDeliveryState(signal: ReactiveSignal<any, any>): StateDelivery;
|
|
76
|
+
/**
|
|
77
|
+
* Drives a reader with `setState` instead of `useSyncExternalStore` (`delivery: 'state'`).
|
|
78
|
+
*
|
|
79
|
+
* The render reads the signal directly (so a render that happens for any other reason sees fresh
|
|
80
|
+
* data) and passes the version it rendered. On commit the reader subscribes, claiming the render
|
|
81
|
+
* lease that `subscribe` (the signal's `addListenerLazy` result) represents, pulls the signal and
|
|
82
|
+
* compares the version it rendered with the signal's current one, so a change that landed between
|
|
83
|
+
* render and subscribe is never lost. Notifications are coalesced per reader and flushed together,
|
|
84
|
+
* in one `runBatch`, on `scheduleReactDelivery`. The `setState` runs outside any transition, at
|
|
85
|
+
* React's default priority, which waits for an in-progress transition rather than restarting it.
|
|
86
|
+
*
|
|
87
|
+
* Revealing. When the subscription layout effect connects a reader that was hidden after it
|
|
88
|
+
* rendered, the reader pulls the signal and, if it moved since that render, updates with a
|
|
89
|
+
* `setState` from the layout effect. React renders that synchronously, before the revealing commit
|
|
90
|
+
* paints, so revealed content never shows a stale value; the cost is one SyncLane render of that
|
|
91
|
+
* reader, only when something changed, and nothing when nothing did. A reveal is a reconnect (the
|
|
92
|
+
* content was shown, then hidden) or the first connect of a reader that a commit included while
|
|
93
|
+
* hidden: content prerendered inside a hidden `<Activity>`, which mounts no effects until it is
|
|
94
|
+
* revealed. A first mount is not a reveal: a change between its render and its commit is
|
|
95
|
+
* delivered at default priority like any other, so a screen mounting while data ticks does not
|
|
96
|
+
* pay a second, synchronous render of every reader before it paints.
|
|
97
|
+
*
|
|
98
|
+
* Hiding. A Suspense boundary that hides already-revealed content (react-freeze) disconnects layout
|
|
99
|
+
* effects but not passive ones; `<Activity mode="hidden">` disconnects both. Deliveries follow the
|
|
100
|
+
* layout effect, so a hidden reader is not rendered, unless its own render is what suspended; the
|
|
101
|
+
* subscription follows the passive effect, so it lives exactly as long as a `useSyncExternalStore`
|
|
102
|
+
* subscription would: a Suspense hide keeps the signal watched (relays stay active), `<Activity>`
|
|
103
|
+
* and unmount release it. When the layout effect reconnects, the reader catches up as above, so
|
|
104
|
+
* revealed content never shows a value that changed while it was hidden.
|
|
105
|
+
*/
|
|
106
|
+
export declare function useStateDelivery(delivery: StateDelivery, signal: ReactiveSignal<any, any>, subscribe: (listener: () => void) => () => void, version: number, manager: PauseSignalsManager | null): void;
|
|
107
|
+
//# sourceMappingURL=delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../../src/react/delivery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAqD,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,0FAA0F;AAC1F,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;;GAIG;AACH,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a,CAOrF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAChC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,EAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,mBAAmB,GAAG,IAAI,GAClC,IAAI,CA0DN"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { ContextProvider } from './provider.js';
|
|
2
|
-
export { default as component, isAsyncFunctionWithoutTransform, runSyncReplayAsyncComponent, SIGNALIUM_ASYNC_COMPONENT, throwIfSignaliumAsyncComponentPassedToUse, } from './component.js';
|
|
2
|
+
export { default as component, type ComponentOptions, isAsyncFunctionWithoutTransform, runSyncReplayAsyncComponent, SIGNALIUM_ASYNC_COMPONENT, throwIfSignaliumAsyncComponentPassedToUse, } from './component.js';
|
|
3
3
|
export { useContext } from './context.js';
|
|
4
4
|
export { useSignal } from './use-signal.js';
|
|
5
|
-
export { useReactive, useReactiveShallow, useReactiveDeep } from './use-reactive.js';
|
|
5
|
+
export { useReactive, useReactiveShallow, useReactiveDeep, type ReactiveHookOptions } from './use-reactive.js';
|
|
6
|
+
export type { ReactDelivery, ReactReaderOptions } from './delivery.js';
|
|
6
7
|
export { PauseSignalsProvider } from './pause-signals-context.js';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,+BAA+B,EAC/B,2BAA2B,EAC3B,yBAAyB,EACzB,yCAAyC,GAC1C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,gBAAgB,EACrB,+BAA+B,EAC/B,2BAA2B,EAC3B,yBAAyB,EACzB,yCAAyC,GAC1C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC"}
|