@stacksjs/stx 0.2.582 → 0.2.584

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 (261) hide show
  1. package/dist/{chunk-qazn64pm.js → chunk-03qf2z4d.js} +1 -1
  2. package/dist/{chunk-yk3fbzx5.js → chunk-07869zev.js} +4 -4
  3. package/dist/chunk-08g5j4fq.js +2 -0
  4. package/dist/chunk-0hpw65yr.js +2 -0
  5. package/dist/chunk-11jmasqb.js +2 -0
  6. package/dist/chunk-2c7ysn9s.js +2 -0
  7. package/dist/chunk-2wb1w0p6.js +2 -0
  8. package/dist/chunk-2wx2aczp.js +2 -0
  9. package/dist/chunk-325dn55d.js +4 -0
  10. package/dist/chunk-34kxj258.js +2 -0
  11. package/dist/{chunk-ktyctev3.js → chunk-3y5tzxm6.js} +2 -2
  12. package/dist/{chunk-h0a2s340.js → chunk-49xtxzr8.js} +2 -2
  13. package/dist/chunk-4efqcpg5.js +2 -0
  14. package/dist/{chunk-5kh5ehfh.js → chunk-4h58as2c.js} +2 -2
  15. package/dist/chunk-4k6h00kk.js +2 -0
  16. package/dist/{chunk-y8q1n7hx.js → chunk-4myvw20e.js} +10 -10
  17. package/dist/chunk-4szz2esp.js +2 -0
  18. package/dist/chunk-4wkghwag.js +2 -0
  19. package/dist/chunk-53grq69s.js +2 -0
  20. package/dist/chunk-55n8mhq4.js +2 -0
  21. package/dist/chunk-5s229r1e.js +2 -0
  22. package/dist/chunk-5zg3xj45.js +18 -0
  23. package/dist/{chunk-hzfhn2vr.js → chunk-67m2prah.js} +2 -2
  24. package/dist/chunk-6djvj6hg.js +2 -0
  25. package/dist/chunk-6ebj7gfr.js +2 -0
  26. package/dist/{chunk-g4crr86j.js → chunk-6hgngmn0.js} +3 -3
  27. package/dist/chunk-71tnfe1n.js +2 -0
  28. package/dist/{chunk-101ekf6y.js → chunk-794v5crp.js} +2 -2
  29. package/dist/chunk-7dkwf9h5.js +2 -0
  30. package/dist/{chunk-cnknvvwm.js → chunk-7fghm9zy.js} +1 -1
  31. package/dist/{chunk-ayy9mmrw.js → chunk-7ra30crf.js} +7 -7
  32. package/dist/{chunk-117xss52.js → chunk-7xw1e8t6.js} +2 -2
  33. package/dist/{chunk-c0s3k64c.js → chunk-7ydavm3h.js} +2 -2
  34. package/dist/{chunk-qdyp2zqf.js → chunk-82bttwqm.js} +2 -2
  35. package/dist/chunk-8992smwz.js +2 -0
  36. package/dist/{chunk-0vnngvy1.js → chunk-8s7zbhdd.js} +4 -4
  37. package/dist/chunk-8zn83jfs.js +2 -0
  38. package/dist/{chunk-zz02hwec.js → chunk-96zgn94z.js} +26 -26
  39. package/dist/{chunk-43h8q2cm.js → chunk-9cpxzze0.js} +9 -9
  40. package/dist/{chunk-vx75fb0d.js → chunk-9e091vkf.js} +3 -3
  41. package/dist/chunk-9pk5jhqa.js +3 -0
  42. package/dist/{chunk-dvgvvy5b.js → chunk-9r5w6s80.js} +3 -3
  43. package/dist/{chunk-c0h2eqe0.js → chunk-a8n6mt7s.js} +2 -2
  44. package/dist/{chunk-djft0m5h.js → chunk-agy4mxn8.js} +2 -2
  45. package/dist/{chunk-ev5f79mg.js → chunk-axz1x4r9.js} +5 -5
  46. package/dist/{chunk-6w2yqtrd.js → chunk-b5van393.js} +2 -2
  47. package/dist/{chunk-w3rmepwy.js → chunk-bfbmdjh4.js} +2 -2
  48. package/dist/chunk-bqtph83n.js +2 -0
  49. package/dist/chunk-bs1bdhvp.js +2 -0
  50. package/dist/{chunk-0k5faspy.js → chunk-bsy10tz6.js} +6 -6
  51. package/dist/chunk-c1c4sh7t.js +2 -0
  52. package/dist/{chunk-zk2xk0wd.js → chunk-c6egfhy6.js} +2 -2
  53. package/dist/chunk-ce2d0hz9.js +2 -0
  54. package/dist/chunk-cjq9k1xb.js +2 -0
  55. package/dist/{chunk-k9th7hc4.js → chunk-d2jb1rkp.js} +5 -5
  56. package/dist/{chunk-yfq2v7x5.js → chunk-d4awfk42.js} +7 -7
  57. package/dist/chunk-d9vjsqs4.js +2 -0
  58. package/dist/{chunk-8v19753h.js → chunk-e26pzdxy.js} +1 -1
  59. package/dist/{chunk-nrfh7gaa.js → chunk-e556dvy4.js} +3 -3
  60. package/dist/{chunk-3qrrv6af.js → chunk-e6h7pzym.js} +1 -1
  61. package/dist/{chunk-cb2pyg5t.js → chunk-ebfpjnf3.js} +2 -2
  62. package/dist/chunk-ede39b7h.js +3 -0
  63. package/dist/chunk-f0fxyh3e.js +2 -0
  64. package/dist/{chunk-4srg0qbv.js → chunk-f29fk7dw.js} +2 -2
  65. package/dist/chunk-fjyhc41r.js +2 -0
  66. package/dist/{chunk-1v1mew46.js → chunk-fkq55rh7.js} +1 -1
  67. package/dist/chunk-fn4wwgnc.js +2 -0
  68. package/dist/{chunk-t8wpzqs4.js → chunk-g8mxprxj.js} +1 -1
  69. package/dist/chunk-h2534p6q.js +2 -0
  70. package/dist/{chunk-9jh2ake5.js → chunk-h7atbtds.js} +5 -5
  71. package/dist/{chunk-yy3ser06.js → chunk-h988fxh3.js} +5 -5
  72. package/dist/chunk-hr34x6sx.js +2 -0
  73. package/dist/{chunk-ta3wn842.js → chunk-hsy9rhct.js} +2 -2
  74. package/dist/chunk-hygxh993.js +2 -0
  75. package/dist/{chunk-s12bnv32.js → chunk-hz11wmx9.js} +2 -2
  76. package/dist/{chunk-71sdgv7e.js → chunk-j7kcjgxy.js} +215 -56
  77. package/dist/chunk-j87tntna.js +2 -0
  78. package/dist/{chunk-tszkg6sj.js → chunk-jqbk6pfk.js} +2 -2
  79. package/dist/{chunk-be2ba3hj.js → chunk-k1szsenr.js} +2 -2
  80. package/dist/{chunk-3wy8q3aq.js → chunk-k3rnpjxf.js} +5 -5
  81. package/dist/{chunk-jtbzmbzz.js → chunk-k71e38fk.js} +4 -4
  82. package/dist/chunk-kgtnfvqb.js +2 -0
  83. package/dist/chunk-krwrx9x9.js +2 -0
  84. package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
  85. package/dist/{chunk-4rkvwm6v.js → chunk-m3w67x05.js} +9 -9
  86. package/dist/chunk-m5j8hht5.js +2 -0
  87. package/dist/chunk-mc8j6dwa.js +2 -0
  88. package/dist/{chunk-vpdx7qr3.js → chunk-mmbspaqh.js} +2 -2
  89. package/dist/{chunk-pmpb34md.js → chunk-n0t938d2.js} +7 -7
  90. package/dist/{chunk-c1r7zq0q.js → chunk-n2gy2arh.js} +89 -89
  91. package/dist/chunk-n2j3pn9s.js +2 -0
  92. package/dist/{chunk-sv5nvfmb.js → chunk-np6nm4rq.js} +2 -2
  93. package/dist/chunk-ns1jqzqk.js +2 -0
  94. package/dist/chunk-p973efbe.js +2 -0
  95. package/dist/{chunk-m8tm44rq.js → chunk-pg164sdw.js} +2 -2
  96. package/dist/{chunk-yhpyqsbr.js → chunk-pxw4edw8.js} +4 -4
  97. package/dist/{chunk-1r1maqep.js → chunk-q1cvef6b.js} +3 -3
  98. package/dist/chunk-q765v7b2.js +2 -0
  99. package/dist/{chunk-620szfcp.js → chunk-qebxzf9w.js} +3 -3
  100. package/dist/{chunk-jpqkm8tm.js → chunk-qf3axv86.js} +3 -3
  101. package/dist/{chunk-7hkc96de.js → chunk-qhr1tkhj.js} +7 -7
  102. package/dist/chunk-qq59xzwc.js +2 -0
  103. package/dist/chunk-r0e743c3.js +2 -0
  104. package/dist/{chunk-qccgncp2.js → chunk-rdm5mfc5.js} +6 -6
  105. package/dist/chunk-s043hpvd.js +2 -0
  106. package/dist/{chunk-rr8a7d4q.js → chunk-s1ptn02h.js} +3 -3
  107. package/dist/{chunk-xpnpg967.js → chunk-s5vxxwg6.js} +2 -2
  108. package/dist/chunk-sckze59r.js +2 -0
  109. package/dist/chunk-sjkdpsca.js +3 -0
  110. package/dist/chunk-sr1md7vv.js +2845 -0
  111. package/dist/chunk-t431anrx.js +2 -0
  112. package/dist/chunk-t7mxbt40.js +2 -0
  113. package/dist/{chunk-r47cs92n.js → chunk-tc15vkfh.js} +2 -2
  114. package/dist/{chunk-6z3e1tyz.js → chunk-tnafnb23.js} +1 -1
  115. package/dist/{chunk-ah9xyss2.js → chunk-v8ze2q95.js} +2 -2
  116. package/dist/{chunk-t4g2fptt.js → chunk-vf15db1j.js} +6 -6
  117. package/dist/chunk-vvqxbhfx.js +2 -0
  118. package/dist/{chunk-cdgwkzms.js → chunk-w24qmxc3.js} +3 -3
  119. package/dist/chunk-w7zgftez.js +2 -0
  120. package/dist/chunk-wfp36qf4.js +2 -0
  121. package/dist/chunk-wn2gzwmv.js +2 -0
  122. package/dist/{chunk-wwj8zbzc.js → chunk-wywprjc5.js} +5 -5
  123. package/dist/chunk-x5qymgxa.js +2 -0
  124. package/dist/chunk-xfe2nzxd.js +2 -0
  125. package/dist/chunk-xjwgzp6s.js +2 -0
  126. package/dist/chunk-xyepqdjy.js +2 -0
  127. package/dist/chunk-y5ryjdpv.js +122 -0
  128. package/dist/{chunk-3e3dpp7w.js → chunk-y5x8xnnf.js} +3 -3
  129. package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
  130. package/dist/chunk-yhqaafsw.js +2 -0
  131. package/dist/chunk-yn2d8x8m.js +3 -0
  132. package/dist/{chunk-kp0hg06s.js → chunk-z2mg470f.js} +4 -4
  133. package/dist/chunk-z7trbwn3.js +2 -0
  134. package/dist/{chunk-eww6sdzz.js → chunk-zgv1h2np.js} +2 -2
  135. package/dist/{chunk-bj29pwm0.js → chunk-zrw1zf54.js} +3 -3
  136. package/dist/chunk-zxf8f71v.js +2 -0
  137. package/dist/chunk-zxt75k06.js +2 -0
  138. package/dist/cli.js +46 -46
  139. package/dist/client/signals-authoring-runtime.js +13 -6
  140. package/dist/client/signals-binding-utils-runtime.js +14 -1
  141. package/dist/client/signals-component-api-runtime.js +3 -1
  142. package/dist/client/signals-event-shorthand-runtime.js +1 -1
  143. package/dist/client/signals-expression-runtime.js +1 -1
  144. package/dist/client/signals-host-runtime.js +72 -1
  145. package/dist/client/signals-manifest-hydration-runtime.js +20 -0
  146. package/dist/client/signals-model-runtime.js +2 -0
  147. package/dist/client/signals-mount-runtime.js +5 -1
  148. package/dist/client/signals-overlay-runtime.js +29 -6
  149. package/dist/client/signals-process-element-runtime.js +22 -7
  150. package/dist/client/signals-public-api-runtime.js +2 -0
  151. package/dist/client/signals-style-runtime.js +1 -1
  152. package/dist/component-model.d.ts +1 -1
  153. package/dist/component-model.js +6 -3
  154. package/dist/component-renderer.js +26 -6
  155. package/dist/composition-api.js +3 -2
  156. package/dist/craft-entry.js +2 -2
  157. package/dist/craft.js +2 -2
  158. package/dist/native/compiler/bundle.js +8 -3
  159. package/dist/native/compiler/design-tokens.d.ts +4 -0
  160. package/dist/native/compiler/design-tokens.js +28 -0
  161. package/dist/native/compiler/headwind-to-style.d.ts +5 -4
  162. package/dist/native/compiler/headwind-to-style.js +105 -65
  163. package/dist/native/compiler/html-to-ir.d.ts +5 -1
  164. package/dist/native/compiler/html-to-ir.js +75 -244
  165. package/dist/native/compiler/inline-style.d.ts +13 -0
  166. package/dist/native/compiler/inline-style.js +285 -0
  167. package/dist/native/compiler/ir.d.ts +5 -1
  168. package/dist/native/compiler/render-screen.js +3 -1
  169. package/dist/native/compiler/style-variables.d.ts +8 -0
  170. package/dist/native/compiler/style-variables.js +142 -0
  171. package/dist/native/compiler/stylesheet-theme.d.ts +6 -0
  172. package/dist/native/compiler/stylesheet-theme.js +110 -0
  173. package/dist/native/runtime/binding-tree.js +12 -0
  174. package/dist/native/runtime/craft-bridge.js +5 -2
  175. package/dist/native/runtime/jsc-globals.d.ts +10 -3
  176. package/dist/native/runtime/jsc-globals.js +23 -4
  177. package/dist/native/runtime/native-host.d.ts +17 -2
  178. package/dist/native/runtime/native-host.js +492 -39
  179. package/dist/native/runtime/overlay-presenter.d.ts +29 -0
  180. package/dist/native/runtime/overlay-presenter.js +69 -0
  181. package/dist/native/runtime/shared-screen.js +13 -1
  182. package/dist/native/runtime/view-operations.d.ts +20 -0
  183. package/dist/native/runtime/view-operations.js +35 -0
  184. package/dist/native/testing-mutations.d.ts +4 -0
  185. package/dist/native/testing-mutations.js +64 -0
  186. package/dist/native/testing.d.ts +2 -0
  187. package/dist/native/testing.js +19 -2
  188. package/dist/pwa.js +3 -3
  189. package/dist/ssg.js +8 -8
  190. package/dist/testing.js +2 -0
  191. package/dist/types/config-types.d.ts +2 -0
  192. package/dist/utils.d.ts +1 -1
  193. package/dist/utils.js +25 -5
  194. package/package.json +5 -5
  195. package/dist/chunk-0047meje.js +0 -2
  196. package/dist/chunk-00p22wzr.js +0 -3
  197. package/dist/chunk-1cat8kdj.js +0 -2
  198. package/dist/chunk-1dwnp35v.js +0 -2
  199. package/dist/chunk-2dnr5qfk.js +0 -2
  200. package/dist/chunk-2rx9d75e.js +0 -4
  201. package/dist/chunk-2v73cjbc.js +0 -2
  202. package/dist/chunk-30rf7k4n.js +0 -122
  203. package/dist/chunk-3akgppsy.js +0 -2
  204. package/dist/chunk-3x6p9me0.js +0 -2
  205. package/dist/chunk-4t67wmcg.js +0 -2
  206. package/dist/chunk-51zn42jy.js +0 -2
  207. package/dist/chunk-5702x95v.js +0 -2
  208. package/dist/chunk-5db5sxy3.js +0 -3
  209. package/dist/chunk-5pgbsc3a.js +0 -2
  210. package/dist/chunk-60c2bsh9.js +0 -2
  211. package/dist/chunk-79v4d9qh.js +0 -2
  212. package/dist/chunk-7pp2vx1g.js +0 -2
  213. package/dist/chunk-84f9dnq5.js +0 -2
  214. package/dist/chunk-8tq5x4z8.js +0 -2
  215. package/dist/chunk-8zm6tkqb.js +0 -2
  216. package/dist/chunk-a1z36dt5.js +0 -2
  217. package/dist/chunk-atsf1fe0.js +0 -2
  218. package/dist/chunk-b8qd6h1q.js +0 -2
  219. package/dist/chunk-ccxs40xy.js +0 -2
  220. package/dist/chunk-cg8hg6cs.js +0 -3
  221. package/dist/chunk-cp442y7a.js +0 -2
  222. package/dist/chunk-d4en5d3s.js +0 -2
  223. package/dist/chunk-dh80d57p.js +0 -2
  224. package/dist/chunk-dpn1pmxj.js +0 -2
  225. package/dist/chunk-dtcc09x1.js +0 -2
  226. package/dist/chunk-dyqte1xq.js +0 -2
  227. package/dist/chunk-e4n4v022.js +0 -2
  228. package/dist/chunk-efgk2xv1.js +0 -2
  229. package/dist/chunk-faghmmrs.js +0 -2838
  230. package/dist/chunk-fj70wq7k.js +0 -2
  231. package/dist/chunk-g2fw68zm.js +0 -2
  232. package/dist/chunk-hcgm37dy.js +0 -2
  233. package/dist/chunk-hd2bn5q7.js +0 -2
  234. package/dist/chunk-j1nqnmcd.js +0 -18
  235. package/dist/chunk-k7jqkt93.js +0 -2
  236. package/dist/chunk-mhjwtkx9.js +0 -2
  237. package/dist/chunk-mqy7g74k.js +0 -2
  238. package/dist/chunk-mxe21m6q.js +0 -2
  239. package/dist/chunk-ne03tfje.js +0 -2
  240. package/dist/chunk-p2sns0bn.js +0 -2
  241. package/dist/chunk-q2a58n2a.js +0 -2
  242. package/dist/chunk-s1sycp43.js +0 -2
  243. package/dist/chunk-s932zfjz.js +0 -2
  244. package/dist/chunk-sp46w7z9.js +0 -2
  245. package/dist/chunk-sy1bk1ry.js +0 -2
  246. package/dist/chunk-t48ws5j0.js +0 -2
  247. package/dist/chunk-thbc9gtj.js +0 -2
  248. package/dist/chunk-tn9v10q2.js +0 -2
  249. package/dist/chunk-tpd5nwa3.js +0 -2
  250. package/dist/chunk-tpt4bgs5.js +0 -2
  251. package/dist/chunk-v8p5p2kp.js +0 -2
  252. package/dist/chunk-v9jd283e.js +0 -2
  253. package/dist/chunk-vq0cb1m9.js +0 -2
  254. package/dist/chunk-wg2w7zmt.js +0 -3
  255. package/dist/chunk-wgkxgsqx.js +0 -2
  256. package/dist/chunk-y1bppxgw.js +0 -2
  257. package/dist/chunk-yv5rwthv.js +0 -2
  258. package/dist/chunk-yygze2s0.js +0 -2
  259. package/dist/chunk-z1r4tdqy.js +0 -2
  260. package/dist/chunk-z732tf98.js +0 -2
  261. package/dist/chunk-zv288w4e.js +0 -2
