@stacksjs/stx 0.2.366 → 0.2.368

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 (57) hide show
  1. package/dist/{chunk-vd3ja1q9.js → chunk-04qfhvwh.js} +1 -1
  2. package/dist/{chunk-5gwf1fxm.js → chunk-1q5vxmm2.js} +1 -1
  3. package/dist/{chunk-jq1pddw6.js → chunk-2g3xnk2j.js} +1 -1
  4. package/dist/{chunk-34thbja9.js → chunk-301caz1g.js} +1 -1
  5. package/dist/{chunk-0jp8bx88.js → chunk-38q84mff.js} +1 -1
  6. package/dist/{chunk-65nbdz3c.js → chunk-3mw9269k.js} +1 -1
  7. package/dist/{chunk-exve9vx9.js → chunk-4bx30vz5.js} +1 -1
  8. package/dist/{chunk-chnhccbg.js → chunk-63z1kw0k.js} +1 -1
  9. package/dist/{chunk-09xgdh4x.js → chunk-6d7z4e7v.js} +1 -1
  10. package/dist/{chunk-53breaeh.js → chunk-6ec0dk8n.js} +1 -1
  11. package/dist/{chunk-2hpey68b.js → chunk-88qse1rb.js} +1 -1
  12. package/dist/{chunk-y1twpva6.js → chunk-b04c020d.js} +1 -1
  13. package/dist/{chunk-0vary9ym.js → chunk-bkhksb74.js} +1 -1
  14. package/dist/{chunk-e2wkw0mv.js → chunk-bs64kcb6.js} +1 -1
  15. package/dist/{chunk-hd3g347d.js → chunk-c1jewr67.js} +1 -1
  16. package/dist/{chunk-wb2y68dk.js → chunk-d5r2cqkg.js} +1 -1
  17. package/dist/{chunk-y4j6br2e.js → chunk-dmzzbw55.js} +1 -1
  18. package/dist/{chunk-2wbs79rn.js → chunk-dxw41d46.js} +1 -1
  19. package/dist/{chunk-5yhbx6em.js → chunk-hgxc6601.js} +1 -1
  20. package/dist/{chunk-rg473fqn.js → chunk-htd9bf38.js} +1 -1
  21. package/dist/{chunk-v8ncfppj.js → chunk-hxgmf1a8.js} +1 -1
  22. package/dist/{chunk-vr3a5wma.js → chunk-jnv4283w.js} +1 -1
  23. package/dist/{chunk-dvzxdyth.js → chunk-k0wkxgb7.js} +1 -1
  24. package/dist/{chunk-z9zayxg4.js → chunk-k11m8bez.js} +1 -1
  25. package/dist/{chunk-jf9mv5tq.js → chunk-kaf0x9rk.js} +77 -37
  26. package/dist/{chunk-9n4wz4p2.js → chunk-n7sq6rpd.js} +1 -1
  27. package/dist/{chunk-ksfnb7rd.js → chunk-nyw7c3e3.js} +1 -1
  28. package/dist/{chunk-y3gd1g9s.js → chunk-pdhkzprw.js} +16 -16
  29. package/dist/{chunk-2d737x81.js → chunk-q0wwegph.js} +2 -2
  30. package/dist/{chunk-e16evm88.js → chunk-qj8jfkst.js} +1 -1
  31. package/dist/{chunk-k2sdmmmq.js → chunk-rbhndq6q.js} +2 -2
  32. package/dist/{chunk-g1wgckhg.js → chunk-rfqw1q2h.js} +1 -1
  33. package/dist/{chunk-3vctbh57.js → chunk-rn0j7n49.js} +1 -1
  34. package/dist/{chunk-hdpcrf2k.js → chunk-rt76x1hv.js} +1 -1
  35. package/dist/{chunk-jxc8ezvk.js → chunk-rzwwtqxm.js} +1 -1
  36. package/dist/{chunk-m883x1fp.js → chunk-sazv95fq.js} +1 -1
  37. package/dist/{chunk-t0bnbghk.js → chunk-t376jx7f.js} +1 -1
  38. package/dist/{chunk-8czscsf3.js → chunk-v794te0v.js} +1 -1
  39. package/dist/{chunk-bxgq1ec0.js → chunk-vrbjwgva.js} +1 -1
  40. package/dist/{chunk-t6928tnd.js → chunk-vtyys0r4.js} +1 -1
  41. package/dist/{chunk-nhshe26k.js → chunk-vzt7pas7.js} +8 -8
  42. package/dist/{chunk-r92073jh.js → chunk-w08mr6wd.js} +1 -1
  43. package/dist/{chunk-nfmdrmgz.js → chunk-w4ft9mhg.js} +1 -1
  44. package/dist/{chunk-264fwxyv.js → chunk-wnr635ma.js} +2 -2
  45. package/dist/{chunk-cvpr7j0a.js → chunk-wwwh8bxe.js} +1 -1
  46. package/dist/{chunk-b3yn2q9z.js → chunk-x3dxrzgq.js} +1 -1
  47. package/dist/{chunk-z541dzm4.js → chunk-xgzrx7ya.js} +1 -1
  48. package/dist/{chunk-09ypvk2t.js → chunk-y7m8sp4g.js} +1 -1
  49. package/dist/{chunk-tc8yfmm5.js → chunk-yrb6gyny.js} +1 -1
  50. package/dist/{chunk-ht2neybr.js → chunk-zzf0k3my.js} +1 -1
  51. package/dist/cli.js +8 -8
  52. package/dist/craft-entry.js +1 -1
  53. package/dist/craft.js +1 -1
  54. package/dist/pwa.js +1 -1
  55. package/dist/signals.js +77 -37
  56. package/dist/ssg.js +2 -2
  57. package/package.json +5 -5
