@stacksjs/stx 0.2.629 → 0.2.631

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 (220) hide show
  1. package/dist/chunk-05zhvg8t.js +20 -0
  2. package/dist/chunk-0c31twby.js +2 -0
  3. package/dist/{chunk-0s1hpqas.js → chunk-0jeqp6yz.js} +2 -2
  4. package/dist/chunk-0nvb2x2f.js +2 -0
  5. package/dist/chunk-0whv8hnp.js +4 -0
  6. package/dist/{chunk-q1983d5e.js → chunk-179c1rdn.js} +2 -2
  7. package/dist/chunk-1e25xd0z.js +6 -0
  8. package/dist/{chunk-jp6yn9mj.js → chunk-1ma56c2h.js} +2 -2
  9. package/dist/{chunk-3ap1vsh3.js → chunk-27h1xs4k.js} +12 -12
  10. package/dist/{chunk-5m0r0j79.js → chunk-2vqz7v37.js} +3 -3
  11. package/dist/{chunk-10s16tad.js → chunk-2wvz3fd2.js} +2 -2
  12. package/dist/chunk-3jda301z.js +2 -0
  13. package/dist/{chunk-gc1dzxee.js → chunk-3p2b88pd.js} +2 -2
  14. package/dist/chunk-46qg1tqe.js +2 -0
  15. package/dist/{chunk-66e4ga0z.js → chunk-4fv3jq16.js} +2 -2
  16. package/dist/{chunk-k1k2t4ez.js → chunk-4y06ekvt.js} +1 -1
  17. package/dist/chunk-5fjb6avv.js +2 -0
  18. package/dist/chunk-5kprybdd.js +2 -0
  19. package/dist/{chunk-n5xbv1a9.js → chunk-62kxavc5.js} +3 -3
  20. package/dist/{chunk-rdm35qqn.js → chunk-6684b8ym.js} +11 -11
  21. package/dist/{chunk-6kd84jx3.js → chunk-6mtth8d1.js} +3 -3
  22. package/dist/chunk-6n6nnt33.js +2 -0
  23. package/dist/chunk-6per0k6j.js +2 -0
  24. package/dist/{chunk-aktzv0x2.js → chunk-70npkeh2.js} +2 -2
  25. package/dist/{chunk-4tyj5vpw.js → chunk-776f05vk.js} +4 -4
  26. package/dist/{chunk-szjgbjw1.js → chunk-7a8jkwah.js} +2 -2
  27. package/dist/{chunk-wbhzt74k.js → chunk-7cw0wkbx.js} +1 -1
  28. package/dist/chunk-7f1dw9r4.js +2 -0
  29. package/dist/{chunk-khzyc41k.js → chunk-7ky2ny63.js} +13 -13
  30. package/dist/{chunk-h431swg6.js → chunk-7mpv1a02.js} +9 -9
  31. package/dist/chunk-7zjv015g.js +2 -0
  32. package/dist/{chunk-q35z0cyg.js → chunk-85bbtv3m.js} +1 -1
  33. package/dist/{chunk-qb7a4am2.js → chunk-85g35me6.js} +2 -2
  34. package/dist/chunk-87nt0kty.js +2 -0
  35. package/dist/{chunk-3dth76ce.js → chunk-88d5s6v3.js} +3 -3
  36. package/dist/chunk-8a3sdg2y.js +2 -0
  37. package/dist/chunk-8e9hd2jq.js +4 -0
  38. package/dist/{chunk-0c7ss25y.js → chunk-8gksvwsm.js} +3 -3
  39. package/dist/chunk-8vbfbtke.js +2 -0
  40. package/dist/chunk-91ranpvz.js +2 -0
  41. package/dist/chunk-96ypgjm4.js +2 -0
  42. package/dist/{chunk-1gtrs8va.js → chunk-9b4e815s.js} +8 -8
  43. package/dist/chunk-9cg6q8mw.js +2 -0
  44. package/dist/{chunk-gd7vq083.js → chunk-a2ztn8cr.js} +1 -1
  45. package/dist/chunk-ag4eck6d.js +2 -0
  46. package/dist/chunk-aq02drjz.js +2 -0
  47. package/dist/{chunk-jsw5yby0.js → chunk-aqra0qcg.js} +3 -3
  48. package/dist/{chunk-xheh68kv.js → chunk-av9zf0zb.js} +5 -5
  49. package/dist/chunk-ayt4qd82.js +2 -0
  50. package/dist/{chunk-m735gtc4.js → chunk-az1y9jks.js} +2 -2
  51. package/dist/chunk-b3mazye4.js +2 -0
  52. package/dist/chunk-b5cv9xp7.js +2852 -0
  53. package/dist/{chunk-dayjd2sj.js → chunk-b7p3yca7.js} +4 -4
  54. package/dist/chunk-bn6sarwd.js +2 -0
  55. package/dist/chunk-c7xt5gyb.js +2 -0
  56. package/dist/chunk-cac98pkx.js +2 -0
  57. package/dist/{chunk-6j4f8dwx.js → chunk-cbj2hmx5.js} +5 -5
  58. package/dist/chunk-czg6ewy3.js +2 -0
  59. package/dist/{chunk-sxpnpvt5.js → chunk-d1ya7f79.js} +4 -4
  60. package/dist/chunk-dcwmcqbr.js +2 -0
  61. package/dist/{chunk-19bhnbyn.js → chunk-dz4hrgw8.js} +83 -64
  62. package/dist/chunk-ed1qn902.js +2 -0
  63. package/dist/chunk-ev479f3z.js +2 -0
  64. package/dist/{chunk-x6pz1h3x.js → chunk-evs5gb3q.js} +10 -10
  65. package/dist/{chunk-crws777p.js → chunk-fskpdva4.js} +46 -46
  66. package/dist/{chunk-5rtatjwq.js → chunk-gh34r6qb.js} +2 -2
  67. package/dist/chunk-gmg6aj7y.js +2 -0
  68. package/dist/{chunk-fhxfh4nf.js → chunk-h4ashx84.js} +1 -1
  69. package/dist/chunk-hc1m2psz.js +3 -0
  70. package/dist/{chunk-4hmdcmw1.js → chunk-hfe8g644.js} +6 -6
  71. package/dist/chunk-htaed68z.js +2 -0
  72. package/dist/{chunk-g8gzxhp8.js → chunk-j1rnhv0w.js} +3 -3
  73. package/dist/chunk-j2jm2nqz.js +2 -0
  74. package/dist/chunk-jb8d4n60.js +2 -0
  75. package/dist/{chunk-mktk70gq.js → chunk-k2nrx78c.js} +2 -2
  76. package/dist/chunk-kdnbxwkb.js +2 -0
  77. package/dist/{chunk-8zqgb3q9.js → chunk-kf2vas4j.js} +5 -5
  78. package/dist/chunk-kt5mzw2w.js +2 -0
  79. package/dist/chunk-kt994306.js +2 -0
  80. package/dist/{chunk-6qvskcwp.js → chunk-mer3aea0.js} +4 -4
  81. package/dist/chunk-mezphhpa.js +2 -0
  82. package/dist/{chunk-5wrmcbch.js → chunk-myhxapnn.js} +2 -2
  83. package/dist/chunk-n7d69a2q.js +2 -0
  84. package/dist/{chunk-z4te6223.js → chunk-nz6bzffm.js} +4 -4
  85. package/dist/{chunk-ksn8mf12.js → chunk-pfas39mf.js} +9 -9
  86. package/dist/{chunk-j18z5nxq.js → chunk-phbnrw2h.js} +2 -2
  87. package/dist/{chunk-9g5sv1p6.js → chunk-q2p6y0cn.js} +7 -7
  88. package/dist/{chunk-jm478rek.js → chunk-qfppetcn.js} +1 -1
  89. package/dist/{chunk-wsbccxwy.js → chunk-qpbd2fwp.js} +9 -9
  90. package/dist/{chunk-qx2ra6fk.js → chunk-qvqgbvfa.js} +6 -6
  91. package/dist/chunk-qz3tnvwm.js +2 -0
  92. package/dist/{chunk-dvbgbd06.js → chunk-rns21kkv.js} +2 -2
  93. package/dist/{chunk-08jyyegp.js → chunk-rq9cbw2y.js} +1 -1
  94. package/dist/{chunk-q7wj2ypd.js → chunk-s0ar60ng.js} +6 -6
  95. package/dist/chunk-sddytf9n.js +2 -0
  96. package/dist/chunk-spvr2vvh.js +2 -0
  97. package/dist/{chunk-0z189871.js → chunk-t84ww3qb.js} +2 -2
  98. package/dist/chunk-t91250ag.js +2 -0
  99. package/dist/{chunk-n8595zaf.js → chunk-tmbqz710.js} +1 -1
  100. package/dist/{chunk-hjp38m0w.js → chunk-tme29zh9.js} +2 -2
  101. package/dist/chunk-txkc9w9q.js +2 -0
  102. package/dist/chunk-ty1c2276.js +2 -0
  103. package/dist/{chunk-det49x62.js → chunk-v5500ews.js} +2 -2
  104. package/dist/chunk-vepjs3tg.js +2 -0
  105. package/dist/{chunk-v3anfm9d.js → chunk-vfbdxxbf.js} +2 -2
  106. package/dist/{chunk-7mehf3h5.js → chunk-w9c7z8p3.js} +2 -2
  107. package/dist/chunk-wfp754ya.js +2 -0
  108. package/dist/chunk-wp3qcfb4.js +3 -0
  109. package/dist/{chunk-qxtgxcm8.js → chunk-x17fpc0x.js} +6 -6
  110. package/dist/chunk-x3sbsxdq.js +2 -0
  111. package/dist/chunk-xdcvp8tt.js +2 -0
  112. package/dist/{chunk-ebkjpj5m.js → chunk-xh98er3b.js} +2 -2
  113. package/dist/{chunk-9z9f3d6b.js → chunk-xrj3tekf.js} +2 -2
  114. package/dist/chunk-xxnh7gv8.js +2 -0
  115. package/dist/{chunk-tchpwc6h.js → chunk-y2t8xd39.js} +2 -2
  116. package/dist/chunk-y4egzqqf.js +2 -0
  117. package/dist/chunk-y4nm9wq4.js +2 -0
  118. package/dist/{chunk-ygkwp4sf.js → chunk-y5hdc1sb.js} +2 -2
  119. package/dist/chunk-ygx0akfn.js +2 -0
  120. package/dist/chunk-yn9fwnq2.js +2 -0
  121. package/dist/{chunk-nhmqd1g9.js → chunk-yq9rfnd6.js} +1 -1
  122. package/dist/chunk-z0gfb7b4.js +2 -0
  123. package/dist/chunk-z3e54btj.js +2 -0
  124. package/dist/{chunk-773vgw1k.js → chunk-z6fb4m1j.js} +3 -3
  125. package/dist/cli.js +21 -21
  126. package/dist/client/signals-class-runtime.js +1 -1
  127. package/dist/client/signals-component-hydration-runtime.js +1 -1
  128. package/dist/client/signals-component-props-runtime.js +3 -3
  129. package/dist/client/signals-container-cleanup-runtime.js +1 -1
  130. package/dist/client/signals-dom-ready-runtime.js +4 -4
  131. package/dist/client/signals-event-shorthand-runtime.js +2 -2
  132. package/dist/client/signals-expression-runtime.js +21 -2
  133. package/dist/client/signals-for-runtime.js +6 -6
  134. package/dist/client/signals-handler-runtime.js +1 -1
  135. package/dist/client/signals-hydration-audit-runtime.js +1 -1
  136. package/dist/client/signals-hydration-runtime.js +1 -1
  137. package/dist/client/signals-if-chain-runtime.js +3 -3
  138. package/dist/client/signals-if-runtime.js +7 -7
  139. package/dist/client/signals-lazy-hydration-runtime.js +1 -1
  140. package/dist/client/signals-manifest-hydration-runtime.js +1 -1
  141. package/dist/client/signals-model-runtime.js +1 -1
  142. package/dist/client/signals-mount-runtime.js +3 -3
  143. package/dist/client/signals-process-element-runtime.js +7 -7
  144. package/dist/client/signals-show-runtime.js +1 -1
  145. package/dist/client/signals-spa-load-runtime.js +5 -5
  146. package/dist/client/signals-style-runtime.js +1 -1
  147. package/dist/client-scope-bindings.d.ts +6 -0
  148. package/dist/client-scope-bindings.js +98 -0
  149. package/dist/client-script-bundler.js +9 -3
  150. package/dist/client-script.js +2 -1
  151. package/dist/craft-entry.js +2 -2
  152. package/dist/craft.js +2 -2
  153. package/dist/includes.js +4 -2
  154. package/dist/pwa.js +3 -3
  155. package/dist/signal-processing.d.ts +2 -6
  156. package/dist/signal-processing.js +4 -80
  157. package/dist/ssg.js +10 -10
  158. package/dist/stx-virtual-ts.js +4 -2
  159. package/dist/utils.js +5 -3
  160. package/package.json +5 -5
  161. package/dist/chunk-0fcxfd5f.js +0 -2
  162. package/dist/chunk-0fgp13q4.js +0 -2
  163. package/dist/chunk-2340emvg.js +0 -2
  164. package/dist/chunk-317xf7hx.js +0 -2
  165. package/dist/chunk-4kyrzkvg.js +0 -2
  166. package/dist/chunk-5q7gcr0f.js +0 -2
  167. package/dist/chunk-5s91drvs.js +0 -2
  168. package/dist/chunk-6377p5ry.js +0 -2
  169. package/dist/chunk-7h4mxhkh.js +0 -2
  170. package/dist/chunk-7zdefvrn.js +0 -2
  171. package/dist/chunk-8898f767.js +0 -2
  172. package/dist/chunk-8jgrakqd.js +0 -2850
  173. package/dist/chunk-9j2tpg46.js +0 -2
  174. package/dist/chunk-9wbraw07.js +0 -2
  175. package/dist/chunk-b7fgatb5.js +0 -3
  176. package/dist/chunk-c0yb755y.js +0 -2
  177. package/dist/chunk-chaee0vj.js +0 -2
  178. package/dist/chunk-dn050jj1.js +0 -2
  179. package/dist/chunk-dyp3vncz.js +0 -2
  180. package/dist/chunk-e876sg0j.js +0 -2
  181. package/dist/chunk-ekfmad19.js +0 -2
  182. package/dist/chunk-fnzv245x.js +0 -2
  183. package/dist/chunk-g9sv00hm.js +0 -15
  184. package/dist/chunk-hjkm6k8c.js +0 -2
  185. package/dist/chunk-hpvkkke2.js +0 -2
  186. package/dist/chunk-hsmaakds.js +0 -2
  187. package/dist/chunk-k1vjhhd4.js +0 -2
  188. package/dist/chunk-kp4j8vja.js +0 -2
  189. package/dist/chunk-mb8c650x.js +0 -2
  190. package/dist/chunk-pbk2kwec.js +0 -2
  191. package/dist/chunk-ppaj0hef.js +0 -2
  192. package/dist/chunk-pz5zh3tg.js +0 -2
  193. package/dist/chunk-q068mc46.js +0 -2
  194. package/dist/chunk-q4a2j4qr.js +0 -3
  195. package/dist/chunk-q9dh9dte.js +0 -2
  196. package/dist/chunk-qnjhh828.js +0 -2
  197. package/dist/chunk-qz7fyxwp.js +0 -2
  198. package/dist/chunk-rj0nyb2t.js +0 -2
  199. package/dist/chunk-s63fkwzc.js +0 -2
  200. package/dist/chunk-sgn1h15s.js +0 -2
  201. package/dist/chunk-smpyb21z.js +0 -2
  202. package/dist/chunk-snd65r8z.js +0 -2
  203. package/dist/chunk-sp94c1vv.js +0 -2
  204. package/dist/chunk-swv69q75.js +0 -4
  205. package/dist/chunk-th9wcse5.js +0 -2
  206. package/dist/chunk-v1ck0wd3.js +0 -2
  207. package/dist/chunk-vhak3tvx.js +0 -2
  208. package/dist/chunk-w24zd7sj.js +0 -2
  209. package/dist/chunk-wda1fsbk.js +0 -2
  210. package/dist/chunk-wfettff6.js +0 -2
  211. package/dist/chunk-wq97shs3.js +0 -2
  212. package/dist/chunk-xfvbm4pn.js +0 -2
  213. package/dist/chunk-xg1jtz8h.js +0 -2
  214. package/dist/chunk-xppat53n.js +0 -2
  215. package/dist/chunk-xxv8rfxs.js +0 -2
  216. package/dist/chunk-y17jdnrm.js +0 -4
  217. package/dist/chunk-yceb9scc.js +0 -2
  218. package/dist/chunk-z04480ar.js +0 -2
  219. package/dist/chunk-z4xqznsb.js +0 -2
  220. package/dist/chunk-zedvwcta.js +0 -6