@@ -12,6 +12,14 @@ export const SIGNALS_HOST_RUNTIME = ` // \u2500\u2500 Host \u2500\u2500
12
12
  // branch swap, and nowhere near the line that caused it, which keeps the web path
13
13
  // exactly as it was: same calls, one property lookup earlier.
14
14
  var stxHost = window.__stx_host || {
15
+ parent: function(node) { return node ? node.parentElement : null; },
16
+ getAttribute: function(node, name) { return node && node.getAttribute ? node.getAttribute(name) : null; },
17
+ observeChildren: function(node, callback) {
18
+ var active = true;
19
+ var observer = new MutationObserver(function() { if (active) callback(); });
20
+ observer.observe(node, { childList: true, subtree: true });
21
+ return function() { active = false; observer.disconnect(); };
22
+ },
15
23
  setText: function(node, value) { node.textContent = value; },
16
24
  setMarkup: function(node, value) { node.innerHTML = value == null ? '' : value; },
17
25
  setAttribute: function(node, name, value) {
@@ -25,7 +33,55 @@ export const SIGNALS_HOST_RUNTIME = ` // \u2500\u2500 Host \u2500\u2500
25
33
  node.setAttribute(name, next);
26
34
  },
27
35
  removeAttribute: function(node, name) { node.removeAttribute(name); },
