signalium 2.3.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/dist/cjs/development/component-shared-Cug2Y5YZ.js +33 -0
  3. package/dist/cjs/development/component-shared-Cug2Y5YZ.js.map +1 -0
  4. package/dist/cjs/development/{debug-ouT0N0E4.js → debug-C46WDxhL.js} +47 -195
  5. package/dist/cjs/development/debug-C46WDxhL.js.map +1 -0
  6. package/dist/cjs/development/debug.js +1 -1
  7. package/dist/cjs/development/index.js +3 -2
  8. package/dist/cjs/development/index.js.map +1 -1
  9. package/dist/cjs/development/react/index.js +256 -87
  10. package/dist/cjs/development/react/index.js.map +1 -1
  11. package/dist/cjs/development/react/index.server.js +14 -0
  12. package/dist/cjs/development/react/index.server.js.map +1 -0
  13. package/dist/cjs/development/react/server.js +37 -0
  14. package/dist/cjs/development/react/server.js.map +1 -0
  15. package/dist/cjs/development/{snapshot-BPJ-qw6l.js → snapshot-48aGePMZ.js} +2 -2
  16. package/dist/cjs/development/{snapshot-BPJ-qw6l.js.map → snapshot-48aGePMZ.js.map} +1 -1
  17. package/dist/cjs/development/transform/index.js +196 -13
  18. package/dist/cjs/development/transform/index.js.map +1 -1
  19. package/dist/cjs/development/utils.js +6 -6
  20. package/dist/cjs/development/utils.js.map +1 -1
  21. package/dist/cjs/production/component-shared-D0J85PUi.js +33 -0
  22. package/dist/cjs/production/component-shared-D0J85PUi.js.map +1 -0
  23. package/dist/cjs/production/{contexts-DtQMtXO7.js → contexts-CM3QLfV8.js} +47 -198
  24. package/dist/cjs/production/contexts-CM3QLfV8.js.map +1 -0
  25. package/dist/cjs/production/debug.js +1 -1
  26. package/dist/cjs/production/index.js +3 -2
  27. package/dist/cjs/production/index.js.map +1 -1
  28. package/dist/cjs/production/react/index.js +242 -89
  29. package/dist/cjs/production/react/index.js.map +1 -1
  30. package/dist/cjs/production/react/index.server.js +14 -0
  31. package/dist/cjs/production/react/index.server.js.map +1 -0
  32. package/dist/cjs/production/react/server.js +37 -0
  33. package/dist/cjs/production/react/server.js.map +1 -0
  34. package/dist/cjs/production/{snapshot-Dw62eSpw.js → snapshot-BCESZVAP.js} +2 -2
  35. package/dist/cjs/production/{snapshot-Dw62eSpw.js.map → snapshot-BCESZVAP.js.map} +1 -1
  36. package/dist/cjs/production/transform/index.js +196 -13
  37. package/dist/cjs/production/transform/index.js.map +1 -1
  38. package/dist/cjs/production/utils.js +6 -6
  39. package/dist/cjs/production/utils.js.map +1 -1
  40. package/dist/esm/development/component-shared-CLSmdnGU.js +34 -0
  41. package/dist/esm/development/component-shared-CLSmdnGU.js.map +1 -0
  42. package/dist/esm/development/{debug-DaK9qsbI.js → debug-BTLbgTPK.js} +79 -227
  43. package/dist/esm/development/debug-BTLbgTPK.js.map +1 -0
  44. package/dist/esm/development/debug.js +9 -9
  45. package/dist/esm/development/index.js +14 -13
  46. package/dist/esm/development/react/index.js +232 -79
  47. package/dist/esm/development/react/index.js.map +1 -1
  48. package/dist/esm/development/react/index.server.js +14 -0
  49. package/dist/esm/development/react/index.server.js.map +1 -0
  50. package/dist/esm/development/react/server.js +20 -0
  51. package/dist/esm/development/react/server.js.map +1 -0
  52. package/dist/esm/development/{snapshot-D8ZJEbwO.js → snapshot-Ca_rQa4c.js} +2 -2
  53. package/dist/esm/development/{snapshot-D8ZJEbwO.js.map → snapshot-Ca_rQa4c.js.map} +1 -1
  54. package/dist/esm/development/transform/index.js +197 -14
  55. package/dist/esm/development/transform/index.js.map +1 -1
  56. package/dist/esm/development/utils.js +11 -11
  57. package/dist/esm/development/utils.js.map +1 -1
  58. package/dist/esm/index.d.ts +2 -2
  59. package/dist/esm/index.d.ts.map +1 -1
  60. package/dist/esm/internals/async.d.ts +3 -3
  61. package/dist/esm/internals/async.d.ts.map +1 -1
  62. package/dist/esm/internals/contexts.d.ts +10 -6
  63. package/dist/esm/internals/contexts.d.ts.map +1 -1
  64. package/dist/esm/internals/core-api.d.ts +2 -2
  65. package/dist/esm/internals/core-api.d.ts.map +1 -1
  66. package/dist/esm/internals/get.d.ts.map +1 -1
  67. package/dist/esm/internals/reactive.d.ts +3 -9
  68. package/dist/esm/internals/reactive.d.ts.map +1 -1
  69. package/dist/esm/internals/scheduling.d.ts +0 -2
  70. package/dist/esm/internals/scheduling.d.ts.map +1 -1
  71. package/dist/esm/internals/watch.d.ts +3 -4
  72. package/dist/esm/internals/watch.d.ts.map +1 -1
  73. package/dist/esm/production/component-shared-Dva0S5e3.js +34 -0
  74. package/dist/esm/production/component-shared-Dva0S5e3.js.map +1 -0
  75. package/dist/esm/production/{contexts-US_h2nBi.js → contexts-FxCndlvf.js} +71 -222
  76. package/dist/esm/production/contexts-FxCndlvf.js.map +1 -0
  77. package/dist/esm/production/debug.js +1 -1
  78. package/dist/esm/production/index.js +14 -13
  79. package/dist/esm/production/react/index.js +219 -82
  80. package/dist/esm/production/react/index.js.map +1 -1
  81. package/dist/esm/production/react/index.server.js +14 -0
  82. package/dist/esm/production/react/index.server.js.map +1 -0
  83. package/dist/esm/production/react/server.js +20 -0
  84. package/dist/esm/production/react/server.js.map +1 -0
  85. package/dist/esm/production/{snapshot-CfJGJCvW.js → snapshot-TYiTYPGB.js} +2 -2
  86. package/dist/esm/production/{snapshot-CfJGJCvW.js.map → snapshot-TYiTYPGB.js.map} +1 -1
  87. package/dist/esm/production/transform/index.js +197 -14
  88. package/dist/esm/production/transform/index.js.map +1 -1
  89. package/dist/esm/production/utils.js +11 -11
  90. package/dist/esm/production/utils.js.map +1 -1
  91. package/dist/esm/react/async-component.d.ts +42 -0
  92. package/dist/esm/react/async-component.d.ts.map +1 -0
  93. package/dist/esm/react/component-server.d.ts +4 -0
  94. package/dist/esm/react/component-server.d.ts.map +1 -0
  95. package/dist/esm/react/component-shared.d.ts +21 -0
  96. package/dist/esm/react/component-shared.d.ts.map +1 -0
  97. package/dist/esm/react/component.d.ts +5 -1
  98. package/dist/esm/react/component.d.ts.map +1 -1
  99. package/dist/esm/react/index.d.ts +3 -4
  100. package/dist/esm/react/index.d.ts.map +1 -1
  101. package/dist/esm/react/index.server.d.ts +8 -0
  102. package/dist/esm/react/index.server.d.ts.map +1 -0
  103. package/dist/esm/react/pause-signals-context.d.ts +18 -0
  104. package/dist/esm/react/pause-signals-context.d.ts.map +1 -0
  105. package/dist/esm/react/server.d.ts +12 -0
  106. package/dist/esm/react/server.d.ts.map +1 -0
  107. package/dist/esm/react/use-reactive.d.ts +36 -7
  108. package/dist/esm/react/use-reactive.d.ts.map +1 -1
  109. package/dist/esm/transform/async.d.ts.map +1 -1
  110. package/dist/esm/transform/callback.d.ts.map +1 -1
  111. package/dist/esm/transform/index.d.ts +1 -0
  112. package/dist/esm/transform/index.d.ts.map +1 -1
  113. package/dist/esm/transform/preset.d.ts +1 -0
  114. package/dist/esm/transform/preset.d.ts.map +1 -1
  115. package/dist/esm/transform/use-reactive.d.ts +9 -0
  116. package/dist/esm/transform/use-reactive.d.ts.map +1 -0
  117. package/dist/esm/types.d.ts +33 -10
  118. package/dist/esm/types.d.ts.map +1 -1
  119. package/dist/esm/utils.d.ts +2 -2
  120. package/dist/esm/utils.d.ts.map +1 -1
  121. package/package.json +35 -4
  122. package/react-server.js +15 -0
  123. package/dist/cjs/development/debug-ouT0N0E4.js.map +0 -1
  124. package/dist/cjs/production/contexts-DtQMtXO7.js.map +0 -1
  125. package/dist/esm/development/debug-DaK9qsbI.js.map +0 -1
  126. package/dist/esm/internals/weakref.d.ts +0 -3
  127. package/dist/esm/internals/weakref.d.ts.map +0 -1
  128. package/dist/esm/production/contexts-US_h2nBi.js.map +0 -1
  129. package/dist/esm/react/suspend-signals-context.d.ts +0 -3
  130. package/dist/esm/react/suspend-signals-context.d.ts.map +0 -1
