@stacksjs/stx 0.2.583 → 0.2.585

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 (243) hide show
  1. package/dist/{chunk-ck1yca7g.js → chunk-03qf2z4d.js} +1 -1
  2. package/dist/{chunk-6m3me7yj.js → chunk-03xsf9jm.js} +9 -9
  3. package/dist/{chunk-sv5nvfmb.js → chunk-048eyjyj.js} +2 -2
  4. package/dist/{chunk-je1as16r.js → chunk-076h7nb9.js} +5 -5
  5. package/dist/{chunk-hp9nxva6.js → chunk-07869zev.js} +4 -4
  6. package/dist/chunk-0hpw65yr.js +2 -0
  7. package/dist/chunk-11jmasqb.js +2 -0
  8. package/dist/chunk-2c7ysn9s.js +2 -0
  9. package/dist/chunk-2wb1w0p6.js +2 -0
  10. package/dist/chunk-2wx2aczp.js +2 -0
  11. package/dist/{chunk-pbwk8tzz.js → chunk-33q5zka4.js} +1 -1
  12. package/dist/chunk-3qmx12d3.js +2845 -0
  13. package/dist/{chunk-ktyctev3.js → chunk-3y5tzxm6.js} +2 -2
  14. package/dist/chunk-3ybbat49.js +2 -0
  15. package/dist/{chunk-2943qhdt.js → chunk-45x4myqe.js} +2 -2
  16. package/dist/chunk-4dpab4j6.js +2 -0
  17. package/dist/{chunk-5kh5ehfh.js → chunk-4h58as2c.js} +2 -2
  18. package/dist/chunk-4vnwge6p.js +2 -0
  19. package/dist/chunk-4w37cqg9.js +2 -0
  20. package/dist/chunk-51pz8cwa.js +2 -0
  21. package/dist/chunk-65agttgm.js +2 -0
  22. package/dist/{chunk-ye66wc53.js → chunk-67m2prah.js} +2 -2
  23. package/dist/{chunk-521pe0hb.js → chunk-6cg03r93.js} +4 -4
  24. package/dist/chunk-6djvj6hg.js +2 -0
  25. package/dist/{chunk-4pmgr32a.js → chunk-6hgngmn0.js} +3 -3
  26. package/dist/{chunk-09zwhsf9.js → chunk-751b5zv9.js} +3 -3
  27. package/dist/{chunk-mjj24qpb.js → chunk-794v5crp.js} +2 -2
  28. package/dist/chunk-7ae40484.js +2 -0
  29. package/dist/chunk-7dkwf9h5.js +2 -0
  30. package/dist/chunk-7dtyf7hq.js +2 -0
  31. package/dist/chunk-7ebt9n43.js +4 -0
  32. package/dist/{chunk-cnknvvwm.js → chunk-7fghm9zy.js} +1 -1
  33. package/dist/{chunk-117xss52.js → chunk-7xw1e8t6.js} +2 -2
  34. package/dist/{chunk-w6wtxj54.js → chunk-7ydavm3h.js} +2 -2
  35. package/dist/chunk-80g8kaes.js +2 -0
  36. package/dist/{chunk-qdyp2zqf.js → chunk-82bttwqm.js} +2 -2
  37. package/dist/chunk-8992smwz.js +2 -0
  38. package/dist/{chunk-qn8gdw21.js → chunk-8s7zbhdd.js} +4 -4
  39. package/dist/{chunk-02qaqamv.js → chunk-91pdg853.js} +7 -7
  40. package/dist/chunk-9j6hk72q.js +2 -0
  41. package/dist/{chunk-96mb3brj.js → chunk-9nt3q23a.js} +3 -3
  42. package/dist/chunk-9pk5jhqa.js +3 -0
  43. package/dist/{chunk-g9zeybqh.js → chunk-9qsnq026.js} +2 -2
  44. package/dist/{chunk-m417sp42.js → chunk-a30mtx17.js} +4 -4
  45. package/dist/chunk-a3k4nfq2.js +2 -0
  46. package/dist/{chunk-c0h2eqe0.js → chunk-a8n6mt7s.js} +2 -2
  47. package/dist/{chunk-xp7fxc6p.js → chunk-awgvt956.js} +5 -5
  48. package/dist/{chunk-mt9x626h.js → chunk-axz1x4r9.js} +5 -5
  49. package/dist/{chunk-8tq83fq7.js → chunk-b217d16p.js} +57 -57
  50. package/dist/{chunk-w3rmepwy.js → chunk-bfbmdjh4.js} +2 -2
  51. package/dist/chunk-bhg4pvtn.js +2 -0
  52. package/dist/{chunk-0k5faspy.js → chunk-bsy10tz6.js} +6 -6
  53. package/dist/{chunk-dvc15djp.js → chunk-c6egfhy6.js} +2 -2
  54. package/dist/chunk-c8fdccgp.js +2 -0
  55. package/dist/chunk-ce2d0hz9.js +2 -0
  56. package/dist/{chunk-4pkpr5cg.js → chunk-cqr5cv7h.js} +4 -4
  57. package/dist/chunk-cw76edds.js +2 -0
  58. package/dist/{chunk-ky1426s1.js → chunk-cy07dhqh.js} +10 -10
  59. package/dist/chunk-czrs87r9.js +2 -0
  60. package/dist/{chunk-ycj0342k.js → chunk-d0tmc6v5.js} +2 -2
  61. package/dist/chunk-d9vjsqs4.js +2 -0
  62. package/dist/chunk-ddgyj88h.js +2 -0
  63. package/dist/chunk-dj90w48e.js +2 -0
  64. package/dist/chunk-dngzks8e.js +2 -0
  65. package/dist/chunk-e01j75cr.js +122 -0
  66. package/dist/{chunk-kfwmqacd.js → chunk-e556dvy4.js} +3 -3
  67. package/dist/chunk-ede39b7h.js +3 -0
  68. package/dist/chunk-emxa2djv.js +2 -0
  69. package/dist/chunk-esj49jvz.js +2 -0
  70. package/dist/chunk-eztvhppz.js +2 -0
  71. package/dist/{chunk-4srg0qbv.js → chunk-f29fk7dw.js} +2 -2
  72. package/dist/{chunk-vke73gts.js → chunk-fkq55rh7.js} +1 -1
  73. package/dist/chunk-h2534p6q.js +2 -0
  74. package/dist/{chunk-2nehykbm.js → chunk-h7atbtds.js} +5 -5
  75. package/dist/chunk-h9gtc6bk.js +2 -0
  76. package/dist/{chunk-h0a2s340.js → chunk-haag5n42.js} +2 -2
  77. package/dist/{chunk-cby4mkjf.js → chunk-hj8tr9g0.js} +1 -1
  78. package/dist/{chunk-en7xxgtb.js → chunk-hsy9rhct.js} +2 -2
  79. package/dist/{chunk-qccgncp2.js → chunk-htcptqtn.js} +6 -6
  80. package/dist/chunk-hwnvfke9.js +2 -0
  81. package/dist/chunk-hygxh993.js +2 -0
  82. package/dist/{chunk-s12bnv32.js → chunk-hz11wmx9.js} +2 -2
  83. package/dist/{chunk-wyn5rfzk.js → chunk-j7kcjgxy.js} +115 -26
  84. package/dist/chunk-j8v5164e.js +2 -0
  85. package/dist/chunk-jqy5q8m0.js +2 -0
  86. package/dist/{chunk-0dfgefjv.js → chunk-jtx74677.js} +2 -2
  87. package/dist/chunk-jy7yzat1.js +2 -0
  88. package/dist/{chunk-vkc51n9m.js → chunk-k1szsenr.js} +2 -2
  89. package/dist/{chunk-sv08pd66.js → chunk-k71e38fk.js} +4 -4
  90. package/dist/{chunk-ac6v3s3k.js → chunk-kfhghjh6.js} +2 -2
  91. package/dist/{chunk-ym1sb5bg.js → chunk-m7ddgrsm.js} +5 -5
  92. package/dist/{chunk-vpdx7qr3.js → chunk-mmbspaqh.js} +2 -2
  93. package/dist/{chunk-6fc8vw2v.js → chunk-mnnxa3r7.js} +7 -7
  94. package/dist/chunk-n7yk4nc1.js +2 -0
  95. package/dist/chunk-ns1jqzqk.js +2 -0
  96. package/dist/chunk-p973efbe.js +2 -0
  97. package/dist/{chunk-m8tm44rq.js → chunk-pg164sdw.js} +2 -2
  98. package/dist/{chunk-x552npae.js → chunk-pxw4edw8.js} +4 -4
  99. package/dist/chunk-q03kn4d1.js +2 -0
  100. package/dist/{chunk-1r1maqep.js → chunk-q1cvef6b.js} +3 -3
  101. package/dist/{chunk-jpqkm8tm.js → chunk-qf3axv86.js} +3 -3
  102. package/dist/{chunk-dhq80e4r.js → chunk-qhr1tkhj.js} +7 -7
  103. package/dist/chunk-qq59xzwc.js +2 -0
  104. package/dist/{chunk-h3z9b6bw.js → chunk-qx0tcsdm.js} +11 -11
  105. package/dist/chunk-r0e743c3.js +2 -0
  106. package/dist/chunk-r90v2jz6.js +2 -0
  107. package/dist/chunk-rtgf9fgc.js +2 -0
  108. package/dist/chunk-s043hpvd.js +2 -0
  109. package/dist/{chunk-hzqyfdpy.js → chunk-s2h601k7.js} +7 -7
  110. package/dist/chunk-shzesarq.js +2 -0
  111. package/dist/chunk-sjkdpsca.js +3 -0
  112. package/dist/chunk-sqpme1hg.js +2 -0
  113. package/dist/{chunk-e809x7m0.js → chunk-t212h9zm.js} +1 -1
  114. package/dist/{chunk-r47cs92n.js → chunk-tc15vkfh.js} +2 -2
  115. package/dist/chunk-thydj877.js +2 -0
  116. package/dist/{chunk-6z3e1tyz.js → chunk-tnafnb23.js} +1 -1
  117. package/dist/{chunk-ah9xyss2.js → chunk-v8ze2q95.js} +2 -2
  118. package/dist/{chunk-xytkfa48.js → chunk-vf15db1j.js} +6 -6
  119. package/dist/chunk-vv1kr9dn.js +2 -0
  120. package/dist/{chunk-dm1qh2vq.js → chunk-w24qmxc3.js} +3 -3
  121. package/dist/{chunk-nhd9m8h5.js → chunk-wkrf41se.js} +6 -6
  122. package/dist/chunk-wm9nzg76.js +2 -0
  123. package/dist/chunk-wn2gzwmv.js +2 -0
  124. package/dist/{chunk-07anexcg.js → chunk-ww28zfwt.js} +2 -2
  125. package/dist/chunk-x5qymgxa.js +2 -0
  126. package/dist/chunk-xfe2nzxd.js +2 -0
  127. package/dist/chunk-xjwgzp6s.js +2 -0
  128. package/dist/chunk-xnbkyj4g.js +2 -0
  129. package/dist/chunk-xyepqdjy.js +2 -0
  130. package/dist/{chunk-wwj8zbzc.js → chunk-y09g63k0.js} +5 -5
  131. package/dist/{chunk-3e3dpp7w.js → chunk-y5x8xnnf.js} +3 -3
  132. package/dist/chunk-y93y2qat.js +2 -0
  133. package/dist/{chunk-nh3svtvj.js → chunk-yhhfxx17.js} +5 -5
  134. package/dist/{chunk-bj29pwm0.js → chunk-zrw1zf54.js} +3 -3
  135. package/dist/cli.js +20 -20
  136. package/dist/client/signals-host-runtime.js +52 -1
  137. package/dist/client/signals-manifest-hydration-runtime.js +13 -0
  138. package/dist/client/signals-overlay-runtime.js +29 -6
  139. package/dist/client/signals-public-api-runtime.js +2 -0
  140. package/dist/client/signals-style-runtime.js +1 -1
  141. package/dist/component-renderer.js +26 -6
  142. package/dist/craft-entry.js +2 -2
  143. package/dist/craft.js +2 -2
  144. package/dist/native/accessibility.d.ts +18 -0
  145. package/dist/native/accessibility.js +89 -0
  146. package/dist/native/compiler/design-tokens.d.ts +4 -0
  147. package/dist/native/compiler/design-tokens.js +28 -0
  148. package/dist/native/compiler/headwind-to-style.d.ts +5 -4
  149. package/dist/native/compiler/headwind-to-style.js +105 -65
  150. package/dist/native/compiler/html-to-ir.d.ts +3 -1
  151. package/dist/native/compiler/html-to-ir.js +49 -243
  152. package/dist/native/compiler/inline-style.d.ts +13 -0
  153. package/dist/native/compiler/inline-style.js +285 -0
  154. package/dist/native/compiler/ir.d.ts +5 -1
  155. package/dist/native/compiler/render-screen.js +3 -1
  156. package/dist/native/compiler/style-variables.d.ts +8 -0
  157. package/dist/native/compiler/style-variables.js +142 -0
  158. package/dist/native/compiler/stylesheet-theme.d.ts +6 -0
  159. package/dist/native/compiler/stylesheet-theme.js +110 -0
  160. package/dist/native/runtime/craft-bridge.js +3 -1
  161. package/dist/native/runtime/native-host.d.ts +13 -2
  162. package/dist/native/runtime/native-host.js +242 -36
  163. package/dist/native/runtime/overlay-presenter.d.ts +29 -0
  164. package/dist/native/runtime/overlay-presenter.js +69 -0
  165. package/dist/native/runtime/shared-screen.js +12 -1
  166. package/dist/native/runtime/view-operations.d.ts +20 -0
  167. package/dist/native/runtime/view-operations.js +35 -0
  168. package/dist/native/testing-mutations.d.ts +4 -0
  169. package/dist/native/testing-mutations.js +64 -0
  170. package/dist/native/testing.d.ts +2 -0
  171. package/dist/native/testing.js +18 -1
  172. package/dist/pwa.js +3 -3
  173. package/dist/ssg.js +9 -9
  174. package/dist/testing.js +2 -0
  175. package/dist/types/config-types.d.ts +2 -0
  176. package/dist/utils.d.ts +1 -1
  177. package/dist/utils.js +25 -5
  178. package/package.json +5 -5
  179. package/dist/chunk-00p22wzr.js +0 -3
  180. package/dist/chunk-0fx3ppnt.js +0 -2
  181. package/dist/chunk-0sfexf9t.js +0 -2
  182. package/dist/chunk-2927nax9.js +0 -2
  183. package/dist/chunk-2rj0ttas.js +0 -2
  184. package/dist/chunk-2rx9d75e.js +0 -4
  185. package/dist/chunk-3ae39ttg.js +0 -2
  186. package/dist/chunk-3x6p9me0.js +0 -2
  187. package/dist/chunk-440yjsk5.js +0 -2
  188. package/dist/chunk-58z26y07.js +0 -2
  189. package/dist/chunk-5db5sxy3.js +0 -3
  190. package/dist/chunk-5r9k9s3m.js +0 -2
  191. package/dist/chunk-76vza4ve.js +0 -2
  192. package/dist/chunk-84f9dnq5.js +0 -2
  193. package/dist/chunk-8tq5x4z8.js +0 -2
  194. package/dist/chunk-8y8bbsh5.js +0 -2
  195. package/dist/chunk-9kzycb15.js +0 -2
  196. package/dist/chunk-agfhb2qd.js +0 -2
  197. package/dist/chunk-ay6dzpt4.js +0 -2
  198. package/dist/chunk-b9njk81d.js +0 -2
  199. package/dist/chunk-bfbcmfww.js +0 -2
  200. package/dist/chunk-br01jvra.js +0 -2
  201. package/dist/chunk-c12y2bet.js +0 -2
  202. package/dist/chunk-c2nwchk0.js +0 -2
  203. package/dist/chunk-cxqrwvc5.js +0 -2
  204. package/dist/chunk-czea8zr1.js +0 -2
  205. package/dist/chunk-d99kfx3k.js +0 -2
  206. package/dist/chunk-dpn1pmxj.js +0 -2
  207. package/dist/chunk-dskrwa8f.js +0 -2
  208. package/dist/chunk-e6ycqvdm.js +0 -2
  209. package/dist/chunk-efgk2xv1.js +0 -2
  210. package/dist/chunk-fj70wq7k.js +0 -2
  211. package/dist/chunk-fvx6pd66.js +0 -2
  212. package/dist/chunk-hrbjapvr.js +0 -2
  213. package/dist/chunk-jc4mxq56.js +0 -2
  214. package/dist/chunk-jdpyxt8j.js +0 -2
  215. package/dist/chunk-k0zev8wc.js +0 -2
  216. package/dist/chunk-mhjwtkx9.js +0 -2
  217. package/dist/chunk-n4e02qdz.js +0 -2838
  218. package/dist/chunk-nx8rf4qd.js +0 -2
  219. package/dist/chunk-pe5bk9ns.js +0 -2
  220. package/dist/chunk-qb2j34sp.js +0 -2
  221. package/dist/chunk-qknfceta.js +0 -2
  222. package/dist/chunk-s932zfjz.js +0 -2
  223. package/dist/chunk-sf98zgw2.js +0 -2
  224. package/dist/chunk-sgsp4dph.js +0 -2
  225. package/dist/chunk-t48ws5j0.js +0 -2
  226. package/dist/chunk-tfxmzat6.js +0 -122
  227. package/dist/chunk-thbc9gtj.js +0 -2
  228. package/dist/chunk-tms7amrb.js +0 -2
  229. package/dist/chunk-tn9v10q2.js +0 -2
  230. package/dist/chunk-v0zgarvv.js +0 -2
  231. package/dist/chunk-v9jd283e.js +0 -2
  232. package/dist/chunk-vczw73ga.js +0 -2
  233. package/dist/chunk-webrqm20.js +0 -2
  234. package/dist/chunk-wg2w7zmt.js +0 -3
  235. package/dist/chunk-wgkxgsqx.js +0 -2
  236. package/dist/chunk-wngqr949.js +0 -2
  237. package/dist/chunk-xyzy84x0.js +0 -2
  238. package/dist/chunk-y1jffvkj.js +0 -2
  239. package/dist/chunk-yas134jv.js +0 -2
  240. package/dist/chunk-yd55vynh.js +0 -2
  241. package/dist/chunk-yygze2s0.js +0 -2
  242. package/dist/chunk-z732tf98.js +0 -2
  243. package/dist/chunk-ze86h6vp.js +0 -2
