@stacksjs/stx 0.2.363 → 0.2.365

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 (62) hide show
  1. package/dist/{chunk-725npc6m.js → chunk-0t0b5yex.js} +1 -1
  2. package/dist/{chunk-6557pfz9.js → chunk-0thch80p.js} +1 -1
  3. package/dist/{chunk-9rx9bbqh.js → chunk-11v2ysbe.js} +1 -1
  4. package/dist/{chunk-4my2kn5x.js → chunk-1nv116m3.js} +1 -1
  5. package/dist/{chunk-9y0btmfc.js → chunk-1q2b0r3v.js} +1 -1
  6. package/dist/{chunk-00hwz03z.js → chunk-2aqq5j7c.js} +1 -1
  7. package/dist/{chunk-fxt2hxh0.js → chunk-346jyc33.js} +1 -1
  8. package/dist/{chunk-25yvh46m.js → chunk-4dzsp35z.js} +1 -1
  9. package/dist/{chunk-5mjz2qgs.js → chunk-55k6352k.js} +1 -1
  10. package/dist/{chunk-5ppdkjhy.js → chunk-5qs1t2cd.js} +1 -1
  11. package/dist/{chunk-e45zxsgj.js → chunk-5t826ypq.js} +1 -1
  12. package/dist/{chunk-asshx9sb.js → chunk-6njr31wk.js} +1 -1
  13. package/dist/{chunk-kzg9gjmy.js → chunk-6tk817fg.js} +1 -1
  14. package/dist/{chunk-egnck8vx.js → chunk-77g77ygz.js} +1 -1
  15. package/dist/{chunk-t2yqh8nb.js → chunk-7ptewn2w.js} +2 -2
  16. package/dist/{chunk-3fd7w2va.js → chunk-7yyfbhna.js} +1 -1
  17. package/dist/{chunk-14fy0xrz.js → chunk-8zdq8kk5.js} +1 -1
  18. package/dist/{chunk-51tct8h7.js → chunk-a47e67th.js} +1 -1
  19. package/dist/{chunk-hs1azpgz.js → chunk-atf4tj9y.js} +1 -1
  20. package/dist/{chunk-5fqs93qg.js → chunk-bh1m0x85.js} +1 -1
  21. package/dist/{chunk-khaasesy.js → chunk-bszp4vx1.js} +1 -1
  22. package/dist/{chunk-gv6a9fsn.js → chunk-bxnx8sga.js} +1 -1
  23. package/dist/{chunk-pwctc0m1.js → chunk-czzy14fj.js} +80 -39
  24. package/dist/{chunk-sxnb6ws9.js → chunk-d5r4zwyd.js} +8 -8
  25. package/dist/{chunk-cbh9bfk7.js → chunk-dk40tcv1.js} +1 -1
  26. package/dist/{chunk-phq051sh.js → chunk-eczq4cxz.js} +1 -1
  27. package/dist/{chunk-yp1cbwvf.js → chunk-g63sh9bx.js} +1 -1
  28. package/dist/{chunk-3n0hpd5m.js → chunk-hyrm54da.js} +1 -1
  29. package/dist/{chunk-cjz5nzak.js → chunk-jerrq5k1.js} +1 -1
  30. package/dist/{chunk-3e0ba18k.js → chunk-k10f0c00.js} +1 -1
  31. package/dist/{chunk-jwna46yq.js → chunk-k3ktx8w2.js} +1 -1
  32. package/dist/{chunk-wk7wn1nw.js → chunk-kmd694ky.js} +2 -2
  33. package/dist/{chunk-mwj6w2r7.js → chunk-mks2cgty.js} +1 -1
  34. package/dist/{chunk-yvv9qjcd.js → chunk-n5791wn3.js} +1 -1
  35. package/dist/{chunk-y6ysrzx8.js → chunk-p33qyhtc.js} +1 -1
  36. package/dist/{chunk-ttfb1v63.js → chunk-p8nasx5y.js} +1 -1
  37. package/dist/{chunk-q92wr6a0.js → chunk-pbt7f5h9.js} +1 -1
  38. package/dist/{chunk-bcd9byk3.js → chunk-q28ekhhb.js} +2 -2
  39. package/dist/{chunk-pw8q3ety.js → chunk-r5dta1qf.js} +16 -16
  40. package/dist/{chunk-tcsgynpc.js → chunk-r8hr3jhh.js} +1 -1
  41. package/dist/{chunk-jtzfd61j.js → chunk-ry56srm9.js} +1 -1
  42. package/dist/{chunk-n3xxhvng.js → chunk-se8fh272.js} +1 -1
  43. package/dist/{chunk-2bsaq9kq.js → chunk-syy0njsk.js} +1 -1
  44. package/dist/{chunk-k1trppjz.js → chunk-tfnq0cj6.js} +1 -1
  45. package/dist/{chunk-a127v0w5.js → chunk-ttw7qrz0.js} +1 -1
  46. package/dist/{chunk-sf45fhg4.js → chunk-v8ccphfs.js} +1 -1
  47. package/dist/{chunk-4n3vnzs0.js → chunk-wkeymrkg.js} +1 -1
  48. package/dist/{chunk-xy3gx0x7.js → chunk-xr8ergcp.js} +1 -1
  49. package/dist/chunk-y32dbdta.js +3 -0
  50. package/dist/{chunk-ec4072zn.js → chunk-y3ns6824.js} +1 -1
  51. package/dist/{chunk-yg0qm73a.js → chunk-ys4hpkrp.js} +1 -1
  52. package/dist/{chunk-1e0jj83h.js → chunk-z274qgsn.js} +1 -1
  53. package/dist/{chunk-pkandp4e.js → chunk-zjqw2fde.js} +1 -1
  54. package/dist/cli.js +8 -8
  55. package/dist/craft-entry.js +1 -1
  56. package/dist/craft.js +1 -1
  57. package/dist/pwa.js +1 -1
  58. package/dist/signals-api.js +16 -2
  59. package/dist/signals.js +79 -38
  60. package/dist/ssg.js +2 -2
  61. package/package.json +5 -5
  62. package/dist/chunk-0t1yyn1d.js +0 -3
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Aj as I,Bj as M,Fj as P,Gj as T,Hj as x,Ij as C,wj as B,xj as F,yj as H,zj as O}from"./chunk-0t1yyn1d.js";import{Ov as L,Qv as R,Sv as S}from"./chunk-7racewc5.js";var w=null;function j(){return w}function g(z,W){if(w)w.provides.set(z,W);else V.set(z,W)}function v(z,W){let Q=w;while(Q){if(Q.provides.has(z))return Q.provides.get(z);Q=Q.parent}if(V.has(z))return V.get(z);return W}var V=new Map;function m(z,W){V.set(z,W)}function U(z){let W=w,Q=W?.el,Z=Array.isArray(z)?z:z&&typeof z==="object"?Object.keys(z):[];if(Q&&Z.length>0){let $=Q.__stx_component_emits||=Object.create(null);for(let Y of Z)$[Y]=!0}let _=($,...Y)=>{if(typeof document>"u")return;if(Q){let A=Q.__stx_component_emits||=Object.create(null);A[$]=!0,Q.dispatchEvent(new CustomEvent($,{detail:Y.length===1?Y[0]:Y,bubbles:!0,cancelable:!0}))}};if(W)W.emit=_;return _}function y(z){if(w)w.exposed=z}function h(z){let W=Promise.resolve();return z?W.then(z):W}function p(z){if(w)w.errorCapturedHooks.push(z)}function u(z,W,Q){let Z=W?.parent;while(Z){for(let _ of Z.errorCapturedHooks)if(_(z,W,Q)===!1)return;Z=Z.parent}}function l(){return w?.slots??{}}function d(){return w?.slots??{}}function i(){return w?.attrs??{}}function c(z){let W=z.__provides?new Map(Object.entries(z.__provides)):new Map;return{...z,__provides:W,__provide(Q,Z){W.set(Q,Z)},__inject(Q,Z){if(W.has(Q))return W.get(Q);if(z.__provides){let _=z.__provides instanceof Map?z.__provides:new Map(Object.entries(z.__provides));if(_.has(Q))return _.get(Q)}return Z}}}function o(){return`
2
+ import{Aj as I,Bj as M,Fj as P,Gj as T,Hj as x,Ij as C,wj as B,xj as F,yj as H,zj as O}from"./chunk-y32dbdta.js";import{Ov as L,Qv as R,Sv as S}from"./chunk-7racewc5.js";var w=null;function j(){return w}function g(z,W){if(w)w.provides.set(z,W);else V.set(z,W)}function v(z,W){let Q=w;while(Q){if(Q.provides.has(z))return Q.provides.get(z);Q=Q.parent}if(V.has(z))return V.get(z);return W}var V=new Map;function m(z,W){V.set(z,W)}function U(z){let W=w,Q=W?.el,Z=Array.isArray(z)?z:z&&typeof z==="object"?Object.keys(z):[];if(Q&&Z.length>0){let $=Q.__stx_component_emits||=Object.create(null);for(let Y of Z)$[Y]=!0}let _=($,...Y)=>{if(typeof document>"u")return;if(Q){let A=Q.__stx_component_emits||=Object.create(null);A[$]=!0,Q.dispatchEvent(new CustomEvent($,{detail:Y.length===1?Y[0]:Y,bubbles:!0,cancelable:!0}))}};if(W)W.emit=_;return _}function y(z){if(w)w.exposed=z}function h(z){let W=Promise.resolve();return z?W.then(z):W}function p(z){if(w)w.errorCapturedHooks.push(z)}function u(z,W,Q){let Z=W?.parent;while(Z){for(let _ of Z.errorCapturedHooks)if(_(z,W,Q)===!1)return;Z=Z.parent}}function l(){return w?.slots??{}}function d(){return w?.slots??{}}function i(){return w?.attrs??{}}function c(z){let W=z.__provides?new Map(Object.entries(z.__provides)):new Map;return{...z,__provides:W,__provide(Q,Z){W.set(Q,Z)},__inject(Q,Z){if(W.has(Q))return W.get(Q);if(z.__provides){let _=z.__provides instanceof Map?z.__provides:new Map(Object.entries(z.__provides));if(_.has(Q))return _.get(Q)}return Z}}}function o(){return`
3
3
  // STX Composition API Runtime
4
4
  (function() {
5
5
  const _provides = new Map();
@@ -167,6 +167,25 @@ console.log('[stx] entering IIFE');
167
167
  // Reactive Core
168
168
  // ==========================================================================
169
169
 
170
+ // Compiled expression functions, by parameter list and body. A binding was
171
+ // compiled with new Function on every evaluation: a page with a few hundred
172
+ // names in scope rebuilt a function of a few hundred parameters for every
173
+ // binding of every row, every time a row re-rendered. Opening a 386-message
174
+ // conversation took seven seconds in WebKit, the window frozen meanwhile.
175
+ // A Function built this way closes over nothing, so one can be reused.
176
+ const __stxCompiled = new Map();
177
+ function __stxCompile(params, body) {
178
+ const key = params.join(',') + '\\x01' + body;
179
+ let fn = __stxCompiled.get(key);
180
+ if (!fn) {
181
+ fn = new Function(...params, body);
182
+ // Bounded: expressions are finite per page, but SPA navigation adds more.
183
+ if (__stxCompiled.size >= 5000) __stxCompiled.clear();
184
+ __stxCompiled.set(key, fn);
185
+ }
186
+ return fn;
187
+ }
188
+
170
189
  let activeEffect = null;
171
190
  const effectStack = [];
172
191
  const pendingEffects = new Set();
@@ -756,7 +775,7 @@ else {
756
775
  // First evaluate the base expression
757
776
  let value;
758
777
  try {
759
- const fn = new Function(...Object.keys(scope), 'return ' + valueExpr);
778
+ const fn = __stxCompile(Object.keys(scope), 'return ' + valueExpr);
760
779
  value = fn(...Object.values(scope));
761
780
  }
762
781
  catch (e) {
@@ -777,7 +796,7 @@ catch (e) {
777
796
  if (/^['"].*['"]$/.test(arg)) return arg.slice(1, -1);
778
797
  // Try to evaluate as expression in scope
779
798
  try {
780
- const fn = new Function(...Object.keys(scope), 'return ' + arg);
799
+ const fn = __stxCompile(Object.keys(scope), 'return ' + arg);
781
800
  return fn(...Object.values(scope));
782
801
  }
783
802
  catch (e) {
@@ -825,7 +844,10 @@ else {
825
844
  }
826
845
  const prev = value;
827
846
  value = newValue;
828
- subscribers.forEach(cb => cb(value, prev));
847
+ subscribers.forEach(cb => {
848
+ try { cb(value, prev); }
849
+ catch (e) { console.error('[stx] subscriber error:', e); }
850
+ });
829
851
  if (isBatching) {
830
852
  effects.forEach(effect => pendingEffects.add(effect));
831
853
  }
@@ -839,7 +861,10 @@ else {
839
861
  // Notify as if the value changed, for an array or object mutated in place.
840
862
  // set() cannot do it: the value is the same reference, so Object.is skips.
841
863
  signal.trigger = () => {
842
- subscribers.forEach(cb => cb(value, value));
864
+ subscribers.forEach(cb => {
865
+ try { cb(value, value); }
866
+ catch (e) { console.error('[stx] subscriber error:', e); }
867
+ });
843
868
  if (isBatching) {
844
869
  effects.forEach(effect => pendingEffects.add(effect));
845
870
  }
@@ -929,8 +954,10 @@ finally {
929
954
  if (isDisposed) return;
930
955
  if (__stxDevtoolsTracking) { runEffect._runCount++; __stxDevtoolsStats.effectRuns++; }
931
956
  if (cleanup) {
932
- cleanup();
957
+ const pending = cleanup;
933
958
  cleanup = undefined;
959
+ try { pending(); }
960
+ catch (e) { console.error('[stx] effect cleanup error:', e); }
934
961
  }
935
962
  const prev = activeEffect;
936
963
  activeEffect = runEffect;
@@ -953,11 +980,18 @@ finally {
953
980
  isDisposed = true;
954
981
  // Only log if this is likely a real error, not a stale SPA effect.
955
982
  // Stale effects reference variables from a previous page's scope that no longer exist.
983
+ //
984
+ // Reported, never re-thrown. Re-thrown, it escaped the .set() that ran
985
+ // this effect, and that set() stopped notifying everything after it:
986
+ // a list half-rendered with raw {{ }} and no click handlers, a
987
+ // selection that moved while the view it drives did not, and nothing
988
+ // in the console, because the exception ended inside an event handler
989
+ // or a native callback. One broken effect took the page with it.
956
990
  if (e instanceof ReferenceError) {
957
991
  // Silently dispose \u2014 this is expected during SPA navigation when
958
- // old effects fire against the new page's scope. Don't re-throw.
992
+ // old effects fire against the new page's scope.
959
993
  } else {
960
- throw e;
994
+ console.error('[stx] effect error (the effect is disposed):', e);
961
995
  }
962
996
  }
963
997
  finally {
@@ -1023,10 +1057,17 @@ catch (e) { console.warn('[stx] dispose error:', e); } });
1023
1057
  return;
1024
1058
  }
1025
1059
  isBatching = true;
1026
- fn();
1027
- isBatching = false;
1028
- pendingEffects.forEach(e => e());
1029
- pendingEffects.clear();
1060
+ // finally: a throw inside fn left isBatching set for good, and every later
1061
+ // update was queued for a flush that never came - the page stopped.
1062
+ try {
1063
+ fn();
1064
+ }
1065
+ finally {
1066
+ isBatching = false;
1067
+ const queued = Array.from(pendingEffects);
1068
+ pendingEffects.clear();
1069
+ queued.forEach(e => e());
1070
+ }
1030
1071
  }
1031
1072
 
1032
1073
  // ==========================================================================
@@ -2047,7 +2088,7 @@ finally {
2047
2088
  || expressionUsesSignalApi(expr, prop);
2048
2089
  })
2049
2090
  : baseScope;
2050
- const fn = new Function(...Object.keys(baseScope), 'return ' + expr);
2091
+ const fn = __stxCompile(Object.keys(baseScope), 'return ' + expr);
2051
2092
  const result = fn(...Object.values(scope));
2052
2093
  // Post-eval unwrap \u2014 see evalAttrExpr note for the reason.
2053
2094
  return (result && typeof result === 'function' && (result._isSignal || result._isDerived)) ? result() : result;
@@ -2215,7 +2256,7 @@ catch (e) {
2215
2256
  const v = scope[k];
2216
2257
  handlerScope[k] = (v && typeof v === 'function' && v._isStxLoopItem) ? v() : v;
2217
2258
  });
2218
- const fn = new Function(...Object.keys(handlerScope), '$event', expr);
2259
+ const fn = __stxCompile(Object.keys(handlerScope).concat(['$event']), expr);
2219
2260
  fn(...Object.values(handlerScope), event);
2220
2261
  }
2221
2262
  catch (e) {
@@ -2525,7 +2566,7 @@ catch (e) {
2525
2566
  return expressionCallsSignal(expression, prop)
2526
2567
  || expressionUsesSignalApi(expression, prop);
2527
2568
  });
2528
- var fn = new Function('__scope__', 'with(__scope__) { return (' + expression + ') }');
2569
+ var fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expression + ') }');
2529
2570
  value = fn(unwrapScope);
2530
2571
  if (value && typeof value === 'function' && (value._isSignal || value._isDerived)) value = value();
2531
2572
  }
@@ -2733,7 +2774,7 @@ catch (e) {
2733
2774
  var memoExpr = el.getAttribute('data-stx-memo');
2734
2775
  try {
2735
2776
  var memoScope = { ...globalHelpers, ...scope, ...(findElementScope(el) || {}) };
2736
- var memoFn = new Function(...Object.keys(memoScope), 'return ' + memoExpr);
2777
+ var memoFn = __stxCompile(Object.keys(memoScope), 'return ' + memoExpr);
2737
2778
  var memoVals = JSON.stringify(memoFn(...Object.values(memoScope)));
2738
2779
  if (el.__stx_memo_prev === memoVals) {
2739
2780
  return; // Dependencies unchanged \u2014 skip re-processing
@@ -2786,7 +2827,7 @@ catch (e) {
2786
2827
  else {
2787
2828
  // Use auto-unwrap proxy (Feature #1)
2788
2829
  const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
2789
- const fn = new Function(...Object.keys(capturedScope), 'return ' + expr);
2830
+ const fn = __stxCompile(Object.keys(capturedScope), 'return ' + expr);
2790
2831
  bindingNode.textContent = fn(...Object.values(unwrapScope));
2791
2832
  }
2792
2833
  }
@@ -2795,7 +2836,7 @@ catch (e) {
2795
2836
  // because it converts the signal to its value before the expression runs.
2796
2837
  // Retry without auto-unwrap so signal functions remain callable.
2797
2838
  try {
2798
- const fn = new Function(...Object.keys(capturedScope), 'return ' + expr);
2839
+ const fn = __stxCompile(Object.keys(capturedScope), 'return ' + expr);
2799
2840
  bindingNode.textContent = fn(...Object.values(capturedScope));
2800
2841
  }
2801
2842
  catch (e2) {
@@ -2912,7 +2953,7 @@ else if (part) {
2912
2953
 
2913
2954
  // Use auto-unwrap proxy (Feature #1)
2914
2955
  const unwrapScope = createExpressionAutoUnwrapProxy(activeScope, expr);
2915
- const fn = new Function('__scope__', 'with(__scope__) { return (' + expr + ') }');
2956
+ const fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
2916
2957
  var value = maybeUnwrapSignal(fn(unwrapScope));
2917
2958
  noteExprSuccess(expr);
2918
2959
  return value;
@@ -2921,7 +2962,7 @@ catch (e) {
2921
2962
  // Auto-unwrap can break explicit signal calls like errorData().message
2922
2963
  // Retry without auto-unwrap so signal functions remain callable
2923
2964
  try {
2924
- const fn = new Function('__scope__', 'with(__scope__) { return (' + expr + ') }');
2965
+ const fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
2925
2966
  var retried = maybeUnwrapSignal(fn(activeScope));
2926
2967
  noteExprSuccess(expr);
2927
2968
  return retried;
@@ -3235,7 +3276,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
3235
3276
  return 'if(' + k + ' !== __s["' + k + '"]()) __s["' + k + '"].set(' + k + ')';
3236
3277
  }).join(';');
3237
3278
  var body = getVars + ';' + value + ';' + setVars;
3238
- var fn2 = new Function('__s', '$event', body);
3279
+ var fn2 = __stxCompile(['__s', '$event'], body);
3239
3280
  fn2(eventCapturedScope, handlerEvent);
3240
3281
  } else if (hasSignals) {
3241
3282
  // Function calls with signals in scope keep any signal used through
@@ -3258,10 +3299,10 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
3258
3299
  }
3259
3300
  return 'var ' + k + ' = __s["' + k + '"] && typeof __s["' + k + '"] === "function" && __s["' + k + '"]._isSignal ? __s["' + k + '"]() : __s["' + k + '"]';
3260
3301
  }).join(';');
3261
- var fn3 = new Function('__s', '$event', unwrapVars + ';' + value);
3302
+ var fn3 = __stxCompile(['__s', '$event'], unwrapVars + ';' + value);
3262
3303
  fn3(eventCapturedScope, handlerEvent);
3263
3304
  } else {
3264
- var fn = new Function(...Object.keys(eventCapturedScope), '$event', value);
3305
+ var fn = __stxCompile(Object.keys(eventCapturedScope).concat(['$event']), value);
3265
3306
  fn(...Object.values(eventCapturedScope), handlerEvent);
3266
3307
  }
3267
3308
  }
@@ -3387,13 +3428,13 @@ catch (e) {
3387
3428
  var value;
3388
3429
  try {
3389
3430
  var unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
3390
- var fn = new Function(...Object.keys(capturedScope), 'return ' + expr);
3431
+ var fn = __stxCompile(Object.keys(capturedScope), 'return ' + expr);
3391
3432
  value = fn(...Object.values(unwrapScope));
3392
3433
  } catch (e1) {
3393
3434
  // Retry without unwrapping \u2014 handles edge cases where the proxy
3394
3435
  // interferes with certain expression patterns
3395
3436
  try {
3396
- var fn2 = new Function(...Object.keys(capturedScope), 'return ' + expr);
3437
+ var fn2 = __stxCompile(Object.keys(capturedScope), 'return ' + expr);
3397
3438
  value = fn2(...Object.values(capturedScope));
3398
3439
  } catch (e2) {
3399
3440
  // Suppress ReferenceError/TypeError during async init \u2014 a signal
@@ -3439,7 +3480,7 @@ catch (e) {
3439
3480
  return direct();
3440
3481
  try {
3441
3482
  var unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
3442
- var fn = new Function('__scope__', 'with(__scope__) { return (' + expr + ') }');
3483
+ var fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
3443
3484
  return fn(unwrapScope);
3444
3485
  }
3445
3486
  catch (e) {
@@ -3467,7 +3508,7 @@ else {
3467
3508
  // Routing through it also drops the old requirement that every scope
3468
3509
  // key be a valid identifier, since nothing is destructured now.
3469
3510
  var writeScope = createModelWriteProxy(capturedScope);
3470
- var writeFn = new Function('__scope__', '__v__', 'with(__scope__) { ' + expr + ' = __v__ }');
3511
+ var writeFn = __stxCompile(['__scope__', '__v__'], 'with(__scope__) { ' + expr + ' = __v__ }');
3471
3512
  writeFn(writeScope, val);
3472
3513
  }
3473
3514
  }
@@ -3581,7 +3622,7 @@ else {
3581
3622
  const safeKeys = keys.filter(k => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k));
3582
3623
  let fn;
3583
3624
  try {
3584
- fn = new Function(...safeKeys, 'return ' + expr);
3625
+ fn = __stxCompile(safeKeys, 'return ' + expr);
3585
3626
  } catch (e) {
3586
3627
  console.warn('[STX] bindClass compile error:', expr, e);
3587
3628
  return;
@@ -3650,12 +3691,12 @@ else {
3650
3691
  // throw TypeError.
3651
3692
  try {
3652
3693
  const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
3653
- const fn = new Function(...Object.keys(capturedScope), 'return ' + expr);
3694
+ const fn = __stxCompile(Object.keys(capturedScope), 'return ' + expr);
3654
3695
  return fn(...Object.values(unwrapScope));
3655
3696
  }
3656
3697
  catch (e1) {
3657
3698
  try {
3658
- const fn2 = new Function(...Object.keys(capturedScope), 'return ' + expr);
3699
+ const fn2 = __stxCompile(Object.keys(capturedScope), 'return ' + expr);
3659
3700
  return fn2(...Object.values(capturedScope));
3660
3701
  }
3661
3702
  catch (e2) {
@@ -4141,7 +4182,7 @@ else {
4141
4182
  return expressionCallsSignal(expression, prop)
4142
4183
  || expressionUsesSignalApi(expression, prop);
4143
4184
  });
4144
- const fn = new Function(...Object.keys(scope), 'return ' + expression);
4185
+ const fn = __stxCompile(Object.keys(scope), 'return ' + expression);
4145
4186
  return fn(...Object.values(unwrapScope));
4146
4187
  }
4147
4188
  catch (e) {
@@ -4164,7 +4205,7 @@ catch (e) {
4164
4205
  });
4165
4206
  // new Function body is non-strict, so with() works \u2014 only accessed
4166
4207
  // properties trigger the proxy's get trap and register as dependencies
4167
- const fn = new Function('__scope__', 'with(__scope__) { return ' + expression + ' }');
4208
+ const fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4168
4209
  return fn(unwrapScope);
4169
4210
  } catch (e) {
4170
4211
  if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
@@ -4259,7 +4300,7 @@ catch (e) {
4259
4300
  try {
4260
4301
  const scope = { [itemName]: item };
4261
4302
  if (indexName) scope[indexName] = index;
4262
- const fn = new Function(itemName, indexName || '_idx', 'return ' + keyExpr);
4303
+ const fn = __stxCompile([itemName, indexName || '_idx'], 'return ' + keyExpr);
4263
4304
  return String(fn(item, index));
4264
4305
  } catch (e) {
4265
4306
  return String(index);
@@ -4682,12 +4723,12 @@ catch (e) {
4682
4723
  try {
4683
4724
  var unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
4684
4725
  // new Function body is non-strict, so with() works.
4685
- var fn = new Function('__scope__', 'with(__scope__) { return ' + expression + ' }');
4726
+ var fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4686
4727
  return fn(unwrapScope);
4687
4728
  }
4688
4729
  catch (e1) {
4689
4730
  try {
4690
- var fn2 = new Function('__scope__', 'with(__scope__) { return ' + expression + ' }');
4731
+ var fn2 = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4691
4732
  return fn2(scope);
4692
4733
  }
4693
4734
  catch (e2) {
@@ -4931,14 +4972,14 @@ catch (e) { /* a disposer of its own is not this branch's problem */ }
4931
4972
  try {
4932
4973
  const scope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
4933
4974
  const unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
4934
- const fn = new Function('__scope__', 'with(__scope__) { return ' + expression + ' }');
4975
+ const fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4935
4976
  return fn(unwrapScope);
4936
4977
  }
4937
4978
  catch (e1) {
4938
4979
  try {
4939
4980
  // Retry without the unwrap proxy so call-syntax (signal()) works.
4940
4981
  const scope2 = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
4941
- const fn2 = new Function('__scope__', 'with(__scope__) { return ' + expression + ' }');
4982
+ const fn2 = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4942
4983
  return fn2(scope2);
4943
4984
  }
4944
4985
  catch (e2) {
@@ -8231,7 +8272,7 @@ else {
8231
8272
  if (matches) {
8232
8273
  matches.forEach(match => {
8233
8274
  const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');
8234
- const fn = new Function(...Object.keys(componentScope), 'return ' + expr);
8275
+ const fn = __stxCompile(Object.keys(componentScope), 'return ' + expr);
8235
8276
  const value = fn(...Object.values(componentScope));
8236
8277
  result = result.replace(match, value != null ? value : '');
8237
8278
  });
@@ -8258,7 +8299,7 @@ else if (el.tagName === 'META') {
8258
8299
  matches.forEach(match => {
8259
8300
  const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');
8260
8301
  if (/^__[A-Z_]+__$/.test(expr.trim())) return;
8261
- const fn = new Function(...Object.keys(componentScope), 'return ' + expr);
8302
+ const fn = __stxCompile(Object.keys(componentScope), 'return ' + expr);
8262
8303
  const value = fn(...Object.values(componentScope));
8263
8304
  result = result.replace(match, value != null ? value : '');
8264
8305
  });