@sprlab/wccompiler 0.5.6 → 0.5.7

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/bin/wcc.js CHANGED
@@ -19,7 +19,7 @@ async function build(config, cwd) {
19
19
  const __filename = fileURLToPath(import.meta.url);
20
20
  const __dirname = dirname(__filename);
21
21
  const { reactiveRuntime } = await import('../lib/reactive-runtime.js');
22
- const signalsContent = reactiveRuntime.trim().replace(/^/gm, '') + '\nexport { __signal, __computed, __effect, __batch };\n';
22
+ const signalsContent = reactiveRuntime.trim().replace(/^/gm, '') + '\nexport { __signal, __computed, __effect, __batch, __untrack };\n';
23
23
  const signalsDest = join(outputDir, '__wcc-signals.js');
24
24
  writeFileSync(signalsDest, signalsContent);
25
25
 
package/lib/codegen.js CHANGED
@@ -541,6 +541,7 @@ export function generateComponent(parseResult, options = {}) {
541
541
  const usedRuntime = new Set(['__signal']); // always need __signal
542
542
  if (computeds.length > 0) usedRuntime.add('__computed');
543
543
  if (effects.length > 0 || bindings.length > 0 || showBindings.length > 0 || modelBindings.length > 0 || attrBindings.length > 0 || ifBlocks.length > 0 || forBlocks.length > 0 || watchers.length > 0 || childComponents.length > 0 || slots.some(s => s.slotProps.length > 0)) usedRuntime.add('__effect');
544
+ if (watchers.length > 0) usedRuntime.add('__untrack');
544
545
  const imports = [...usedRuntime].join(', ');
545
546
  lines.push(`import { ${imports} } from '${options.runtimeImportPath}';`);
546
547
  } else {
@@ -848,10 +849,12 @@ export function generateComponent(parseResult, options = {}) {
848
849
  lines.push(` const ${w.newParam} = ${watchRef};`);
849
850
  lines.push(` if (this.__prev_${w.target} !== undefined) {`);
850
851
  lines.push(` const ${w.oldParam} = this.__prev_${w.target};`);
852
+ lines.push(' __untrack(() => {');
851
853
  const bodyLines = body.split('\n');
852
854
  for (const line of bodyLines) {
853
- lines.push(` ${line}`);
855
+ lines.push(` ${line}`);
854
856
  }
857
+ lines.push(' });');
855
858
  lines.push(' }');
856
859
  lines.push(` this.__prev_${w.target} = ${w.newParam};`);
857
860
  lines.push(' }));');
@@ -863,10 +866,12 @@ export function generateComponent(parseResult, options = {}) {
863
866
  lines.push(` const ${w.newParam} = ${getterExpr};`);
864
867
  lines.push(` if (this.${prevName} !== undefined) {`);
865
868
  lines.push(` const ${w.oldParam} = this.${prevName};`);
866
- const bodyLines = body.split('\n');
867
- for (const line of bodyLines) {
868
- lines.push(` ${line}`);
869
+ lines.push(' __untrack(() => {');
870
+ const bodyLines2 = body.split('\n');
871
+ for (const line of bodyLines2) {
872
+ lines.push(` ${line}`);
869
873
  }
874
+ lines.push(' });');
870
875
  lines.push(' }');
871
876
  lines.push(` this.${prevName} = ${w.newParam};`);
872
877
  lines.push(' }));');
@@ -90,4 +90,11 @@ function __batch(fn) {
90
90
  }
91
91
  }
92
92
  }
93
+
94
+ function __untrack(fn) {
95
+ const prev = __currentEffect;
96
+ __currentEffect = null;
97
+ try { return fn(); }
98
+ finally { __currentEffect = prev; }
99
+ }
93
100
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprlab/wccompiler",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Zero-runtime compiler that transforms .wcc single-file components into native web components with signals-based reactivity",
5
5
  "type": "module",
6
6
  "bin": {