28
- setStyle: function(node, value) {
36
+ observeAttributes: function(node, names, callback) {
37
+ var observer = new MutationObserver(callback);
38
+ observer.observe(node, { attributes: true, attributeFilter: names });
39
+ return function() { observer.disconnect(); };
40
+ },
41
+ setStyle: function(node, value, replaceBinding) {
42
+ // A binding owns its current keys, not the element's entire inline style.
43
+ // Keep the original value and priority so removing a key restores them.
44
+ if (replaceBinding) {
45
+ var next = Object.create(null);
46
+ var priorities = Object.create(null);
47
+ if (typeof value === 'string') {
48
+ var parsed = document.createElement('div').style;
49
+ parsed.cssText = value;
50
+ for (var i = 0; i < parsed.length; i++) {
51
+ var property = parsed.item(i);
52
+ next[property] = parsed.getPropertyValue(property);
53
+ priorities[property] = parsed.getPropertyPriority(property);
54
+ }
55
+ }
56
+ else if (value && typeof value === 'object' && !Array.isArray(value)) {
57
+ Object.keys(value).forEach(function(key) {
58
+ if (value[key] == null || value[key] === '') return;
59
+ var name = key.indexOf('--') === 0 ? key : key.replace(/[A-Z]/g, function(c) { return '-' + c.toLowerCase(); });
60
+ next[name] = value[key];
61
+ });
62
+ }
63
+ var baseline = node.__stx_bound_style_baseline || (node.__stx_bound_style_baseline = Object.create(null));
64
+ Object.keys(baseline).forEach(function(name) {
65
+ if (Object.prototype.hasOwnProperty.call(next, name)) return;
66
+ var prior = baseline[name];
67
+ if (prior.value) node.style.setProperty(name, prior.value, prior.priority);
68
+ else node.style.removeProperty(name);
69
+ if (name === 'display') node.__stx_display = prior.value;
70
+ delete baseline[name];
71
+ });
72
+ Object.keys(next).forEach(function(name) {
73
+ if (!Object.prototype.hasOwnProperty.call(baseline, name)) {
74
+ baseline[name] = {
75
+ value: name === 'display' && node.__stx_visible === false ? node.__stx_display || '' : node.style.getPropertyValue(name),
76
+ priority: node.style.getPropertyPriority(name)
77
+ };
78
+ }
79
+ node.style.setProperty(name, next[name], priorities[name] || '');
80
+ if (name === 'display') node.__stx_display = next[name];
81
+ });
82
+ if (node.__stx_visible === false) node.style.display = 'none';
83
+ return;
84
+ }
29
85
  if (typeof value === 'object' && value !== null) {
30
86
  Object.assign(node.style, value);
31
87
  if (Object.prototype.hasOwnProperty.call(value, 'display')) node.__stx_display = value.display || '';
@@ -57,6 +113,21 @@ export const SIGNALS_HOST_RUNTIME = ` // \u2500\u2500 Host \u2500\u2500
57
113
  // parameter silently makes every touch listener blocking again, so it stays
58
114
  // in the signature and each host decides what to do with it.
59
115
  listen: function(node, event, handler, options) { node.addEventListener(event, handler, options); },
116
+ emitComponentEvent: function(node, event) { return node.dispatchEvent(event); },
117
+ onFormReset: function(node, callback) {
118
+ var active = true;
119
+ var document = node.ownerDocument;
120
+ var listener = function(event) {
121
+ if (event.target !== node.form) return;
122
+ // The reset event precedes the browser default action and may be
123
+ // canceled by a later listener. Synchronize models only afterward.
124
+ queueMicrotask(function() {
125
+ if (active && !event.defaultPrevented) callback();
126
+ });
127
+ };
128
+ document.addEventListener('reset', listener, true);
129
+ return function() { active = false; document.removeEventListener('reset', listener, true); };
130
+ },
60
131
 
61
132
  // Returns the PREVIOUS visibility. bindShow needs to know whether it just
62
133
  // revealed something, and asking the node afterwards is the one read-back
@@ -43,6 +43,11 @@ export const SIGNALS_MANIFEST_HYDRATION_RUNTIME = ` /**
43
43
  // that no longer exists in the host tree. Browser hydration keeps its
44
44
  // existing behaviour because it does not pass resolvedNodes here.
45
45
  if (resolvedNodes && node.__stxId !== undefined && node.isConnected === false) continue;
46
+ if (resolvedNodes && node.hasAttribute && node.hasAttribute('data-stx-scope')
47
+ && !hasPendingLoopBoundary(node)) {
48
+ node.__stx_parent_scope = resolveComponentCallerScope(node, scope);
49
+ bindParentComponentProps(node, node.__stx_parent_scope);
50
+ }
46
51
  processElement(node, scope, true);
47
52
  }
48
53
  return true;
@@ -66,12 +71,27 @@ export const SIGNALS_MANIFEST_HYDRATION_RUNTIME = ` /**
66
71
  var disposeEffects = trackEffects(function() {
67
72
  processFromManifest(root, scope, manifest, resolvedNodes);
68
73
  });
74
+ // The manifest visits bindings, not every component. Static component
75
+ // roots still own lifecycle hooks, and those hooks must see fully bound
76
+ // props/refs. Detached conditional and loop sources must not mount.
77
+ [root].concat(stxHost.descendants(root)).forEach(function(node) {
78
+ if (!node || node.isConnected === false || !node.getAttribute || hasPendingLoopBoundary(node)) return;
79
+ var scopeId = node.getAttribute('data-stx-scope');
80
+ var local = scopeId && window.stx._scopes && window.stx._scopes[scopeId];
81
+ if (!local || local.__mounted || local.__suspended) return;
82
+ if (node.hasAttribute('stx-hydrate') && !node.__stx_hydrated) return;
83
+ local.__el = node;
84
+ local.__mounted = true;
85
+ runMountCallbacks(local.__mountCallbacks || [], scopeDestroySink(local));
86
+ });
69
87
  runMountCallbacks(localMountHooks, localDestroyHooks);
70
88
  var mounted = true;
71
89
  return function disposeHost() {
72
90
  if (!mounted) return;
73
91
  mounted = false;
74
92
  disposeEffects();
93
+ disposeSubtreeEffects(root);
94
+ disposeSubtreeScopes(root);
75
95
  var hooks = localDestroyHooks.splice(0, localDestroyHooks.length);
76
96
  for (var i = 0; i < hooks.length; i++) {
77
97
  try { hooks[i](); }
@@ -58,6 +58,8 @@ catch (e) {
58
58
  }
59
59
  };
60
60
 
61
+ bindFormControlReset(el, 'model', getValue, setValue);
62
+
61
63
  if (tag === 'input' && type === 'checkbox') {
62
64
  var syncCheckbox = () => {
63
65
  var current = getValue();
@@ -197,7 +197,11 @@ else {
197
197
  if (typeof scope === 'object' && scope !== null) {
198
198
  scope.$el = root;
199
199
  scope.$refs = scope.$refs || {};
200
- root.__stx_scope = scope; // Store isolated scope on element
200
+ // An auto-mounted page can start with a shared component. That
201
+ // wrapper already owns a component scope: the page supplies its
202
+ // caller, not a replacement for its handlers/refs/prop signals.
203
+ if (root.hasAttribute('data-stx-component-wrapper')) root.__stx_parent_scope = scope;
204
+ else root.__stx_scope = scope;
201
205
  Object.assign(componentScope, scope); // Keep for backwards compat
202
206
  }
203
207
 
@@ -111,6 +111,19 @@ export const SIGNALS_OVERLAY_RUNTIME = ` // \u2500\u2500 Overlay stack \u2500\u
111
111
 
112
112
  // Lock, listen and inert to match the stack after any change.
113
113
  function _overlaySync() {
114
+ if (stxHost.isNative) {
115
+ stxHost.syncOverlays(_overlays.map(function(entry) {
116
+ return Object.assign({}, entry, { onRequestClose: function(event) {
117
+ if (entry.onRequestClose) { entry.onRequestClose(event); return; }
118
+ var reason = event && (event.reason || (event.nativeEvent && event.nativeEvent.reason));
119
+ if (reason === 'backdrop') { if (entry.onBackdrop) entry.onBackdrop(); }
120
+ else if (reason === 'back' || reason === 'escape') { if (entry.onEscape) entry.onEscape(); }
121
+ else if (!!entry.onBackdrop === !!entry.onEscape) { if (entry.onEscape) entry.onEscape(); }
122
+ else console.warn('[stx:overlays] Native dismissal was denied: this host must report reason=backdrop or reason=back to honor different closeOnBackdrop/closeOnEscape policies.');
123
+ } });
124
+ }));
125
+ return;
126
+ }
114
127
  for (var i = 0; i < _overlayInerted.length; i++) {
115
128
  try { _overlayInerted[i].inert = false; }
116
129
  catch (_e) { /* element may be gone */ }
@@ -259,10 +272,15 @@ export const SIGNALS_OVERLAY_RUNTIME = ` // \u2500\u2500 Overlay stack \u2500\u
259
272
  var at = _overlayIndex(id);
260
273
  if (at !== -1) {
261
274
  var existing = _overlays[at];
275
+ var updated = Object.assign({}, existing);
262
276
  for (var key in opts) {
263
- if (Object.prototype.hasOwnProperty.call(opts, key)) existing[key] = opts[key];
277
+ if (Object.prototype.hasOwnProperty.call(opts, key)) updated[key] = opts[key];
264
278
  }
265
- _overlaySync();
279
+ // A native presenter holds callbacks for the last accepted entry.
280
+ // Do not mutate it until the replacement has passed host validation.
281
+ _overlays[at] = updated;
282
+ try { _overlaySync(); }
283
+ catch (e) { _overlays[at] = existing; throw e; }
266
284
  return;
267
285
  }
268
286
  var isModal = opts.modal !== false;
@@ -273,18 +291,23 @@ export const SIGNALS_OVERLAY_RUNTIME = ` // \u2500\u2500 Overlay stack \u2500\u
273
291
  root: opts.root || null,
274
292
  zIndex: typeof opts.zIndex === 'number' ? opts.zIndex : null,
275
293
  onEscape: opts.onEscape || null,
294
+ onBackdrop: opts.onBackdrop || null,
276
295
  initialFocus: opts.initialFocus || null,
277
296
  // A popup hands focus back itself, to its own trigger, and only when
278
297
  // focus was inside it; a modal layer always does.
279
298
  restoreFocus: opts.restoreFocus !== undefined ? opts.restoreFocus !== false : isModal,
280
- opener: opts.opener !== undefined ? opts.opener : document.activeElement
299
+ opener: opts.opener !== undefined ? opts.opener : (stxHost.isNative ? null : document.activeElement),
300
+ // Native Modal reports backdrop/back dismissal through the same host
301
+ // event. Shared components supply the applicable dismissal policy.
302
+ onRequestClose: opts.onRequestClose || null
281
303
  };
282
304
  _overlays.push(entry);
283
- _overlaySync();
305
+ try { _overlaySync(); }
306
+ catch (e) { _overlays.splice(_overlays.indexOf(entry), 1); throw e; }
284
307
  // Synchronously first, so a caller that asserts focus straight after
285
308
  // opening sees it; then retried for a panel that is not displayed yet.
286
309
  // A popup keeps focus where its own keyboard handling puts it.
287
- if (isModal || opts.initialFocus) _overlayFocusIn(entry, 10);
310
+ if (!stxHost.isNative && (isModal || opts.initialFocus)) _overlayFocusIn(entry, 10);
288
311
  },
