@stacksjs/stx 0.2.588 → 0.2.590

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 (164) hide show
  1. package/dist/{chunk-s043hpvd.js → chunk-04gt67sv.js} +1 -1
  2. package/dist/chunk-122y2fkw.js +3 -0
  3. package/dist/chunk-138zjhwa.js +2 -0
  4. package/dist/{chunk-751b5zv9.js → chunk-14t0wps0.js} +1 -1
  5. package/dist/{chunk-03qf2z4d.js → chunk-18ws9heh.js} +1 -1
  6. package/dist/{chunk-33q5zka4.js → chunk-1944jgb2.js} +1 -1
  7. package/dist/{chunk-tc15vkfh.js → chunk-25zpd110.js} +2 -2
  8. package/dist/{chunk-emxa2djv.js → chunk-2qt63502.js} +1 -1
  9. package/dist/{chunk-qhr1tkhj.js → chunk-38mt83wa.js} +6 -6
  10. package/dist/chunk-3bx12g3y.js +2 -0
  11. package/dist/{chunk-j8v5164e.js → chunk-3q312svf.js} +1 -1
  12. package/dist/chunk-3vcvsc17.js +2 -0
  13. package/dist/{chunk-k1szsenr.js → chunk-48s1nprc.js} +2 -2
  14. package/dist/{chunk-qf3axv86.js → chunk-4st1qw62.js} +2 -2
  15. package/dist/chunk-55bmmwtx.js +2 -0
  16. package/dist/{chunk-cqr5cv7h.js → chunk-5rs5jnqk.js} +5 -5
  17. package/dist/chunk-64xcx3y4.js +2 -0
  18. package/dist/{chunk-y5x8xnnf.js → chunk-6eg9a3mt.js} +2 -2
  19. package/dist/{chunk-3qmx12d3.js → chunk-6qnemg0e.js} +298 -298
  20. package/dist/{chunk-ww28zfwt.js → chunk-7b0svfg0.js} +1 -1
  21. package/dist/chunk-7frsbxzd.js +2 -0
  22. package/dist/chunk-7nr3f2bw.js +2 -0
  23. package/dist/chunk-83rmpb0b.js +2 -0
  24. package/dist/chunk-88mj71mb.js +2 -0
  25. package/dist/{chunk-9qsnq026.js → chunk-9cgga2aw.js} +2 -2
  26. package/dist/{chunk-45x4myqe.js → chunk-9e49fnj9.js} +2 -2
  27. package/dist/{chunk-f29fk7dw.js → chunk-9h1ytsgm.js} +2 -2
  28. package/dist/{chunk-jtx74677.js → chunk-9q079ttt.js} +1 -1
  29. package/dist/chunk-9t6gzmze.js +2 -0
  30. package/dist/{chunk-vf15db1j.js → chunk-9wtb959p.js} +5 -5
  31. package/dist/{chunk-794v5crp.js → chunk-9x4r15mv.js} +2 -2
  32. package/dist/{chunk-pxw4edw8.js → chunk-a7crvy3b.js} +2 -2
  33. package/dist/chunk-acm2tym9.js +2 -0
  34. package/dist/{chunk-c6egfhy6.js → chunk-b3c1gggs.js} +2 -2
  35. package/dist/chunk-bd5gxtt2.js +2 -0
  36. package/dist/chunk-bepj7q9j.js +2 -0
  37. package/dist/{chunk-t212h9zm.js → chunk-cxhqps9m.js} +1 -1
  38. package/dist/chunk-d81h4mxd.js +2 -0
  39. package/dist/{chunk-b217d16p.js → chunk-dbp1sj5f.js} +36 -36
  40. package/dist/chunk-dgtxj56t.js +3 -0
  41. package/dist/chunk-ds66kaac.js +127 -0
  42. package/dist/chunk-emx9v5z8.js +2 -0
  43. package/dist/chunk-eqa0wdv9.js +4 -0
  44. package/dist/{chunk-haag5n42.js → chunk-f17rcvdb.js} +1 -1
  45. package/dist/chunk-ffykng6w.js +2 -0
  46. package/dist/{chunk-076h7nb9.js → chunk-fjw3sn55.js} +5 -5
  47. package/dist/chunk-fn9gdw2x.js +2 -0
  48. package/dist/{chunk-bhg4pvtn.js → chunk-frm8k9gj.js} +1 -1
  49. package/dist/chunk-fwt5fh5w.js +2 -0
  50. package/dist/{chunk-m7ddgrsm.js → chunk-g6ew2drc.js} +4 -4
  51. package/dist/{chunk-6cg03r93.js → chunk-g7fjra7a.js} +4 -4
  52. package/dist/{chunk-03xsf9jm.js → chunk-gh181dnr.js} +8 -8
  53. package/dist/{chunk-6hgngmn0.js → chunk-gzpxvca7.js} +1 -1
  54. package/dist/{chunk-d0tmc6v5.js → chunk-h9gbsgrt.js} +1 -1
  55. package/dist/{chunk-qx0tcsdm.js → chunk-hhcmn37g.js} +3 -3
  56. package/dist/chunk-hhwnd24n.js +2 -0
  57. package/dist/chunk-hq4mtcp0.js +2 -0
  58. package/dist/{chunk-7fghm9zy.js → chunk-j1dmkt29.js} +1 -1
  59. package/dist/chunk-jhswy523.js +2 -0
  60. package/dist/{chunk-mmbspaqh.js → chunk-jtq8e3b0.js} +2 -2
  61. package/dist/chunk-jyqanvwp.js +2 -0
  62. package/dist/chunk-k6bmhf83.js +2 -0
  63. package/dist/{chunk-3ybbat49.js → chunk-khdvzjzd.js} +1 -1
  64. package/dist/{chunk-q03kn4d1.js → chunk-krvaknk7.js} +1 -1
  65. package/dist/{chunk-30acme5g.js → chunk-kx52xt96.js} +2 -2
  66. package/dist/chunk-m0ngddr1.js +2 -0
  67. package/dist/{chunk-yhhfxx17.js → chunk-mkmgy50k.js} +4 -4
  68. package/dist/chunk-n06xznty.js +2 -0
  69. package/dist/{chunk-048eyjyj.js → chunk-nb0ytx70.js} +2 -2
  70. package/dist/chunk-nft0k8sy.js +2 -0
  71. package/dist/{chunk-wkrf41se.js → chunk-nmfnstjg.js} +1 -1
  72. package/dist/chunk-p69ay3bg.js +2 -0
  73. package/dist/{chunk-hj8tr9g0.js → chunk-p9yqetnj.js} +1 -1
  74. package/dist/{chunk-07869zev.js → chunk-pb7vste8.js} +3 -3
  75. package/dist/chunk-pbvtyw5h.js +2 -0
  76. package/dist/{chunk-a30mtx17.js → chunk-ph2hzxz7.js} +2 -2
  77. package/dist/chunk-pq9yr5f5.js +2 -0
  78. package/dist/chunk-q5rqp7rm.js +2 -0
  79. package/dist/{chunk-cy07dhqh.js → chunk-q66ry997.js} +2 -2
  80. package/dist/{chunk-pg164sdw.js → chunk-q6h6yjg4.js} +2 -2
  81. package/dist/{chunk-91pdg853.js → chunk-qf39z0hg.js} +3 -3
  82. package/dist/chunk-qhy84exn.js +2 -0
  83. package/dist/chunk-san161h4.js +2 -0
  84. package/dist/{chunk-7ydavm3h.js → chunk-shnsvsg4.js} +2 -2
  85. package/dist/{chunk-kfhghjh6.js → chunk-shnvs7x9.js} +2 -2
  86. package/dist/{chunk-s2h601k7.js → chunk-sjehpstn.js} +7 -7
  87. package/dist/{chunk-w24qmxc3.js → chunk-t19th11m.js} +1 -1
  88. package/dist/{chunk-awgvt956.js → chunk-tc3ne706.js} +9 -9
  89. package/dist/chunk-td7a6wwq.js +2 -0
  90. package/dist/{chunk-3y5tzxm6.js → chunk-tds3d65g.js} +2 -2
  91. package/dist/{chunk-mnnxa3r7.js → chunk-vhgdz0qf.js} +2 -2
  92. package/dist/{chunk-j7kcjgxy.js → chunk-vn6h03nq.js} +68 -40
  93. package/dist/chunk-w3k1r8r5.js +2 -0
  94. package/dist/{chunk-e556dvy4.js → chunk-wkxzzdzs.js} +2 -2
  95. package/dist/{chunk-ns1jqzqk.js → chunk-wr6gw263.js} +1 -1
  96. package/dist/chunk-wrp7m33d.js +2 -0
  97. package/dist/{chunk-7xw1e8t6.js → chunk-y0qjpcc8.js} +3 -3
  98. package/dist/chunk-y3g9jaa4.js +2 -0
  99. package/dist/{chunk-fkq55rh7.js → chunk-y3wdf7v7.js} +1 -1
  100. package/dist/chunk-y6909jm7.js +2 -0
  101. package/dist/{chunk-ede39b7h.js → chunk-zvs13kgh.js} +2 -2
  102. package/dist/cli.js +14 -14
  103. package/dist/client/signals-component-hydration-runtime.js +57 -29
  104. package/dist/craft-entry.js +1 -1
  105. package/dist/craft.js +1 -1
  106. package/dist/dev-server/ts-css.js +7 -2
  107. package/dist/native/compiler/app-theme.d.ts +9 -0
  108. package/dist/native/compiler/app-theme.js +51 -0
  109. package/dist/native/compiler/bundle.js +7 -3
  110. package/dist/native/compiler/headwind-to-style.d.ts +6 -0
  111. package/dist/native/compiler/headwind-to-style.js +7 -0
  112. package/dist/native/compiler/html-to-ir.js +7 -1
  113. package/dist/native/compiler/render-screen.js +2 -1
  114. package/dist/native/runtime/craft-bridge.js +1 -1
  115. package/dist/native/ui.d.ts +90 -0
  116. package/dist/native/ui.js +37 -0
  117. package/dist/pwa.js +3 -3
  118. package/dist/ssg.js +10 -10
  119. package/dist/theme-tokens.d.ts +38 -3
  120. package/dist/theme-tokens.js +18 -6
  121. package/dist/ts-css-config.d.ts +1 -0
  122. package/dist/ts-css-config.js +4 -3
  123. package/package.json +5 -5
  124. package/dist/chunk-11jmasqb.js +0 -2
  125. package/dist/chunk-2wx2aczp.js +0 -2
  126. package/dist/chunk-4dpab4j6.js +0 -2
  127. package/dist/chunk-4vnwge6p.js +0 -2
  128. package/dist/chunk-4w37cqg9.js +0 -2
  129. package/dist/chunk-51pz8cwa.js +0 -2
  130. package/dist/chunk-65agttgm.js +0 -2
  131. package/dist/chunk-7ae40484.js +0 -2
  132. package/dist/chunk-7dtyf7hq.js +0 -2
  133. package/dist/chunk-7ebt9n43.js +0 -4
  134. package/dist/chunk-80g8kaes.js +0 -2
  135. package/dist/chunk-9pk5jhqa.js +0 -3
  136. package/dist/chunk-a3d5g1ss.js +0 -122
  137. package/dist/chunk-a3k4nfq2.js +0 -2
  138. package/dist/chunk-c8fdccgp.js +0 -2
  139. package/dist/chunk-cw76edds.js +0 -2
  140. package/dist/chunk-czrs87r9.js +0 -2
  141. package/dist/chunk-d9vjsqs4.js +0 -2
  142. package/dist/chunk-ddgyj88h.js +0 -2
  143. package/dist/chunk-dj90w48e.js +0 -2
  144. package/dist/chunk-dngzks8e.js +0 -2
  145. package/dist/chunk-eztvhppz.js +0 -2
  146. package/dist/chunk-h2534p6q.js +0 -2
  147. package/dist/chunk-h9gtc6bk.js +0 -2
  148. package/dist/chunk-hwnvfke9.js +0 -2
  149. package/dist/chunk-hygxh993.js +0 -2
  150. package/dist/chunk-jqy5q8m0.js +0 -2
  151. package/dist/chunk-jy7yzat1.js +0 -2
  152. package/dist/chunk-n7yk4nc1.js +0 -2
  153. package/dist/chunk-qd4snptd.js +0 -2
  154. package/dist/chunk-r90v2jz6.js +0 -2
  155. package/dist/chunk-rtgf9fgc.js +0 -2
  156. package/dist/chunk-sjkdpsca.js +0 -3
  157. package/dist/chunk-sqpme1hg.js +0 -2
  158. package/dist/chunk-thydj877.js +0 -2
  159. package/dist/chunk-vv1kr9dn.js +0 -2
  160. package/dist/chunk-wm9nzg76.js +0 -2
  161. package/dist/chunk-x5qymgxa.js +0 -2
  162. package/dist/chunk-xnbkyj4g.js +0 -2
  163. package/dist/chunk-xyepqdjy.js +0 -2
  164. package/dist/chunk-y93y2qat.js +0 -2
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The grouped look a native screen is built from, in role classes.
3
+ *
4
+ * Apple's Settings shape: a grouped page, inset groups with rounded corners,
5
+ * 13pt uppercase section headers, 17pt rows at least 44pt tall, hairlines
6
+ * inset to where the text starts, secondary text a step back, and one colour
7
+ * for what can be tapped. Bound as `:class="ui.group"` and the like.
8
+ *
9
+ * Two apps each kept a copy of this vocabulary as literal colours - one in
10
+ * Apple's greys and blue, one in its own greens - and roughly a thousand hex
11
+ * values between them repeated it inline. Written in roles instead, the
12
+ * vocabulary is shared and each app's palette comes from its css config
13
+ * (`roles: { page, panel, fg, accent, ... }`, see docs/features/theming.md),
14
+ * which reaches a native screen as well as the web.
15
+ *
16
+ * import { nativeUi as ui } from '@stacksjs/stx/native/ui'
17
+ * <View :class="ui.screen"><Text :class="ui.header">Account</Text><View :class="ui.group">…</View></View>
18
+ *
19
+ * The shared components (`GroupedList`, `SegmentedControl`, `ChoiceChips`,
20
+ * `EmptyState`, `ErrorState`) draw the same shapes from the same roles, so a
21
+ * screen can mix them with hand-built rows and nothing looks borrowed.
22
+ *
23
+ * @module native/ui
24
+ */
25
+ export declare const nativeUi: {
26
+ /** The whole screen: the grouped page behind every group. */
27
+ screen: 'flex-1 bg-page';
28
+ /** A section's header, above a group. */
29
+ header: 'mx-8 mt-7 mb-1.5 text-[13px] uppercase text-fg-soft';
30
+ /** A note under a group. */
31
+ footer: 'mx-8 mt-1.5 text-[13px] text-fg-soft';
32
+ /** An inset grouped section holding rows. */
33
+ group: 'mx-4 overflow-hidden rounded-panel bg-panel';
34
+ /** A group holding a drawing or a block of content rather than rows. */
35
+ card: 'mx-4 p-4 rounded-panel bg-panel';
36
+ /** A row in a group. */
37
+ row: 'flex-row items-center gap-3 px-4 py-2.5 min-h-[44px]';
38
+ /** The hairline between rows, inset to where their text starts. */
39
+ separator: 'ml-4 h-[0.5px] bg-line';
40
+ /** The same, past a 29pt icon tile. */
41
+ separatorIcon: 'ml-[57px] h-[0.5px] bg-line';
42
+ /** A screen's own heading, where the navigation bar does not carry one. */
43
+ heading: 'text-[30px] font-bold text-fg';
44
+ /** A row's main words. */
45
+ title: 'text-[17px] text-fg';
46
+ /** A row's main words, emphasised. */
47
+ titleStrong: 'text-[17px] font-semibold text-fg';
48
+ /** Running text. */
49
+ body: 'text-[17px] text-fg-strong';
50
+ /** A line under a title. */
51
+ subtitle: 'text-[15px] text-fg-soft';
52
+ /** Small print: a caption, a date, a unit. */
53
+ caption: 'text-[13px] text-fg-soft';
54
+ /** A value at a row's end. */
55
+ value: 'text-[17px] text-fg-soft';
56
+ /** A big number in a stat. */
57
+ figure: 'text-[22px] font-semibold text-fg';
58
+ /** The disclosure chevron: it says the row opens something, so it stays legible. */
59
+ chevron: 'h-3.5 w-3.5 text-fg-soft';
60
+ /** Something to tap, as words. */
61
+ tint: 'text-accent';
62
+ /** Something that cannot be undone, as words. */
63
+ destructive: 'text-danger';
64
+ /** A status that needs attention but is not an error. */
65
+ warning: 'text-warning';
66
+ /** A form field. */
67
+ input: 'min-h-[44px] px-3 rounded-control bg-surface-sunken text-[17px] text-fg';
68
+ /** The search field at the top of a list. */
69
+ search: 'flex-row items-center gap-2 mx-4 px-2.5 h-9 rounded-control bg-surface-sunken';
70
+ /** The filled button at the end of a flow, and its words. */
71
+ primaryButton: 'items-center justify-center min-h-[50px] px-4 rounded-control bg-accent-solid';
72
+ primaryButtonText: 'text-[17px] font-semibold text-accent-ink';
73
+ /** A quieter button beside it, and its words. */
74
+ secondaryButton: 'items-center justify-center min-h-[44px] px-3 rounded-control bg-surface-sunken';
75
+ secondaryButtonText: 'text-[15px] font-semibold text-fg-strong';
76
+ /** A button floating over a map or a photograph. */
77
+ floatingButton: 'items-center justify-center min-h-[44px] px-3 rounded-pill bg-panel shadow-md';
78
+ /** A filled destructive button, and its words. */
79
+ destructiveButton: 'items-center justify-center min-h-[50px] px-4 rounded-control bg-danger-solid';
80
+ destructiveButtonText: 'text-[17px] font-semibold text-danger-ink';
81
+ /** A rounded-square icon tile leading a row; its glyph is white. */
82
+ iconTile: 'items-center justify-center h-[29px] w-[29px] rounded-[7px] bg-accent-solid';
83
+ iconGlyph: 'h-[18px] w-[18px] text-white';
84
+ /** A tinted note: a notice, a threat, a status that is good news. */
85
+ noticeAccent: 'p-3 rounded-panel bg-accent-soft';
86
+ noticeAccentText: 'text-[15px] text-accent-soft-ink';
87
+ noticeDanger: 'p-3 rounded-panel bg-danger-soft';
88
+ noticeDangerText: 'text-[15px] text-danger-soft-ink'
89
+ };
90
+ export type NativeUiClass = keyof typeof nativeUi;
@@ -0,0 +1,37 @@
1
+ export const nativeUi = {
2
+ screen: "flex-1 bg-page",
3
+ header: "mx-8 mt-7 mb-1.5 text-[13px] uppercase text-fg-soft",
4
+ footer: "mx-8 mt-1.5 text-[13px] text-fg-soft",
5
+ group: "mx-4 overflow-hidden rounded-panel bg-panel",
6
+ card: "mx-4 p-4 rounded-panel bg-panel",
7
+ row: "flex-row items-center gap-3 px-4 py-2.5 min-h-[44px]",
8
+ separator: "ml-4 h-[0.5px] bg-line",
9
+ separatorIcon: "ml-[57px] h-[0.5px] bg-line",
10
+ heading: "text-[30px] font-bold text-fg",
11
+ title: "text-[17px] text-fg",
12
+ titleStrong: "text-[17px] font-semibold text-fg",
13
+ body: "text-[17px] text-fg-strong",
14
+ subtitle: "text-[15px] text-fg-soft",
15
+ caption: "text-[13px] text-fg-soft",
16
+ value: "text-[17px] text-fg-soft",
17
+ figure: "text-[22px] font-semibold text-fg",
18
+ chevron: "h-3.5 w-3.5 text-fg-soft",
19
+ tint: "text-accent",
20
+ destructive: "text-danger",
21
+ warning: "text-warning",
22
+ input: "min-h-[44px] px-3 rounded-control bg-surface-sunken text-[17px] text-fg",
23
+ search: "flex-row items-center gap-2 mx-4 px-2.5 h-9 rounded-control bg-surface-sunken",
24
+ primaryButton: "items-center justify-center min-h-[50px] px-4 rounded-control bg-accent-solid",
25
+ primaryButtonText: "text-[17px] font-semibold text-accent-ink",
26
+ secondaryButton: "items-center justify-center min-h-[44px] px-3 rounded-control bg-surface-sunken",
27
+ secondaryButtonText: "text-[15px] font-semibold text-fg-strong",
28
+ floatingButton: "items-center justify-center min-h-[44px] px-3 rounded-pill bg-panel shadow-md",
29
+ destructiveButton: "items-center justify-center min-h-[50px] px-4 rounded-control bg-danger-solid",
30
+ destructiveButtonText: "text-[17px] font-semibold text-danger-ink",
31
+ iconTile: "items-center justify-center h-[29px] w-[29px] rounded-[7px] bg-accent-solid",
32
+ iconGlyph: "h-[18px] w-[18px] text-white",
33
+ noticeAccent: "p-3 rounded-panel bg-accent-soft",
34
+ noticeAccentText: "text-[15px] text-accent-soft-ink",
35
+ noticeDanger: "p-3 rounded-panel bg-danger-soft",
36
+ noticeDangerText: "text-[15px] text-danger-soft-ink"
37
+ };
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
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>
2
+ import{Qn,He,ni,lc}from"./chunk-pb7vste8.js";import{Zn,ss,ic,ac,cc}from"./chunk-9wtb959p.js";import{Qo,ei,ti,sc,oc}from"./chunk-a8n6mt7s.js";import{ce,St,os}from"./chunk-4st1qw62.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-3bx12g3y.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=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};
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=ce(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Qn(n,t);if(a){let s=He(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 ae(n,t){return ss(n,t)}function se(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,ce as generatePrecacheManifest,St as generatePrecacheManifestJs,M as generatePwaIcons,Zn as generatePwaTags,Qn as generateServiceWorker,lc as generateServiceWorkerAuto,ic as generateSwRegistrationScript,cc as generateThemeColorMeta,N as getExpectedIconPaths,He as getServiceWorkerFileName,ss as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ni as isWorkboxEnabled,q as mergeManifestConfig,ae 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-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(`
2
+ import"./chunk-tds3d65g.js";import"./chunk-38mt83wa.js";import"./chunk-v8ze2q95.js";import{ct,lt,ut,dt,pt,ft}from"./chunk-a7crvy3b.js";import"./chunk-b3c1gggs.js";import"./chunk-jtq8e3b0.js";import{f,Ge,L,J,n,o}from"./chunk-6qnemg0e.js";import"./chunk-gh181dnr.js";import{yr}from"./chunk-qf39z0hg.js";import"./chunk-48s1nprc.js";import"./chunk-9e49fnj9.js";import"./chunk-82bttwqm.js";import"./chunk-k71e38fk.js";import"./chunk-mkmgy50k.js";import{le,kt,Ct}from"./chunk-5rs5jnqk.js";import{Jo,Yo,Zo}from"./chunk-zrw1zf54.js";import{xt,un,dn}from"./chunk-122y2fkw.js";import"./chunk-t19th11m.js";import{a}from"./chunk-dgtxj56t.js";import x from"fs";import g from"path";import{createHash as Pt}from"crypto";function $t(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Dt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Rt(t){return Bun.hash(t).toString(16)}function it(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(Dt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=$t(h);let S=Rt(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Pt("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 st(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 at(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=at(e.default??e);if(l)return l}catch{}}return null}async function ot(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=at(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 gt(){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 ht{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,8 +8,8 @@ import"./chunk-3y5tzxm6.js";import"./chunk-qhr1tkhj.js";import"./chunk-v8ze2q95.
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 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
- 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}
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 wt(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
+ 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 le(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"?>
15
15
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@@ -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();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",`
44
+ </rss>`}async function zt(t={}){let i=Date.now();Ct();let s=await o(process.cwd()),r=s.build||{},c=await ot({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(gt());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-64xcx3y4.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-krvaknk7.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 ht(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-64xcx3y4.js");await u('<div class="bg-black"></div>')}catch{}ct();let yt=s?.routeMiddleware?.dir||"middleware";await ut(process.cwd(),yt);let H=lt();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let St=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:vt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),bt=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...St,...bt];if(tt.length>0){let C=dt(d,M,F||{}),O=pt(C,null,void 0,{isServer:!0}),E=await ft(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,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:
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 wt(v,M,vt,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 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(`
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}=it(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=st(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=kt();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=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?`
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=dn();if(Z)await V(Z,g.join(e.outputDir,un)),console.log(`Copied assets from ${xt}`)}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 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>
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 wt(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 Ge(t)}function Vt(t,i){return`<!DOCTYPE html>
86
86
  <html>
87
87
  <head>
88
88
  <meta charset="utf-8">
@@ -1,5 +1,13 @@
1
1
  /** The CSS custom property that backs a role. */
2
2
  export declare function tokenVariable(name: string): string;
3
+ /**
4
+ * Names in an app's overrides that stx has no role for.
5
+ *
6
+ * Returned rather than thrown: a renamed role should not take a site down,
7
+ * but it must not be silent either - an unanswered role is a component
8
+ * quietly drawing the stock colour, which reads as a design decision.
9
+ */
10
+ export declare function unknownRoleNames(overrides?: ThemeRoleOverrides): string[];
3
11
  /**
4
12
  * The palette entries to merge into `theme.colors`.
5
13
  *
@@ -18,7 +26,7 @@ export declare function semanticColors(palette: Palette): Record<string, string>
18
26
  * compile to `.dark .dark\:x`), so a token and a `dark:` utility on the same
19
27
  * page agree about what dark mode is.
20
28
  */
21
- export declare function semanticTokenCSS(palette: Palette): string;
29
+ export declare function semanticTokenCSS(palette: Palette, roles?: Record<string, RoleColor>): string;
22
30
  /** Every variable a role token reads, for documentation and tooling. */
23
31
  export declare function semanticTokenNames(): string[];
24
32
  /** The CSS custom property that backs a shape role. */
@@ -38,7 +46,7 @@ export declare function shapeRadii(): Record<string, string>;
38
46
  * No `.dark` counterpart: a radius does not change with the colour scheme, and
39
47
  * emitting an empty dark block would invite someone to fill it in.
40
48
  */
41
- export declare function shapeTokenCSS(): string;
49
+ export declare function shapeTokenCSS(shapes?: Record<string, string>): string;
42
50
  /** Every variable a shape role reads, for documentation and tooling. */
43
51
  export declare function shapeTokenNames(): string[];
44
52
  /** The CSS custom property that backs a density role. */
@@ -62,7 +70,7 @@ export declare function densityFontSizes(): Record<string, [string, { lineHeight
62
70
  * No `.dark` counterpart, for the reason the shape roles have none: room does
63
71
  * not change with the colour scheme.
64
72
  */
65
- export declare function densityTokenCSS(): string;
73
+ export declare function densityTokenCSS(density?: Record<string, string>): string;
66
74
  /** Every variable a density role reads, for documentation and tooling. */
67
75
  export declare function densityTokenNames(): string[];
68
76
  /**
@@ -481,4 +489,31 @@ export declare interface SemanticToken {
481
489
  dark: string
482
490
  description: string
483
491
  }
492
+ /**
493
+ * Role values an app declares in its css config, beside `theme`.
494
+ *
495
+ * export default {
496
+ * roles: { accent: { light: 'emerald-600', dark: 'emerald-400' }, page: { light: 'slate-50', dark: 'slate-950' } },
497
+ * shapes: { control: '9999px' },
498
+ * }
499
+ *
500
+ * The alternative every app had was a literal `:root` / `.dark` block in its
501
+ * own stylesheet - one app wrote one for every role, plus a test to keep it
502
+ * from drifting from its palette. That block never reached a native screen,
503
+ * which compiles without the page stylesheet, so a shared component drew
504
+ * stx's stock greys there while the web showed the app's palette.
505
+ */
506
+ export declare interface ThemeRoleOverrides {
507
+ roles?: Record<string, RoleColor>
508
+ shapes?: Record<string, string>
509
+ density?: Record<string, string>
510
+ }
484
511
  declare type Palette = Record<string, unknown>;
512
+ /**
513
+ * An app's answer for a colour role, in each mode.
514
+ *
515
+ * Each value is a palette reference (`emerald-600`) or a literal colour
516
+ * (`#24724b`, `oklch(...)`, `white`). A bare string is the same value in both
517
+ * modes; a `{ light }` with no `dark` keeps the role's stock dark value.
518
+ */
519
+ export type RoleColor = string | { light?: string, dark?: string }
@@ -76,6 +76,18 @@ function resolveShade(palette, reference) {
76
76
  const value = family[reference.slice(split + 1)];
77
77
  return typeof value === "string" ? value : void 0;
78
78
  }
79
+ const LITERAL_COLOR = /^(?:#[\da-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|var)\(.*\)|white|black|transparent|currentcolor)$/i;
80
+ function resolveColor(palette, reference) {
81
+ const value = reference.trim();
82
+ return resolveShade(palette, value) ?? (LITERAL_COLOR.test(value) ? value : void 0);
83
+ }
84
+ export function unknownRoleNames(overrides = {}) {
85
+ return [
86
+ ...Object.keys(overrides.roles ?? {}).filter((name) => !SEMANTIC_TOKENS[name]).map((name) => `roles.${name}`),
87
+ ...Object.keys(overrides.shapes ?? {}).filter((name) => !SHAPE_TOKENS[name]).map((name) => `shapes.${name}`),
88
+ ...Object.keys(overrides.density ?? {}).filter((name) => !DENSITY_TOKENS[name]).map((name) => `density.${name}`)
89
+ ];
90
+ }
79
91
  export function semanticColors(palette) {
80
92
  const colors = {};
81
93
  for (const [name, token] of Object.entries(SEMANTIC_TOKENS)) {
@@ -86,10 +98,10 @@ export function semanticColors(palette) {
86
98
  }
87
99
  return colors;
88
100
  }
89
- export function semanticTokenCSS(palette) {
101
+ export function semanticTokenCSS(palette, roles = {}) {
90
102
  const light = [], dark = [];
91
103
  for (const [name, token] of Object.entries(SEMANTIC_TOKENS)) {
92
- const lightValue = resolveShade(palette, token.light), darkValue = resolveShade(palette, token.dark);
104
+ const answer = roles[name], lightAnswer = typeof answer === "string" ? answer : answer?.light, darkAnswer = typeof answer === "string" ? answer : answer?.dark, lightValue = lightAnswer && resolveColor(palette, lightAnswer) || resolveShade(palette, token.light), darkValue = darkAnswer && resolveColor(palette, darkAnswer) || resolveShade(palette, token.dark);
93
105
  if (lightValue === void 0)
94
106
  continue;
95
107
  light.push(` ${tokenVariable(name)}: ${lightValue};`);
@@ -127,11 +139,11 @@ export function shapeRadii() {
127
139
  radii[name] = `var(${shapeVariable(name)}, ${token.value})`;
128
140
  return radii;
129
141
  }
130
- export function shapeTokenCSS() {
142
+ export function shapeTokenCSS(shapes = {}) {
131
143
  return [
132
144
  "/* stx shape tokens \u2014 a radius by what the thing is. */",
133
145
  ":root {",
134
- ...Object.entries(SHAPE_TOKENS).map(([name, token]) => ` ${shapeVariable(name)}: ${token.value};`),
146
+ ...Object.entries(SHAPE_TOKENS).map(([name, token]) => ` ${shapeVariable(name)}: ${shapes[name] ?? token.value};`),
135
147
  "}",
136
148
  ""
137
149
  ].join(`
@@ -184,11 +196,11 @@ export function densityFontSizes() {
184
196
  sizes[name] = [densityValue(size), { lineHeight: densityValue(leading) }];
185
197
  return sizes;
186
198
  }
187
- export function densityTokenCSS() {
199
+ export function densityTokenCSS(density = {}) {
188
200
  return [
189
201
  "/* stx density tokens \u2014 how much room a control or a table cell takes. */",
190
202
  ":root {",
191
- ...Object.entries(DENSITY_TOKENS).map(([name, token]) => ` ${densityVariable(name)}: ${token.value};`),
203
+ ...Object.entries(DENSITY_TOKENS).map(([name, token]) => ` ${densityVariable(name)}: ${density[name] ?? token.value};`),
192
204
  "}",
193
205
  ""
194
206
  ].join(`
@@ -27,6 +27,7 @@ export declare interface MergedCssConfig {
27
27
  includePreflight: boolean
28
28
  minify: boolean
29
29
  tokenCSS: string
30
+ unknownRoles: string[]
30
31
  fonts?: Dict
31
32
  }
32
33
  declare type Dict = Record<string, any>;
@@ -1,4 +1,4 @@
1
- import { densityFontSizes, densitySpacing, densityTokenCSS, semanticColors, semanticTokenCSS, shapeRadii, shapeTokenCSS } from "./theme-tokens.js";
1
+ import { densityFontSizes, densitySpacing, densityTokenCSS, semanticColors, semanticTokenCSS, shapeRadii, shapeTokenCSS, unknownRoleNames } from "./theme-tokens.js";
2
2
  function isPlainObject(value) {
3
3
  return typeof value === "object" && value !== null && !Array.isArray(value);
4
4
  }
@@ -36,7 +36,7 @@ export function mergeCssConfig(base = {}, user = {}) {
36
36
  }, preflights = [
37
37
  ...base.preflights || [],
38
38
  ...user.preflights || []
39
- ], { fonts: baseFonts, ...baseRest } = base, { fonts: userFonts, ...userRest } = user, fonts = userFonts ?? baseFonts;
39
+ ], { fonts: baseFonts, ...baseRest } = base, { fonts: userFonts, roles, shapes, density, ...userRest } = user, overrides = { roles, shapes, density }, fonts = userFonts ?? baseFonts;
40
40
  return {
41
41
  config: {
42
42
  ...baseRest,
@@ -52,7 +52,8 @@ export function mergeCssConfig(base = {}, user = {}) {
52
52
  shortcuts,
53
53
  includePreflight: user.preflight !== !1,
54
54
  minify: user.minify === !0,
55
- tokenCSS: semanticTokenCSS(basePalette) + shapeTokenCSS() + densityTokenCSS(),
55
+ tokenCSS: semanticTokenCSS({ ...basePalette, ...theme.colors }, roles) + shapeTokenCSS(shapes) + densityTokenCSS(density),
56
+ unknownRoles: unknownRoleNames(overrides),
56
57
  ...fonts ? { fonts } : {}
57
58
  };
58
59
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.588",
4
+ "version": "0.2.590",
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.588",
132
- "@stacksjs/sanitizer": "0.2.588",
131
+ "@stacksjs/desktop": "0.2.590",
132
+ "@stacksjs/sanitizer": "0.2.590",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
- "bun-plugin-stx": "0.2.588",
134
+ "bun-plugin-stx": "0.2.590",
135
135
  "bunfig": "^0.15.21",
136
- "stx-router": "0.2.588",
136
+ "stx-router": "0.2.590",
137
137
  "ts-broadcasting": "^0.0.11",
138
138
  "ts-images": "^0.2.22",
139
139
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{O,jt}from"./chunk-mmbspaqh.js";export{jt as stripModuleImports,O as transformStoreImports};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Me,tn,xu}from"./chunk-j7kcjgxy.js";import{W,nn,Su,rn,es,Gn,Kn,ku,Cu,_u,sn,on,ts,Xn,Eu}from"./chunk-7ydavm3h.js";import"./chunk-c6egfhy6.js";export{es as batch,xu as default,nn as derived,rn as effect,Me as generateSignalsRuntime,tn as generateSignalsRuntimeDev,on as isDerived,sn as isSignal,Su as memo,Kn as onDestroy,Gn as onMount,Xn as peek,_u as pendingLifecycleCounts,Cu as runDestroyCallbacks,ku as runMountCallbacks,W as state,ts as untrack,Eu as useOptimistic};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ua,vo,da,pa,wo,fa,ga,ma,ha,xo,ya,vl}from"./chunk-m7ddgrsm.js";import{Po,ka}from"./chunk-haag5n42.js";import{B,F,z,Ut,Q,ie,Wn,De,mt,Wt,qt,Gt,H,Kt,Xt,qn}from"./chunk-048eyjyj.js";import{ec}from"./chunk-bfbmdjh4.js";import"./chunk-7xw1e8t6.js";export{F as DEFAULT_FORMATS,z as DEFAULT_QUALITY,B as DEFAULT_WIDTHS,qn as ImageProcessingError,pa as clearImageCache,wo as createImageDirective,ka as createImageHandler,ga as createImagePlugin,vl as defaultImageConfig,Xt as formatSize,xo as generateImageManifest,mt as generateSizes,De as generateSrcSet,Wt as getFallbackVariant,Wn as getImageMetadata,H as getMimeType,Kt as getTotalSize,qt as groupVariantsByFormat,Po as handleImageRequest,fa as imageDirective,Q as isImageBackendAvailable,Gt as isImageFile,Ut as isSharpAvailable,ha as optimizeDirectory,ma as optimizeImage,vo as parseImageComponent,ie as processImage,da as processImageComponents,ua as renderImageComponent,ec as rewriteImagesWithSiblings,ya as writeImageManifest};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Fe,kc,Qu,ed,td,nd,Cc,_c,rd,sd,ui,od,fn,gn,tr}from"./chunk-3qmx12d3.js";import"./chunk-w24qmxc3.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-45x4myqe.js";import"./chunk-k1szsenr.js";import"./chunk-91pdg853.js";import"./chunk-03xsf9jm.js";import"./chunk-qhr1tkhj.js";import"./chunk-mmbspaqh.js";import"./chunk-c6egfhy6.js";import"./chunk-pxw4edw8.js";import"./chunk-82bttwqm.js";export{nd as __setSignalsGeneratorsForTest,Fe as cacheEngineFingerprint,gn as cacheTemplate,fn as checkCache,od as clearDevCaches,_c as getCachedRouterScript,Cc as getCachedSignalsRuntime,rd as getServeClientAsset,ui as getServeModuleBundle,tr as hashFilePath,ed as invalidateFileCache,td as invalidateFileCacheByDir,Qu as readFileCached,sd as registerServeModuleBundle,kc as templateCache};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Cl}from"./chunk-ww28zfwt.js";import"./chunk-076h7nb9.js";import"./chunk-j7kcjgxy.js";import"./chunk-yhhfxx17.js";import"./chunk-3qmx12d3.js";import"./chunk-w24qmxc3.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-45x4myqe.js";import"./chunk-k1szsenr.js";import"./chunk-91pdg853.js";import"./chunk-03xsf9jm.js";import"./chunk-qhr1tkhj.js";import"./chunk-mmbspaqh.js";import"./chunk-c6egfhy6.js";import"./chunk-pxw4edw8.js";import"./chunk-82bttwqm.js";export{Cl as buildForProduction};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{pd,Ic,Cs,_s,xi,Si,Es,Ts,ar,Oc,ki,Ci,Dc,Ge}from"./chunk-3qmx12d3.js";import"./chunk-w24qmxc3.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-45x4myqe.js";import"./chunk-k1szsenr.js";import"./chunk-91pdg853.js";import"./chunk-03xsf9jm.js";import"./chunk-qhr1tkhj.js";import"./chunk-mmbspaqh.js";import"./chunk-c6egfhy6.js";import"./chunk-pxw4edw8.js";import"./chunk-82bttwqm.js";export{pd as clearScriptScanCache,Es as convertServerLoopAttributesToDirectives,xi as convertSignalDirectivesToAttributes,Ts as convertSignalLoopsToAttributes,Oc as extractExports,Ci as findMarkupIndexOutsideScripts,_s as hasSignalsSyntax,Cs as parseLoopExpression,Si as preEvalLiteralReactiveIfs,ar as processScriptSetup,ki as processSignals,Dc as rewriteStxImportSpecifiers,Ic as scanScriptTags,Ge as stripStxRuntimeImports};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{K,ds,ps,hc,Et,oi,gs,ii,Gu,be,pn,ve}from"./chunk-3qmx12d3.js";import"./chunk-w24qmxc3.js";import"./chunk-v8ze2q95.js";import{Li,s}from"./chunk-y5x8xnnf.js";import"./chunk-k71e38fk.js";import"./chunk-45x4myqe.js";import"./chunk-k1szsenr.js";import"./chunk-91pdg853.js";import"./chunk-03xsf9jm.js";import"./chunk-qhr1tkhj.js";import"./chunk-mmbspaqh.js";import"./chunk-c6egfhy6.js";import"./chunk-pxw4edw8.js";import"./chunk-82bttwqm.js";export{K as BROWSER_CORE_IMPORTS,hc as STX_AUTO_IMPORTS,ds as extractAndStripCssImports,be as extractBridgeData,Li as findInterpolationEnd,ii as generateAutoImportDestructuring,Gu as generateBrowserAutoImportDestructuring,pn as generateServerDataBridge,Et as injectBrowserCoreAutoImports,ve as processClientScript,gs as referencesName,ps as renderVendorStyleTags,s as stripCommentsAndLiterals,oi as transformAutoImports};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Po,ka}from"./chunk-haag5n42.js";import"./chunk-048eyjyj.js";import"./chunk-7xw1e8t6.js";export{ka as createImageHandler,Po as handleImageRequest};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{vn,Pc,ks}from"./chunk-3qmx12d3.js";import"./chunk-w24qmxc3.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-45x4myqe.js";import"./chunk-k1szsenr.js";import"./chunk-91pdg853.js";import"./chunk-03xsf9jm.js";import{_e}from"./chunk-qhr1tkhj.js";import"./chunk-mmbspaqh.js";import"./chunk-c6egfhy6.js";import"./chunk-pxw4edw8.js";import"./chunk-82bttwqm.js";export{_e as freeIdentifiers,ks as processComponents,Pc as processESImports,vn as rendersAsElement};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import a from"fs";function Ne(r){return o(r)}var g=1000,i=new Map;function en(){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 ht(r,n,t){let e=r.get(n);return e!==void 0&&e.signature===t?e.value:void 0}function U(r,n,t,e){return r.set(n,{signature:t,value:e}),e}
4
- export{Ne,en,ht,U};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{A,Qc,Ls,o,P,hd,yd}from"./chunk-3qmx12d3.js";import"./chunk-w24qmxc3.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-45x4myqe.js";import"./chunk-k1szsenr.js";import"./chunk-91pdg853.js";import"./chunk-03xsf9jm.js";import"./chunk-qhr1tkhj.js";import"./chunk-mmbspaqh.js";import"./chunk-c6egfhy6.js";import"./chunk-pxw4edw8.js";import"./chunk-82bttwqm.js";export{P as config,A as defaultConfig,hd as defineStxConfig,Ls as discoverConfig,o as loadStxConfig,Qc as resolveStxDirectories,yd as validateConfig};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import t from"fs";import r from"path";var yt="resources/assets",an="assets";function cn(o=process.cwd()){let s=r.resolve(o,yt);return t.existsSync(s)&&t.statSync(s).isDirectory()?s:null}
3
- export{yt,an,cn};