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.
- package/CHANGELOG.md +35 -0
- package/dist/cjs/development/react/index.js +4 -3
- package/dist/cjs/development/react/index.js.map +1 -1
- package/dist/cjs/development/transform/index.js +192 -13
- package/dist/cjs/development/transform/index.js.map +1 -1
- package/dist/cjs/production/react/index.js +4 -3
- package/dist/cjs/production/react/index.js.map +1 -1
- package/dist/cjs/production/transform/index.js +192 -13
- package/dist/cjs/production/transform/index.js.map +1 -1
- package/dist/esm/development/react/index.js +4 -3
- package/dist/esm/development/react/index.js.map +1 -1
- package/dist/esm/development/transform/index.js +193 -14
- package/dist/esm/development/transform/index.js.map +1 -1
- package/dist/esm/production/react/index.js +4 -3
- package/dist/esm/production/react/index.js.map +1 -1
- package/dist/esm/production/transform/index.js +193 -14
- package/dist/esm/production/transform/index.js.map +1 -1
- package/dist/esm/react/use-reactive.d.ts +5 -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/index.d.ts +1 -0
- package/dist/esm/transform/index.d.ts.map +1 -1
- package/dist/esm/transform/preset.d.ts +1 -0
- package/dist/esm/transform/preset.d.ts.map +1 -1
- package/dist/esm/transform/use-reactive.d.ts +9 -0
- package/dist/esm/transform/use-reactive.d.ts.map +1 -0
- package/package.json +1 -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/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,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,CAA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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"],"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,8BAA8B,WAAW,WAAW;AAChE,MAAI,WAAW,SAAS,GAAG;AACvB,WAAO,oCAAoC,WAAW,SAAS;AAAA,EACnE;AACA,SAAO,CAAC,QAAQ,oCAAoC,KAAK,SAAS;AACtE;ACvLA,SAAS,sBAAsB,KAAK,MAAM;AACtC,SAAO;AAAA,IACH,SAAS;AAAA,MACL,2BAA2B;AAAA,QACvB,oBAAoB,MAAM,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,8BAA8B;AAAA,QAC1B,oBAAoB,MAAM,sBAAsB,CAAA;AAAA,QAChD,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;"}
|
|
@@ -123,13 +123,14 @@ function useReactiveDeep(fn, ...args) {
|
|
|
123
123
|
}
|
|
124
124
|
const suspended = useSignalsSuspended();
|
|
125
125
|
const scope = useScope() ?? getGlobalScope();
|
|
126
|
-
const signalRef = useRef();
|
|
127
|
-
const cloneSignalRef = useRef();
|
|
128
|
-
const valueRef = useRef();
|
|
126
|
+
const signalRef = useRef(void 0);
|
|
127
|
+
const cloneSignalRef = useRef(void 0);
|
|
128
|
+
const valueRef = useRef(void 0);
|
|
129
129
|
const [, def] = getReactiveFnAndDefinition(fn);
|
|
130
130
|
const signal2 = scope.get(def, args);
|
|
131
131
|
if (signalRef.current !== signal2) {
|
|
132
132
|
signalRef.current = signal2;
|
|
133
|
+
valueRef.current = void 0;
|
|
133
134
|
cloneSignalRef.current = reactiveSignal(() => {
|
|
134
135
|
const next = snapshot(signal2.value, valueRef.current);
|
|
135
136
|
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":["useReactContext","useContext","_jsx","signal"],"mappings":";;;;AAEO,MAAM,eAAe,cAAc,MAAS;AAC5C,SAAS,WAAW;AACvB,SAAOA,aAAgB,YAAY;AACvC;AACO,SAAS,WAAW,SAAS;AAEhC,QAAM,QAAQ,sBAAsB,SAAS,SAAQ;AACrD,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,6EAA6E;AAAA,EACjG;AACA,SAAO,MAAM,WAAW,OAAO,KAAK,QAAQ;AAChD;ACRO,SAAS,gBAAgB,EAAE,UAAU,WAAW,CAAA,GAAI,UAAU,QAAS;AAC1E,QAAM,cAAcC,aAAW,YAAY,KAAK,eAAc;AAC9D,QAAM,QAAQ;AAAA,IAAQ,MAAM,IAAI,YAAY,UAAU,UAAU,cAAc,MAAS;AAAA;AAAA,IAEvF,CAAC,aAAa,SAAS,UAAU,QAAQ,CAAC;AAAA,EAAC;AAC3C,SAAOC,IAAK,aAAa,UAAU,EAAE,OAAO,OAAO,UAAoB;AAC3E;ACVA,MAAM,wBAAwB,cAAc,KAAK;AACrC,MAAC,yBAAyB,sBAAsB;AACrD,SAAS,sBAAsB;AAClC,SAAOD,aAAW,qBAAqB;AAC3C;ACEe,SAAS,UAAU,IAAI;AAClC,QAAM,YAAY,CAAC,UAAU;AACzB,UAAM,QAAQ,SAAQ;AACtB,UAAM,YAAY,oBAAmB;AACrC,UAAM,cAAc,OAAO,MAAS;AACpC,UAAM,WAAW,OAAO,KAAK;AAC7B,aAAS,UAAU;AACnB,QAAIE,UAAS,YAAY;AACzB,QAAIA,YAAW,QAAW;AACtB,kBAAY,UAAUA,UAAS,qBAAqB;AAAA,QAChD,SAAS,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AU,YAAYA,SAAQ;AAC9B,cAAU,UAAUA;AACpB,mBAAe,UAAU,eAAe,MAAM;AAC1C,YAAM,OAAO,SAASA,QAAO,OAAO,SAAS,OAAO;AACpD,eAAS,UAAU;AACnB,aAAO;AAAA,IACX,CAAC;AAAA,EACL;AACA,QAAM,cAAc,eAAe;AACnC,cAAY,aAAa,SAAS;AAClC,SAAO,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":["useReactContext","useContext","_jsx","signal"],"mappings":";;;;AAEO,MAAM,eAAe,cAAc,MAAS;AAC5C,SAAS,WAAW;AACvB,SAAOA,aAAgB,YAAY;AACvC;AACO,SAAS,WAAW,SAAS;AAEhC,QAAM,QAAQ,sBAAsB,SAAS,SAAQ;AACrD,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,6EAA6E;AAAA,EACjG;AACA,SAAO,MAAM,WAAW,OAAO,KAAK,QAAQ;AAChD;ACRO,SAAS,gBAAgB,EAAE,UAAU,WAAW,CAAA,GAAI,UAAU,QAAS;AAC1E,QAAM,cAAcC,aAAW,YAAY,KAAK,eAAc;AAC9D,QAAM,QAAQ;AAAA,IAAQ,MAAM,IAAI,YAAY,UAAU,UAAU,cAAc,MAAS;AAAA;AAAA,IAEvF,CAAC,aAAa,SAAS,UAAU,QAAQ,CAAC;AAAA,EAAC;AAC3C,SAAOC,IAAK,aAAa,UAAU,EAAE,OAAO,OAAO,UAAoB;AAC3E;ACVA,MAAM,wBAAwB,cAAc,KAAK;AACr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,OAAM;AAAA,EAChC;AACJ;AACO,SAAS,gBAAgB,OAAO,MAAM;AACzC,MAAI,mBAAkB,GAAI;AACtB,UAAM,IAAI,MAAM,gHAAgH;AAAA,EACpI;AACA,QAAM,YAAY,oBAAmB;AACrC,QAAM,QAAQ,SAAQ,KAAM,eAAc;AAC1C,QAAM,YAAY,OAAO,MAAS;AAClC,QAAM,iBAAiB,OAAO,MAAS;AACvC,QAAM,WAAW,OAAO,MAAS;AACjC,QAAM,GAAG,GAAG,IAAI,2BAA2B,EAAE;AAC7C,QAAMA,UAAS,MAAM,IAAI,KAAK,IAAI;AAClC,MAAI,UAAU,YAAYA,SAAQ;AAC9B,cAAU,UAAUA;AACpB,aAAS,UAAU;AACnB,mBAAe,UAAU,eAAe,MAAM;AAC1C,YAAM,OAAO,SAASA,QAAO,OAAO,SAAS,OAAO;AACpD,eAAS,UAAU;AACnB,aAAO;AAAA,IACX,CAAC;AAAA,EACL;AACA,QAAM,cAAc,eAAe;AACnC,cAAY,aAAa,SAAS;AAClC,SAAO,qBAAqB,YAAY,gBAAe,GAAI,MAAM,YAAY,OAAO,MAAM,YAAY,KAAK;AAC/G;"}
|
|
@@ -25,7 +25,9 @@ function createSignaliumAsyncTransform(api, opts) {
|
|
|
25
25
|
["reactiveMethod", ["signalium"]],
|
|
26
26
|
["relay", ["signalium"]],
|
|
27
27
|
["task", ["signalium"]],
|
|
28
|
-
["watcher", ["signalium"]]
|
|
28
|
+
["watcher", ["signalium"]],
|
|
29
|
+
["useReactive", ["signalium/react"]],
|
|
30
|
+
["useReactiveDeep", ["signalium/react"]]
|
|
29
31
|
], opts?.transformedImports, opts?.importPaths);
|
|
30
32
|
const t = api.types;
|
|
31
33
|
const isTrackedImport = (localName, path) => {
|
|
@@ -112,7 +114,9 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
112
114
|
["reactiveMethod", ["signalium"]],
|
|
113
115
|
["relay", ["signalium"]],
|
|
114
116
|
["task", ["signalium"]],
|
|
115
|
-
["watcher", ["signalium"]]
|
|
117
|
+
["watcher", ["signalium"]],
|
|
118
|
+
["useReactive", ["signalium/react"]],
|
|
119
|
+
["useReactiveDeep", ["signalium/react"]]
|
|
116
120
|
], opts?.transformedImports, opts?.importPaths);
|
|
117
121
|
const t = api.types;
|
|
118
122
|
const callbackImportPath = opts?.callbackImportPath ?? "signalium";
|
|
@@ -157,14 +161,14 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
157
161
|
}
|
|
158
162
|
return false;
|
|
159
163
|
}
|
|
160
|
-
function
|
|
164
|
+
function lookupCallbackIdentifier(programPath) {
|
|
161
165
|
for (const bodyPath of programPath.get("body")) {
|
|
162
166
|
if (!bodyPath.isImportDeclaration())
|
|
163
167
|
continue;
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
168
|
+
const importDecl = bodyPath.node;
|
|
169
|
+
if (importDecl.source.value !== callbackImportPath)
|
|
166
170
|
continue;
|
|
167
|
-
for (const spec of
|
|
171
|
+
for (const spec of importDecl.specifiers) {
|
|
168
172
|
if (spec.type === "ImportSpecifier") {
|
|
169
173
|
const ispec = spec;
|
|
170
174
|
const imported = ispec.imported;
|
|
@@ -174,12 +178,20 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
}
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
function ensureCallbackIdentifier(programPath) {
|
|
184
|
+
const existing = lookupCallbackIdentifier(programPath);
|
|
185
|
+
if (existing !== void 0)
|
|
186
|
+
return existing;
|
|
177
187
|
for (const bodyPath of programPath.get("body")) {
|
|
178
188
|
if (!bodyPath.isImportDeclaration())
|
|
179
189
|
continue;
|
|
180
190
|
const node = bodyPath.node;
|
|
181
191
|
if (node.source.value !== callbackImportPath)
|
|
182
192
|
continue;
|
|
193
|
+
if (node.importKind === "type")
|
|
194
|
+
continue;
|
|
183
195
|
const localName2 = programPath.scope.generateUidIdentifier("callback").name;
|
|
184
196
|
node.specifiers.push(t.importSpecifier(t.identifier(localName2), t.identifier("callback")));
|
|
185
197
|
return localName2;
|
|
@@ -237,7 +249,8 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
237
249
|
return;
|
|
238
250
|
const outerFn = arg0;
|
|
239
251
|
const programPath = callPath.findParent((p) => p.isProgram());
|
|
240
|
-
const
|
|
252
|
+
const getCallbackName = () => ensureCallbackIdentifier(programPath);
|
|
253
|
+
const peekCallbackName = () => lookupCallbackIdentifier(programPath);
|
|
241
254
|
const counters = /* @__PURE__ */ new WeakMap();
|
|
242
255
|
counters.set(outerFn.node, 0);
|
|
243
256
|
const getNextIndexFor = (fnNode) => {
|
|
@@ -282,7 +295,7 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
282
295
|
const callee = parent.node.callee;
|
|
283
296
|
if (t.isIdentifier(callee)) {
|
|
284
297
|
const calleeId = callee;
|
|
285
|
-
if (calleeId.name ===
|
|
298
|
+
if (calleeId.name === peekCallbackName()) {
|
|
286
299
|
return;
|
|
287
300
|
}
|
|
288
301
|
}
|
|
@@ -294,7 +307,7 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
294
307
|
if (deps.length > 0) {
|
|
295
308
|
args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
|
|
296
309
|
}
|
|
297
|
-
const wrapped = t.callExpression(t.identifier(
|
|
310
|
+
const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
|
|
298
311
|
innerFnPath.replaceWith(wrapped);
|
|
299
312
|
innerFnPath.skip();
|
|
300
313
|
}
|
|
@@ -334,7 +347,7 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
334
347
|
const callee = parent.node.callee;
|
|
335
348
|
if (t.isIdentifier(callee)) {
|
|
336
349
|
const calleeId = callee;
|
|
337
|
-
if (calleeId.name ===
|
|
350
|
+
if (calleeId.name === peekCallbackName()) {
|
|
338
351
|
return;
|
|
339
352
|
}
|
|
340
353
|
}
|
|
@@ -346,7 +359,7 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
346
359
|
if (deps.length > 0) {
|
|
347
360
|
args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
|
|
348
361
|
}
|
|
349
|
-
const wrapped = t.callExpression(t.identifier(
|
|
362
|
+
const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
|
|
350
363
|
innerFnPath.replaceWith(wrapped);
|
|
351
364
|
innerFnPath.skip();
|
|
352
365
|
}
|
|
@@ -368,7 +381,7 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
368
381
|
if (deps.length > 0) {
|
|
369
382
|
args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
|
|
370
383
|
}
|
|
371
|
-
const wrapped = t.callExpression(t.identifier(
|
|
384
|
+
const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
|
|
372
385
|
const constDecl = t.variableDeclaration("const", [t.variableDeclarator(id, wrapped)]);
|
|
373
386
|
innerDeclPath.replaceWith(constDecl);
|
|
374
387
|
innerDeclPath.skip();
|
|
@@ -390,7 +403,7 @@ function createSignaliumCallbackTransform(api, opts) {
|
|
|
390
403
|
if (deps.length > 0) {
|
|
391
404
|
args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
|
|
392
405
|
}
|
|
393
|
-
const wrapped = t.callExpression(t.identifier(
|
|
406
|
+
const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
|
|
394
407
|
const key = innerMethodPath.node.key;
|
|
395
408
|
const computed = innerMethodPath.node.computed || false;
|
|
396
409
|
const prop = t.objectProperty(key, wrapped, computed);
|
|
@@ -526,6 +539,166 @@ function signaliumPromiseMethodsTransform(apiOrOpts, maybeOpts) {
|
|
|
526
539
|
}
|
|
527
540
|
return (api) => createSignaliumPromiseMethodsTransform(api, apiOrOpts);
|
|
528
541
|
}
|
|
542
|
+
function createSignaliumUseReactiveTransform(api, opts) {
|
|
543
|
+
const trackedNames = /* @__PURE__ */ new Set(["useReactive", "useReactiveDeep"]);
|
|
544
|
+
const filteredAdditional = opts?.transformedImports?.filter(([name]) => trackedNames.has(name));
|
|
545
|
+
const transformedImports = createTransformedImports([
|
|
546
|
+
["useReactive", ["signalium/react"]],
|
|
547
|
+
["useReactiveDeep", ["signalium/react"]]
|
|
548
|
+
], filteredAdditional, opts?.importPaths);
|
|
549
|
+
const t = api.types;
|
|
550
|
+
const reactImportPath = opts?.reactImportPath ?? "react";
|
|
551
|
+
const isTrackedImport = (localName, path) => {
|
|
552
|
+
const binding = path.scope.getBinding(localName);
|
|
553
|
+
if (!binding || !t.isImportSpecifier(binding.path.node))
|
|
554
|
+
return false;
|
|
555
|
+
const importSpec = binding.path.node;
|
|
556
|
+
const importedName = importSpec.imported.name;
|
|
557
|
+
const importDecl = binding.path.parent;
|
|
558
|
+
if (!t.isImportDeclaration(importDecl))
|
|
559
|
+
return false;
|
|
560
|
+
const importPaths = transformedImports.get(importedName);
|
|
561
|
+
if (!importPaths)
|
|
562
|
+
return false;
|
|
563
|
+
return importPaths.some((p) => typeof p === "string" ? importDecl.source.value === p : p.test(importDecl.source.value));
|
|
564
|
+
};
|
|
565
|
+
const isTargetCall = (path) => {
|
|
566
|
+
const callee = path.node.callee;
|
|
567
|
+
if (!t.isIdentifier(callee))
|
|
568
|
+
return false;
|
|
569
|
+
return isTrackedImport(callee.name, path);
|
|
570
|
+
};
|
|
571
|
+
function isIdentifierInTypePosition(refPath) {
|
|
572
|
+
let current = refPath.parentPath;
|
|
573
|
+
let child = refPath;
|
|
574
|
+
while (current) {
|
|
575
|
+
const nodeType = current.node.type;
|
|
576
|
+
if (nodeType && nodeType.startsWith("TS")) {
|
|
577
|
+
if (current.isTSAsExpression() || current.isTSSatisfiesExpression?.() || current.isTSNonNullExpression() || current.isTSInstantiationExpression?.()) {
|
|
578
|
+
if (child.key === "expression")
|
|
579
|
+
return false;
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
child = current;
|
|
585
|
+
current = current.parentPath;
|
|
586
|
+
}
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
function ensureUseCallbackIdentifier(programPath) {
|
|
590
|
+
for (const bodyPath of programPath.get("body")) {
|
|
591
|
+
if (!bodyPath.isImportDeclaration())
|
|
592
|
+
continue;
|
|
593
|
+
const importDecl2 = bodyPath.node;
|
|
594
|
+
if (importDecl2.source.value !== reactImportPath)
|
|
595
|
+
continue;
|
|
596
|
+
for (const spec of importDecl2.specifiers) {
|
|
597
|
+
if (spec.type !== "ImportSpecifier")
|
|
598
|
+
continue;
|
|
599
|
+
const ispec = spec;
|
|
600
|
+
const imported = ispec.imported;
|
|
601
|
+
if (imported && imported.name === "useCallback") {
|
|
602
|
+
return ispec.local.name;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
for (const bodyPath of programPath.get("body")) {
|
|
607
|
+
if (!bodyPath.isImportDeclaration())
|
|
608
|
+
continue;
|
|
609
|
+
const node = bodyPath.node;
|
|
610
|
+
if (node.source.value !== reactImportPath)
|
|
611
|
+
continue;
|
|
612
|
+
const localName2 = programPath.scope.generateUidIdentifier("useCallback").name;
|
|
613
|
+
node.specifiers.push(t.importSpecifier(t.identifier(localName2), t.identifier("useCallback")));
|
|
614
|
+
return localName2;
|
|
615
|
+
}
|
|
616
|
+
const localName = programPath.scope.generateUidIdentifier("useCallback").name;
|
|
617
|
+
const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier("useCallback"))], t.stringLiteral(reactImportPath));
|
|
618
|
+
const [first] = programPath.get("body");
|
|
619
|
+
if (first) {
|
|
620
|
+
first.insertBefore(importDecl);
|
|
621
|
+
} else {
|
|
622
|
+
programPath.pushContainer("body", importDecl);
|
|
623
|
+
}
|
|
624
|
+
return localName;
|
|
625
|
+
}
|
|
626
|
+
function collectDeps(innerFn) {
|
|
627
|
+
const depNames = /* @__PURE__ */ new Set();
|
|
628
|
+
const innerScope = innerFn.scope;
|
|
629
|
+
const innerNode = innerFn.node;
|
|
630
|
+
innerFn.traverse({
|
|
631
|
+
ReferencedIdentifier(refPath) {
|
|
632
|
+
const nearestFn = refPath.getFunctionParent();
|
|
633
|
+
if (!nearestFn || nearestFn.node !== innerNode)
|
|
634
|
+
return;
|
|
635
|
+
const name = refPath.node.name;
|
|
636
|
+
const binding = refPath.scope.getBinding(name);
|
|
637
|
+
if (!binding)
|
|
638
|
+
return;
|
|
639
|
+
if (isIdentifierInTypePosition(refPath))
|
|
640
|
+
return;
|
|
641
|
+
if (binding.scope.path.isProgram())
|
|
642
|
+
return;
|
|
643
|
+
let declScope = binding.scope;
|
|
644
|
+
while (declScope) {
|
|
645
|
+
if (declScope === innerScope)
|
|
646
|
+
return;
|
|
647
|
+
declScope = declScope.parent;
|
|
648
|
+
}
|
|
649
|
+
if (binding.kind === "param" && binding.scope === innerScope)
|
|
650
|
+
return;
|
|
651
|
+
depNames.add(name);
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
return Array.from(depNames);
|
|
655
|
+
}
|
|
656
|
+
function isAlreadyMemoized(argPath) {
|
|
657
|
+
if (!argPath.isCallExpression())
|
|
658
|
+
return false;
|
|
659
|
+
const callee = argPath.node.callee;
|
|
660
|
+
if (!t.isIdentifier(callee))
|
|
661
|
+
return false;
|
|
662
|
+
const name = callee.name;
|
|
663
|
+
return name === "useCallback" || name === "useMemo" || /useCallback$/.test(name);
|
|
664
|
+
}
|
|
665
|
+
return {
|
|
666
|
+
name: "signalium-transform-use-reactive",
|
|
667
|
+
visitor: {
|
|
668
|
+
CallExpression(callPath) {
|
|
669
|
+
if (!isTargetCall(callPath))
|
|
670
|
+
return;
|
|
671
|
+
const args = callPath.get("arguments");
|
|
672
|
+
if (args.length !== 1)
|
|
673
|
+
return;
|
|
674
|
+
let fnPath = args[0];
|
|
675
|
+
while (fnPath.isTSAsExpression() || fnPath.isTSSatisfiesExpression?.() || fnPath.isTSNonNullExpression() || fnPath.isTSInstantiationExpression?.()) {
|
|
676
|
+
fnPath = fnPath.get("expression");
|
|
677
|
+
}
|
|
678
|
+
if (!(fnPath.isArrowFunctionExpression() || fnPath.isFunctionExpression()))
|
|
679
|
+
return;
|
|
680
|
+
if (isAlreadyMemoized(fnPath))
|
|
681
|
+
return;
|
|
682
|
+
const programPath = callPath.findParent((p) => p.isProgram());
|
|
683
|
+
const useCallbackName = ensureUseCallbackIdentifier(programPath);
|
|
684
|
+
const innerFn = fnPath;
|
|
685
|
+
const deps = collectDeps(innerFn);
|
|
686
|
+
const wrapped = t.callExpression(t.identifier(useCallbackName), [
|
|
687
|
+
innerFn.node,
|
|
688
|
+
t.arrayExpression(deps.map((n) => t.identifier(n)))
|
|
689
|
+
]);
|
|
690
|
+
fnPath.replaceWith(wrapped);
|
|
691
|
+
fnPath.skip();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
function signaliumUseReactiveTransform(apiOrOpts, maybeOpts) {
|
|
697
|
+
if (isBabelApi(apiOrOpts)) {
|
|
698
|
+
return createSignaliumUseReactiveTransform(apiOrOpts, maybeOpts);
|
|
699
|
+
}
|
|
700
|
+
return (api) => createSignaliumUseReactiveTransform(api, apiOrOpts);
|
|
701
|
+
}
|
|
529
702
|
function createSignaliumPreset(api, opts) {
|
|
530
703
|
return {
|
|
531
704
|
plugins: [
|
|
@@ -535,6 +708,11 @@ function createSignaliumPreset(api, opts) {
|
|
|
535
708
|
callbackImportPath: opts?.callbackImportPath
|
|
536
709
|
}),
|
|
537
710
|
signaliumAsyncTransform({ transformedImports: opts?.transformedImports ?? [], importPaths: opts?.importPaths }),
|
|
711
|
+
signaliumUseReactiveTransform({
|
|
712
|
+
transformedImports: opts?.transformedImports ?? [],
|
|
713
|
+
importPaths: opts?.importPaths,
|
|
714
|
+
reactImportPath: opts?.reactImportPath
|
|
715
|
+
}),
|
|
538
716
|
signaliumPromiseMethodsTransform({
|
|
539
717
|
transformedImports: opts?.transformedImports ?? [],
|
|
540
718
|
importPaths: opts?.importPaths,
|
|
@@ -553,6 +731,7 @@ export {
|
|
|
553
731
|
signaliumAsyncTransform,
|
|
554
732
|
signaliumCallbackTransform,
|
|
555
733
|
signaliumPreset,
|
|
556
|
-
signaliumPromiseMethodsTransform
|
|
734
|
+
signaliumPromiseMethodsTransform,
|
|
735
|
+
signaliumUseReactiveTransform
|
|
557
736
|
};
|
|
558
737
|
//# sourceMappingURL=index.js.map
|