289
312
  /** Take an overlay off the stack, wherever it is in it. */
290
313
  close: function(id) {
@@ -296,7 +319,7 @@ export const SIGNALS_OVERLAY_RUNTIME = ` // \u2500\u2500 Overlay stack \u2500\u
296
319
  // Only the overlay that had the keyboard gives it back. Closing one
297
320
  // underneath (its owner went away) must not pull focus out of the top.
298
321
  var opener = entry.opener;
299
- if (wasTop && entry.restoreFocus && opener && opener.isConnected !== false && typeof opener.focus === 'function') {
322
+ if (!stxHost.isNative && wasTop && entry.restoreFocus && opener && opener.isConnected !== false && typeof opener.focus === 'function') {
300
323
  try { opener.focus(); }
301
324
  catch (_e) { /* gone; nothing to give focus back to */ }
302
325
  }
@@ -22,8 +22,12 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
22
22
  return;
23
23
  }
24
24
 
25
- if (el.nodeType === Node.ELEMENT_NODE && el.tagName === 'BUTTON' && el.hasAttribute && el.hasAttribute('@click')) {
26
-
25
+ if (el.nodeType === Node.ELEMENT_NODE && el.hasAttribute
26
+ && el.hasAttribute('data-stx-scope') && !hasPendingLoopBoundary(el)) {
27
+ // A page walk can reach a component before the dedicated scope pass.
28
+ // Resolve its caller before props/events bind and their guards latch.
29
+ el.__stx_parent_scope = el.__stx_parent_scope || resolveComponentCallerScope(el, scope);
30
+ bindParentComponentProps(el, el.__stx_parent_scope);
27
31
  }
28
32
  if (el.nodeType === Node.ELEMENT_NODE && el.hasAttribute) {
29
33
  // x-data elements: the reactive bridge has registered their scope into window.stx._scopes.
@@ -350,6 +354,13 @@ catch (e2) {
350
354
  var bindingScope = el.__stx_parent_scope && parentBindingNames.includes(attrName)
351
355
  ? el.__stx_parent_scope
352
356
  : attrCapturedScope;
357
+ if ((attrName === 'value' || attrName === 'checked') && attrName in el) {
358
+ var modelName = value.trim().match(/^([a-zA-Z_$][\\w$]*)(?:\\(\\))?$/);
359
+ var resetModel = modelName && bindingScope[modelName[1]];
360
+ if (resetModel && resetModel._isSignal && typeof resetModel.set === 'function') {
361
+ bindFormControlReset(el, attrName, resetModel, function(initial) { resetModel.set(initial); });
362
+ }
363
+ }
353
364
  effect(() => {
354
365
  if (!attributesVisible()) return;
355
366
  const v = evalAttrExpr(value, bindingScope);
@@ -503,6 +514,9 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
503
514
  if (refOwnerScope.$refs) refOwnerScope.$refs[value] = el;
504
515
  }
505
516
  else {
517
+ // Manifest hydration receives the page scope for each node. A
518
+ // component-local ref still belongs to the node's owning scope.
519
+ if (refOwnerScope && refOwnerScope.$refs) refOwnerScope.$refs[value] = el;
506
520
  if (scope.$refs) scope.$refs[value] = el;
507
521
  if (componentScope.$refs) componentScope.$refs[value] = el;
508
522
  }
@@ -512,7 +526,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
512
526
  // it silently returned undefined.
513
527
  var refTarget = refCaller && refOwnerScope
514
528
  ? refOwnerScope[value]
515
- : (scope && scope[value]) || componentScope[value];
529
+ : (refOwnerScope && refOwnerScope[value]) || (scope && scope[value]) || componentScope[value];
516
530
  if (refTarget && typeof refTarget === 'function' && refTarget._isSignal && typeof refTarget.set === 'function') {
517
531
  refTarget.set(el);
518
532
  }
@@ -570,9 +584,10 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
570
584
  // Vue-style component handlers receive the emitted payload directly.
571
585
  // Native root events still receive the Event object so server-only
572
586
  // components can forward clicks and other browser events.
573
- var handlerEvent = isForwardedComponentEvent && event instanceof CustomEvent
574
- ? event.detail
575
- : event;
587
+ var emittedArgs = isForwardedComponentEvent && event instanceof CustomEvent
588
+ && Array.isArray(event.__stx_emit_args) ? event.__stx_emit_args : null;
589
+ var handlerEvent = emittedArgs ? emittedArgs[0]
590
+ : isForwardedComponentEvent && event instanceof CustomEvent ? event.detail : event;
576
591
 
577
592
  // Skip an opener click that reaches UI which just became visible in
578
593
  // this frame. A click whose target is inside the revealed subtree is
@@ -605,7 +620,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
605
620
  try {
606
621
  if (!value || /^__[A-Z_]+__$/.test(value.trim())) return;
607
622
  var shorthandFn = parseEventShorthand(value, eventCapturedScope);
608
- if (shorthandFn) { shorthandFn(handlerEvent); return; }
623
+ if (shorthandFn) { shorthandFn.apply(null, emittedArgs || [handlerEvent]); return; }
609
624
  // Check if any scope values are signals (x-data pattern)
610
625
  // A derived value reads like a signal in a handler, as it does in a
611
626
  // binding: \`pick(selectedPackage)\` passes the package. Leaving it
@@ -109,6 +109,8 @@ export function signalsPublicApiRuntime(componentApiRuntime) {
109
109
  ${componentApiRuntime}
110
110
 
111
111
  _mountCallbacks: mountCallbacks,
112
+ // Internal adapter for the shared component library, not a DOM facade.
113
+ _host: stxHost,
112
114
  _destroyCallbacks: destroyCallbacks,
113
115
  _cleanupContainer: cleanupContainer,
114
116
  _flushLoad: flushStxLoad,
@@ -29,7 +29,7 @@ catch (e2) {
29
29
  effect(() => {
30
30
  if (isVisible && !isVisible()) return;
31
31
  const value = evalExpr();
32
- stxHost.setStyle(el, value);
32
+ stxHost.setStyle(el, value, true);
33
33
  });
34
34
  }
35
35
  `;
@@ -4,7 +4,7 @@ import type { Signal } from './signals-api';
4
4
  * function closure-free: the runtime embeds its JavaScript source, with all
5
5
  * reactive and lifecycle dependencies supplied explicitly.
6
6
  */
7
- export declare function createModelSignal<T>(source: Signal<T>, modifiers: () => ModelModifiers, emit: (value: T) => void, options: ModelOptions<T>, cleanup: (fn: () => void) => void): ModelSignal<T>;
7
+ export declare function createModelSignal<T>(source: Signal<T>, modifiers: () => ModelModifiers, emit: (value: T) => void, options: ModelOptions<T>, cleanup: (fn: () => void) => void, mount?: (fn: () => void) => void): ModelSignal<T>;
8
8
  export declare function useModel<T>(options: ModelOptions<T> & { default: T }): ModelSignal<T>;
9
9
  export declare function useModel<T>(name: string, options: ModelOptions<T> & { default: T }): ModelSignal<T>;
10
10
  export declare function useModel<T = unknown>(name?: string, options?: ModelOptions<T>): ModelSignal<T | undefined>;
@@ -1,6 +1,6 @@
1
1
  import { defineEmits, getCurrentInstance } from "./composition-api.js";
2
- import { effect, isDerived, isSignal, onDestroy, state } from "./signals-api.js";
3
- export function createModelSignal(source, modifiers, emit, options, cleanup) {
2
+ import { effect, isDerived, isSignal, onDestroy, onMount, state } from "./signals-api.js";
3
+ export function createModelSignal(source, modifiers, emit, options, cleanup, mount) {
4
4
  let active = !0;
5
5
  const subscriptions = new Set, read = (value) => options.get ? options.get(value) : value, model = () => read(source());
6
6
  Object.defineProperty(model, "_isSignal", { value: !0 });
@@ -47,6 +47,9 @@ export function createModelSignal(source, modifiers, emit, options, cleanup) {
47
47
  subscriptions.forEach((unsubscribe) => unsubscribe());
48
48
  subscriptions.clear();
49
49
  });
50
+ mount?.(() => {
51
+ active = !0;
52
+ });
50
53
  return model;
51
54
  }
52
55
  export function useModel(nameOrOptions = "modelValue", options = {}) {
@@ -55,5 +58,5 @@ export function useModel(nameOrOptions = "modelValue", options = {}) {
55
58
  source.set(value === void 0 ? opts.default : value);
56
59
  });
57
60
  onDestroy(stop);
58
- return createModelSignal(source, () => readProp(modifierName) || {}, (value) => emit(`update:${name}`, value), opts, onDestroy);
61
+ return createModelSignal(source, () => readProp(modifierName) || {}, (value) => emit(`update:${name}`, value), opts, onDestroy, onMount);
59
62
  }
