signalium 2.3.2 → 2.4.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.
@@ -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/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 ['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 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 ], 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 ensureCallbackIdentifier(programPath) {\n // Try to 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 // 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 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 const callbackName = ensureCallbackIdentifier(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 === callbackName) {\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(callbackName), 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 === callbackName) {\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(callbackName), 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(callbackName), 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(callbackName), 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 { signaliumAsyncTransform } from './async.js';\nimport { signaliumCallbackTransform } from './callback.js';\nimport { signaliumPromiseMethodsTransform } from './promise.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 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":["importDecl","localName"],"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,KAA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AM,sBAAsB,CAAA;AAAA,QAChD,aAAa,MAAM;AAAA,QACnB,oBAAoB,MAAM;AAAA,MAC1C,CAAa;AAAA,MACD,wBAAwB,EAAE,oBAAoB,MAAM,sBAAsB,CAAA,GAAI,aAAa,MAAM,aAAa;AAAA,MAC9G,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
+ {"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 ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['useReactive', ['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 ['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', 'useReactiveDeep']);\n const filteredAdditional = opts?.transformedImports?.filter(([name]) => trackedNames.has(name));\n const transformedImports = createTransformedImports([\n ['useReactive', ['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,YAAY,CAAC,WAAW,CAAC;AAAA,IAC1B,CAAC,kBAAkB,CAAC,WAAW,CAAC;AAAA,IAChC,CAAC,SAAS,CAAC,WAAW,CAAC;A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,sBAAsB,KAAK,SAAS;AACxD;;;;;;"}
@@ -125,13 +125,14 @@ function useReactiveDeep(fn, ...args) {
125
125
  }
126
126
  const suspended = useSignalsSuspended();
127
127
  const scope = useScope() ?? contexts.getGlobalScope();
128
- const signalRef = react.useRef();
129
- const cloneSignalRef = react.useRef();
130
- const valueRef = react.useRef();
128
+ const signalRef = react.useRef(void 0);
129
+ const cloneSignalRef = react.useRef(void 0);
130
+ const valueRef = react.useRef(void 0);
131
131
  const [, def] = snapshot.getReactiveFnAndDefinition(fn);
132
132
  const signal = scope.get(def, args);
133
133
  if (signalRef.current !== signal) {
134
134
  signalRef.current = signal;
135
+ valueRef.current = void 0;
135
136
  cloneSignalRef.current = snapshot.reactiveSignal(() => {
136
137
  const next = snapshot.snapshot(signal.value, valueRef.current);
137
138
  valueRef.current = next;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../.tsc-out/react/context.js","../../../../.tsc-out/react/provider.js","../../../../.tsc-out/react/suspend-signals-context.js","../../../../.tsc-out/react/component.js","../../../../.tsc-out/react/use-signal.js","../../../../.tsc-out/react/use-reactive.js"],"sourcesContent":["import { createContext, useContext as useReactContext } from 'react';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nexport const ScopeContext = createContext(undefined);\nexport function useScope() {\n return useReactContext(ScopeContext);\n}\nexport function useContext(context) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scope = getCurrentConsumer()?.scope ?? useScope();\n if (!scope) {\n throw new Error('useContext must be used within a signal hook, a withContext, or a component');\n }\n return scope.getContext(context) ?? context.defaultValue;\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useContext, useMemo } from 'react';\nimport { ScopeContext } from './context.js';\nimport { getGlobalScope, SignalScope } from '../internals/contexts.js';\nimport { hashValue } from '../internals/utils/hash.js';\nexport function ContextProvider({ children, contexts = [], inherit = true, }) {\n const parentScope = useContext(ScopeContext) ?? getGlobalScope();\n const scope = useMemo(() => new SignalScope(contexts, inherit ? parentScope : undefined), \n // eslint-disable-next-line react-hooks/exhaustive-deps\n [parentScope, inherit, hashValue(contexts)]);\n return _jsx(ScopeContext.Provider, { value: scope, children: children });\n}\n","import { createContext, useContext } from 'react';\nconst SuspendSignalsContext = createContext(false);\nexport const SuspendSignalsProvider = SuspendSignalsContext.Provider;\nexport function useSignalsSuspended() {\n return useContext(SuspendSignalsContext);\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useMemo, useRef, useSyncExternalStore } from 'react';\nimport { useScope } from './context.js';\nimport { useSignalsSuspended } from './suspend-signals-context.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { runSignal } from '../internals/get.js';\nimport { hashValue } from '../internals/utils/hash.js';\nexport default function component(fn) {\n const Component = (props) => {\n const scope = useScope();\n const suspended = useSignalsSuspended();\n const fnSignalRef = useRef(undefined);\n const propsRef = useRef(props);\n propsRef.current = props;\n let signal = fnSignalRef.current;\n if (signal === undefined) {\n fnSignalRef.current = signal = createReactiveSignal({\n compute: () => fn(propsRef.current),\n equals: () => false,\n isRelay: false,\n tracer: undefined,\n }, [], undefined, scope);\n signal._isLazy = true;\n }\n signal.setSuspended(suspended);\n // We always want to re-render when the signal is updated, regardless of\n // whether or not the result changed. This is because the signal is lazy,\n // so it will not be updated until the next render.\n useSyncExternalStore(signal.addListenerLazy(), () => signal.updatedCount, () => signal.updatedCount);\n runSignal(signal);\n return signal.value;\n };\n return (props) => {\n const hash = hashValue(props);\n // Renders Comp only when hash changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => _jsx(Component, { ...props }), [hash]);\n };\n}\n","import { useRef } from 'react';\nimport { signal } from '../index.js';\nexport function useSignal(value, opts) {\n const ref = useRef(undefined);\n if (!ref.current) {\n ref.current = signal(value, opts);\n }\n return ref.current;\n}\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport { useCallback, useRef, useSyncExternalStore } from 'react';\nimport { getReactiveFnAndDefinition, reactiveSignal } from '../internals/core-api.js';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nimport { isReactivePromise, isRelay } from '../internals/async.js';\nimport { snapshot } from '../internals/utils/snapshot.js';\nimport { useScope } from './context.js';\nimport { useSignalsSuspended } from './suspend-signals-context.js';\nimport { getGlobalScope } from '../internals/contexts.js';\nconst useStateSignal = (signal) => {\n const suspended = useSignalsSuspended();\n return useSyncExternalStore(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(suspended ? () => () => { } : onStoreChange => signal.addListener(onStoreChange), [\n signal,\n suspended,\n ]), () => signal.value, () => signal.value);\n};\nconst useReactiveFnSignal = (signal) => {\n const suspended = useSignalsSuspended();\n signal.setSuspended(suspended);\n return useSyncExternalStore(signal.addListenerLazy(), () => signal.value, () => signal.value);\n};\nconst useReactivePromise = (promise) => {\n if (isRelay(promise)) {\n useReactiveFnSignal(promise['_signal']);\n }\n useStateSignal(promise['_version']);\n return promise;\n};\nconst useReactiveFn = (fn, ...args) => {\n const [, def] = getReactiveFnAndDefinition(fn);\n const scope = useScope() ?? getGlobalScope();\n const signal = scope.get(def, args);\n const value = useReactiveFnSignal(signal);\n // Reactive promises can update their value independently of the signal, since\n // we reuse the same promise object for each result. We need to entangle the\n // version of the promise here so that we can trigger a re-render when the\n // promise value updates.\n //\n // If hooks could be called in dynamic order this would not be necessary, we\n // could entangle the promise when it is used. But, because that is not the\n // case, we need to eagerly entangle.\n if (typeof value === 'object' && value !== null && isReactivePromise(value)) {\n return useReactivePromise(value);\n }\n return value;\n};\nconst isNonNullishAsyncSignal = (value) => {\n return typeof value === 'object' && value !== null && isReactivePromise(value);\n};\nexport function useReactive(signal, ...args) {\n if (getCurrentConsumer()) {\n if (typeof signal === 'function') {\n return signal(...args);\n }\n else if (isNonNullishAsyncSignal(signal)) {\n return signal;\n }\n else {\n return signal.value;\n }\n }\n if (typeof signal === 'function') {\n return useReactiveFn(signal, ...args);\n }\n else if (typeof signal === 'object' && signal !== null && isReactivePromise(signal)) {\n return useReactivePromise(signal);\n }\n else {\n return useStateSignal(signal);\n }\n}\nexport function useReactiveDeep(fn, ...args) {\n if (getCurrentConsumer()) {\n throw new Error('useReactiveDeep cannot be used inside of a reactive context. You can use the signal/function directly instead.');\n }\n const suspended = useSignalsSuspended();\n const scope = useScope() ?? getGlobalScope();\n const signalRef = useRef();\n const cloneSignalRef = useRef();\n const valueRef = useRef();\n const [, def] = getReactiveFnAndDefinition(fn);\n const signal = scope.get(def, args);\n if (signalRef.current !== signal) {\n signalRef.current = signal;\n cloneSignalRef.current = reactiveSignal(() => {\n const next = snapshot(signal.value, valueRef.current);\n valueRef.current = next;\n return next;\n });\n }\n const cloneSignal = cloneSignalRef.current;\n cloneSignal.setSuspended(suspended);\n return useSyncExternalStore(cloneSignal.addListenerLazy(), () => cloneSignal.value, () => cloneSignal.value);\n}\n"],"names":["createContext","useReactContext","getCurrentConsumer","contexts","useContext","getGlobalScope","useMemo","SignalScope","hashValue","_jsx","useRef","createReactiveSignal","useSyncExternalStore","runSignal","signal","useCallback","isRelay","getReactiveFnAndDefinition","isReactivePromise","reactiveSignal","snapshot"],"mappings":";;;;;;AAEO,MAAM,eAAeA,MAAAA,cAAc,MAAS;AAC5C,SAAS,WAAW;AACvB,SAAOC,MAAAA,WAAgB,YAAY;AACvC;AACO,SAAS,WAAW,SAAS;AAEhC,QAAM,QAAQC,SAAAA,sBAAsB,SAAS,SAAQ;AACrD,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,6EAA6E;AAAA,EACjG;AACA,SAAO,MAAM,WAAW,OAAO,KAAK,QAAQ;AAChD;ACRO,SAAS,gBAAgB,EAAE,UAAQ,UAAEC,aAAW,CAAA,GAAI,UAAU,QAAS;AAC1E,QAAM,cAAcC,MAAAA,WAAW,YAAY,KAAKC,SAAAA,eAAc;AAC9D,QAAM,QAAQC,MAAAA;AAAAA,IAAQ,MAAM,IAAIC,SAAAA,YAAYJ,YAAU,UAAU,cAAc,MAAS;AAAA;AAAA,IAEvF,CAAC,aAAa,SAASK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,OAAO;AAAA,IAClB;AAAA,EACJ;AACA,MAAI,OAAO,WAAW,YAAY;AAC9B,WAAO,cAAc,QAAQ,GAAG,IAAI;AAAA,EACxC,WACS,OAAO,WAAW,YAAY,WAAW,QAAQgB,SAAAA,kBAAkB,MAAM,GAAG;AACjF,WAAO,mBAAmB,MAAM;AAAA,EACpC,OACK;AACD,WAAO,eAAe,MAAM;AAAA,EAChC;AACJ;AACO,SAAS,gBAAgB,OAAO,MAAM;AACzC,MAAIhB,SAAAA,mBAAkB,GAAI;AACtB,UAAM,IAAI,MAAM,gHAAgH;AAAA,EACpI;AACA,QAAM,YAAY,oBAAmB;AACrC,QAAM,QAAQ,SAAQ,KAAMG,wBAAc;AAC1C,QAAM,YAAYK,MAAAA,OAAM;AACxB,QAAM,iBAAiBA,MAAAA,OAAM;AAC7B,QAAM,WAAWA,MAAAA,OAAM;AACvB,QAAM,GAAG,GAAG,IAAIO,SAAAA,2BAA2B,EAAE;AAC7C,QAAM,SAAS,MAAM,IAAI,KAAK,IAAI;AAClC,MAAI,UAAU,YAAY,QAAQ;AAC9B,cAAU,UAAU;AACpB,mBAAe,UAAUE,SAAAA,eAAe,MAAM;AAC1C,YAAM,OAAOC,SAAAA,SAAS,OAAO,OAAO,SAAS,OAAO;AACpD,eAAS,UAAU;AACnB,aAAO;AAAA,IACX,CAAC;AAAA,EACL;AACA,QAAM,cAAc,eAAe;AACnC,cAAY,aAAa,SAAS;AAClC,SAAOR,MAAAA,qBAAqB,YAAY,gBAAe,GAAI,MAAM,YAAY,OAAO,MAAM,YAAY,KAAK;AAC/G;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../.tsc-out/react/context.js","../../../../.tsc-out/react/provider.js","../../../../.tsc-out/react/suspend-signals-context.js","../../../../.tsc-out/react/component.js","../../../../.tsc-out/react/use-signal.js","../../../../.tsc-out/react/use-reactive.js"],"sourcesContent":["import { createContext, useContext as useReactContext } from 'react';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nexport const ScopeContext = createContext(undefined);\nexport function useScope() {\n return useReactContext(ScopeContext);\n}\nexport function useContext(context) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scope = getCurrentConsumer()?.scope ?? useScope();\n if (!scope) {\n throw new Error('useContext must be used within a signal hook, a withContext, or a component');\n }\n return scope.getContext(context) ?? context.defaultValue;\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useContext, useMemo } from 'react';\nimport { ScopeContext } from './context.js';\nimport { getGlobalScope, SignalScope } from '../internals/contexts.js';\nimport { hashValue } from '../internals/utils/hash.js';\nexport function ContextProvider({ children, contexts = [], inherit = true, }) {\n const parentScope = useContext(ScopeContext) ?? getGlobalScope();\n const scope = useMemo(() => new SignalScope(contexts, inherit ? parentScope : undefined), \n // eslint-disable-next-line react-hooks/exhaustive-deps\n [parentScope, inherit, hashValue(contexts)]);\n return _jsx(ScopeContext.Provider, { value: scope, children: children });\n}\n","import { createContext, useContext } from 'react';\nconst SuspendSignalsContext = createContext(false);\nexport const SuspendSignalsProvider = SuspendSignalsContext.Provider;\nexport function useSignalsSuspended() {\n return useContext(SuspendSignalsContext);\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useMemo, useRef, useSyncExternalStore } from 'react';\nimport { useScope } from './context.js';\nimport { useSignalsSuspended } from './suspend-signals-context.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { runSignal } from '../internals/get.js';\nimport { hashValue } from '../internals/utils/hash.js';\nexport default function component(fn) {\n const Component = (props) => {\n const scope = useScope();\n const suspended = useSignalsSuspended();\n const fnSignalRef = useRef(undefined);\n const propsRef = useRef(props);\n propsRef.current = props;\n let signal = fnSignalRef.current;\n if (signal === undefined) {\n fnSignalRef.current = signal = createReactiveSignal({\n compute: () => fn(propsRef.current),\n equals: () => false,\n isRelay: false,\n tracer: undefined,\n }, [], undefined, scope);\n signal._isLazy = true;\n }\n signal.setSuspended(suspended);\n // We always want to re-render when the signal is updated, regardless of\n // whether or not the result changed. This is because the signal is lazy,\n // so it will not be updated until the next render.\n useSyncExternalStore(signal.addListenerLazy(), () => signal.updatedCount, () => signal.updatedCount);\n runSignal(signal);\n return signal.value;\n };\n return (props) => {\n const hash = hashValue(props);\n // Renders Comp only when hash changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => _jsx(Component, { ...props }), [hash]);\n };\n}\n","import { useRef } from 'react';\nimport { signal } from '../index.js';\nexport function useSignal(value, opts) {\n const ref = useRef(undefined);\n if (!ref.current) {\n ref.current = signal(value, opts);\n }\n return ref.current;\n}\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport { useCallback, useRef, useSyncExternalStore } from 'react';\nimport { getReactiveFnAndDefinition, reactiveSignal } from '../internals/core-api.js';\nimport { getCurrentConsumer } from '../internals/consumer.js';\nimport { isReactivePromise, isRelay } from '../internals/async.js';\nimport { snapshot } from '../internals/utils/snapshot.js';\nimport { useScope } from './context.js';\nimport { useSignalsSuspended } from './suspend-signals-context.js';\nimport { getGlobalScope } from '../internals/contexts.js';\nconst useStateSignal = (signal) => {\n const suspended = useSignalsSuspended();\n return useSyncExternalStore(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(suspended ? () => () => { } : onStoreChange => signal.addListener(onStoreChange), [\n signal,\n suspended,\n ]), () => signal.value, () => signal.value);\n};\nconst useReactiveFnSignal = (signal) => {\n const suspended = useSignalsSuspended();\n signal.setSuspended(suspended);\n return useSyncExternalStore(signal.addListenerLazy(), () => signal.value, () => signal.value);\n};\nconst useReactivePromise = (promise) => {\n if (isRelay(promise)) {\n useReactiveFnSignal(promise['_signal']);\n }\n useStateSignal(promise['_version']);\n return promise;\n};\n/**\n * Resolves a thunk or `reactive()`-registered fn to its scope-cached\n * `ReactiveSignal` and subscribes. For inline thunks, `getReactiveFnAndDefinition`\n * memoizes the `ReactiveDefinition` in a `WeakMap` keyed by fn identity, so a\n * memoized thunk (via `useCallback` or the Signalium Babel preset) reuses the\n * same def + scope-cached signal across renders. A fresh fn each render\n * (pathological fallback case) produces a fresh signal per render, which is\n * correct but slower.\n */\nconst useReactiveFn = (fn, ...args) => {\n const [, def] = getReactiveFnAndDefinition(fn);\n const scope = useScope() ?? getGlobalScope();\n const signal = scope.get(def, args);\n const value = useReactiveFnSignal(signal);\n // Reactive promises can update their value independently of the signal, since\n // we reuse the same promise object for each result. We need to entangle the\n // version of the promise here so that we can trigger a re-render when the\n // promise value updates.\n //\n // If hooks could be called in dynamic order this would not be necessary, we\n // could entangle the promise when it is used. But, because that is not the\n // case, we need to eagerly entangle.\n if (typeof value === 'object' && value !== null && isReactivePromise(value)) {\n return useReactivePromise(value);\n }\n return value;\n};\nconst isNonNullishAsyncSignal = (value) => {\n return typeof value === 'object' && value !== null && isReactivePromise(value);\n};\nexport function useReactive(signal, ...args) {\n if (getCurrentConsumer()) {\n if (typeof signal === 'function') {\n return signal(...args);\n }\n else if (isNonNullishAsyncSignal(signal)) {\n return signal;\n }\n else {\n return signal.value;\n }\n }\n if (typeof signal === 'function') {\n return useReactiveFn(signal, ...args);\n }\n else if (typeof signal === 'object' && signal !== null && isReactivePromise(signal)) {\n return useReactivePromise(signal);\n }\n else {\n return useStateSignal(signal);\n }\n}\nexport function useReactiveDeep(fn, ...args) {\n if (getCurrentConsumer()) {\n throw new Error('useReactiveDeep cannot be used inside of a reactive context. You can use the signal/function directly instead.');\n }\n const suspended = useSignalsSuspended();\n const scope = useScope() ?? getGlobalScope();\n const signalRef = useRef(undefined);\n const cloneSignalRef = useRef(undefined);\n const valueRef = useRef(undefined);\n const [, def] = getReactiveFnAndDefinition(fn);\n const signal = scope.get(def, args);\n if (signalRef.current !== signal) {\n signalRef.current = signal;\n valueRef.current = undefined;\n cloneSignalRef.current = reactiveSignal(() => {\n const next = snapshot(signal.value, valueRef.current);\n valueRef.current = next;\n return next;\n });\n }\n const cloneSignal = cloneSignalRef.current;\n cloneSignal.setSuspended(suspended);\n return useSyncExternalStore(cloneSignal.addListenerLazy(), () => cloneSignal.value, () => cloneSignal.value);\n}\n"],"names":["createContext","useReactContext","getCurrentConsumer","contexts","useContext","getGlobalScope","useMemo","SignalScope","hashValue","_jsx","useRef","createReactiveSignal","useSyncExternalStore","runSignal","signal","useCallback","isRelay","getReactiveFnAndDefinition","isReactivePromise","reactiveSignal","snapshot"],"mappings":";;;;;;AAEO,MAAM,eAAeA,MAAAA,cAAc,MAAS;AAC5C,SAAS,WAAW;AACvB,SAAOC,MAAAA,WAAgB,YAAY;AACvC;AACO,SAAS,WAAW,SAAS;AAEhC,QAAM,QAAQC,SAAAA,sBAAsB,SAAS,SAAQ;AACrD,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,6EAA6E;AAAA,EACjG;AACA,SAAO,MAAM,WAAW,OAAO,KAAK,QAAQ;AAChD;ACRO,SAAS,gBAAgB,EAAE,UAAQ,UAAEC,aAAW,CAAA,GAAI,UAAU,QAAS;AAC1E,QAAM,cAAcC,MAAAA,WAAW,YAAY,KAAKC,SAAAA,eAAc;AAC9D,QAAM,QAAQC,MAAAA;AAAAA,IAAQ,MAAM,IAAIC,SAAAA,YAAYJ,YAAU,UAAU,cAAc,MAAS;AAAA;AAAA,IAEvF,CAAC,aAAa,SAASK,mBAAUL,UAAQ,CAAC;AAAA,EAAC;AAC3C,SAAOM,WAAAA,IAAK,aAAa,UAAU,EAAE,OAAO,OAAO,UAAoB;AAC3E;ACVA,MAAM,wBAAwBT,MAAAA,cAAc,KAAK;AACrC,MAAC,yBAAyB,sBAAsB;AACrD,SAAS,sBAAsB;AAClC,SAAOI,MAAAA,WAAW,qBAAqB;AAC3C;ACEe,SAAS,UAAU,IAAI;AAClC,QAAM,YAAY,CAAC,UAAU;AACzB,UAAM,QAAQ,SAAQ;AACtB,UAAM,YAAY,oBAAmB;AACrC,UAAM,cAAcM,MAAAA,OAAO,MAAS;AACpC,UAAM,WAAWA,MAAAA,OAAO,KAAK;AAC7B,aAAS,UAAU;AACnB,QAAI,SAAS,YAAY;AACzB,QAAI,WAA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C,QAAM,iBAAiBA,MAAAA,OAAO,MAAS;AACvC,QAAM,WAAWA,MAAAA,OAAO,MAAS;AACjC,QAAM,GAAG,GAAG,IAAIO,SAAAA,2BAA2B,EAAE;AAC7C,QAAM,SAAS,MAAM,IAAI,KAAK,IAAI;AAClC,MAAI,UAAU,YAAY,QAAQ;AAC9B,cAAU,UAAU;AACpB,aAAS,UAAU;AACnB,mBAAe,UAAUE,SAAAA,eAAe,MAAM;AAC1C,YAAM,OAAOC,SAAAA,SAAS,OAAO,OAAO,SAAS,OAAO;AACpD,eAAS,UAAU;AACnB,aAAO;AAAA,IACX,CAAC;AAAA,EACL;AACA,QAAM,cAAc,eAAe;AACnC,cAAY,aAAa,SAAS;AAClC,SAAOR,MAAAA,qBAAqB,YAAY,gBAAe,GAAI,MAAM,YAAY,OAAO,MAAM,YAAY,KAAK;AAC/G;;;;;;;;;"}
@@ -27,7 +27,9 @@ function createSignaliumAsyncTransform(api, opts) {
27
27
  ["reactiveMethod", ["signalium"]],
28
28
  ["relay", ["signalium"]],
29
29
  ["task", ["signalium"]],
30
- ["watcher", ["signalium"]]
30
+ ["watcher", ["signalium"]],
31
+ ["useReactive", ["signalium/react"]],
32
+ ["useReactiveDeep", ["signalium/react"]]
31
33
  ], opts?.transformedImports, opts?.importPaths);
32
34
  const t = api.types;
33
35
  const isTrackedImport = (localName, path) => {
@@ -114,7 +116,9 @@ function createSignaliumCallbackTransform(api, opts) {
114
116
  ["reactiveMethod", ["signalium"]],
115
117
  ["relay", ["signalium"]],
116
118
  ["task", ["signalium"]],
117
- ["watcher", ["signalium"]]
119
+ ["watcher", ["signalium"]],
120
+ ["useReactive", ["signalium/react"]],
121
+ ["useReactiveDeep", ["signalium/react"]]
118
122
  ], opts?.transformedImports, opts?.importPaths);
119
123
  const t = api.types;
120
124
  const callbackImportPath = opts?.callbackImportPath ?? "signalium";
@@ -159,14 +163,14 @@ function createSignaliumCallbackTransform(api, opts) {
159
163
  }
160
164
  return false;
161
165
  }
162
- function ensureCallbackIdentifier(programPath) {
166
+ function lookupCallbackIdentifier(programPath) {
163
167
  for (const bodyPath of programPath.get("body")) {
164
168
  if (!bodyPath.isImportDeclaration())
165
169
  continue;
166
- const importDecl2 = bodyPath.node;
167
- if (importDecl2.source.value !== callbackImportPath)
170
+ const importDecl = bodyPath.node;
171
+ if (importDecl.source.value !== callbackImportPath)
168
172
  continue;
169
- for (const spec of importDecl2.specifiers) {
173
+ for (const spec of importDecl.specifiers) {
170
174
  if (spec.type === "ImportSpecifier") {
171
175
  const ispec = spec;
172
176
  const imported = ispec.imported;
@@ -176,12 +180,20 @@ function createSignaliumCallbackTransform(api, opts) {
176
180
  }
177
181
  }
178
182
  }
183
+ return void 0;
184
+ }
185
+ function ensureCallbackIdentifier(programPath) {
186
+ const existing = lookupCallbackIdentifier(programPath);
187
+ if (existing !== void 0)
188
+ return existing;
179
189
  for (const bodyPath of programPath.get("body")) {
180
190
  if (!bodyPath.isImportDeclaration())
181
191
  continue;
182
192
  const node = bodyPath.node;
183
193
  if (node.source.value !== callbackImportPath)
184
194
  continue;
195
+ if (node.importKind === "type")
196
+ continue;
185
197
  const localName2 = programPath.scope.generateUidIdentifier("callback").name;
186
198
  node.specifiers.push(t.importSpecifier(t.identifier(localName2), t.identifier("callback")));
187
199
  return localName2;
@@ -239,7 +251,8 @@ function createSignaliumCallbackTransform(api, opts) {
239
251
  return;
240
252
  const outerFn = arg0;
241
253
  const programPath = callPath.findParent((p) => p.isProgram());
242
- const callbackName = ensureCallbackIdentifier(programPath);
254
+ const getCallbackName = () => ensureCallbackIdentifier(programPath);
255
+ const peekCallbackName = () => lookupCallbackIdentifier(programPath);
243
256
  const counters = /* @__PURE__ */ new WeakMap();
244
257
  counters.set(outerFn.node, 0);
245
258
  const getNextIndexFor = (fnNode) => {
@@ -284,7 +297,7 @@ function createSignaliumCallbackTransform(api, opts) {
284
297
  const callee = parent.node.callee;
285
298
  if (t.isIdentifier(callee)) {
286
299
  const calleeId = callee;
287
- if (calleeId.name === callbackName) {
300
+ if (calleeId.name === peekCallbackName()) {
288
301
  return;
289
302
  }
290
303
  }
@@ -296,7 +309,7 @@ function createSignaliumCallbackTransform(api, opts) {
296
309
  if (deps.length > 0) {
297
310
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
298
311
  }
299
- const wrapped = t.callExpression(t.identifier(callbackName), args);
312
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
300
313
  innerFnPath.replaceWith(wrapped);
301
314
  innerFnPath.skip();
302
315
  }
@@ -336,7 +349,7 @@ function createSignaliumCallbackTransform(api, opts) {
336
349
  const callee = parent.node.callee;
337
350
  if (t.isIdentifier(callee)) {
338
351
  const calleeId = callee;
339
- if (calleeId.name === callbackName) {
352
+ if (calleeId.name === peekCallbackName()) {
340
353
  return;
341
354
  }
342
355
  }
@@ -348,7 +361,7 @@ function createSignaliumCallbackTransform(api, opts) {
348
361
  if (deps.length > 0) {
349
362
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
350
363
  }
351
- const wrapped = t.callExpression(t.identifier(callbackName), args);
364
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
352
365
  innerFnPath.replaceWith(wrapped);
353
366
  innerFnPath.skip();
354
367
  }
@@ -370,7 +383,7 @@ function createSignaliumCallbackTransform(api, opts) {
370
383
  if (deps.length > 0) {
371
384
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
372
385
  }
373
- const wrapped = t.callExpression(t.identifier(callbackName), args);
386
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
374
387
  const constDecl = t.variableDeclaration("const", [t.variableDeclarator(id, wrapped)]);
375
388
  innerDeclPath.replaceWith(constDecl);
376
389
  innerDeclPath.skip();
@@ -392,7 +405,7 @@ function createSignaliumCallbackTransform(api, opts) {
392
405
  if (deps.length > 0) {
393
406
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
394
407
  }
395
- const wrapped = t.callExpression(t.identifier(callbackName), args);
408
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
396
409
  const key = innerMethodPath.node.key;
397
410
  const computed = innerMethodPath.node.computed || false;
398
411
  const prop = t.objectProperty(key, wrapped, computed);
@@ -528,6 +541,166 @@ function signaliumPromiseMethodsTransform(apiOrOpts, maybeOpts) {
528
541
  }
529
542
  return (api) => createSignaliumPromiseMethodsTransform(api, apiOrOpts);
530
543
  }
544
+ function createSignaliumUseReactiveTransform(api, opts) {
545
+ const trackedNames = /* @__PURE__ */ new Set(["useReactive", "useReactiveDeep"]);
546
+ const filteredAdditional = opts?.transformedImports?.filter(([name]) => trackedNames.has(name));
547
+ const transformedImports = createTransformedImports([
548
+ ["useReactive", ["signalium/react"]],
549
+ ["useReactiveDeep", ["signalium/react"]]
550
+ ], filteredAdditional, opts?.importPaths);
551
+ const t = api.types;
552
+ const reactImportPath = opts?.reactImportPath ?? "react";
553
+ const isTrackedImport = (localName, path) => {
554
+ const binding = path.scope.getBinding(localName);
555
+ if (!binding || !t.isImportSpecifier(binding.path.node))
556
+ return false;
557
+ const importSpec = binding.path.node;
558
+ const importedName = importSpec.imported.name;
559
+ const importDecl = binding.path.parent;
560
+ if (!t.isImportDeclaration(importDecl))
561
+ return false;
562
+ const importPaths = transformedImports.get(importedName);
563
+ if (!importPaths)
564
+ return false;
565
+ return importPaths.some((p) => typeof p === "string" ? importDecl.source.value === p : p.test(importDecl.source.value));
566
+ };
567
+ const isTargetCall = (path) => {
568
+ const callee = path.node.callee;
569
+ if (!t.isIdentifier(callee))
570
+ return false;
571
+ return isTrackedImport(callee.name, path);
572
+ };
573
+ function isIdentifierInTypePosition(refPath) {
574
+ let current = refPath.parentPath;
575
+ let child = refPath;
576
+ while (current) {
577
+ const nodeType = current.node.type;
578
+ if (nodeType && nodeType.startsWith("TS")) {
579
+ if (current.isTSAsExpression() || current.isTSSatisfiesExpression?.() || current.isTSNonNullExpression() || current.isTSInstantiationExpression?.()) {
580
+ if (child.key === "expression")
581
+ return false;
582
+ return true;
583
+ }
584
+ return true;
585
+ }
586
+ child = current;
587
+ current = current.parentPath;
588
+ }
589
+ return false;
590
+ }
591
+ function ensureUseCallbackIdentifier(programPath) {
592
+ for (const bodyPath of programPath.get("body")) {
593
+ if (!bodyPath.isImportDeclaration())
594
+ continue;
595
+ const importDecl2 = bodyPath.node;
596
+ if (importDecl2.source.value !== reactImportPath)
597
+ continue;
598
+ for (const spec of importDecl2.specifiers) {
599
+ if (spec.type !== "ImportSpecifier")
600
+ continue;
601
+ const ispec = spec;
602
+ const imported = ispec.imported;
603
+ if (imported && imported.name === "useCallback") {
604
+ return ispec.local.name;
605
+ }
606
+ }
607
+ }
608
+ for (const bodyPath of programPath.get("body")) {
609
+ if (!bodyPath.isImportDeclaration())
610
+ continue;
611
+ const node = bodyPath.node;
612
+ if (node.source.value !== reactImportPath)
613
+ continue;
614
+ const localName2 = programPath.scope.generateUidIdentifier("useCallback").name;
615
+ node.specifiers.push(t.importSpecifier(t.identifier(localName2), t.identifier("useCallback")));
616
+ return localName2;
617
+ }
618
+ const localName = programPath.scope.generateUidIdentifier("useCallback").name;
619
+ const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier("useCallback"))], t.stringLiteral(reactImportPath));
620
+ const [first] = programPath.get("body");
621
+ if (first) {
622
+ first.insertBefore(importDecl);
623
+ } else {
624
+ programPath.pushContainer("body", importDecl);
625
+ }
626
+ return localName;
627
+ }
628
+ function collectDeps(innerFn) {
629
+ const depNames = /* @__PURE__ */ new Set();
630
+ const innerScope = innerFn.scope;
631
+ const innerNode = innerFn.node;
632
+ innerFn.traverse({
633
+ ReferencedIdentifier(refPath) {
634
+ const nearestFn = refPath.getFunctionParent();
635
+ if (!nearestFn || nearestFn.node !== innerNode)
636
+ return;
637
+ const name = refPath.node.name;
638
+ const binding = refPath.scope.getBinding(name);
639
+ if (!binding)
640
+ return;
641
+ if (isIdentifierInTypePosition(refPath))
642
+ return;
643
+ if (binding.scope.path.isProgram())
644
+ return;
645
+ let declScope = binding.scope;
646
+ while (declScope) {
647
+ if (declScope === innerScope)
648
+ return;
649
+ declScope = declScope.parent;
650
+ }
651
+ if (binding.kind === "param" && binding.scope === innerScope)
652
+ return;
653
+ depNames.add(name);
654
+ }
655
+ });
656
+ return Array.from(depNames);
657
+ }
658
+ function isAlreadyMemoized(argPath) {
659
+ if (!argPath.isCallExpression())
660
+ return false;
661
+ const callee = argPath.node.callee;
662
+ if (!t.isIdentifier(callee))
663
+ return false;
664
+ const name = callee.name;
665
+ return name === "useCallback" || name === "useMemo" || /useCallback$/.test(name);
666
+ }
667
+ return {
668
+ name: "signalium-transform-use-reactive",
669
+ visitor: {
670
+ CallExpression(callPath) {
671
+ if (!isTargetCall(callPath))
672
+ return;
673
+ const args = callPath.get("arguments");
674
+ if (args.length !== 1)
675
+ return;
676
+ let fnPath = args[0];
677
+ while (fnPath.isTSAsExpression() || fnPath.isTSSatisfiesExpression?.() || fnPath.isTSNonNullExpression() || fnPath.isTSInstantiationExpression?.()) {
678
+ fnPath = fnPath.get("expression");
679
+ }
680
+ if (!(fnPath.isArrowFunctionExpression() || fnPath.isFunctionExpression()))
681
+ return;
682
+ if (isAlreadyMemoized(fnPath))
683
+ return;
684
+ const programPath = callPath.findParent((p) => p.isProgram());
685
+ const useCallbackName = ensureUseCallbackIdentifier(programPath);
686
+ const innerFn = fnPath;
687
+ const deps = collectDeps(innerFn);
688
+ const wrapped = t.callExpression(t.identifier(useCallbackName), [
689
+ innerFn.node,
690
+ t.arrayExpression(deps.map((n) => t.identifier(n)))
691
+ ]);
692
+ fnPath.replaceWith(wrapped);
693
+ fnPath.skip();
694
+ }
695
+ }
696
+ };
697
+ }
698
+ function signaliumUseReactiveTransform(apiOrOpts, maybeOpts) {
699
+ if (isBabelApi(apiOrOpts)) {
700
+ return createSignaliumUseReactiveTransform(apiOrOpts, maybeOpts);
701
+ }
702
+ return (api) => createSignaliumUseReactiveTransform(api, apiOrOpts);
703
+ }
531
704
  function createSignaliumPreset(api, opts) {
532
705
  return {
533
706
  plugins: [
@@ -537,6 +710,11 @@ function createSignaliumPreset(api, opts) {
537
710
  callbackImportPath: opts?.callbackImportPath
538
711
  }),
539
712
  signaliumAsyncTransform({ transformedImports: opts?.transformedImports ?? [], importPaths: opts?.importPaths }),
713
+ signaliumUseReactiveTransform({
714
+ transformedImports: opts?.transformedImports ?? [],
715
+ importPaths: opts?.importPaths,
716
+ reactImportPath: opts?.reactImportPath
717
+ }),
540
718
  signaliumPromiseMethodsTransform({
541
719
  transformedImports: opts?.transformedImports ?? [],
542
720
  importPaths: opts?.importPaths,
@@ -555,4 +733,5 @@ exports.signaliumAsyncTransform = signaliumAsyncTransform;
555
733
  exports.signaliumCallbackTransform = signaliumCallbackTransform;
556
734
  exports.signaliumPreset = signaliumPreset;
557
735
  exports.signaliumPromiseMethodsTransform = signaliumPromiseMethodsTransform;
736
+ exports.signaliumUseReactiveTransform = signaliumUseReactiveTransform;
558
737
  //# sourceMappingURL=index.js.map