@@ -184,7 +184,7 @@ else {
184
184
  return expression;
185
185
  }
186
186
  // Use passedScope instead of componentScope to preserve context through nested processing
187
- const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };
187
+ const scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
188
188
  const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
189
189
  if (typeof prop !== 'string') return false;
190
190
  return expressionCallsSignal(expression, prop)
@@ -205,7 +205,7 @@ catch (e) {
205
205
  const evalLazy = (expression, extraScope = {}) => {
206
206
  try {
207
207
  if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;
208
- const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };
208
+ const scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
209
209
  const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
210
210
  if (typeof prop !== 'string') return false;
211
211
  return expressionCallsSignal(expression, prop)
@@ -274,9 +274,9 @@ catch (e) {
274
274
  itemSignal._isStxLoopItem = true;
275
275
  const indexSignal = state(index);
276
276
 
277
- const itemScope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };
278
- itemScope[itemName] = itemSignal;
279
- if (indexName) itemScope[indexName] = indexSignal;
277
+ const itemScope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}));
278
+ Object.defineProperty(itemScope, itemName, { value: itemSignal, writable: true, enumerable: true, configurable: true });
279
+ if (indexName) Object.defineProperty(itemScope, indexName, { value: indexSignal, writable: true, enumerable: true, configurable: true });
280
280
 