@@ -0,0 +1,35 @@
1
+ export function nativeViewError(code, message) {
2
+ return Object.assign(Error(message), { code });
3
+ }
4
+ export function createNativeViewOperations(protocol, capabilities, beforeRequest) {
5
+ const supported = new Set(capabilities);
6
+ function prepare(capability) {
7
+ if (!supported.has(capability))
8
+ throw nativeViewError("UNSUPPORTED", `This Craft host does not advertise ${capability}`);
9
+ beforeRequest();
10
+ }
11
+ return {
12
+ capabilities: { focus: supported.has("viewFocus"), measure: supported.has("viewMeasure") },
13
+ async focus(nodeId, options = {}) {
14
+ if (options.signal?.aborted)
15
+ throw nativeViewError("CANCELLED", "Native focus was cancelled");
16
+ const mode = options.mode ?? "keyboard";
17
+ if (mode !== "keyboard" && mode !== "accessibility")
18
+ throw nativeViewError("INVALID_ARGUMENT", "View.focus mode must be keyboard or accessibility");
19
+ prepare("viewFocus");
20
+ const result = await protocol.callNativeAPI("View", "focus", { nodeId, mode });
21
+ if (options.signal?.aborted)
22
+ throw nativeViewError("CANCELLED", "Native focus was cancelled");
23
+ if (result !== !0)
24
+ throw nativeViewError("INVALID_RESPONSE", "View.focus did not confirm focus");
25
+ return !0;
26
+ },
27
+ async measure(nodeId) {
28
+ prepare("viewMeasure");
29
+ const box = await protocol.callNativeAPI("View", "measure", { nodeId });
30
+ if (!box || !["x", "y", "width", "height", "viewportWidth", "viewportHeight"].every((key) => typeof box[key] === "number" && Number.isFinite(box[key])) || box.width < 0 || box.height < 0 || box.viewportWidth < 0 || box.viewportHeight < 0 || !["points", "dp"].includes(box.unit) || box.coordinateSpace !== "screenViewport")
31
+ throw nativeViewError("INVALID_RESPONSE", "View.measure returned invalid viewport bounds");
32
+ return box;
33
+ }
34
+ };
35
+ }
@@ -0,0 +1,4 @@
1
+ import type { NativeNode, NativeOperation } from './testing';
2
+ /** Preflight topology on a copy: a rejected batch must never partially alter the test phone. */
3
+ export declare function validateTestMutations(source: Map<string, NativeNode>, operations: NativeOperation[]): TestMutationError | null;
4
+ export declare interface TestMutationError { code: string, message: string, operationIndex: number }
@@ -0,0 +1,64 @@
1
+ export function validateTestMutations(source, operations) {
2
+ const containers = new Set(["View", "SafeAreaView", "ScrollView", "KeyboardAvoidingView", "Modal", "Pressable", "TouchableOpacity", "TouchableHighlight", "ImageBackground", "FlatList", "SectionList", "Fragment", "Svg", "G", "Map"].map((type) => type.toLowerCase())), nodes = new Map([...source].map(([id, node]) => [id, {
3
+ type: node.type,
4
+ parent: null,
5
+ children: node.children.filter((child) => typeof child !== "string").map((child) => child.id)
6
+ }]));
7
+ for (const [id, node] of nodes)
8
+ for (const child of node.children) {
9
+ const entry = nodes.get(child);
10
+ if (entry)
11
+ entry.parent = id;
12
+ }
13
+ const drop = (id) => {
14
+ const node = nodes.get(id);
15
+ if (!node)
16
+ return;
17
+ node.children.forEach(drop);
18
+ nodes.delete(id);
19
+ };
20
+ for (const [operationIndex, op] of operations.entries()) {
21
+ const fail = (code, message) => ({ code, message, operationIndex });
22
+ if (op.op === "createNode") {
23
+ if (nodes.has(op.id))
24
+ return fail("DUPLICATE_NODE", `Node ${op.id} already exists`);
25
+ if (!op.node?.type)
26
+ return fail("INVALID_NODE", "createNode requires a node type");
27
+ nodes.set(op.id, { type: op.node.type, parent: null, children: [] });
28
+ } else if (op.op === "insertChild" || op.op === "moveChild") {
29
+ const parent = nodes.get(op.parentId), child = nodes.get(op.childId);
30
+ if (!parent)
31
+ return fail("UNKNOWN_PARENT", `Node ${op.parentId} does not exist`);
32
+ if (!child)
33
+ return fail("UNKNOWN_NODE", `Node ${op.childId} does not exist`);
34
+ if (!containers.has(parent.type.toLowerCase()))
35
+ return fail("INVALID_PARENT", `Node ${op.parentId} cannot contain children`);
36
+ if (op.op === "insertChild" && child.parent !== null)
37
+ return fail("NODE_ATTACHED", `Node ${op.childId} already has a parent`);
38
+ if (op.op === "moveChild") {
39
+ if (child.parent !== op.parentId || !parent.children.includes(op.childId))
40
+ return fail("NOT_A_CHILD", `Node ${op.childId} is not a child of ${op.parentId}`);
41
+ parent.children.splice(parent.children.indexOf(op.childId), 1);
42
+ }
43
+ for (let id = op.parentId;id; id = nodes.get(id)?.parent ?? null)
44
+ if (id === op.childId)
45
+ return fail("CYCLE", "Placement would create a cycle");
46
+ if (!Number.isInteger(op.index) || op.index < 0 || op.index > parent.children.length)
47
+ return fail("INVALID_INDEX", `Index must be between 0 and ${parent.children.length}`);
48
+ parent.children.splice(op.index, 0, op.childId);
49
+ child.parent = op.parentId;
50
+ } else if (op.op === "removeNode" || op.op === "updateNode") {
51
+ const node = nodes.get(op.id);
52
+ if (!node)
53
+ return fail("UNKNOWN_NODE", `Node ${op.id} does not exist`);
54
+ if (op.op === "removeNode") {
55
+ const parent = node.parent ? nodes.get(node.parent) : null;
56
+ if (parent)
57
+ parent.children = parent.children.filter((id) => id !== op.id);
58
+ drop(op.id);
59
+ }
60
+ } else
61
+ return fail("INVALID_OPERATION", `Unknown mutation ${op.op}`);
62
+ }
63
+ return null;
64
+ }
@@ -1,3 +1,4 @@
1
+ import { type TestMutationError } from './testing-mutations';
1
2
  import path from 'node:path';