@@ -2606,8 +2606,8 @@ catch (e) {
2606
2606
  return expressionCallsSignal(expression, prop)
2607
2607
  || expressionUsesSignalApi(expression, prop);
2608
2608
  });
2609
- var fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expression + ') }');
2610
- value = fn(unwrapScope);
2609
+ var fn = __stxCompileScoped(unwrapScope, [], 'return (' + expression + ')');
2610
+ value = fn(...__stxArgs(fn, unwrapScope));
2611
2611
  if (value && typeof value === 'function' && (value._isSignal || value._isDerived)) value = value();
2612
2612
  }
2613
2613
  catch (e) {
@@ -2993,8 +2993,8 @@ else if (part) {
2993
2993
 
2994
2994
  // Use auto-unwrap proxy (Feature #1)
2995
2995
  const unwrapScope = createExpressionAutoUnwrapProxy(activeScope, expr);
2996
- const fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
2997
- var value = maybeUnwrapSignal(fn(unwrapScope));
2996
+ const fn = __stxCompileScoped(unwrapScope, [], 'return (' + expr + ')');
2997
+ var value = maybeUnwrapSignal(fn(...__stxArgs(fn, unwrapScope)));
2998
2998
  noteExprSuccess(expr);
2999
2999
  return value;
3000
3000
  }
@@ -3002,8 +3002,8 @@ catch (e) {
3002
3002
  // Auto-unwrap can break explicit signal calls like errorData().message
3003
3003
  // Retry without auto-unwrap so signal functions remain callable
3004
3004
  try {
3005
- const fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
3006
- var retried = maybeUnwrapSignal(fn(activeScope));
3005
+ const fn = __stxCompileScoped(activeScope, [], 'return (' + expr + ')');
3006
+ var retried = maybeUnwrapSignal(fn(...__stxArgs(fn, activeScope)));
3007
3007
  noteExprSuccess(expr);
3008
3008
  return retried;
3009
3009
  }
@@ -3520,8 +3520,8 @@ catch (e) {
3520
3520
  return direct();
3521
3521
  try {
3522
3522
  var unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
3523
- var fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
3524
- return fn(unwrapScope);
3523
+ var fn = __stxCompileScoped(unwrapScope, [], 'return (' + expr + ')');
3524
+ return fn(...__stxArgs(fn, unwrapScope));
3525
3525
  }
3526
3526
  catch (e) {
3527
3527
  if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] ' + attrName + ' get error:', expr, e);
@@ -4138,8 +4138,12 @@ else if (typeof value === 'string') {
4138
4138
  let templateContent;
4139
4139
  if (isTemplate) {
4140
4140
  templateContent = el.content;
4141
+ deferRowConditionals(templateContent);
4141
4142
  }
4142
4143
  else {
4144
+ // Before the source is cloned into the row template, so that clone does
4145
+ // not build the conditional elements either.
4146
+ deferRowConditionals(el);
4143
4147
  const wrapper = stxHost.clone(el);
4144
4148
  wrapper.removeAttribute('@for');
4145
4149
  wrapper.removeAttribute(':for');
@@ -4246,10 +4250,12 @@ catch (e) {
4246
4250
  return expressionCallsSignal(expression, prop)
4247
4251
  || expressionUsesSignalApi(expression, prop);
4248
4252
  });
4249
- // new Function body is non-strict, so with() works \u2014 only accessed
4250
- // properties trigger the proxy's get trap and register as dependencies
4251
- const fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4252
- return fn(unwrapScope);
4253
+ // Compiled over the names the expression mentions (__stxCompileScoped),
4254
+ // so only those are read and register as dependencies. It used with()
4255
+ // over the proxy, which JavaScriptCore resolves through proxy traps on
4256
+ // every identifier - 36x slower than V8 for a list of message rows.
4257
+ const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
4258
+ return fn(...__stxArgs(fn, unwrapScope));
4253
4259
  } catch (e) {
4254
4260
  if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
4255
4261
  return '';
@@ -4643,6 +4649,50 @@ catch (e) {
4643
4649
  });
4644
4650
  }
4645
4651
 
4652
+ // A :for row is a clone of its template, so a conditional element in the row
4653
+ // is built for every row whether or not its condition ever holds; :if then
4654
+ // parks the false ones. In WebKit a <video> or <audio> sets up a media player
4655
+ // as it is created: a message list with one media slot per attachment took
4656
+ // 1.8s to render instead of 18ms, and every row paid for elements it never
4657
+ // showed. Before any row is cloned, each eligible conditional element in the
4658
+ // row template is moved into a <template> carrying its condition. Template
4659
+ // content is inert, so a cloned row builds the element only when the
4660
+ // condition holds (bindIf clones template content on the first true).
4661
+ //
4662
+ // Left alone: an if/else chain (its branches must stay siblings), an element
4663
+ // that is also a loop, a component (its setup script is a sibling), and
4664
+ // anything holding a script.
4665
+ var IF_ATTRS = [':if', 'x-if', '@if'];
4666
+ var FOR_ATTRS = [':for', 'x-for', '@for'];
4667
+ function deferRowConditionals(root) {
4668
+ if (!root || !root.querySelectorAll || typeof document === 'undefined' || !document.createElement) return;
4669
+ // A walk, not a selector: escaping ':' and '@' in an attribute selector
4670
+ // through this generated source is easy to get wrong, and wrong throws.
4671
+ var candidates = Array.prototype.slice.call(root.querySelectorAll('*'));
4672
+ for (var i = 0; i < candidates.length; i++) {
4673
+ var el = candidates[i];
4674
+ if (el.tagName === 'TEMPLATE' || !el.parentNode) continue;
4675
+ var attr = null;
4676
+ for (var a = 0; a < IF_ATTRS.length; a++) {
4677
+ if (el.hasAttribute(IF_ATTRS[a])) { attr = IF_ATTRS[a]; break; }
4678
+ }
4679
+ if (!attr) continue;
4680
+ var skip = false;
4681
+ for (var f = 0; f < FOR_ATTRS.length; f++) {
4682
+ if (el.hasAttribute(FOR_ATTRS[f])) skip = true;
4683
+ }
4684
+ if (skip || getElseAttrInfo(el)) continue;
4685
+ var next = el.nextElementSibling;
4686
+ if (next && (getElseAttrInfo(next) || next.tagName === 'SCRIPT')) continue;
4687
+ if (el.hasAttribute('data-stx-scope') || el.hasAttribute('x-data') || el.querySelector('script')) continue;
4688
+ var holder = document.createElement('template');
4689
+ holder.setAttribute(attr, el.getAttribute(attr));
4690
+ el.removeAttribute(attr);
4691
+ el.parentNode.insertBefore(holder, el);
4692
+ holder.content.appendChild(el);
4693
+ }
4694
+ }
4695
+
4646
4696
  var __bindIfCounter = 0;
4647
4697
  // \u2500\u2500 x-else / x-else-if chain support (stacksjs/stx#1734) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
4648
4698
  // Returns { name, terminal } for an else/else-if attribute present on el,
@@ -4765,14 +4815,14 @@ catch (e) {
4765
4815
  var scope = { ...globalHelpers, ...capturedComponentScope, ...(b.capturedElementScope || {}) };
4766
4816
  try {
4767
4817
  var unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
4768
- // new Function body is non-strict, so with() works.
4769
- var fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4770
- return fn(unwrapScope);
4818
+ // Compiled over the names the expression mentions (see __stxCompileScoped).
4819
+ var fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
4820
+ return fn(...__stxArgs(fn, unwrapScope));
4771
4821
  }
4772
4822
  catch (e1) {
4773
4823
  try {
4774
- var fn2 = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
4775
- return fn2(scope);
4824
+ var fn2 = __stxCompileScoped(scope, [], 'return ' + expression + '');
4825
+ return fn2(...__stxArgs(fn2, scope));
4776
4826
  }
4777
4827
  catch (e2) {
4778
4828
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expression, e2);
@@ -4980,22 +5030,12 @@ catch (e) { /* a disposer of its own is not this branch's problem */ }
4980
5030
  el.removeAttribute(attrName);
4981
5031
 
4982
5032
  if (isTemplate) {
4983
- // For templates, we need to handle the content fragment
4984
- const content = el.content;
4985
- currentNodes = Array.from(content.childNodes).map(n => stxHost.clone(n));
4986
- // Insert cloned content initially
4987
- // Capture the anchor once. Re-reading placeholder.nextSibling after
4988
- // every insertion points at the node just inserted and reverses a
4989
- // multi-root template branch.
4990
- const initialAnchor = placeholder.nextSibling;
4991
- currentNodes.forEach(node => stxHost.insert(parent, node, initialAnchor));
4992
- // The end of this branch's range, bound at the same time as the content
4993
- // it closes (#1955). Needed here too, not only on re-show: the first
4994
- // hide of a branch that was never toggled removes THIS content, and a
4995
- // nested :for renders rows that are siblings of these clones rather than
4996
- // among them.
4997
- endMarker = stxHost.anchor('stx-if-end');
4998
- stxHost.insert(parent, endMarker, initialAnchor);
5033
+ // Nothing is cloned until the condition holds: the effect below clones
5034
+ // template.content on the first true and binds it then. Every branch
5035
+ // used to be cloned and inserted up front and the false ones removed, so
5036
+ // a false branch still built its elements - in WebKit a <video> or
5037
+ // <audio> sets up a media player as it is created.
5038
+ isInserted = false;
4999
5039
  stxHost.remove(el); // Remove the template element itself
5000
5040
  }
5001
5041
 
@@ -5015,15 +5055,15 @@ catch (e) { /* a disposer of its own is not this branch's problem */ }
5015
5055
  try {
5016
5056
  const scope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
5017
5057
  const unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
5018
- const fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
5019
- return fn(unwrapScope);
5058
+ const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
5059
+ return fn(...__stxArgs(fn, unwrapScope));
5020
5060
  }
5021
5061
  catch (e1) {
5022
5062
  try {
5023
5063
  // Retry without the unwrap proxy so call-syntax (signal()) works.
5024
5064
  const scope2 = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
5025
- const fn2 = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
5026
- return fn2(scope2);
5065
+ const fn2 = __stxCompileScoped(scope2, [], 'return ' + expression + '');
5066
+ return fn2(...__stxArgs(fn2, scope2));
5027
5067
  }
5028
5068
  catch (e2) {
5029
5069
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expression, e2);
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ip as b,Jp as c,Kp as d,Lp as e,mo as a}from"./chunk-y3gd1g9s.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-y4j6br2e.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-rg473fqn.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{d as validateClientScript,c as processOnceDirective,b as processJsonDirective,e as processDirectives,a as injectRouterScript};
2
+ import{Ip as b,Jp as c,Kp as d,Lp as e,mo as a}from"./chunk-pdhkzprw.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-dmzzbw55.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-htd9bf38.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{d as validateClientScript,c as processOnceDirective,b as processJsonDirective,e as processDirectives,a as injectRouterScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Kj as b,Lj as c,Mj as d,Nj as e,Oj as f,Pj as g,Qj as h,Rj as i,Sj as j,Tj as k,Uj as l,Vj as m,Wj as n,Xj as o}from"./chunk-2wbs79rn.js";import{ul as a}from"./chunk-qjvny3wf.js";import"./chunk-y3gd1g9s.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-y4j6br2e.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-rg473fqn.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{b as templateCache,j as registerServeModuleBundle,c as readFileCached,e as invalidateFileCacheByDir,d as invalidateFileCache,o as hashFilePath,k as getServeModuleBundle,i as getServeClientAsset,g as getCachedSignalsRuntime,h as getCachedRouterScript,l as clearDevCaches,m as checkCache,n as cacheTemplate,a as cacheEngineFingerprint,f as __setSignalsGeneratorsForTest};
2
+ import{Kj as b,Lj as c,Mj as d,Nj as e,Oj as f,Pj as g,Qj as h,Rj as i,Sj as j,Tj as k,Uj as l,Vj as m,Wj as n,Xj as o}from"./chunk-dxw41d46.js";import{ul as a}from"./chunk-qjvny3wf.js";import"./chunk-pdhkzprw.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-dmzzbw55.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-htd9bf38.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{b as templateCache,j as registerServeModuleBundle,c as readFileCached,e as invalidateFileCacheByDir,d as invalidateFileCache,o as hashFilePath,k as getServeModuleBundle,i as getServeClientAsset,g as getCachedSignalsRuntime,h as getCachedRouterScript,l as clearDevCaches,m as checkCache,n as cacheTemplate,a as cacheEngineFingerprint,f as __setSignalsGeneratorsForTest};