281
281
  const elements = [];
282
282
  if (isTemplate) {
@@ -398,7 +398,7 @@ catch (e) {
398
398
  var rootInScope = true;
399
399
  var rootVal;
400
400
  try {
401
- var diagMerged = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };
401
+ var diagMerged = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}));
402
402
  var firstIdent = listExpr.match(/^[A-Za-z_$][\\w$]*/);
403
403
  rootName = firstIdent ? firstIdent[0] : '?';
404
404
  rootInScope = Object.prototype.hasOwnProperty.call(diagMerged, rootName);
@@ -50,7 +50,7 @@ export const SIGNALS_HANDLER_RUNTIME = ` function expressionUsesSignalApi(expre
50
50
  }
51
51
  // First try component-level scope
52
52
  const elementScope = findElementScope(el || currentElement);
53
- const scope = { ...globalHelpers, ...componentScope, ...(elementScope || {}) };
53
+ const scope = mergeTemplateScopes(globalHelpers, componentScope, (elementScope || {}));
54
54
 
55
55
  // Check for shorthand syntax (Feature #8)
56
56
  const shorthandFn = parseEventShorthand(expr, scope);
@@ -162,7 +162,7 @@ export const SIGNALS_HYDRATION_AUDIT_RUNTIME = ` // ===========================
162
162
  s.el.__stx_audit_recovered = true;