@@ -23,11 +23,15 @@ const createTransformedImports = (defaultImports, additionalImports, globalImpor
23
23
  function createSignaliumAsyncTransform(api, opts) {
24
24
  const transformedImports = createTransformedImports([
25
25
  ["callback", ["signalium"]],
26
+ ["component", ["signalium/react"]],
26
27
  ["reactive", ["signalium"]],
27
28
  ["reactiveMethod", ["signalium"]],
28
29
  ["relay", ["signalium"]],
29
30
  ["task", ["signalium"]],
30
- ["watcher", ["signalium"]]
31
+ ["watcher", ["signalium"]],
32
+ ["useReactive", ["signalium/react"]],
33
+ ["useReactiveShallow", ["signalium/react"]],
34
+ ["useReactiveDeep", ["signalium/react"]]
31
35
  ], opts?.transformedImports, opts?.importPaths);
32
36
  const t = api.types;
33
37
  const isTrackedImport = (localName, path) => {
@@ -114,7 +118,10 @@ function createSignaliumCallbackTransform(api, opts) {
114
118
  ["reactiveMethod", ["signalium"]],
115
119
  ["relay", ["signalium"]],
116
120
  ["task", ["signalium"]],
117
- ["watcher", ["signalium"]]
121
+ ["watcher", ["signalium"]],
122
+ ["useReactive", ["signalium/react"]],
123
+ ["useReactiveShallow", ["signalium/react"]],
124
+ ["useReactiveDeep", ["signalium/react"]]
118
125
  ], opts?.transformedImports, opts?.importPaths);
119
126
  const t = api.types;
120
127
  const callbackImportPath = opts?.callbackImportPath ?? "signalium";
@@ -159,14 +166,14 @@ function createSignaliumCallbackTransform(api, opts) {
159
166
  }
160
167
  return false;
161
168
  }
162
- function ensureCallbackIdentifier(programPath) {
169
+ function lookupCallbackIdentifier(programPath) {
163
170
  for (const bodyPath of programPath.get("body")) {
164
171
  if (!bodyPath.isImportDeclaration())
165
172
  continue;
166
- const importDecl2 = bodyPath.node;
167
- if (importDecl2.source.value !== callbackImportPath)
173
+ const importDecl = bodyPath.node;
174
+ if (importDecl.source.value !== callbackImportPath)
168
175
  continue;
169
- for (const spec of importDecl2.specifiers) {
176
+ for (const spec of importDecl.specifiers) {
170
177
  if (spec.type === "ImportSpecifier") {
171
178
  const ispec = spec;
172
179
  const imported = ispec.imported;
@@ -176,12 +183,20 @@ function createSignaliumCallbackTransform(api, opts) {
176
183
  }
177
184
  }
178
185
  }
186
+ return void 0;
187
+ }
188
+ function ensureCallbackIdentifier(programPath) {
189
+ const existing = lookupCallbackIdentifier(programPath);
190
+ if (existing !== void 0)
191
+ return existing;
179
192
  for (const bodyPath of programPath.get("body")) {
180
193
  if (!bodyPath.isImportDeclaration())
181
194
  continue;
182
195
  const node = bodyPath.node;
183
196
  if (node.source.value !== callbackImportPath)
184
197
  continue;
198
+ if (node.importKind === "type")
199
+ continue;
185
200
  const localName2 = programPath.scope.generateUidIdentifier("callback").name;
186
201
  node.specifiers.push(t.importSpecifier(t.identifier(localName2), t.identifier("callback")));
187
202
  return localName2;
@@ -239,7 +254,8 @@ function createSignaliumCallbackTransform(api, opts) {
239
254
  return;
240
255
  const outerFn = arg0;
241
256
  const programPath = callPath.findParent((p) => p.isProgram());
242
- const callbackName = ensureCallbackIdentifier(programPath);
257
+ const getCallbackName = () => ensureCallbackIdentifier(programPath);
258
+ const peekCallbackName = () => lookupCallbackIdentifier(programPath);
243
259
  const counters = /* @__PURE__ */ new WeakMap();
244
260
  counters.set(outerFn.node, 0);
245
261
  const getNextIndexFor = (fnNode) => {
@@ -284,7 +300,7 @@ function createSignaliumCallbackTransform(api, opts) {
284
300
  const callee = parent.node.callee;
285
301
  if (t.isIdentifier(callee)) {
286
302
  const calleeId = callee;
287
- if (calleeId.name === callbackName) {
303
+ if (calleeId.name === peekCallbackName()) {
288
304
  return;
289
305
  }
290
306
  }
@@ -296,7 +312,7 @@ function createSignaliumCallbackTransform(api, opts) {
296
312
  if (deps.length > 0) {
297
313
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
298
314
  }
299
- const wrapped = t.callExpression(t.identifier(callbackName), args);
315
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
300
316
  innerFnPath.replaceWith(wrapped);
301
317
  innerFnPath.skip();
302
318
  }
@@ -336,7 +352,7 @@ function createSignaliumCallbackTransform(api, opts) {
336
352
  const callee = parent.node.callee;
337
353
  if (t.isIdentifier(callee)) {
338
354
  const calleeId = callee;
339
- if (calleeId.name === callbackName) {
355
+ if (calleeId.name === peekCallbackName()) {
340
356
  return;
341
357
  }
342
358
  }
@@ -348,7 +364,7 @@ function createSignaliumCallbackTransform(api, opts) {
348
364
  if (deps.length > 0) {
349
365
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
350
366
  }
351
- const wrapped = t.callExpression(t.identifier(callbackName), args);
367
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
352
368
  innerFnPath.replaceWith(wrapped);
353
369
  innerFnPath.skip();
354
370
  }
@@ -370,7 +386,7 @@ function createSignaliumCallbackTransform(api, opts) {
370
386
  if (deps.length > 0) {
371
387
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
372
388
  }
373
- const wrapped = t.callExpression(t.identifier(callbackName), args);
389
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
374
390
  const constDecl = t.variableDeclaration("const", [t.variableDeclarator(id, wrapped)]);
375
391
  innerDeclPath.replaceWith(constDecl);
376
392
  innerDeclPath.skip();
@@ -392,7 +408,7 @@ function createSignaliumCallbackTransform(api, opts) {
392
408
  if (deps.length > 0) {
393
409
  args.push(t.arrayExpression(deps.map((n) => t.identifier(n))));
394
410
  }
395
- const wrapped = t.callExpression(t.identifier(callbackName), args);
411
+ const wrapped = t.callExpression(t.identifier(getCallbackName()), args);
396
412
  const key = innerMethodPath.node.key;
397
413
  const computed = innerMethodPath.node.computed || false;
398
414
  const prop = t.objectProperty(key, wrapped, computed);
@@ -528,6 +544,167 @@ function signaliumPromiseMethodsTransform(apiOrOpts, maybeOpts) {
528
544
  }
529
545
  return (api) => createSignaliumPromiseMethodsTransform(api, apiOrOpts);
530
546
  }
547
+ function createSignaliumUseReactiveTransform(api, opts) {
548
+ const trackedNames = /* @__PURE__ */ new Set(["useReactive", "useReactiveShallow", "useReactiveDeep"]);
549
+ const filteredAdditional = opts?.transformedImports?.filter(([name]) => trackedNames.has(name));
550
+ const transformedImports = createTransformedImports([
551
+ ["useReactive", ["signalium/react"]],
552
+ ["useReactiveShallow", ["signalium/react"]],
553
+ ["useReactiveDeep", ["signalium/react"]]
554
+ ], filteredAdditional, opts?.importPaths);
555
+ const t = api.types;
556
+ const reactImportPath = opts?.reactImportPath ?? "react";
557
+ const isTrackedImport = (localName, path) => {
558
+ const binding = path.scope.getBinding(localName);
559
+ if (!binding || !t.isImportSpecifier(binding.path.node))
560
+ return false;
561
+ const importSpec = binding.path.node;
562
+ const importedName = importSpec.imported.name;
563
+ const importDecl = binding.path.parent;
564
+ if (!t.isImportDeclaration(importDecl))
565
+ return false;
566
+ const importPaths = transformedImports.get(importedName);
567
+ if (!importPaths)
568
+ return false;
569
+ return importPaths.some((p) => typeof p === "string" ? importDecl.source.value === p : p.test(importDecl.source.value));
570
+ };
571
+ const isTargetCall = (path) => {
572
+ const callee = path.node.callee;
573
+ if (!t.isIdentifier(callee))
574
+ return false;
575
+ return isTrackedImport(callee.name, path);
576
+ };
577
+ function isIdentifierInTypePosition(refPath) {
578
+ let current = refPath.parentPath;
579
+ let child = refPath;
580
+ while (current) {
581
+ const nodeType = current.node.type;
582
+ if (nodeType && nodeType.startsWith("TS")) {
583
+ if (current.isTSAsExpression() || current.isTSSatisfiesExpression?.() || current.isTSNonNullExpression() || current.isTSInstantiationExpression?.()) {
584
+ if (child.key === "expression")
585
+ return false;
586
+ return true;
587
+ }
588
+ return true;
589
+ }
590
+ child = current;
591
+ current = current.parentPath;
592
+ }
593
+ return false;
594
+ }
595
+ function ensureUseCallbackIdentifier(programPath) {
596
+ for (const bodyPath of programPath.get("body")) {
597
+ if (!bodyPath.isImportDeclaration())
598
+ continue;
599
+ const importDecl2 = bodyPath.node;
600
+ if (importDecl2.source.value !== reactImportPath)
601
+ continue;
602
+ for (const spec of importDecl2.specifiers) {
603
+ if (spec.type !== "ImportSpecifier")
604
+ continue;
605
+ const ispec = spec;
606
+ const imported = ispec.imported;
607
+ if (imported && imported.name === "useCallback") {
608
+ return ispec.local.name;
609
+ }
610
+ }
611
+ }
612
+ for (const bodyPath of programPath.get("body")) {
613
+ if (!bodyPath.isImportDeclaration())
614
+ continue;
615
+ const node = bodyPath.node;
616
+ if (node.source.value !== reactImportPath)
617
+ continue;
618
+ const localName2 = programPath.scope.generateUidIdentifier("useCallback").name;
619
+ node.specifiers.push(t.importSpecifier(t.identifier(localName2), t.identifier("useCallback")));
620
+ return localName2;
621
+ }
622
+ const localName = programPath.scope.generateUidIdentifier("useCallback").name;
623
+ const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier("useCallback"))], t.stringLiteral(reactImportPath));
624
+ const [first] = programPath.get("body");
625
+ if (first) {
626
+ first.insertBefore(importDecl);
627
+ } else {
628
+ programPath.pushContainer("body", importDecl);
629
+ }
630
+ return localName;
631
+ }
632
+ function collectDeps(innerFn) {
633
+ const depNames = /* @__PURE__ */ new Set();
634
+ const innerScope = innerFn.scope;
635
+ const innerNode = innerFn.node;
636
+ innerFn.traverse({
637
+ ReferencedIdentifier(refPath) {
638
+ const nearestFn = refPath.getFunctionParent();
639
+ if (!nearestFn || nearestFn.node !== innerNode)
640
+ return;
641
+ const name = refPath.node.name;
642
+ const binding = refPath.scope.getBinding(name);
643
+ if (!binding)
644
+ return;
645
+ if (isIdentifierInTypePosition(refPath))
646
+ return;
647
+ if (binding.scope.path.isProgram())
648
+ return;
649
+ let declScope = binding.scope;
650
+ while (declScope) {
651
+ if (declScope === innerScope)
652
+ return;
653
+ declScope = declScope.parent;
654
+ }
655
+ if (binding.kind === "param" && binding.scope === innerScope)
656
+ return;
657
+ depNames.add(name);
658
+ }
659
+ });
660
+ return Array.from(depNames);
661
+ }
662
+ function isAlreadyMemoized(argPath) {
663
+ if (!argPath.isCallExpression())
664
+ return false;
665
+ const callee = argPath.node.callee;
666
+ if (!t.isIdentifier(callee))
667
+ return false;
668
+ const name = callee.name;
669
+ return name === "useCallback" || name === "useMemo" || /useCallback$/.test(name);
670
+ }
671
+ return {
672
+ name: "signalium-transform-use-reactive",
673
+ visitor: {
674
+ CallExpression(callPath) {
675
+ if (!isTargetCall(callPath))
676
+ return;
677
+ const args = callPath.get("arguments");
678
+ if (args.length !== 1)
679
+ return;
680
+ let fnPath = args[0];
681
+ while (fnPath.isTSAsExpression() || fnPath.isTSSatisfiesExpression?.() || fnPath.isTSNonNullExpression() || fnPath.isTSInstantiationExpression?.()) {
682
+ fnPath = fnPath.get("expression");
683
+ }
684
+ if (!(fnPath.isArrowFunctionExpression() || fnPath.isFunctionExpression()))
685
+ return;
686
+ if (isAlreadyMemoized(fnPath))
687
+ return;
688
+ const programPath = callPath.findParent((p) => p.isProgram());
689
+ const useCallbackName = ensureUseCallbackIdentifier(programPath);
690
+ const innerFn = fnPath;
691
+ const deps = collectDeps(innerFn);
692
+ const wrapped = t.callExpression(t.identifier(useCallbackName), [
693
+ innerFn.node,
694
+ t.arrayExpression(deps.map((n) => t.identifier(n)))
695
+ ]);
696
+ fnPath.replaceWith(wrapped);
697
+ fnPath.skip();
698
+ }
699
+ }
700
+ };
701
+ }
702
+ function signaliumUseReactiveTransform(apiOrOpts, maybeOpts) {
703
+ if (isBabelApi(apiOrOpts)) {
704
+ return createSignaliumUseReactiveTransform(apiOrOpts, maybeOpts);
705
+ }
706
+ return (api) => createSignaliumUseReactiveTransform(api, apiOrOpts);
707
+ }
531
708
  function createSignaliumPreset(api, opts) {
532
709
  return {
533
710
  plugins: [
@@ -537,6 +714,11 @@ function createSignaliumPreset(api, opts) {
537
714
  callbackImportPath: opts?.callbackImportPath
538
715
  }),
539
716
  signaliumAsyncTransform({ transformedImports: opts?.transformedImports ?? [], importPaths: opts?.importPaths }),
717
+ signaliumUseReactiveTransform({
718
+ transformedImports: opts?.transformedImports ?? [],
719
+ importPaths: opts?.importPaths,
720
+ reactImportPath: opts?.reactImportPath
721
+ }),
540
722
  signaliumPromiseMethodsTransform({
541
723
  transformedImports: opts?.transformedImports ?? [],
542
724
  importPaths: opts?.importPaths,
@@ -555,4 +737,5 @@ exports.signaliumAsyncTransform = signaliumAsyncTransform;
555
737
  exports.signaliumCallbackTransform = signaliumCallbackTransform;
556
738
  exports.signaliumPreset = signaliumPreset;
557
739
  exports.signaliumPromiseMethodsTransform = signaliumPromiseMethodsTransform;
740
+ exports.signaliumUseReactiveTransform = signaliumUseReactiveTransform;
558
741
  //# sourceMappingURL=index.js.map
@@ -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,kBA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H,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,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 ['component', ['signalium/react']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isReactiveCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n const isWithinTrackedCall = (path) => {\n let current = path.parentPath;\n while (current) {\n if (current.isCallExpression() && isReactiveCall(current))\n return true;\n current = current.parentPath;\n }\n return false;\n };\n function convertReactiveToGenerator(path) {\n if (!isWithinTrackedCall(path))\n return;\n if (!path.node.async)\n return;\n path.traverse({\n AwaitExpression(awaitPath) {\n const funcParent = awaitPath.getFunctionParent();\n if (funcParent?.node !== path.node)\n return;\n awaitPath.replaceWith(t.yieldExpression(awaitPath.node.argument));\n },\n });\n path.node.async = false;\n if (t.isArrowFunctionExpression(path.node)) {\n let hasThis = false;\n path.traverse({\n ThisExpression() {\n hasThis = true;\n },\n });\n const functionBody = t.isBlockStatement(path.node.body)\n ? path.node.body\n : t.blockStatement([t.returnStatement(path.node.body)]);\n const newFunction = t.functionExpression(null, path.node.params, functionBody, true, false);\n if (hasThis) {\n path.replaceWith(t.callExpression(t.memberExpression(newFunction, t.identifier('bind')), [t.thisExpression()]));\n }\n else {\n path.replaceWith(newFunction);\n }\n }\n else {\n path.node.generator = true;\n }\n }\n return {\n name: 'signalium-transform-reactive-async',\n visitor: {\n FunctionExpression: convertReactiveToGenerator,\n ArrowFunctionExpression: convertReactiveToGenerator,\n },\n };\n}\nexport function signaliumAsyncTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumAsyncTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumAsyncTransform(api, apiOrOpts);\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\nfunction createSignaliumCallbackTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['component', ['signalium/react']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const callbackImportPath = opts?.callbackImportPath ?? 'signalium';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n const matches = importPaths.find(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n return matches ? (typeof matches === 'string' ? matches : importDecl.source.value) : false;\n };\n const isTargetWrapperCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return !!isTrackedImport(callee.name, path);\n };\n function isIdentifierInTypePosition(refPath) {\n // Walk up ancestors and detect if the identifier is within TS type-only constructs\n // Allow identifiers inside the expression arm of TS* expression wrappers\n let current = refPath.parentPath;\n let child = refPath;\n while (current) {\n const nodeType = current.node.type;\n if (nodeType && nodeType.startsWith('TS')) {\n if (current.isTSAsExpression() ||\n current.isTSSatisfiesExpression?.() ||\n current.isTSNonNullExpression() ||\n current.isTSInstantiationExpression?.()) {\n // If we reached this TS* expression via its 'expression' arm, it's runtime, not type-only\n if (child.key === 'expression')\n return false;\n return true;\n }\n return true;\n }\n child = current;\n current = current.parentPath;\n }\n return false;\n }\n function lookupCallbackIdentifier(programPath) {\n // Find an existing direct import: import { callback as X } from 'signalium'\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== callbackImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type === 'ImportSpecifier') {\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'callback') {\n return ispec.local.name;\n }\n }\n }\n }\n return undefined;\n }\n function ensureCallbackIdentifier(programPath) {\n const existing = lookupCallbackIdentifier(programPath);\n if (existing !== undefined)\n return existing;\n // Try to augment an existing import from 'signalium'\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== callbackImportPath)\n continue;\n // Skip `import type` declarations — adding a value specifier there would\n // make it type-only at runtime.\n if (node.importKind === 'type')\n continue;\n const localName = programPath.scope.generateUidIdentifier('callback').name;\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('callback')));\n return localName;\n }\n // Otherwise, insert a new import from 'signalium'\n const localName = 'callback';\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('callback'))], t.stringLiteral(callbackImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n function collectDeps(innerFn) {\n const depNames = new Set();\n const innerScope = innerFn.scope;\n const innerNode = innerFn.node;\n innerFn.traverse({\n ReferencedIdentifier(refPath) {\n // Only consider refs whose nearest function parent is the inner function\n const nearestFn = refPath.getFunctionParent();\n if (!nearestFn || nearestFn.node !== innerNode)\n return;\n const name = refPath.node.name;\n const binding = refPath.scope.getBinding(name);\n if (!binding)\n return;\n // Ignore identifiers that appear only in type positions\n if (isIdentifierInTypePosition(refPath))\n return;\n // Exclude module scope\n if (binding.scope.path.isProgram())\n return;\n // Exclude identifiers declared within the inner function itself or any nested scope inside it\n let declScope = binding.scope;\n while (declScope) {\n if (declScope === innerScope)\n return;\n declScope = declScope.parent;\n }\n // Exclude only the inner function's own parameters\n if (binding.kind === 'param' && binding.scope === innerScope)\n return;\n depNames.add(name);\n },\n });\n return depNames;\n }\n return {\n name: 'signalium-transform-callback-wrapping',\n visitor: {\n CallExpression(callPath) {\n if (!isTargetWrapperCall(callPath))\n return;\n const arg0 = callPath.get('arguments')[0];\n if (!arg0)\n return;\n if (!(arg0.isFunctionExpression() || arg0.isArrowFunctionExpression()))\n return;\n const outerFn = arg0;\n const programPath = callPath.findParent((p) => p.isProgram());\n // Lazily resolve the `callback` import local name so we don't add a\n // dead `import { callback } from 'signalium'` when the outer fn has no\n // inner callbacks to wrap.\n const getCallbackName = () => ensureCallbackIdentifier(programPath);\n // For the \"skip if already wrapped in callback()\" check: consult the\n // existing imports without forcing one to be added.\n const peekCallbackName = () => lookupCallbackIdentifier(programPath);\n // Maintain per-function counters\n const counters = new WeakMap();\n counters.set(outerFn.node, 0);\n const getNextIndexFor = (fnNode) => {\n const current = counters.get(fnNode) ?? 0;\n counters.set(fnNode, current + 1);\n return current;\n };\n outerFn.traverse({\n // Initialize counters for any function-like node when first seen\n FunctionExpression: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerFnPath) {\n if (innerFnPath.node === outerFn.node)\n return;\n // Skip converting when the function is passed directly as a callback\n // to a tracked call AND that call is nested within another tracked call.\n const immediateParent = innerFnPath.parentPath;\n if (immediateParent && immediateParent.isCallExpression()) {\n const callee = immediateParent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (isTrackedImport(calleeId.name, immediateParent)) {\n let current = immediateParent.parentPath;\n while (current) {\n if (current.isCallExpression()) {\n const parentCallee = current.node.callee;\n if (t.isIdentifier(parentCallee)) {\n const parentCalleeId = parentCallee;\n if (isTrackedImport(parentCalleeId.name, current)) {\n return; // nested direct callback – skip\n }\n }\n }\n current = current.parentPath;\n }\n }\n }\n }\n // Skip if already wrapped in callback()\n const parent = innerFnPath.parentPath;\n if (parent && parent.isCallExpression()) {\n const callee = parent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (calleeId.name === peekCallbackName()) {\n return;\n }\n }\n }\n const deps = Array.from(collectDeps(innerFnPath));\n // Determine parent function to index against\n const parentFn = (innerFnPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [innerFnPath.node, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n innerFnPath.replaceWith(wrapped);\n innerFnPath.skip();\n },\n },\n ArrowFunctionExpression: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerFnPath) {\n if (innerFnPath.node === outerFn.node)\n return;\n // Skip converting when the function is passed directly as a callback\n // to a tracked call AND that call is nested within another tracked call.\n const immediateParent = innerFnPath.parentPath;\n if (immediateParent && immediateParent.isCallExpression()) {\n const callee = immediateParent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (isTrackedImport(calleeId.name, immediateParent)) {\n let current = immediateParent.parentPath;\n while (current) {\n if (current.isCallExpression()) {\n const parentCallee = current.node.callee;\n if (t.isIdentifier(parentCallee)) {\n const parentCalleeId = parentCallee;\n if (isTrackedImport(parentCalleeId.name, current)) {\n return; // nested direct callback – skip\n }\n }\n }\n current = current.parentPath;\n }\n }\n }\n }\n // Skip if already wrapped in callback()\n const parent = innerFnPath.parentPath;\n if (parent && parent.isCallExpression()) {\n const callee = parent.node.callee;\n if (t.isIdentifier(callee)) {\n const calleeId = callee;\n if (calleeId.name === peekCallbackName()) {\n return;\n }\n }\n }\n const deps = Array.from(collectDeps(innerFnPath));\n const parentFn = (innerFnPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [innerFnPath.node, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n innerFnPath.replaceWith(wrapped);\n innerFnPath.skip();\n },\n },\n FunctionDeclaration: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerDeclPath) {\n const id = innerDeclPath.node.id;\n if (!id)\n return;\n const fnExpr = t.functionExpression(id, innerDeclPath.node.params, innerDeclPath.node.body, innerDeclPath.node.generator, innerDeclPath.node.async);\n const deps = Array.from(collectDeps(innerDeclPath));\n const parentFn = (innerDeclPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [fnExpr, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n const constDecl = t.variableDeclaration('const', [t.variableDeclarator(id, wrapped)]);\n innerDeclPath.replaceWith(constDecl);\n innerDeclPath.skip();\n },\n },\n ObjectMethod: {\n enter(fnPath) {\n if (!counters.has(fnPath.node))\n counters.set(fnPath.node, 0);\n },\n exit(innerMethodPath) {\n if (innerMethodPath.node.kind !== 'method')\n return;\n const fnExpr = t.functionExpression(null, innerMethodPath.node.params, innerMethodPath.node.body, innerMethodPath.node.generator, innerMethodPath.node.async);\n const deps = Array.from(collectDeps(innerMethodPath));\n const parentFn = (innerMethodPath.parentPath?.getFunctionParent() || outerFn);\n const argIndex = getNextIndexFor(parentFn.node);\n const args = [fnExpr, t.numericLiteral(argIndex)];\n if (deps.length > 0) {\n args.push(t.arrayExpression(deps.map(n => t.identifier(n))));\n }\n const wrapped = t.callExpression(t.identifier(getCallbackName()), args);\n const key = innerMethodPath.node.key;\n const computed = innerMethodPath.node.computed || false;\n const prop = t.objectProperty(key, wrapped, computed);\n innerMethodPath.replaceWith(prop);\n innerMethodPath.skip();\n },\n },\n });\n },\n },\n };\n}\nexport function signaliumCallbackTransform(apiOrOpts, opts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumCallbackTransform(apiOrOpts, opts);\n }\n else {\n return (api) => createSignaliumCallbackTransform(api, apiOrOpts);\n }\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\nconst PROMISE_STATIC_METHODS = new Set(['all', 'race', 'any', 'allSettled', 'resolve', 'reject', 'withResolvers']);\nfunction createSignaliumPromiseMethodsTransform(api, opts) {\n const transformedImports = createTransformedImports([\n ['callback', ['signalium']],\n ['reactive', ['signalium']],\n ['reactiveMethod', ['signalium']],\n ['relay', ['signalium']],\n ['task', ['signalium']],\n ['watcher', ['signalium']],\n ], opts?.transformedImports, opts?.importPaths);\n const t = api.types;\n const promiseImportPath = opts?.promiseImportPath ?? 'signalium';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isReactiveCall = (path) => {\n if (!t.isCallExpression(path.node))\n return false;\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n const isWithinTrackedCall = (path) => {\n let current = path.parentPath;\n while (current) {\n if (current.isCallExpression() && isReactiveCall(current))\n return true;\n current = current.parentPath;\n }\n return false;\n };\n function ensureReactivePromiseIdentifier(programPath) {\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== promiseImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type === 'ImportSpecifier') {\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'ReactivePromise') {\n return ispec.local.name;\n }\n }\n }\n }\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== promiseImportPath)\n continue;\n const localName = 'ReactivePromise';\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('ReactivePromise')));\n return localName;\n }\n const localName = 'ReactivePromise';\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('ReactivePromise'))], t.stringLiteral(promiseImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n return {\n name: 'signalium-transform-reactive-promise-methods',\n visitor: {\n CallExpression(callPath) {\n if (!isWithinTrackedCall(callPath))\n return;\n const callee = callPath.node.callee;\n if (!t.isMemberExpression(callee))\n return;\n if (callee.computed)\n return;\n const object = callee.object;\n const property = callee.property;\n if (!t.isIdentifier(object, { name: 'Promise' }))\n return;\n if (callPath.scope.getBinding('Promise'))\n return;\n if (!t.isIdentifier(property))\n return;\n const methodName = property.name;\n if (!PROMISE_STATIC_METHODS.has(methodName))\n return;\n const programPath = callPath.findParent((p) => p.isProgram());\n const reactivePromiseId = ensureReactivePromiseIdentifier(programPath);\n const newCallee = t.memberExpression(t.identifier(reactivePromiseId), t.identifier(methodName));\n callPath.node.callee = newCallee;\n },\n },\n };\n}\nexport function signaliumPromiseMethodsTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumPromiseMethodsTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumPromiseMethodsTransform(api, apiOrOpts);\n}\n","import { createTransformedImports, isBabelApi } from './utils.js';\n/**\n * Wraps the thunk argument of `useReactive` / `useReactiveDeep` in\n * `React.useCallback(fn, [deps])`. The captured identifiers are collected from\n * the thunk body the same way the `callback` transform does for `reactive()`\n * callbacks, giving the hook a stable identity across renders when captures are\n * equal. This lets the runtime reuse the underlying `ReactiveSignal`.\n *\n * Runs after the async and callback transforms so the inner function has\n * already been rewritten (e.g. `async` → `function*`).\n */\nfunction createSignaliumUseReactiveTransform(api, opts) {\n // Only forward user-provided `transformedImports` entries that target the\n // hook names we care about. The shared `transformedImports` preset option is\n // also used by the callback/async transforms to retarget arbitrary identifiers\n // like `reactive`/`task`/`relay`; we must not accidentally pick those up here\n // or we'd wrap inner arrows with `useCallback` in non-React code paths.\n const trackedNames = new Set(['useReactive', 'useReactiveShallow', 'useReactiveDeep']);\n const filteredAdditional = opts?.transformedImports?.filter(([name]) => trackedNames.has(name));\n const transformedImports = createTransformedImports([\n ['useReactive', ['signalium/react']],\n ['useReactiveShallow', ['signalium/react']],\n ['useReactiveDeep', ['signalium/react']],\n ], filteredAdditional, opts?.importPaths);\n const t = api.types;\n const reactImportPath = opts?.reactImportPath ?? 'react';\n const isTrackedImport = (localName, path) => {\n const binding = path.scope.getBinding(localName);\n if (!binding || !t.isImportSpecifier(binding.path.node))\n return false;\n const importSpec = binding.path.node;\n const importedName = importSpec.imported.name;\n const importDecl = binding.path.parent;\n if (!t.isImportDeclaration(importDecl))\n return false;\n const importPaths = transformedImports.get(importedName);\n if (!importPaths)\n return false;\n return importPaths.some(p => typeof p === 'string' ? importDecl.source.value === p : p.test(importDecl.source.value));\n };\n const isTargetCall = (path) => {\n const callee = path.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n return isTrackedImport(callee.name, path);\n };\n function isIdentifierInTypePosition(refPath) {\n let current = refPath.parentPath;\n let child = refPath;\n while (current) {\n const nodeType = current.node.type;\n if (nodeType && nodeType.startsWith('TS')) {\n if (current.isTSAsExpression() ||\n current.isTSSatisfiesExpression?.() ||\n current.isTSNonNullExpression() ||\n current.isTSInstantiationExpression?.()) {\n if (child.key === 'expression')\n return false;\n return true;\n }\n return true;\n }\n child = current;\n current = current.parentPath;\n }\n return false;\n }\n function ensureUseCallbackIdentifier(programPath) {\n // Find an existing `import { useCallback as X } from 'react'`\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const importDecl = bodyPath.node;\n if (importDecl.source.value !== reactImportPath)\n continue;\n for (const spec of importDecl.specifiers) {\n if (spec.type !== 'ImportSpecifier')\n continue;\n const ispec = spec;\n const imported = ispec.imported;\n if (imported && imported.name === 'useCallback') {\n return ispec.local.name;\n }\n }\n }\n // Augment an existing `import ... from 'react'`\n for (const bodyPath of programPath.get('body')) {\n if (!bodyPath.isImportDeclaration())\n continue;\n const node = bodyPath.node;\n if (node.source.value !== reactImportPath)\n continue;\n const localName = programPath.scope.generateUidIdentifier('useCallback').name;\n node.specifiers.push(t.importSpecifier(t.identifier(localName), t.identifier('useCallback')));\n return localName;\n }\n // Otherwise, insert a new import\n const localName = programPath.scope.generateUidIdentifier('useCallback').name;\n const importDecl = t.importDeclaration([t.importSpecifier(t.identifier(localName), t.identifier('useCallback'))], t.stringLiteral(reactImportPath));\n const [first] = programPath.get('body');\n if (first) {\n first.insertBefore(importDecl);\n }\n else {\n programPath.pushContainer('body', importDecl);\n }\n return localName;\n }\n function collectDeps(innerFn) {\n const depNames = new Set();\n const innerScope = innerFn.scope;\n const innerNode = innerFn.node;\n innerFn.traverse({\n ReferencedIdentifier(refPath) {\n const nearestFn = refPath.getFunctionParent();\n if (!nearestFn || nearestFn.node !== innerNode)\n return;\n const name = refPath.node.name;\n const binding = refPath.scope.getBinding(name);\n if (!binding)\n return;\n if (isIdentifierInTypePosition(refPath))\n return;\n if (binding.scope.path.isProgram())\n return;\n let declScope = binding.scope;\n while (declScope) {\n if (declScope === innerScope)\n return;\n declScope = declScope.parent;\n }\n if (binding.kind === 'param' && binding.scope === innerScope)\n return;\n depNames.add(name);\n },\n });\n return Array.from(depNames);\n }\n function isAlreadyMemoized(argPath) {\n if (!argPath.isCallExpression())\n return false;\n const callee = argPath.node.callee;\n if (!t.isIdentifier(callee))\n return false;\n const name = callee.name;\n // Heuristic: any identifier ending in `useCallback` or `useMemo` is treated\n // as already-memoized. Avoids double-wrapping and supports aliased imports.\n return name === 'useCallback' || name === 'useMemo' || /useCallback$/.test(name);\n }\n return {\n name: 'signalium-transform-use-reactive',\n visitor: {\n CallExpression(callPath) {\n if (!isTargetCall(callPath))\n return;\n const args = callPath.get('arguments');\n // Only the thunk form: exactly one argument and it is a function.\n if (args.length !== 1)\n return;\n let fnPath = args[0];\n // Unwrap TS expression wrappers (`as`, `satisfies`, `!`, etc.) so the\n // user can still write `useReactive((async () => ...) as X)`.\n while (fnPath.isTSAsExpression() ||\n fnPath.isTSSatisfiesExpression?.() ||\n fnPath.isTSNonNullExpression() ||\n fnPath.isTSInstantiationExpression?.()) {\n fnPath = fnPath.get('expression');\n }\n if (!(fnPath.isArrowFunctionExpression() || fnPath.isFunctionExpression()))\n return;\n if (isAlreadyMemoized(fnPath))\n return;\n const programPath = callPath.findParent((p) => p.isProgram());\n const useCallbackName = ensureUseCallbackIdentifier(programPath);\n const innerFn = fnPath;\n const deps = collectDeps(innerFn);\n const wrapped = t.callExpression(t.identifier(useCallbackName), [\n innerFn.node,\n t.arrayExpression(deps.map(n => t.identifier(n))),\n ]);\n fnPath.replaceWith(wrapped);\n fnPath.skip();\n },\n },\n };\n}\nexport function signaliumUseReactiveTransform(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumUseReactiveTransform(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumUseReactiveTransform(api, apiOrOpts);\n}\n","import { signaliumAsyncTransform } from './async.js';\nimport { signaliumCallbackTransform } from './callback.js';\nimport { signaliumPromiseMethodsTransform } from './promise.js';\nimport { signaliumUseReactiveTransform } from './use-reactive.js';\nimport { isBabelApi } from './utils.js';\n// Babel preset that sequences the two plugins just like separate entries\n// Usage in babel config: presets: [[require('signalium/transform').signaliumPreset(options)]\nfunction createSignaliumPreset(api, opts) {\n return {\n plugins: [\n signaliumCallbackTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n callbackImportPath: opts?.callbackImportPath,\n }),\n signaliumAsyncTransform({ transformedImports: opts?.transformedImports ?? [], importPaths: opts?.importPaths }),\n signaliumUseReactiveTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n reactImportPath: opts?.reactImportPath,\n }),\n signaliumPromiseMethodsTransform({\n transformedImports: opts?.transformedImports ?? [],\n importPaths: opts?.importPaths,\n promiseImportPath: opts?.promiseImportPath,\n }),\n ],\n };\n}\nexport function signaliumPreset(apiOrOpts, maybeOpts) {\n if (isBabelApi(apiOrOpts)) {\n return createSignaliumPreset(apiOrOpts, maybeOpts);\n }\n return (api) => createSignaliumPreset(api, apiOrOpts);\n}\n"],"names":["localName","importDecl"],"mappings":";;AAAO,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW;AACjF,MAAM,2BAA2B,CAAC,gBAAgB,mBAAmB,sBAAsB;AAC9F,MAAI,mBAAmB;AACnB,mBAAe,QAAQ,CAAC,CAAC,MAAM,KAAK,MAAM;AACtC,YAAM,KAAK,GAAG,iBAAiB;AAAA,IACnC,CAAC;AAAA,EACL;AACA,QAAM,qBAAqB,IAAI,IAAI,cAAc;AACjD,MAAI,qBAAqB,kBAAkB,SAAS,GAAG;AACnD,eAAW,CAAC,MAAM,IAAI,KAAK,mBAAmB;AAC1C,YAAM,WAAW,mBAAmB,IAAI,IAAI;AAC5C,UAAI,UAAU;AACV,iBAAS,KAAK,IAAI;AAAA,MACtB,OACK;AACD,2BAAmB,IAAI,MAAM,CAAC,IAAI,CAAC;AAAA,MACvC;AAAA,IACJ;AAAA,EACJ;AACA,SAAO;AACX;ACnBA,SAAS,8BAA8B,KAAK,MAAM;AAC9C,QAAM,qBAAqB,yBAAyB;AAAA,IAChD,C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AA;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;;;;;;"}
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const snapshot = require("./snapshot-BPJ-qw6l.js");
4
- const debug = require("./debug-ouT0N0E4.js");
3
+ const snapshot = require("./snapshot-48aGePMZ.js");
4
+ const debug = require("./debug-C46WDxhL.js");
5
5
  function watchOnce(fn) {
6
6
  const signal = snapshot.watcher(fn);
7
7
  try {
8
- debug.watchSignal(signal, false);
8
+ debug.watchSignal(signal);
9
9
  let result = debug.getSignal(signal);
10
10
  if (debug.isReactivePromise(result) || debug.isPromise(result)) {
11
11
  result = result.finally(() => {
12
- debug.unwatchSignal(signal, false);
12
+ debug.unwatchSignal(signal);
13
13
  });
14
14
  } else {
15
- debug.unwatchSignal(signal, false);
15
+ debug.unwatchSignal(signal);
16
16
  }
17
17
  return result;
18
18
  } catch (error) {
19
- debug.unwatchSignal(signal, false);
19
+ debug.unwatchSignal(signal);
20
20
  throw error;
21
21
  }
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns A promise that resolves with the function's return value\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n try {\n // Watch the signal to activate any relays\n watchSignal(signal, false);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (isReactivePromise(result) || isPromise(result)) {\n result = result.finally(() => {\n unwatchSignal(signal, false);\n });\n }\n else {\n unwatchSignal(signal, false);\n }\n return result;\n }\n catch (error) {\n unwatchSignal(signal, false);\n throw error;\n }\n}\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":["watcher","watchSignal","getSignal","isReactivePromise","isPromise","unwatchSignal"],"mappings":";;;;AA6BO,SAAS,UAAU,IAAI;AAE1B,QAAM,SAASA,SAAAA,QAAQ,EAAE;AACzB,MAAI;AAEAC,UAAAA,YAAY,QAAQ,KAAK;AAEzB,QAAI,SAASC,MAAAA,UAAU,MAAM;AAC7B,QAAIC,MAAAA,kBAAkB,MAAM,KAAKC,MAAAA,UAAU,MAAM,GAAG;AAChD,eAAS,OAAO,QAAQ,MAAM;AAC1BC,cAAAA,cAAc,QAAQ,KAAK;AAAA,MAC/B,CAAC;AAAA,IACL,OACK;AACDA,YAAAA,cAAc,QAAQ,KAAK;AAAA,IAC/B;AACA,WAAO;AAAA,EACX,SACO,OAAO;AACVA,UAAAA,cAAc,QAAQ,KAAK;AAC3B,UAAM;AAAA,EACV;AACJ;AAgCO,SAAS,aAAa,OAAO,aAAa;AAE7C,MAAI,CAACF,MAAAA,kBAAkB,WAAW,GAAG;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACzE;AAIA,MAAI,YAAY,WAAW;AAGvB,UAAM,SAAS;AACf,UAAM,UAAU,OAAO,UAAU;AACjC,QAAI,SAAS;AACT,YAAM,WAAW,OAAO;AAAA,IAC5B;AAAA,EACJ,WACS,YAAY,YAAY;AAE7B,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,SAAS,KAAK;AAAA,IACxB;AAAA,EACJ,WACS,YAAY,cAAc,YAAY,SAAS;AAEpD,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,QAAQ;AAAA,IAClB;AAAA,EACJ;AACJ;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns A promise that resolves with the function's return value\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n try {\n // Watch the signal to activate any relays\n watchSignal(signal);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (isReactivePromise(result) || isPromise(result)) {\n result = result.finally(() => {\n unwatchSignal(signal);\n });\n }\n else {\n unwatchSignal(signal);\n }\n return result;\n }\n catch (error) {\n unwatchSignal(signal);\n throw error;\n }\n}\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":["watcher","watchSignal","getSignal","isReactivePromise","isPromise","unwatchSignal"],"mappings":";;;;AA6BO,SAAS,UAAU,IAAI;AAE1B,QAAM,SAASA,SAAAA,QAAQ,EAAE;AACzB,MAAI;AAEAC,UAAAA,YAAY,MAAM;AAElB,QAAI,SAASC,MAAAA,UAAU,MAAM;AAC7B,QAAIC,MAAAA,kBAAkB,MAAM,KAAKC,MAAAA,UAAU,MAAM,GAAG;AAChD,eAAS,OAAO,QAAQ,MAAM;AAC1BC,cAAAA,cAAc,MAAM;AAAA,MACxB,CAAC;AAAA,IACL,OACK;AACDA,YAAAA,cAAc,MAAM;AAAA,IACxB;AACA,WAAO;AAAA,EACX,SACO,OAAO;AACVA,UAAAA,cAAc,MAAM;AACpB,UAAM;AAAA,EACV;AACJ;AAgCO,SAAS,aAAa,OAAO,aAAa;AAE7C,MAAI,CAACF,MAAAA,kBAAkB,WAAW,GAAG;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACzE;AAIA,MAAI,YAAY,WAAW;AAGvB,UAAM,SAAS;AACf,UAAM,UAAU,OAAO,UAAU;AACjC,QAAI,SAAS;AACT,YAAM,WAAW,OAAO;AAAA,IAC5B;AAAA,EACJ,WACS,YAAY,YAAY;AAE7B,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,SAAS,KAAK;AAAA,IACxB;AAAA,EACJ,WACS,YAAY,cAAc,YAAY,SAAS;AAEpD,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,QAAQ;AAAA,IAClB;AAAA,EACJ;AACJ;;;;;;;;"}