2
3
  import vm from 'node:vm';
3
4
  /** Wait for `check` to hold, polling every 5ms; throws after `timeoutMs`. */
@@ -68,6 +69,7 @@ export declare interface NativeScreenOptions {
68
69
  export declare interface NativeScreen {
69
70
  nodes: Map<string, NativeNode>
70
71
  messages: NativeMessage[]
72
+ mutationErrors: TestMutationError[]
71
73
  requests: string[]
72
74
  headers: Array<Record<string, string>>
73
75
  opened: string[]
@@ -2,6 +2,7 @@ var {require}=import.meta;import path from "node:path";
2
2
  import vm from "node:vm";
3
3
  import { compileSharedScreenBundle } from "./compiler/bundle.js";
4
4
  import { NativeFormData } from "./runtime/jsc-globals.js";
5
+ import { validateTestMutations } from "./testing-mutations.js";
5
6
  import { createTempDir } from "../temp-dir.js";
6
7
 
7
8
  export class StatusAnswer {
@@ -69,7 +70,7 @@ export function mountNativeScreen(code, screen, options = {}) {
69
70
  intervals.delete(id);
70
71
  clearInterval(id);
71
72
  }
72
- }, apiBase = options.apiBase || "", label = options.requestLabel || ((method, at, init) => `${method} ${at}${init.headers && Object.keys(init.headers).some((name) => name.toLowerCase() === "authorization") ? "" : " (guest)"}`), nodes = new Map, messages = [], requests = [], headers = [], opened = [], replaced = [], moves = [], stored = copy(options.storage ?? {}), natives = [], animations = [], streams = [], secureStorage = { ...options.keychain, ...options.secureStorage }, sessionTokenKey = options.sessionTokenKey ?? "auth.token", sessionWritten = (key, previous) => {
73
+ }, apiBase = options.apiBase || "", label = options.requestLabel || ((method, at, init) => `${method} ${at}${init.headers && Object.keys(init.headers).some((name) => name.toLowerCase() === "authorization") ? "" : " (guest)"}`), nodes = new Map, messages = [], mutationErrors = [], requests = [], headers = [], opened = [], replaced = [], moves = [], stored = copy(options.storage ?? {}), natives = [], animations = [], streams = [], secureStorage = { ...options.keychain, ...options.secureStorage }, sessionTokenKey = options.sessionTokenKey ?? "auth.token", sessionWritten = (key, previous) => {
73
74
  if (key !== sessionTokenKey || options.sessionEvents === !1)
74
75
  return;
75
76
  const token = secureStorage[key] || null;
@@ -251,6 +252,17 @@ export function mountNativeScreen(code, screen, options = {}) {
251
252
  postMessage: (raw) => {
252
253
  const message = JSON.parse(raw);
253
254
  messages.push(JSON.parse(raw));
255
+ if (message.type === "MUTATE") {
256
+ const error = validateTestMutations(nodes, message.payload.operations || []);
257
+ if (error) {
258
+ mutationErrors.push(error);
259
+ queueMicrotask(() => {
260
+ if (!ended)
261
+ receive(JSON.stringify({ type: "MUTATION_ERROR", payload: { ...error, version: 1, batchId: message.payload.batchId } }));
262
+ });
263
+ return;
264
+ }
265
+ }
254
266
  if (message.payload.document)
255
267
  visit(message.payload.document);
256
268
  for (const operation of message.payload.operations || []) {
@@ -374,6 +386,7 @@ export function mountNativeScreen(code, screen, options = {}) {
374
386
  return {
375
387
  nodes,
376
388
  messages,
389
+ mutationErrors,
377
390
  requests,
378
391
  headers,
379
392
  opened,
@@ -440,6 +453,10 @@ export function mountNativeScreen(code, screen, options = {}) {
440
453
  await Bun.sleep(ms);
441
454
  while (performance.now() - started < 5000 && (fetching > 0 || performance.now() - answeredAt < ms))
442
455
  await Bun.sleep(5);
456
+ if (mutationErrors.length) {
457
+ const error = mutationErrors[0];
458
+ throw Error(`Native mutation rejected (${error.code}, operation ${error.operationIndex}): ${error.message}`);
459
+ }
443
460
  },
444
461
  operations: () => messages.filter((message) => message.type === "MUTATE").flatMap((message) => message.payload.operations || []),
445
462
  get ended() {
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Wn,je,Xo,nc}from"./chunk-hp9nxva6.js";import{Vn,Yr,Qa,ec,tc}from"./chunk-xytkfa48.js";import{qo,Go,Ko,Ya,Za}from"./chunk-c0h2eqe0.js";import{ae,yt,Zr}from"./chunk-jpqkm8tm.js";import{sl,ol,il,al,Sr,Td}from"./chunk-ye66wc53.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-nx8rf4qd.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{Yn,je,ni,lc}from"./chunk-07869zev.js";import{Jn,ss,ic,ac,cc}from"./chunk-vf15db1j.js";import{Qo,ei,ti,sc,oc}from"./chunk-a8n6mt7s.js";import{ae,bt,os}from"./chunk-qf3axv86.js";import{dl,pl,fl,gl,Rr,Dd}from"./chunk-67m2prah.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-czrs87r9.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Wn(n,t);if(a){let s=je(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function se(n,t){return Yr(n,t)}function oe(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Go as auditBuildOutput,qo as auditConfig,re as buildPwaAssets,Ko as calculateAuditResult,Za as formatAuditResult,Zr as formatSize,j as generateManifest,_ as generateManifestJson,ec as generateManifestLink,F as generateOfflinePage,ae as generatePrecacheManifest,yt as generatePrecacheManifestJs,M as generatePwaIcons,Vn as generatePwaTags,Wn as generateServiceWorker,nc as generateServiceWorkerAuto,Qa as generateSwRegistrationScript,tc as generateThemeColorMeta,N as getExpectedIconPaths,je as getServiceWorkerFileName,Yr as injectPwaTags,oe as isPwaEnabled,I as isSharpAvailable,Xo as isWorkboxEnabled,q as mergeManifestConfig,se as processPwaHtml,Sr as pwaDirectives,sl as pwaInstallDirective,il as pwaOfflineDirective,al as pwaPushDirective,ol as pwaUpdateDirective,Td as registerPwaDirectives,Ya as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Yn(n,t);if(a){let s=je(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function se(n,t){return ss(n,t)}function oe(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,ei as auditBuildOutput,Qo as auditConfig,re as buildPwaAssets,ti as calculateAuditResult,oc as formatAuditResult,os as formatSize,j as generateManifest,_ as generateManifestJson,ac as generateManifestLink,F as generateOfflinePage,ae as generatePrecacheManifest,bt as generatePrecacheManifestJs,M as generatePwaIcons,Jn as generatePwaTags,Yn as generateServiceWorker,lc as generateServiceWorkerAuto,ic as generateSwRegistrationScript,cc as generateThemeColorMeta,N as getExpectedIconPaths,je as getServiceWorkerFileName,ss as injectPwaTags,oe as isPwaEnabled,I as isSharpAvailable,ni as isWorkboxEnabled,q as mergeManifestConfig,se as processPwaHtml,Rr as pwaDirectives,dl as pwaInstallDirective,fl as pwaOfflineDirective,gl as pwaPushDirective,pl as pwaUpdateDirective,Dd as registerPwaDirectives,sc as runPwaAudit,D as validateManifest};
package/dist/ssg.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import"./chunk-ktyctev3.js";import"./chunk-dhq80e4r.js";import"./chunk-ah9xyss2.js";import{rt,st,ot,it,at,ct}from"./chunk-x552npae.js";import"./chunk-dvc15djp.js";import"./chunk-vpdx7qr3.js";import{f,He,L,J,n,o}from"./chunk-n4e02qdz.js";import"./chunk-6m3me7yj.js";import{ur}from"./chunk-02qaqamv.js";import"./chunk-vkc51n9m.js";import"./chunk-2943qhdt.js";import"./chunk-qdyp2zqf.js";import"./chunk-sv08pd66.js";import"./chunk-nh3svtvj.js";import{ce,bt,vt}from"./chunk-4pkpr5cg.js";import{Uo,Vo,Wo}from"./chunk-bj29pwm0.js";import{ht,rn,sn}from"./chunk-wg2w7zmt.js";import"./chunk-dm1qh2vq.js";import{a}from"./chunk-00p22wzr.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Et=new Set(["visible","idle"]);function dt(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Et.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function jt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ft(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
- `)}class mt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class wt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function Ft(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
2
+ import"./chunk-3y5tzxm6.js";import"./chunk-qhr1tkhj.js";import"./chunk-v8ze2q95.js";import{st,ot,it,at,ct,lt}from"./chunk-pxw4edw8.js";import"./chunk-c6egfhy6.js";import"./chunk-mmbspaqh.js";import{f,Ve,L,J,n,o}from"./chunk-3qmx12d3.js";import"./chunk-03xsf9jm.js";import{yr}from"./chunk-91pdg853.js";import"./chunk-k1szsenr.js";import"./chunk-45x4myqe.js";import"./chunk-82bttwqm.js";import"./chunk-k71e38fk.js";import"./chunk-yhhfxx17.js";import{ce,vt,wt}from"./chunk-cqr5cv7h.js";import{Jo,Yo,Zo}from"./chunk-zrw1zf54.js";import{yt,an,cn}from"./chunk-9pk5jhqa.js";import"./chunk-w24qmxc3.js";import{a}from"./chunk-sjkdpsca.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Et=new Set(["visible","idle"]);function dt(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Et.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function jt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ht(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
+ `)}class ft{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class mt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function Ft(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
4
4
  return (async function getStaticPaths() {
5
5
  ${c[1]}
6
6
  })()
@@ -8,7 +8,7 @@ import"./chunk-ktyctev3.js";import"./chunk-dhq80e4r.js";import"./chunk-ah9xyss2.
8
8
  return (async function getStaticProps() {
9
9
  ${e[1]}
10
10
  })()
11
- `)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function yt(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Tt(t.filePath),w=await At(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
11
+ `)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function St(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Tt(t.filePath),w=await At(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
12
12
  resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of ce(b))h.add(B);if(Object.keys(i).length>0){let b=`<script>if(window.stx)window.stx._rp=${JSON.stringify(i)};else window.__stx_rp=${JSON.stringify(i)};</script>`;if(p.includes("</head>"))p=p.replace("</head>",`${b}
13
13
  </head>`);else p=`${b}
14
14
  ${p}`}if(p=await J(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:Mt(p),dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P};return{html:p,dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P}}function Mt(t){let i=[],s=0,r=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=r.exec(t))!==null){let l=t.slice(s,c.index);i.push(l.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],y=c[2],h=c[3];y=y.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),i.push(w+y+h),s=c.index+c[0].length}let e=t.slice(s);return i.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),i.join("").trim()}function Ut(t){let i=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);i=(i<<5)-i+r,i=i&i}return`"${Math.abs(i).toString(36)}"`}function _t(t,i,s,r){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(i))return!0;return r.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Gt(t,i){return`<?xml version="1.0" encoding="UTF-8"?>
@@ -41,16 +41,16 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
41
41
  ${s.join(`
42
42
  `)}
43
43
  </channel>
44
- </rss>`}async function zt(t={}){let i=Date.now();vt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-0fx3ppnt.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-58z26y07.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new mt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-0fx3ppnt.js");await u('<div class="bg-black"></div>')}catch{}rt();let St=s?.routeMiddleware?.dir||"middleware";await ot(process.cwd(),St);let H=st();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let xt=s?.routeMiddleware?.global||[];Wo(s?.layoutsDir,a(process.cwd()));let K=L(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ot(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<G.length;u+=e.concurrency)X.push(G.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...xt,...$t];if(tt.length>0){let C=it(d,M,F||{}),O=at(C,null,void 0,{isServer:!0}),E=await ct(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
44
+ </rss>`}async function zt(t={}){let i=Date.now();wt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ht());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-dj90w48e.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-q03kn4d1.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new ft(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-dj90w48e.js");await u('<div class="bg-black"></div>')}catch{}st();let xt=s?.routeMiddleware?.dir||"middleware";await it(process.cwd(),xt);let H=ot();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let bt=s?.routeMiddleware?.global||[];Zo(s?.layoutsDir,a(process.cwd()));let K=L(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ot(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<G.length;u+=e.concurrency)X.push(G.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...bt,...$t];if(tt.length>0){let C=at(d,M,F||{}),O=ct(C,null,void 0,{isServer:!0}),E=await lt(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
45
45
  const validate = ${et[1]};
46
46
  return validate(route);
47
- `)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,nt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)nt=!0,l.cachedCount++}if(!k){let C=await yt(v,M,Pt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
47
+ `)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,rt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)rt=!0,l.cachedCount++}if(!k){let C=await St(v,M,Pt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
48
48
  ${C.includeFailures.join(`
49
49
  `)}
50
50
  Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&C.serverScriptFailures.length>0)throw Error(`${C.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
51
51
  ${C.serverScriptFailures.join(`
52
52
  `)}
53
- Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:O}=ut(k,{integrity:e.integrityIslands,minify:e.minify});if(O.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of O){let _=g.join(E,`${R.hash}.js`);if(!await Bun.file(_).exists())await Bun.write(_,R.code);if(!w.has(R.hash)){w.add(R.hash);let T=Buffer.byteLength(R.code,"utf8");y+=T,h[R.hash]={bytes:T,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=O.map((R)=>R.hash),k=C,e.prefetchIslands)k=dt(k)}}if(await x.promises.mkdir(g.dirname(U),{recursive:!0}),await Bun.write(U,k),!_t(d,k,F,e.sitemapExclude))A.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let lt={route:d,outputPath:U,size:Buffer.byteLength(k,"utf8"),cached:nt};if(Q!==!1)lt.revalidateAt=Date.now()+Q*1000;l.pages.push(lt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(j){l.failedCount++,l.errors.push({route:d,error:j}),await e.hooks.onError?.(j,d),console.error(`Error generating ${d}:`,j)}}));let Y=bt();if(Y.length>0){let u=Y.map((m)=>`${m.filePath}: ${m.message}`).join(`
53
+ Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:O}=ut(k,{integrity:e.integrityIslands,minify:e.minify});if(O.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of O){let _=g.join(E,`${R.hash}.js`);if(!await Bun.file(_).exists())await Bun.write(_,R.code);if(!w.has(R.hash)){w.add(R.hash);let T=Buffer.byteLength(R.code,"utf8");y+=T,h[R.hash]={bytes:T,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=O.map((R)=>R.hash),k=C,e.prefetchIslands)k=dt(k)}}if(await x.promises.mkdir(g.dirname(U),{recursive:!0}),await Bun.write(U,k),!_t(d,k,F,e.sitemapExclude))A.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let nt={route:d,outputPath:U,size:Buffer.byteLength(k,"utf8"),cached:rt};if(Q!==!1)nt.revalidateAt=Date.now()+Q*1000;l.pages.push(nt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(j){l.failedCount++,l.errors.push({route:d,error:j}),await e.hooks.onError?.(j,d),console.error(`Error generating ${d}:`,j)}}));let Y=vt();if(Y.length>0){let u=Y.map((m)=>`${m.filePath}: ${m.message}`).join(`
54
54
  `);throw Error(`Client script bundling failed:
55
55
  ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.stx");if(await Bun.file(u).exists()){let m=new Set,v={...s,debug:!1,cache:!1},d=await n(await Bun.file(u).text(),{},u,v,m);await Bun.write(g.join(e.outputDir,"404.html"),d)}else await Bun.write(g.join(e.outputDir,"404.html"),`<!DOCTYPE html>
56
56
  <html lang="en">
@@ -73,7 +73,7 @@ ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.
73
73
  <a href="/">Go home</a>
74
74
  </div>
75
75
  </body>
76
- </html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=ur({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let N=Uo(e.outputDir);if(N.assets>0)console.log(`Externalized ${N.assets} asset(s) from ${N.pages} page(s) (${(N.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=Vo(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await V(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=sn();if(Z)await V(Z,g.join(e.outputDir,rn)),console.log(`Copied assets from ${ht}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
76
+ </html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=yr({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let N=Jo(e.outputDir);if(N.assets>0)console.log(`Externalized ${N.assets} asset(s) from ${N.pages} page(s) (${(N.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=Yo(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await V(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=cn();if(Z)await V(Z,g.join(e.outputDir,an)),console.log(`Copied assets from ${yt}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
77
77
  Island chunks: ${l.islandChunks.count} (${(l.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
78
78
  Build complete!
79
79
  Total: ${l.totalPages} pages
@@ -81,8 +81,8 @@ Build complete!
81
81
  Cached: ${l.cachedCount}
82
82
  Failed: ${l.failedCount}
83
83
  Time: ${l.buildTime}ms${P}
84
- `),l}async function V(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await V(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new wt(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=L(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await yt(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Ut(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
85
- `)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return He(t)}function Vt(t,i){return`<!DOCTYPE html>
84
+ `),l}async function V(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await V(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new mt(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=L(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await St(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Ut(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
85
+ `)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return Ve(t)}function Vt(t,i){return`<!DOCTYPE html>
86
86
  <html>
87
87
  <head>
88
88
  <meta charset="utf-8">
package/dist/testing.js CHANGED
@@ -23,6 +23,8 @@ export function shimAttributes(root) {
23
23
  const map = el.attributes;
24
24
  if (!(map instanceof Map))
25
25
  continue;
26
+ if (el.tagName === "INPUT" && !("indeterminate" in el))
27
+ el.indeterminate = !1;
26
28
  el.__attrMap = map;
27
29
  Object.defineProperty(el, "attributes", {
28
30
  configurable: !0,
@@ -304,6 +304,8 @@ export declare interface StxConfig {
304
304
  componentsDir: string
305
305
  _rootComponentsDir?: string
306
306
  _targetComponentDirs?: string[]
307
+ _targetComponentFallbackNames?: string[]
308
+ _nativeHostAttrs?: boolean
307
309
  layoutsDir?: string
308
310
  fallbackLayoutsDir?: string
309
311
  fallbackComponentsDir?: string
package/dist/utils.d.ts CHANGED
@@ -65,7 +65,7 @@ export declare function slotContentHasExpressions(slotContent: string): boolean;
65
65
  * named `title` also exists in the server context.
66
66
  */
67
67
  export declare function componentClientSignalNames(scripts: string[]): string[];
68
- export declare function renderComponentWithSlot(componentPath: string, props: Record<string, unknown>, slotContent: string, componentsDir: string, parentContext: Record<string, unknown>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>, clientLoopNames?: readonly string[], renderMetadata?: { declaredProps: Set<string> }, lookupName?: string): Promise<string>;
68
+ export declare function renderComponentWithSlot(componentPath: string, props: Record<string, unknown>, slotContent: string, componentsDir: string, parentContext: Record<string, unknown>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>, clientLoopNames?: readonly string[], renderMetadata?: { declaredProps: Set<string>, consumedProps?: Set<string>, reactiveProps?: string[] }, lookupName?: string): Promise<string>;
69
69
  /**
70
70
  * Check if a file exists
71
71
  */
package/dist/utils.js CHANGED
@@ -481,8 +481,10 @@ export async function userComponentFileExists(componentPath, componentsDir, pare
481
481
  push(options._rootComponentsDir);
482
482
  push(path.join(path.dirname(parentFilePath), "components"));
483
483
  push(options.componentsDir);
484
- for (const dir of options._targetComponentDirs ?? [])
485
- push(dir);
484
+ const targetIsFallback = options._targetComponentFallbackNames?.some((name) => name.toLowerCase() === baseName.toLowerCase());
485
+ if (!targetIsFallback)
486
+ for (const dir of options._targetComponentDirs ?? [])
487
+ push(dir);
486
488
  if (configuredRoot) {
487
489
  push(path.resolve(configuredRoot, "resources/views/components"));
488
490
  push(path.resolve(configuredRoot, "resources/components"));
@@ -496,6 +498,9 @@ export async function userComponentFileExists(componentPath, componentsDir, pare
496
498
  for (const dir of pluginDirs)
497
499
  push(typeof dir === "string" ? dir : null);
498
500
  push(options.fallbackComponentsDir);
501
+ if (targetIsFallback)
502
+ for (const dir of options._targetComponentDirs ?? [])
503
+ push(dir);
499
504
  if (baseName.startsWith("./") || baseName.startsWith("../"))
500
505
  return fileExists(path.resolve(path.dirname(parentFilePath), `${baseName}.stx`));
501
506
  const ownComponentsDir = realDir(path.resolve(import.meta.dir, "components")), resolvedDirs = searchDirs.map((dir) => path.isAbsolute(dir) ? dir : path.resolve(resolveBase, dir)), key = `${variants.join("\x00")}\x00\x00${resolvedDirs.join("\x00")}`, known = userComponentFileCache.get(key);
@@ -630,7 +635,8 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
630
635
  searchDirs.push(parentRelative);
631
636
  if (options.componentsDir && options.componentsDir !== componentsDir && !searchDirs.includes(options.componentsDir))
632
637
  searchDirs.push(options.componentsDir);
633
- for (const dir of options._targetComponentDirs ?? [])
638
+ const targetIsFallback = options._targetComponentFallbackNames?.some((name) => name.toLowerCase() === baseName.toLowerCase());
639
+ for (const dir of targetIsFallback ? [] : options._targetComponentDirs ?? [])
634
640
  if (dir && !searchDirs.includes(dir))
635
641
  searchDirs.push(dir);
636
642
  const configuredRoot = typeof options.root === "string" ? path.resolve(options.root) : void 0, resolveBase = configuredRoot ?? path.dirname(parentFilePath), fallbackDirs = [];
@@ -652,6 +658,11 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
652
658
  }
653
659
  if (options.fallbackComponentsDir && !searchDirs.includes(options.fallbackComponentsDir))
654
660
  searchDirs.push(options.fallbackComponentsDir);
661
+ if (targetIsFallback) {
662
+ for (const dir of options._targetComponentDirs ?? [])
663
+ if (dir && !searchDirs.includes(dir))
664
+ searchDirs.push(dir);
665
+ }
655
666
  const normalizedSearchDirs = [...new Set(searchDirs.map((dir) => {
656
667
  if (!dir)
657
668
  return dir;
@@ -742,13 +753,15 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
742
753
  return unresolvedComponentMarkup(componentPath);
743
754
  }
744
755
  if (renderMetadata)
745
- for (const propName of Object.keys(props)) {
756
+ for (const propName of new Set([...Object.keys(props), ...renderMetadata.reactiveProps ?? []])) {
746
757
  const normalized = propName.toLowerCase();
747
758
  if (normalized.startsWith("aria-") || normalized.startsWith("data-"))
748
759
  continue;
749
760
  const escaped = propName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
750
761
  if (new RegExp(`\\b${escaped}\\b`).test(componentContent))
751
762
  renderMetadata.declaredProps.add(propName);
763
+ if (new RegExp(`\\$props\\s*(?:\\.\\s*${escaped}\\b|\\[\\s*['"]${escaped}['"]\\s*\\])`).test(componentContent) || new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${escaped}['"]`).test(componentContent))
764
+ renderMetadata.consumedProps?.add(propName);
752
765
  }
753
766
  const internalKeysToPreserve = new Set([
754
767
  "__originalFilePath",
@@ -1354,8 +1367,14 @@ async function buildComponentIsland(rawContent, componentFilePath, minify) {
1354
1367
  __scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
1355
1368
  __scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
1356
1369
  __scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
1370
+ let __registeringSetupHooks = true;
1357
1371
  const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
1358
- const onDestroy = (fn) => { __scopeVars.__destroyCallbacks.push(fn); __scopeVars.__destroyHooks.push(fn); };
1372
+ const onDestroy = (fn) => {
1373
+ __scopeVars.__destroyCallbacks.push(fn);
1374
+ // A teardown registered inside onMount belongs to this mount alone.
1375
+ // Replaying it AND registering the next mount's teardown doubles cleanup.
1376
+ if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
1377
+ };
1359
1378
 
1360
1379
  try {
1361
1380
  ${content}
@@ -1370,6 +1389,7 @@ catch (e) {}
1370
1389
  Object.assign(__scopeVars, __localVars);
1371
1390
  }
1372
1391
  finally {
1392
+ __registeringSetupHooks = false;
1373
1393
  window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
1374
1394
  window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
1375
1395
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.583",
4
+ "version": "0.2.585",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -128,12 +128,12 @@
128
128
  "dependencies": {
129
129
  "@stacksjs/ts-css": "^0.3.11",
130
130
  "@stacksjs/clapp": "^0.2.16",
131
- "@stacksjs/desktop": "0.2.583",
132
- "@stacksjs/sanitizer": "0.2.583",
131
+ "@stacksjs/desktop": "0.2.585",
132
+ "@stacksjs/sanitizer": "0.2.585",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
- "bun-plugin-stx": "0.2.583",
134
+ "bun-plugin-stx": "0.2.585",
135
135
  "bunfig": "^0.15.21",
136
- "stx-router": "0.2.583",
136
+ "stx-router": "0.2.585",
137
137
  "ts-broadcasting": "^0.0.11",
138
138
  "ts-images": "^0.2.22",
139
139
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,3 +0,0 @@
1
- // @bun
2
- import i from"path";var Pt=".stx",o="STX_DIR",e=null;function Di(t){e=t?.trim()||null}function mn(){return process.env[o]?.trim()||e||Pt}function a(t=process.cwd(),...n){let r=mn();return i.isAbsolute(r)?i.join(r,...n):i.join(t,r,...n)}function hn(t){if(!t||i.isAbsolute(t))return t;let n=t.replace(/\\/g,"/");if(n!==Pt&&!n.startsWith(`${Pt}/`))return t;let r=n.slice(Pt.length+1);return r?i.join(mn(),r):mn()}
3
- export{Pt,Di,mn,a,hn};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Qu,si,ed,oi,vc,wc,$t,pn,td,xc,Sc,nd,f}from"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{$t as buildCss,xc as extractClassNames,wc as fingerprintConfig,Sc as generateCss,td as getCachedCSS,Qu as getCssServeAsset,f as injectCss,si as loadCssEngine,oi as loadCssEngineConfig,pn as rebuildCss,ed as resetCssCache,vc as resolveUserCssConfig,nd as withLinkedModuleBundles};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Vn,Yr,Qa,ec,tc}from"./chunk-xytkfa48.js";import"./chunk-hp9nxva6.js";export{ec as generateManifestLink,Vn as generatePwaTags,Qa as generateSwRegistrationScript,tc as generateThemeColorMeta,Yr as injectPwaTags};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{A,qc,As,o,P,ld,ud}from"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{P as config,A as defaultConfig,ld as defineStxConfig,As as discoverConfig,o as loadStxConfig,qc as resolveStxDirectories,ud as validateConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ne,Zt,gu}from"./chunk-wyn5rfzk.js";import{W,Qt,mu,en,Gr,zn,Hn,hu,yu,bu,tn,nn,Kr,Un,vu}from"./chunk-w6wtxj54.js";import"./chunk-dvc15djp.js";export{Gr as batch,gu as default,Qt as derived,en as effect,Ne as generateSignalsRuntime,Zt as generateSignalsRuntimeDev,nn as isDerived,tn as isSignal,mu as memo,Hn as onDestroy,zn as onMount,Un as peek,bu as pendingLifecycleCounts,yu as runDestroyCallbacks,hu as runMountCallbacks,W as state,Kr as untrack,vu as useOptimistic};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import a from"fs";function Me(r){return o(r)}var g=1000,i=new Map;function Yt(){i.clear()}function o(r){return[...r].sort().map((n)=>{try{let t=a.statSync(n);return`${n}:${t.size}:${t.mtimeMs}`}catch{return`${n}:missing`}}).join(`
3
- `)}function mt(r,n,t){let e=r.get(n);return e!==void 0&&e.signature===t?e.value:void 0}function V(r,n,t,e){return r.set(n,{signature:t,value:e}),e}
4
- export{Me,Yt,mt,V};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{qr,Wl,ql}from"./chunk-6fc8vw2v.js";import"./chunk-4pkpr5cg.js";import"./chunk-nh3svtvj.js";import"./chunk-ktyctev3.js";import"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{ql as clearComposableCache,Wl as getComposableScript,qr as listComposableModules};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Gl}from"./chunk-s12bnv32.js";export{Gl as processDeferDirectives};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ao,Ua,Jt,Ul,Va,Wa,qa,Vl}from"./chunk-kfwmqacd.js";export{Jt as Validator,Ua as defineForm,Va as processErrorDirective,Wa as processErrorsDirective,Vl as processFormValidationDirectives,qa as processHasErrorsDirective,Ao as useForm,Ul as v};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ls,us,ds,rd,Zn,sd}from"./chunk-n4e02qdz.js";export{Zn as clearImageDeliveryCatalog,rd as deliveredImage,ds as efficientDeliverySources,ls as getImageDelivery,us as isTransparentImage,sd as prepareImageDelivery};
@@ -1,3 +0,0 @@
1
- // @bun
2
- function E(){let{NODE_ENV:n}=process.env;return n==="production"}function M(){let{STX_DEBUG:n}=process.env;return!E()||n==="true"}function En(){let{NODE_ENV:n}=process.env;return n==="test"}function Ws(n){return n==="compile"||E()}function Tn(n){if(!n)return n;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(n).trim()}catch{return n}}
3
- export{E,M,En,Ws,Tn};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{fn,Cc,hs}from"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import{_e}from"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{_e as freeIdentifiers,hs as processComponents,Cc as processESImports,fn as rendersAsElement};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ba,Pl,va,wa,Il,Ol}from"./chunk-0dfgefjv.js";import"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{Ol as applySlots,Il as extractSlotContent,Pl as parseSlotElement,ba as parseSlots,wa as processSlots,va as renderSlot};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Oa,Da,Ma,Na,La,ja,Ba,Fa,za,Ha,Hl}from"./chunk-qccgncp2.js";export{Oa as createIslandRegistry,Hl as default,Ha as generateIslandManifest,Ma as generatePartialHydrationCSS,ja as hydrateAll,La as hydrateByStrategy,Na as hydrateIsland,Ba as isHydrated,Fa as onHydrated,Da as processPartialHydrationDirectives,za as processStaticDirectives};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{qo,Go,Ko,Ya,Za}from"./chunk-c0h2eqe0.js";export{Go as auditBuildOutput,qo as auditConfig,Ko as calculateAuditResult,Za as formatAuditResult,Ya as runPwaAudit};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{kt,es,ts,ns,Bu,rs}from"./chunk-nh3svtvj.js";import"./chunk-sv08pd66.js";import"./chunk-vkc51n9m.js";import"./chunk-x552npae.js";export{ts as buildServerApi,Bu as createServerApi,kt as discoverServerApi,es as generateApiTypes,rs as isServerApiSource,ns as productionApiDispatcher};