163
163
  try {
164
164
  var vars = s.registered ? window.stx._scopes[s.id] : null;
165
- if (vars) Object.assign(componentScope, vars);
165
+ if (vars) assignTemplateScope(componentScope, vars);
166
166
  s.el.__stx_disposers = trackEffects(function() { processElement(s.el, componentScope); });
167
167
  s.el.removeAttribute('x-cloak');
168
168
  s.el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
@@ -30,7 +30,7 @@ export const SIGNALS_HYDRATION_RUNTIME = ` // Hydrate a subtree inserted AFTER
30
30
  el.__stx_parent_scope = el.__stx_parent_scope
31
31
  || resolveComponentCallerScope(el, componentScope);
32
32
  bindParentComponentProps(el, el.__stx_parent_scope);
33
- Object.assign(componentScope, scopeVars);
33
+ assignTemplateScope(componentScope, scopeVars);
34
34
  el.__stx_disposers = trackEffects(function() { processElement(el, componentScope); });
35
35
  if (scopeVars.__mountCallbacks && !scopeVars.__mounted) {
36
36
  scopeVars.__mounted = true;
@@ -12,7 +12,7 @@ export const SIGNALS_IF_CHAIN_RUNTIME = ` // Reactive if/else-if/else chain. A
12
12
  var parent = head.parentNode;
13
13
  if (!parent) { console.warn('[STX] bindIfChain: head element has no parent, skipping'); return; }
14
14
 
15
- var capturedComponentScope = { ...passedScope };
15
+ var capturedComponentScope = mergeTemplateScopes(passedScope);
16
16
 
17
17
  // Detach every branch up-front, leaving a positional placeholder comment
18
18
  // so reinsertion preserves source order. Mark each as a chain member so
@@ -79,7 +79,7 @@ export const SIGNALS_IF_CHAIN_RUNTIME = ` // Reactive if/else-if/else chain. A
79
79
  function evalBranch(b) {
80
80
  var expression = b.expr;
81
81
  if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;
82
- var scope = { ...globalHelpers, ...capturedComponentScope, ...(b.capturedElementScope || {}) };
82
+ var scope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (b.capturedElementScope || {}));
83
83
  try {
84
84
  var unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
85
85
  // Compiled over the names the expression mentions (see __stxCompileScoped).
@@ -243,7 +243,7 @@ catch (e) { /* a disposer of its own is not this branch's problem */ }
243
243
  // branch picked after render survive their row's removal (#1954).
244
244
  pick.el.__stx_chain_disposers = trackEffects(function () {
245
245
  peek(function () {
246
- var childScope = { ...globalHelpers, ...capturedComponentScope, ...(pick.capturedElementScope || {}) };
246
+ var childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (pick.capturedElementScope || {}));
247
247
  // Components compiled inside any branch of an if/else-if/else
248
248
  // chain carry scoped setup scripts with them. Branch nodes are
249
249
  // detached before those scripts can execute, so simply
@@ -42,7 +42,7 @@ export const SIGNALS_IF_RUNTIME = ` const detachedBranches = new Set();
42
42
  // Capture BOTH element scope AND passedScope NOW before anything changes
43
43
  // passedScope may contain @for iteration variables or parent component signals
44
44
  const capturedElementScope = findElementScope(el);
45
- const capturedComponentScope = { ...passedScope };
45
+ const capturedComponentScope = mergeTemplateScopes(passedScope);
46
46
 
47
47
  preserveConditionalComponentScopes(el, capturedComponentScope);
48
48
  stxHost.insert(parent, placeholder, el);
@@ -72,7 +72,7 @@ export const SIGNALS_IF_RUNTIME = ` const detachedBranches = new Set();
72
72
  return expression;
73
73
  }
74
74
  try {
75
- const scope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
75
+ const scope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
76
76
  const unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
77
77
  const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
78
78
  return fn(...__stxArgs(fn, unwrapScope));
@@ -80,7 +80,7 @@ export const SIGNALS_IF_RUNTIME = ` const detachedBranches = new Set();
80
80
  catch (e1) {
81
81
  try {
82
82
  // Retry without the unwrap proxy so call-syntax (signal()) works.
83
- const scope2 = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
83
+ const scope2 = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
84
84
  const fn2 = __stxCompileScoped(scope2, [], 'return ' + expression + '');
85
85
  return fn2(...__stxArgs(fn2, scope2));
86
86
  }
@@ -98,7 +98,7 @@ catch (e2) {
98
98
  const processChildrenWithScope = () => {
99
99
  // Build the combined scope for children - no need to modify global componentScope
100
100
  // Just pass the scope explicitly to processElement
101
- const childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
101
+ const childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
102
102
 
103
103
 
104
104
  Array.from(el.childNodes).forEach(child => processElement(child, childScope));
@@ -112,7 +112,7 @@ catch (e2) {
112
112
  // inserted and left inert, so bindings such as :text and {{ expression }}
113
113
  // leaked into the rendered UI until the condition toggled.
114
114
  const processTemplateNodes = (nodes) => {
115
- const childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
115
+ const childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
116
116
  // Components compiled inside a <template :if> carry setup scripts in the
117
117
  // template content. Browser-cloned scripts are inert, so register their
118
118
  // scopes and forwarded props before walking the inserted branch. This is
@@ -131,7 +131,7 @@ catch (e2) {
131
131
 
132
132
  // Evaluate the :if expression \u2014 use direct signal read for simple refs,
133
133
  // falling back to evalExpr for complex expressions
134
- const fullScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
134
+ const fullScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
135
135
  const directSignal = fullScope[expr];
136
136
 
137
137
  effect(() => {
@@ -299,7 +299,7 @@ else if (!value && isInserted) {
299
299
  detachedBranches.add(resume);
300
300
  return;
301
301
  }
302
- var childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
302
+ var childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
303
303
  // A false single-element conditional is detached before the
304
304
  // DOMContentLoaded component-scope pass. When it becomes visible,
305
305
  // hydrate any component roots in the restored subtree first so
@@ -20,7 +20,7 @@ export const SIGNALS_LAZY_HYDRATION_RUNTIME = ` // Lazy hydration: defer proces
20
20
  var effectiveScope = scope;
21
21
  if (sid) {
22
22
  var reg = window.stx._scopes ? window.stx._scopes[sid] : null;
23
- if (reg) effectiveScope = Object.assign({}, scope || {}, reg);
23
+ if (reg) effectiveScope = mergeTemplateScopes(scope, reg);
24
24
  }
25
25
  // Walk children and process them with the (now scope-merged) context
26
26
  Array.from(el.children).forEach(function(child) { processElement(child, effectiveScope); });
@@ -67,7 +67,7 @@ export const SIGNALS_MANIFEST_HYDRATION_RUNTIME = ` /**
67
67
  finally { activeDestroySink = outerSink; }
68
68
  var localMountHooks = mountCallbacks.splice(mountStart);
69
69
  var localDestroyHooks = destroyCallbacks.splice(destroyStart);
70
- var scope = Object.assign({ $refs: {} }, values || {});
70
+ var scope = mergeTemplateScopes({ $refs: {} }, values);
71
71
  var disposeEffects = trackEffects(function() {
72
72
  processFromManifest(root, scope, manifest, resolvedNodes);
73
73
  });
@@ -4,7 +4,7 @@ export const SIGNALS_MODEL_RUNTIME = ` function bindModel(el, expr, passedScope
4
4
  const tag = el.tagName.toLowerCase();
5
5
  const type = el.type;
6
6
  const modifiers = attrName.split('.').slice(1);
7
- const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };
7
+ const capturedScope = mergeTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
8
8
  const coerceValue = (value) => {
9
9
  var next = value;
10
10
  if (modifiers.includes('trim') && typeof next === 'string') next = next.trim();
@@ -35,7 +35,7 @@ export const SIGNALS_MOUNT_RUNTIME = ` mountEl: function(selector, setupFn) {
35
35
  }
36
36
 
37
37
  var disposeEffects = trackEffects(function() {
38
- processElement(root, { ...componentScope, ...(scope || {}) });
38
+ processElement(root, mergeTemplateScopes(componentScope, (scope || {})));
39
39
  });
40
40
  root.__stx_disposers = disposeEffects;
41
41
 
@@ -202,12 +202,12 @@ else {
202
202
  // caller, not a replacement for its handlers/refs/prop signals.
203
203
  if (root.hasAttribute('data-stx-component-wrapper')) root.__stx_parent_scope = scope;
204
204
  else root.__stx_scope = scope;
205
- Object.assign(componentScope, scope); // Keep for backwards compat
205
+ assignTemplateScope(componentScope, scope); // Keep for backwards compat
206
206
  }
207
207
 
208
208
  // Walk DOM and bind directives, tracking effects for cleanup
209
209
  var disposeEffects = trackEffects(function() {
210
- processElement(root, { ...componentScope, ...(scope || {}) });
210
+ processElement(root, mergeTemplateScopes(componentScope, (scope || {})));
211
211
  });
212
212
  root.__stx_disposers = disposeEffects;
213
213
 
@@ -36,14 +36,14 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
36
36
  if (el.hasAttribute('x-data') || el.hasAttribute('data-stx-xdata') || el.__stx_scope) {
37
37
  var xdScope = el.__stx_scope || (findElementScope(el) || {});
38
38
  if (xdScope && Object.keys(xdScope).length > 0) {
39
- scope = { ...scope, ...xdScope };
39
+ scope = mergeTemplateScopes(scope, xdScope);
40
40
  }
41
41
  }
42
42
  // v-memo / @memo \u2014 skip re-processing if dependency values haven't changed
43
43
  if (el.hasAttribute('data-stx-memo')) {
44
44
  var memoExpr = el.getAttribute('data-stx-memo');
45
45
  try {
46
- var memoScope = { ...globalHelpers, ...scope, ...(findElementScope(el) || {}) };
46
+ var memoScope = mergeTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
47
47
  var memoFn = __stxCompileScoped(memoScope, [], 'return ' + memoExpr);
48
48
  var memoVals = JSON.stringify(memoFn(...__stxArgs(memoFn, memoScope)));
49
49
  if (el.__stx_memo_prev === memoVals) {
@@ -73,7 +73,7 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
73
73
  // Capture scope NOW before effects run asynchronously
74
74
  // Use the passed scope parameter (not global componentScope) to preserve context
75
75
  // through nested @if/@for processing where componentScope may be restored
76
- const capturedScope = { ...globalHelpers, ...scope, ...(findElementScope(parentEl) || {}) };
76
+ const capturedScope = mergeTemplateScopes(globalHelpers, scope, (findElementScope(parentEl) || {}));
77
77
  parts.forEach(part => {
78
78
  const match = part.match(/^\\{\\{\\s*([\\s\\S]+?)\\s*\\}\\}$/);
79
79
  if (match) {
@@ -203,7 +203,7 @@ else if (part) {
203
203
 
204
204
  // Capture scope once for all attribute bindings on this element
205
205
  // Use the passed scope parameter to preserve context through nested processing
206
- const attrCapturedScope = { ...globalHelpers, ...scope, ...(findElementScope(el) || {}) };
206
+ const attrCapturedScope = mergeTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
207
207
 
208
208
  // Keep the conditional owners captured while the element is in the tree.
209
209
  // Walking parents on each update loses an outer owner when an inner :if
@@ -560,8 +560,8 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
560
560
  // Capture scope at setup time so @for loop variables are available when event fires
561
561
  const isForwardedComponentEvent = !!(el.__stx_parent_scope && parentEventNames.includes(eventName));
562
562
  let eventCapturedScope = isForwardedComponentEvent
563
- ? { ...globalHelpers, ...el.__stx_parent_scope }
564
- : { ...globalHelpers, ...scope, ...(findElementScope(el) || {}) };
563
+ ? mergeTemplateScopes(globalHelpers, el.__stx_parent_scope)
564
+ : mergeTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
565
565
 
566
566
  stxHost.listen(el, eventName, (event) => {
567
567
  // A forwarded handler belongs to the caller, whose scope can be
@@ -570,7 +570,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
570
570
  // page's scope and only later handed its real caller, so
571
571
  // @pick="pickFromBank" found nothing and did nothing. Read it now.
572
572
  if (isForwardedComponentEvent && el.__stx_parent_scope)
573
- eventCapturedScope = { ...globalHelpers, ...el.__stx_parent_scope };
573
+ eventCapturedScope = mergeTemplateScopes(globalHelpers, el.__stx_parent_scope);
574
574
  // Vue-style component listeners fall through to the rendered native
575
575
  // root unless the child emits the same event. Signal components use
576
576
  // a scope wrapper, so native events arrive here from a descendant.
@@ -2,7 +2,7 @@ export const SIGNALS_SHOW_RUNTIME = ` function bindShow(el, expr, passedScope =
2
2
  if (el.__stx_show_bound) return;
3
3
  el.__stx_show_bound = true;
4
4
 
5
- const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };
5
+ const capturedScope = mergeTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
6
6
 
7
7
  // Check if the expression is a simple signal reference (most common case for :show)
8
8
  const directSignal = capturedScope[expr];
@@ -32,7 +32,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
32
32
  usedLatestSetup = true;
33
33
  if (typeof setupResult === 'object' && setupResult !== null) {
34
34
  console.log('[stx:load] _latestSetup keys:', Object.keys(setupResult).slice(0, 10));
35
- Object.assign(componentScope, setupResult);
35
+ assignTemplateScope(componentScope, setupResult);
36
36
  }
37
37
  } catch (e) {
38
38
  console.error('[stx:load] _latestSetup error:', e);
@@ -48,11 +48,11 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
48
48
  var setupName = el.getAttribute('data-stx');
49
49
  if (setupName && window[setupName]) {
50
50
  var result = window[setupName]();
51
- if (typeof result === 'object') Object.assign(componentScope, result);
51
+ if (typeof result === 'object') assignTemplateScope(componentScope, result);
52
52
  }
53
53
  });
54
54
  }
55
- var spaPageScopeSnapshot = { ...componentScope };
55
+ var spaPageScopeSnapshot = mergeTemplateScopes(componentScope);
56
56
 
57
57
  // Routed component mount scripts execute after DOMContentLoaded. Queue them
58
58
  // until the destination page setup is active so projected props and parent
@@ -123,7 +123,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
123
123
  // the two share take the component's value for the page. The offline
124
124
  // banner's connected flag read as a Settings card's "Connected".
125
125
  if (el.__stx_disposers) return;
126
- Object.assign(componentScope, scopeVars);
126
+ assignTemplateScope(componentScope, scopeVars);
127
127
  var disposeEffects = trackEffects(function() { processElement(el, componentScope); });
128
128
  el.__stx_disposers = disposeEffects;
129
129
  // A replacement layout's scope can live outside the router container.
@@ -142,7 +142,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
142
142
  // full load binds the page before any component, so it never saw this.
143
143
  // A component's own bindings resolve its locals through its scope element,
144
144
  // and a name only a component declares stays reachable as before.
145
- Object.assign(componentScope, spaPageScopeSnapshot);
145
+ assignTemplateScope(componentScope, spaPageScopeSnapshot);
146
146
 
147
147
  // Process the container content \u2014 bind {{ }}, :attr, @event directives.
148
148
  // Run synchronously (not in setTimeout) so componentScope is captured correctly.
@@ -1,6 +1,6 @@
1
1
  export const SIGNALS_STYLE_RUNTIME = ` function bindStyle(el, expr, passedScope = componentScope, isVisible) {
2
2
  // Capture scope at setup time - use passed scope to preserve context
3
- const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };
3
+ const capturedScope = mergeTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
4
4
 
5
5
  const evalExpr = () => {
6
6
  // Mirror bindClass: first try the auto-unwrap proxy (so an expression
@@ -0,0 +1,6 @@
1
+ export declare function extractExports(setupContent: string, mutableOnly?: boolean): string;
2
+ /** Mutable lexical bindings stay live after setup, including onMount assignments. */
3
+ export declare function scopePropertyDescriptor(name: string): string;
4
+ export declare function scopeProperties(source: string, names?: unknown): string;
5
+ /** A bundle's public namespace retains its module's live export descriptors. */
6
+ export declare function scopeObject(source: string, names?: string[]): string;
@@ -0,0 +1,98 @@
1
+ import { stripCommentsAndLiterals } from "./strip-literals.js";
2
+ export function extractExports(setupContent, mutableOnly = !1) {
3
+ const code = stripCommentsAndLiterals(setupContent), names = [], seen = new Set;
4
+ let depth = 0, i = 0;
5
+ const len = code.length, checkDeclaration = () => {
6
+ if (depth !== 0)
7
+ return;
8
+ const declMatch = code.slice(i).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);
9
+ if (declMatch) {
10
+ if (mutableOnly && declMatch[1] === "const")
11
+ return;
12
+ const varName = declMatch[2];
13
+ if (!seen.has(varName)) {
14
+ names.push(varName);
15
+ seen.add(varName);
16
+ }
17
+ return;
18
+ }
19
+ const destructMatch = code.slice(i).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);
20
+ if (destructMatch) {
21
+ if (mutableOnly && code.slice(i).startsWith("const"))
22
+ return;
23
+ destructMatch[1].split(",").forEach((s) => {
24
+ const trimmed = s.trim();
25
+ if (!trimmed)
26
+ return;
27
+ const colonIdx = trimmed.indexOf(":"), name = (colonIdx >= 0 ? trimmed.slice(colonIdx + 1).trim() : trimmed).split(/[\s=]/)[0];
28
+ if (name && !seen.has(name)) {
29
+ names.push(name);
30
+ seen.add(name);
31
+ }
32
+ });
33
+ return;
34
+ }
35
+ const arrayDestructMatch = code.slice(i).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);
36
+ if (arrayDestructMatch) {
37
+ if (mutableOnly && code.slice(i).startsWith("const"))
38
+ return;
39
+ arrayDestructMatch[1].split(",").forEach((s) => {
40
+ const trimmed = s.trim().replace(/^\.\.\./, "");
41
+ if (!trimmed)
42
+ return;
43
+ const name = trimmed.split(/[\s=]/)[0];
44
+ if (name && !seen.has(name)) {
45
+ names.push(name);
46
+ seen.add(name);
47
+ }
48
+ });
49
+ return;
50
+ }
51
+ if (mutableOnly)
52
+ return;
53
+ const funcMatch = code.slice(i).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
54
+ if (funcMatch) {
55
+ const funcName = funcMatch[1];
56
+ if (!seen.has(funcName)) {
57
+ names.push(funcName);
58
+ seen.add(funcName);
59
+ }
60
+ return;
61
+ }
62
+ const asyncMatch = code.slice(i).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
63
+ if (asyncMatch) {
64
+ const funcName = asyncMatch[1];
65
+ if (!seen.has(funcName)) {
66
+ names.push(funcName);
67
+ seen.add(funcName);
68
+ }
69
+ }
70
+ };
71
+ while (i < len) {
72
+ if (code[i] === "{") {
73
+ depth++;
74
+ i++;
75
+ continue;
76
+ }
77
+ if (code[i] === "}") {
78
+ depth--;
79
+ i++;
80
+ continue;
81
+ }
82
+ if (depth === 0 && /[a-z]/i.test(code[i]) && (i === 0 || /\s|[;{}()]/.test(code[i - 1])))
83
+ checkDeclaration();
84
+ i++;
85
+ }
86
+ return names.join(", ");
87
+ }
88
+ export function scopePropertyDescriptor(name) {
89
+ return `{ enumerable: true, configurable: true, get() { return ${name} }, set(__stxValue_${name}) { ${name} = __stxValue_${name} } }`;
90
+ }
91
+ export function scopeProperties(source, names = extractExports(source).split(",").map((name) => name.trim()).filter(Boolean)) {
92
+ const mutable = new Set(extractExports(source, !0).split(",").map((name) => name.trim()));
93
+ return names.map((name) => mutable.has(name) ? `get ${name}() { return ${name} }, set ${name}(__stxValue_${name}) { ${name} = __stxValue_${name} }` : name).join(", ");
94
+ }
95
+ export function scopeObject(source, names) {
96
+ const object = `{ ${scopeProperties(source, names)} }`;
97
+ return extractExports(source).split(",").some((name) => name.trim() === "__stxLiveBindings") ? `Object.defineProperties(${object}, Object.getOwnPropertyDescriptors(__stxLiveBindings))` : object;
98
+ }
@@ -1,3 +1,4 @@
1
+ import { extractExports as scopeExports } from "./client-scope-bindings.js";
1
2
  import path from "node:path";
2
3
  import fs from "node:fs";
3
4
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -9,7 +10,7 @@ import { config, loadStxConfig } from "./config.js";
9
10
  import { isServerApiSource } from "./server-api.js";
10
11
  import { depsUnchanged, renderMemo, snapshotDeps } from "./render-memo.js";
11
12
  import { bracketDepths, stripCommentsAndLiterals } from "./strip-literals.js";
12
- const BUNDLE_CACHE_VERSION = 10;
13
+ const BUNDLE_CACHE_VERSION = 11;
13
14
  function isPrivateClientSource(file, root, serverApi) {
14
15
  return /^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(path.basename(file)) || isServerApiSource(file, root, serverApi);
15
16
  }
@@ -516,7 +517,7 @@ export { ${[...declNames].join(", ")} }` : "";
516
517
  try {
517
518
  bundled = new Bun.Transpiler({ loader: "js", minifyWhitespace: !0 }).transformSync(bundled);
518
519
  } catch {}
519
- const namespace = `__stxBundle_${hash}`, returnedBindings = exposedBindings.map(([publicName, localName]) => `${JSON.stringify(publicName)}: ${localName}`).join(", "), publicDeclarations = exposedBindings.map(([publicName]) => `var ${publicName} = undefined;`).join(`
520
+ const namespace = `__stxBundle_${hash}`, mutableBindings = new Set(scopeExports(code, !0).split(",").map((name) => name.trim())), returnedBindings = exposedBindings.map(([publicName, localName]) => `get ${JSON.stringify(publicName)}() { return ${localName} }${mutableBindings.has(publicName) ? `, set ${JSON.stringify(publicName)}(__stxValue_${localName}) { ${localName} = __stxValue_${localName} }` : ""}`).join(", "), publicDeclarations = exposedBindings.map(([publicName]) => `var ${publicName} = undefined;`).join(`
520
521
  `), publicAssignments = exposedBindings.map(([publicName]) => `${publicName} = ${namespace}[${JSON.stringify(publicName)}];`).join(`
521
522
  `);
522
523
  bundled = `${externalImports.join(`
@@ -528,7 +529,12 @@ ${registryReads.join(`
528
529
  ${bundled}
529
530
  return { ${returnedBindings} };
530
531
  })();
531
- ${publicAssignments}`.trim();
532
+ ${publicAssignments}
533
+ var __stxLiveBindings = typeof __stxLiveBindings === 'undefined' ? {} : __stxLiveBindings;
534
+ Object.keys(${namespace}).forEach(function(name) {
535
+ if (!Object.prototype.hasOwnProperty.call(__stxLiveBindings, name))
536
+ Object.defineProperty(__stxLiveBindings, name, Object.getOwnPropertyDescriptor(${namespace}, name));
537
+ });`.trim();
532
538
  logBundlerDiagnostic("bundled:", hash, "output:", bundled.length, "bytes");
533
539
  if (declNames.size > 0 && exposedBindings.length === 0) {
534
540
  console.warn(`[stx:bundler] dropped every binding for ${path.basename(filePath)} (${hash}); serving the unbundled source and not caching this result`);
@@ -3,6 +3,7 @@ import fs from "node:fs";
3
3
  import { asInvocableStatement, listensPassively } from "./events.js";
4
4
  import { transformStoreImports } from "./store-imports.js";
5
5
  import { declaresClientIdentifier } from "./client-declarations.js";
6
+ import { scopeObject } from "./client-scope-bindings.js";
6
7
  import { declaredNames, parameterAnalysis, unboundNames } from "./client-parameter-bindings.js";
7
8
  import { findInterpolationEnd, stripCommentsAndLiterals } from "./strip-literals.js";
8
9
  export { findInterpolationEnd, stripCommentsAndLiterals } from "./strip-literals.js";
@@ -848,7 +849,7 @@ ${eventCode}`)}
848
849
  const usesSignals = usesReactiveRuntime(scriptContent), isSfcWrapped = /function __stx_setup_/.test(code), alreadyMounts = /\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(scriptContent);
849
850
  function wrapInMount(declarations) {
850
851
  const returnStmt = declarations.length > 0 ? `
851
- return { ${declarations.join(", ")} };` : "", failureMessage = JSON.stringify(`[stx] client block failed${options.filePath ? ` (${options.filePath})` : ""}; this block will not hydrate`);
852
+ return ${scopeObject(code, declarations)};` : "", failureMessage = JSON.stringify(`[stx] client block failed${options.filePath ? ` (${options.filePath})` : ""}; this block will not hydrate`);
852
853
  return `${vendorStyleTags}<script data-stx-scoped data-stx-run="always"${instance}>
853
854
  window.stx.mount(function() {
854
855
  'use strict';
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{as,Jo,Yo}from"./chunk-3dth76ce.js";import"./chunk-1gtrs8va.js";import"./chunk-10s16tad.js";import"./chunk-sxpnpvt5.js";import"./chunk-dvbgbd06.js";import"./chunk-66e4ga0z.js";import"./chunk-8jgrakqd.js";import"./chunk-x6pz1h3x.js";import"./chunk-khzyc41k.js";import"./chunk-gc1dzxee.js";import"./chunk-aktzv0x2.js";import"./chunk-jp6yn9mj.js";import"./chunk-z4te6223.js";import"./chunk-jsw5yby0.js";import{zu,Vo,Hu,Vu,Uo,is,Wo,Uu,qo,Wu,qu,Go,Ko,Xo}from"./chunk-3ap1vsh3.js";import"./chunk-6j4f8dwx.js";import"./chunk-n5xbv1a9.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{cs,Yo,Zo}from"./chunk-88d5s6v3.js";import"./chunk-9b4e815s.js";import"./chunk-2wvz3fd2.js";import"./chunk-d1ya7f79.js";import"./chunk-rns21kkv.js";import"./chunk-4fv3jq16.js";import"./chunk-b5cv9xp7.js";import"./chunk-evs5gb3q.js";import"./chunk-7ky2ny63.js";import"./chunk-3p2b88pd.js";import"./chunk-70npkeh2.js";import"./chunk-1ma56c2h.js";import"./chunk-nz6bzffm.js";import"./chunk-aqra0qcg.js";import{zu,Uo,Hu,Vu,Wo,as,qo,Uu,Go,Wu,qu,Ko,Xo,Jo}from"./chunk-27h1xs4k.js";import"./chunk-cbj2hmx5.js";import"./chunk-62kxavc5.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{zu as CRAFT_BRIDGE_SCRIPT,is as CRAFT_COMPONENTS,Uu as CRAFT_COMPONENT_RUNTIME,Wo as CRAFT_COMPONENT_STYLES,as as NATIVE_COMPONENTS,Go as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Jo as compileToNative,Yo as createHotReloadServer,Vo as generateCraftBridgeScript,V as generateCraftOptimizations,Xo as getAvailableFormats,Ko as getAvailableTargets,qu as getCraftComponents,G as getSSRCacheStats,Uo as injectCraftBridge,Hu as isCraftEnvironment,Y as prerenderForCraft,qo as processCraftComponents,Vu as processCraftDirective,Wu as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{zu as CRAFT_BRIDGE_SCRIPT,as as CRAFT_COMPONENTS,Uu as CRAFT_COMPONENT_RUNTIME,qo as CRAFT_COMPONENT_STYLES,cs as NATIVE_COMPONENTS,Ko as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Yo as compileToNative,Zo as createHotReloadServer,Uo as generateCraftBridgeScript,V as generateCraftOptimizations,Jo as getAvailableFormats,Xo as getAvailableTargets,qu as getCraftComponents,G as getSSRCacheStats,Wo as injectCraftBridge,Hu as isCraftEnvironment,Y as prerenderForCraft,Go as processCraftComponents,Vu as processCraftDirective,Wu as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{as,Jo,Yo}from"./chunk-3dth76ce.js";import"./chunk-1gtrs8va.js";import"./chunk-10s16tad.js";import"./chunk-sxpnpvt5.js";import"./chunk-dvbgbd06.js";import"./chunk-66e4ga0z.js";import"./chunk-8jgrakqd.js";import"./chunk-x6pz1h3x.js";import"./chunk-khzyc41k.js";import"./chunk-gc1dzxee.js";import"./chunk-aktzv0x2.js";import"./chunk-jp6yn9mj.js";import"./chunk-z4te6223.js";import"./chunk-jsw5yby0.js";import{zu,Vo,Hu,Vu,Uo,is,Wo,Uu,qo,Wu,qu,Go,Ko,Xo}from"./chunk-3ap1vsh3.js";import"./chunk-6j4f8dwx.js";import"./chunk-n5xbv1a9.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{cs,Yo,Zo}from"./chunk-88d5s6v3.js";import"./chunk-9b4e815s.js";import"./chunk-2wvz3fd2.js";import"./chunk-d1ya7f79.js";import"./chunk-rns21kkv.js";import"./chunk-4fv3jq16.js";import"./chunk-b5cv9xp7.js";import"./chunk-evs5gb3q.js";import"./chunk-7ky2ny63.js";import"./chunk-3p2b88pd.js";import"./chunk-70npkeh2.js";import"./chunk-1ma56c2h.js";import"./chunk-nz6bzffm.js";import"./chunk-aqra0qcg.js";import{zu,Uo,Hu,Vu,Wo,as,qo,Uu,Go,Wu,qu,Ko,Xo,Jo}from"./chunk-27h1xs4k.js";import"./chunk-cbj2hmx5.js";import"./chunk-62kxavc5.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{zu as CRAFT_BRIDGE_SCRIPT,is as CRAFT_COMPONENTS,Uu as CRAFT_COMPONENT_RUNTIME,Wo as CRAFT_COMPONENT_STYLES,as as NATIVE_COMPONENTS,Go as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Jo as compileToNative,Yo as createHotReloadServer,Vo as generateCraftBridgeScript,V as generateCraftOptimizations,Xo as getAvailableFormats,Ko as getAvailableTargets,qu as getCraftComponents,G as getSSRCacheStats,Uo as injectCraftBridge,Hu as isCraftEnvironment,Y as prerenderForCraft,qo as processCraftComponents,Vu as processCraftDirective,Wu as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{zu as CRAFT_BRIDGE_SCRIPT,as as CRAFT_COMPONENTS,Uu as CRAFT_COMPONENT_RUNTIME,qo as CRAFT_COMPONENT_STYLES,cs as NATIVE_COMPONENTS,Ko as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Yo as compileToNative,Zo as createHotReloadServer,Uo as generateCraftBridgeScript,V as generateCraftOptimizations,Jo as getAvailableFormats,Xo as getAvailableTargets,qu as getCraftComponents,G as getSSRCacheStats,Wo as injectCraftBridge,Hu as isCraftEnvironment,Y as prerenderForCraft,Go as processCraftComponents,Vu as processCraftDirective,Wu as registerCraftComponent,Q as renderSSR};