@@ -496,9 +496,21 @@ async function processCustomElementTags(template, context, filePath, options, de
496
496
  mergedProps[key] = value;
497
497
  for (const [key, value] of Object.entries(resolvedProps.serverDynamic))
498
498
  mergedProps[key] = value;
499
- const renderMetadata = { declaredProps: new Set };
499
+ const renderMetadata = {
500
+ declaredProps: new Set,
501
+ consumedProps: new Set,
502
+ reactiveProps: Object.keys(resolvedProps.clientReactive)
503
+ };
500
504
  let finalContent = await renderComponentWithSlot(componentPath, mergedProps, stashed.restore(tag.content), componentsDir, context, filePath, options, processedComponents, dependencies, [...loopNames], renderMetadata, tag.tagName);
501
- finalContent = forwardHostAttrs(finalContent, resolvedProps, renderMetadata.declaredProps);
505
+ finalContent = forwardHostAttrs(finalContent, resolvedProps, renderMetadata.declaredProps, renderMetadata.consumedProps, options._nativeHostAttrs);
506
+ if (options._nativeHostAttrs) {
507
+ const names = renderMetadata.reactiveProps.filter((name) => !renderMetadata.consumedProps.has(name) && !["if", "for", "show", "key", "ref"].includes(name)).map(pascalToKebab), hostRoot = findRenderedComponentHostRoot(finalContent);
508
+ if (names.length && hostRoot) {
509
+ finalContent = finalContent.slice(0, hostRoot.insertPos) + ' data-stx-native-host-root="true"' + finalContent.slice(hostRoot.insertPos);
510
+ const scopeRoot = findRenderedComponentRoot(finalContent);
511
+ finalContent = finalContent.slice(0, scopeRoot.insertPos) + ` data-stx-native-forward="${names.join(" ")}"` + finalContent.slice(scopeRoot.insertPos);
512
+ }
513
+ }
502
514
  if (Object.keys(resolvedProps.events).length > 0) {
503
515
  const root = findRenderedComponentRoot(finalContent);
504
516
  if (root) {
@@ -541,19 +553,27 @@ function emitClientReactiveAttrs(html, clientReactive) {
541
553
  output = `<template :for="${forExpression.replace(/"/g, "&quot;")}">${output}</template>`;
542
554
  return output;
543
555
  }
544
- function forwardHostAttrs(html, props, declaredProps = new Set) {
556
+ function forwardHostAttrs(html, props, declaredProps = new Set, consumedProps = new Set, nativeTarget = !1) {
545
557
  const root = findRenderedComponentHostRoot(html);
546
558
  if (!root)
547
559
  return html;
548
- const openingTag = html.slice(root.insertPos, root.tagEnd), isNativeHost = /\bdata-native(?:\s|=)/i.test(openingTag), existing = new Set(Object.keys(parseAllAttributes(openingTag))), consumed = new Set(["class", "className"]);
560
+ let openingTag = html.slice(root.insertPos, root.tagEnd);
561
+ const callerClass = props.serverDynamic.class ?? props.static.class;
562
+ if (nativeTarget && typeof callerClass === "string" && callerClass && !consumedProps.has("class")) {
563
+ const classAttr = /(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i, next = classAttr.test(openingTag) ? openingTag.replace(classAttr, (_, space, double, single, bare) => `${space}class="${escapeAttr(`${decodeAttributeEntities(double ?? single ?? bare)} ${callerClass}`)}"`) : ` class="${escapeAttr(callerClass)}"${openingTag}`;
564
+ html = html.slice(0, root.insertPos) + next + html.slice(root.tagEnd);
565
+ root.tagEnd += next.length - openingTag.length;
566
+ openingTag = next;
567
+ }
568
+ const isNativeHost = nativeTarget || /\bdata-native(?:\s|=)/i.test(openingTag), privateProps = isNativeHost ? consumedProps : declaredProps, existing = new Set(Object.keys(parseAllAttributes(openingTag))), consumed = new Set(["class", "className"]);
549
569
  for (const key of Object.keys(props.static)) {
550
570
  const name = props.staticNames[key] ?? key;
551
- if (existing.has(name) || !isNativeHost && (declaredProps.has(key) || !isFallthroughAttribute(name)))
571
+ if (existing.has(name) || privateProps.has(key) || !isNativeHost && !isFallthroughAttribute(name))
552
572
  consumed.add(key);
553
573
  }
554
574
  for (const key of Object.keys(props.serverDynamic)) {
555
575
  const name = props.serverDynamicNames?.[key] ?? key;
556
- if (existing.has(name) || !isNativeHost && (declaredProps.has(key) || !isFallthroughAttribute(name)))
576
+ if (existing.has(name) || privateProps.has(key) || !isNativeHost && !isFallthroughAttribute(name))
557
577
  consumed.add(key);
558
578
  }
559
579
  const forwardedTrue = [];
@@ -68,11 +68,12 @@ export function defineEmits(events) {
68
68
  if (element) {
69
69
  const emittedEvents = element.__stx_component_emits ||= Object.create(null);
70
70
  emittedEvents[event] = !0;
71
- element.dispatchEvent(new CustomEvent(event, {
71
+ const emitted = Object.assign(new CustomEvent(event, {
72
72
  detail: args.length === 1 ? args[0] : args,
73
73
  bubbles: !0,
74
74
  cancelable: !0
75
- }));
75
+ }), { __stx_emit_args: args });
76
+ element.dispatchEvent(emitted);
76
77
  }
77
78
  };
78
79
  if (instance)
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{Jr,Bo,Fo}from"./chunk-620szfcp.js";import"./chunk-7hkc96de.js";import"./chunk-ah9xyss2.js";import"./chunk-yhpyqsbr.js";import"./chunk-zk2xk0wd.js";import"./chunk-vpdx7qr3.js";import"./chunk-faghmmrs.js";import"./chunk-43h8q2cm.js";import"./chunk-ayy9mmrw.js";import"./chunk-be2ba3hj.js";import"./chunk-eww6sdzz.js";import"./chunk-qdyp2zqf.js";import"./chunk-jtbzmbzz.js";import"./chunk-117xss52.js";import{Ad,Io,Pd,Id,Oo,Xr,Do,Od,Mo,Dd,Md,No,Lo,jo}from"./chunk-zz02hwec.js";import"./chunk-j1nqnmcd.js";import"./chunk-cdgwkzms.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{rs,qo,Go}from"./chunk-qebxzf9w.js";import"./chunk-qhr1tkhj.js";import"./chunk-v8ze2q95.js";import"./chunk-pxw4edw8.js";import"./chunk-c6egfhy6.js";import"./chunk-mmbspaqh.js";import"./chunk-sr1md7vv.js";import"./chunk-9cpxzze0.js";import"./chunk-7ra30crf.js";import"./chunk-k1szsenr.js";import"./chunk-zgv1h2np.js";import"./chunk-82bttwqm.js";import"./chunk-k71e38fk.js";import"./chunk-7xw1e8t6.js";import{Lu,Bo,ju,Bu,Fo,ns,zo,Fu,Ho,zu,Hu,Uo,Vo,Wo}from"./chunk-96zgn94z.js";import"./chunk-5zg3xj45.js";import"./chunk-w24qmxc3.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{Ad as CRAFT_BRIDGE_SCRIPT,Xr as CRAFT_COMPONENTS,Od as CRAFT_COMPONENT_RUNTIME,Do as CRAFT_COMPONENT_STYLES,Jr as NATIVE_COMPONENTS,No as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Bo as compileToNative,Fo as createHotReloadServer,Io as generateCraftBridgeScript,V as generateCraftOptimizations,jo as getAvailableFormats,Lo as getAvailableTargets,Md as getCraftComponents,G as getSSRCacheStats,Oo as injectCraftBridge,Pd as isCraftEnvironment,Y as prerenderForCraft,Mo as processCraftComponents,Id as processCraftDirective,Dd 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{Lu as CRAFT_BRIDGE_SCRIPT,ns as CRAFT_COMPONENTS,Fu as CRAFT_COMPONENT_RUNTIME,zo as CRAFT_COMPONENT_STYLES,rs as NATIVE_COMPONENTS,Uo as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,qo as compileToNative,Go as createHotReloadServer,Bo as generateCraftBridgeScript,V as generateCraftOptimizations,Wo as getAvailableFormats,Vo as getAvailableTargets,Hu as getCraftComponents,G as getSSRCacheStats,Fo as injectCraftBridge,ju as isCraftEnvironment,Y as prerenderForCraft,Ho as processCraftComponents,Bu as processCraftDirective,zu as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{Jr,Bo,Fo}from"./chunk-620szfcp.js";import"./chunk-7hkc96de.js";import"./chunk-ah9xyss2.js";import"./chunk-yhpyqsbr.js";import"./chunk-zk2xk0wd.js";import"./chunk-vpdx7qr3.js";import"./chunk-faghmmrs.js";import"./chunk-43h8q2cm.js";import"./chunk-ayy9mmrw.js";import"./chunk-be2ba3hj.js";import"./chunk-eww6sdzz.js";import"./chunk-qdyp2zqf.js";import"./chunk-jtbzmbzz.js";import"./chunk-117xss52.js";import{Ad,Io,Pd,Id,Oo,Xr,Do,Od,Mo,Dd,Md,No,Lo,jo}from"./chunk-zz02hwec.js";import"./chunk-j1nqnmcd.js";import"./chunk-cdgwkzms.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{rs,qo,Go}from"./chunk-qebxzf9w.js";import"./chunk-qhr1tkhj.js";import"./chunk-v8ze2q95.js";import"./chunk-pxw4edw8.js";import"./chunk-c6egfhy6.js";import"./chunk-mmbspaqh.js";import"./chunk-sr1md7vv.js";import"./chunk-9cpxzze0.js";import"./chunk-7ra30crf.js";import"./chunk-k1szsenr.js";import"./chunk-zgv1h2np.js";import"./chunk-82bttwqm.js";import"./chunk-k71e38fk.js";import"./chunk-7xw1e8t6.js";import{Lu,Bo,ju,Bu,Fo,ns,zo,Fu,Ho,zu,Hu,Uo,Vo,Wo}from"./chunk-96zgn94z.js";import"./chunk-5zg3xj45.js";import"./chunk-w24qmxc3.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{Ad as CRAFT_BRIDGE_SCRIPT,Xr as CRAFT_COMPONENTS,Od as CRAFT_COMPONENT_RUNTIME,Do as CRAFT_COMPONENT_STYLES,Jr as NATIVE_COMPONENTS,No as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Bo as compileToNative,Fo as createHotReloadServer,Io as generateCraftBridgeScript,V as generateCraftOptimizations,jo as getAvailableFormats,Lo as getAvailableTargets,Md as getCraftComponents,G as getSSRCacheStats,Oo as injectCraftBridge,Pd as isCraftEnvironment,Y as prerenderForCraft,Mo as processCraftComponents,Id as processCraftDirective,Dd 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{Lu as CRAFT_BRIDGE_SCRIPT,ns as CRAFT_COMPONENTS,Fu as CRAFT_COMPONENT_RUNTIME,zo as CRAFT_COMPONENT_STYLES,rs as NATIVE_COMPONENTS,Uo as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,qo as compileToNative,Go as createHotReloadServer,Bo as generateCraftBridgeScript,V as generateCraftOptimizations,Wo as getAvailableFormats,Vo as getAvailableTargets,Hu as getCraftComponents,G as getSSRCacheStats,Fo as injectCraftBridge,ju as isCraftEnvironment,Y as prerenderForCraft,Ho as processCraftComponents,Bu as processCraftDirective,zu as registerCraftComponent,Q as renderSSR};
@@ -90,8 +90,13 @@ function areasRead(code) {
90
90
  areas.add(match[1]);
91
91
  return [...areas].sort();
92
92
  }
93
- function runtimeDocument(document) {
94
- return { ...document, script: { exports: document.script.exports, functions: [], code: "" } };
93
+ function runtimeDocument(document, root) {
94
+ const source = path.isAbsolute(document.meta.source) ? path.relative(root, document.meta.source).split(path.sep).join("/") : document.meta.source;
95
+ return {
96
+ ...document,
97
+ script: { exports: document.script.exports, functions: [], code: "" },
98
+ meta: { ...document.meta, source, compiledAt: 0 }
99
+ };
95
100
  }
96
101
  export async function compileNativeBundle(options) {
97
102
  const names = Object.keys(options.screens);
@@ -140,7 +145,7 @@ var isApp = ${appFile ? `routeName === ${JSON.stringify(NATIVE_APP_ROUTE)}` : "f
140
145
  if (!isApp && routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));
141
146
  if (isApp ? ${!withApp} : ${JSON.stringify(bundled.map(({ name }) => name))}.indexOf(routeName) === -1) throw new Error(['This bundle does not hold the native screen', routeName].join(' '));` : `var routeName = 'main';
142
147
  var isApp = false;`, selections = bundled.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
143
- nativeDocument = ${JSON.stringify(runtimeDocument(compiled.document))};
148
+ nativeDocument = ${JSON.stringify(runtimeDocument(compiled.document, root))};
144
149
  manifest = ${JSON.stringify(compiled.manifest)};
145
150
  }`).join(`
146
151
  `), setups = bundled.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
@@ -0,0 +1,4 @@
1
+ import type { NativeStyleVariables } from './style-variables';
2
+ export declare function nativeShapeRadius(name: string, variables?: NativeStyleVariables): number | undefined;
3
+ export declare function nativeDensitySpacing(name: string, variables?: NativeStyleVariables): number | undefined;
4
+ export declare function nativeDensityType(name: string, variables?: NativeStyleVariables): { fontSize: number, lineHeight: number } | undefined;
@@ -0,0 +1,28 @@
1
+ import { densityVariable, DENSITY_FONT_SIZES, DENSITY_SPACING, DENSITY_TOKENS, shapeVariable, SHAPE_TOKENS } from "../../theme-tokens.js";
2
+ function tokenLength(value) {
3
+ const match = value && /^(\d+(?:\.\d+)?|\.\d+)(px|rem)?$/.exec(value.trim());
4
+ if (!match)
5
+ return;
6
+ const result = Number(match[1]) * (match[2] === "rem" ? 16 : 1);
7
+ return Number.isFinite(result) ? result : void 0;
8
+ }
9
+ export function nativeShapeRadius(name, variables) {
10
+ if (!SHAPE_TOKENS[name])
11
+ return;
12
+ return tokenLength(variables?.get(shapeVariable(name)) ?? SHAPE_TOKENS[name].value);
13
+ }
14
+ export function nativeDensitySpacing(name, variables) {
15
+ const token = DENSITY_SPACING[name];
16
+ if (!token)
17
+ return;
18
+ return tokenLength(variables?.get(densityVariable(token)) ?? DENSITY_TOKENS[token]?.value);
19
+ }
20
+ export function nativeDensityType(name, variables) {
21
+ const role = DENSITY_FONT_SIZES[name];
22
+ if (!role)
23
+ return;
24
+ const fontSize = tokenLength(variables?.get(densityVariable(role.size)) ?? DENSITY_TOKENS[role.size]?.value), lineHeight = tokenLength(variables?.get(densityVariable(role.leading)) ?? DENSITY_TOKENS[role.leading]?.value);
25
+ if (fontSize === void 0 || lineHeight === void 0)
26
+ return;
27
+ return { fontSize, lineHeight };
28
+ }