@stacksjs/stx 0.2.871 → 0.2.872

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 (120) hide show
  1. package/dist/{chunk-8q37c0jm.js → chunk-18a3vdnq.js} +1 -1
  2. package/dist/{chunk-1ptjecaz.js → chunk-1c8j9zdp.js} +1 -1
  3. package/dist/{chunk-3z3y475q.js → chunk-1p9rb7rt.js} +1 -1
  4. package/dist/{chunk-5kc0r06s.js → chunk-2jccw1km.js} +1 -1
  5. package/dist/chunk-2nd3h37q.js +2 -0
  6. package/dist/{chunk-gqjt1va8.js → chunk-2yrd286h.js} +1 -1
  7. package/dist/chunk-3k5g4tbn.js +2 -0
  8. package/dist/chunk-3qewdhvh.js +2 -0
  9. package/dist/{chunk-xga3xhzr.js → chunk-4ay62hs9.js} +1 -1
  10. package/dist/{chunk-80x7c8d8.js → chunk-4p51hk75.js} +5 -5
  11. package/dist/{chunk-jz76vn4n.js → chunk-4v70bs2q.js} +1 -1
  12. package/dist/{chunk-21vrwgap.js → chunk-5nj2k8zf.js} +1 -1
  13. package/dist/{chunk-qnky63y3.js → chunk-6mkn81pd.js} +1 -1
  14. package/dist/{chunk-3fkbbkkt.js → chunk-6s7q8kw3.js} +2 -2
  15. package/dist/{chunk-ts61qx11.js → chunk-71hjqg16.js} +4 -4
  16. package/dist/{chunk-17ttwt50.js → chunk-7j0qkye5.js} +1 -1
  17. package/dist/chunk-7mqnbn1x.js +2 -0
  18. package/dist/chunk-7q3ar8ay.js +2 -0
  19. package/dist/chunk-808fbm83.js +2 -0
  20. package/dist/chunk-832m6nwr.js +2051 -0
  21. package/dist/{chunk-89xpfwy4.js → chunk-9bnggqhj.js} +8 -8
  22. package/dist/{chunk-98832y5h.js → chunk-9c07p1vq.js} +2 -2
  23. package/dist/{chunk-rpep1ve3.js → chunk-9fyw1xkh.js} +2 -2
  24. package/dist/{chunk-az07qe58.js → chunk-a8164hnf.js} +1 -1
  25. package/dist/{chunk-b7qfjv65.js → chunk-asrzmw7w.js} +1 -1
  26. package/dist/{chunk-fn2j7g8g.js → chunk-av2vknrs.js} +2 -2
  27. package/dist/chunk-b2kkezey.js +2 -0
  28. package/dist/{chunk-n16ba3wz.js → chunk-b8vs32dw.js} +3 -3
  29. package/dist/{chunk-k82hqmma.js → chunk-ba86dkhs.js} +1 -1
  30. package/dist/{chunk-ce49k18q.js → chunk-bbq79tap.js} +5 -5
  31. package/dist/{chunk-wvtmex14.js → chunk-bfvr4byj.js} +5 -5
  32. package/dist/{chunk-jafn6jh0.js → chunk-bmbqr2br.js} +1 -1
  33. package/dist/{chunk-q28q8w89.js → chunk-bqs9wyje.js} +1 -1
  34. package/dist/chunk-c63027nw.js +2 -0
  35. package/dist/{chunk-pffksrxb.js → chunk-csymxc5a.js} +8 -8
  36. package/dist/chunk-cv9vmz5x.js +2 -0
  37. package/dist/{chunk-hgmjxq7t.js → chunk-d0h18m2r.js} +1 -1
  38. package/dist/{chunk-sb8n32rn.js → chunk-dhbpbjt3.js} +1 -1
  39. package/dist/{chunk-a3rqpyt8.js → chunk-dv1edvz8.js} +1 -1
  40. package/dist/{chunk-1dt8e7ew.js → chunk-e2t7mk29.js} +2 -2
  41. package/dist/{chunk-1n7vjs3t.js → chunk-e549f7a9.js} +2 -2
  42. package/dist/chunk-eczy00w6.js +2 -0
  43. package/dist/{chunk-34mx6czk.js → chunk-f5gg0pxj.js} +1 -1
  44. package/dist/chunk-gc4bgven.js +2 -0
  45. package/dist/{chunk-5d0csn7w.js → chunk-hcaedzck.js} +1 -1
  46. package/dist/{chunk-wz1h33pz.js → chunk-hd4vn78w.js} +1 -1
  47. package/dist/{chunk-dy7vqv1x.js → chunk-hhbt8grm.js} +2 -2
  48. package/dist/{chunk-7mbezqy6.js → chunk-j89p53vx.js} +2 -2
  49. package/dist/{chunk-has2s6zj.js → chunk-jcr69v95.js} +2 -2
  50. package/dist/{chunk-c8d5cv6w.js → chunk-jf3n1f32.js} +2 -2
  51. package/dist/chunk-jkevn2jy.js +2 -0
  52. package/dist/{chunk-aktk5r6c.js → chunk-jnj9s2yw.js} +1 -1
  53. package/dist/{chunk-ak6edtk2.js → chunk-jpgc0j8x.js} +2 -2
  54. package/dist/{chunk-avfsad8j.js → chunk-kkevjppm.js} +2 -2
  55. package/dist/{chunk-38tdqbf1.js → chunk-kx6y1cqw.js} +4 -4
  56. package/dist/{chunk-a7drjyq6.js → chunk-kzhget9h.js} +1 -1
  57. package/dist/{chunk-2sw68zck.js → chunk-m131znxe.js} +4 -4
  58. package/dist/chunk-me7cxs0e.js +2 -0
  59. package/dist/{chunk-3972v2g1.js → chunk-mm00bb1p.js} +1 -1
  60. package/dist/{chunk-6npyrm89.js → chunk-my6tp8rn.js} +1 -1
  61. package/dist/chunk-pc8jnkb3.js +2 -0
  62. package/dist/{chunk-2pt2feg2.js → chunk-pj1znb6y.js} +1 -1
  63. package/dist/{chunk-zebk7htd.js → chunk-pnqdwqw9.js} +54 -54
  64. package/dist/{chunk-k7m8659h.js → chunk-q50x1gfd.js} +2 -2
  65. package/dist/{chunk-4gx0z28s.js → chunk-q8d0wf0w.js} +1 -1
  66. package/dist/{chunk-sghbhdtj.js → chunk-qk1fkfvj.js} +1 -1
  67. package/dist/{chunk-hcp8qese.js → chunk-qt4dha3g.js} +3 -3
  68. package/dist/{chunk-hs11350k.js → chunk-qvxtq5vb.js} +1 -1
  69. package/dist/{chunk-5qfrnjkd.js → chunk-rvbw12e1.js} +1 -1
  70. package/dist/{chunk-vrcr4b13.js → chunk-s584xnzx.js} +1 -1
  71. package/dist/{chunk-ptfhh54v.js → chunk-s70e5jbq.js} +9 -9
  72. package/dist/{chunk-04pkrxse.js → chunk-tahw02kf.js} +1 -1
  73. package/dist/{chunk-nbvpjwj1.js → chunk-tc36b3r4.js} +18 -18
  74. package/dist/{chunk-teasmth3.js → chunk-teahvty8.js} +1 -1
  75. package/dist/chunk-tfsf9pes.js +2 -0
  76. package/dist/chunk-thyxsg54.js +2 -0
  77. package/dist/chunk-txjtd4gj.js +2 -0
  78. package/dist/{chunk-ms60vwmg.js → chunk-v4ab2jzz.js} +1 -1
  79. package/dist/{chunk-pczh82f8.js → chunk-v99hgmsx.js} +1 -1
  80. package/dist/chunk-vf91b9b9.js +20 -0
  81. package/dist/{chunk-z4zqtpqn.js → chunk-vmq773pb.js} +1 -1
  82. package/dist/{chunk-s41wm1as.js → chunk-vv9anbw1.js} +1 -1
  83. package/dist/{chunk-74vp2yw4.js → chunk-vvxcebpn.js} +2 -2
  84. package/dist/{chunk-5h9d6jew.js → chunk-wk2rge05.js} +3 -3
  85. package/dist/{chunk-1217683z.js → chunk-y48ykf1n.js} +4 -4
  86. package/dist/chunk-y69hhxn8.js +2 -0
  87. package/dist/{chunk-gkdgg83x.js → chunk-ycb07ppz.js} +1 -1
  88. package/dist/chunk-z0qxrx9r.js +3 -0
  89. package/dist/chunk-z2wfgva6.js +2 -0
  90. package/dist/{chunk-x7redxyd.js → chunk-z9xe3xkg.js} +2 -2
  91. package/dist/{chunk-583rbj5e.js → chunk-zfrzdje6.js} +1 -1
  92. package/dist/cli.js +13 -13
  93. package/dist/component-library.js +140 -36
  94. package/dist/craft-entry.js +1 -1
  95. package/dist/craft.js +1 -1
  96. package/dist/pwa.js +2 -2
  97. package/dist/ssg.js +5 -5
  98. package/package.json +5 -5
  99. package/dist/chunk-3mb2pw1s.js +0 -3
  100. package/dist/chunk-3zm4bwha.js +0 -2
  101. package/dist/chunk-55bne11m.js +0 -2
  102. package/dist/chunk-5mfymtae.js +0 -2
  103. package/dist/chunk-6jc67p70.js +0 -2
  104. package/dist/chunk-9d5cqgy7.js +0 -2
  105. package/dist/chunk-ajaqa958.js +0 -2
  106. package/dist/chunk-ax0ntjxy.js +0 -2
  107. package/dist/chunk-bz52y1cb.js +0 -2
  108. package/dist/chunk-dst4twmx.js +0 -2
  109. package/dist/chunk-f14pyq81.js +0 -20
  110. package/dist/chunk-hb6r4pxp.js +0 -2
  111. package/dist/chunk-j0cfkp98.js +0 -2
  112. package/dist/chunk-kpjtptnx.js +0 -2
  113. package/dist/chunk-ktrfk613.js +0 -2
  114. package/dist/chunk-msvh8rda.js +0 -2042
  115. package/dist/chunk-n1g75yxa.js +0 -2
  116. package/dist/chunk-npayn9fr.js +0 -2
  117. package/dist/chunk-p8t5mnes.js +0 -2
  118. package/dist/chunk-rhhq8k9f.js +0 -2
  119. package/dist/chunk-w3n2jpk5.js +0 -2
  120. package/dist/chunk-ymmcv5g3.js +0 -2
@@ -1,5 +1,6 @@
1
1
  import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { bracketDepths, stripCommentsAndLiterals } from "./strip-literals.js";
3
4
  function reservedMethodMessage(name) {
4
5
  if (name === "connectedCallback")
5
6
  return `method "${name}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;
@@ -60,53 +61,152 @@ function parseMetadata(source, file) {
60
61
  throw Error(`${file}: <script component> must contain JSON metadata (${error.message})`);
61
62
  }
62
63
  }
64
+ function clientMethods(code) {
65
+ const masked = stripCommentsAndLiterals(code), pattern = /(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g, result = [], parser = new Bun.Transpiler({ loader: "ts" });
66
+ let match;
67
+ while (match = pattern.exec(masked)) {
68
+ let cursor = pattern.lastIndex;
69
+ while (/\s/.test(masked[cursor] || ""))
70
+ cursor++;
71
+ const genericStart = cursor;
72
+ if (masked[cursor] === "<")
73
+ cursor = skipBalanced(masked, cursor, "<", ">");
74
+ if (cursor < 0)
75
+ continue;
76
+ const generic = code.slice(genericStart, cursor).trim();
77
+ while (/\s/.test(masked[cursor] || ""))
78
+ cursor++;
79
+ if (masked[cursor] !== "(")
80
+ continue;
81
+ const parameterStart = cursor, parameterEnd = skipBalanced(masked, cursor, "(", ")");
82
+ if (parameterEnd < 0)
83
+ continue;
84
+ for (cursor = parameterEnd;cursor < code.length; cursor++) {
85
+ const token = masked[cursor];
86
+ if (token !== "{" && token !== ";")
87
+ continue;
88
+ const header = code.slice(match.index, cursor).trim();
89
+ let compiled;
90
+ try {
91
+ compiled = parser.transformSync(header + (token === "{" ? "{}" : ";"));
92
+ } catch {
93
+ continue;
94
+ }
95
+ if (token === "{" && !compiled.includes(`function ${match[1]}(`))
96
+ continue;
97
+ if (token === ";" && compiled.trim())
98
+ continue;
99
+ const bodyEnd = token === "{" ? skipBalanced(masked, cursor, "{", "}") : cursor + 1;
100
+ if (bodyEnd < 0)
101
+ break;
102
+ result.push({
103
+ name: match[1],
104
+ header,
105
+ generic,
106
+ parameters: code.slice(parameterStart + 1, parameterEnd - 1),
107
+ returns: code.slice(parameterEnd, cursor).trim().replace(/^:\s*/, ""),
108
+ async: /\basync\s+function/.test(match[0]),
109
+ ...token === "{" ? { source: code.slice(match.index, bodyEnd) } : {}
110
+ });
111
+ pattern.lastIndex = bodyEnd;
112
+ break;
113
+ }
114
+ }
115
+ return result;
116
+ }
117
+ function methodDeclaration(method) {
118
+ const parameters = splitTopLevel(method.parameters, ",", !0).flatMap((raw, index) => {
119
+ const masked = stripCommentsAndLiterals(raw);
120
+ let depth = 0, assignment = -1;
121
+ for (let i = 0;i < masked.length; i++) {
122
+ const token = masked[i];
123
+ if ("([{<".includes(token))
124
+ depth++;
125
+ else if (")]}>".includes(token) && !(token === ">" && masked[i - 1] === "="))
126
+ depth--;
127
+ if (token === "=" && depth === 0 && masked[i + 1] !== ">") {
128
+ assignment = i;
129
+ break;
130
+ }
131
+ }
132
+ const declaration = (assignment < 0 ? raw : raw.slice(0, assignment)).trim(), parts = splitTopLevel(declaration, ":", !0), binding = parts.shift().trim();
133
+ if (binding === "this")
134
+ return [];
135
+ const name = /^[A-Za-z_$]|^\.\.\./.test(binding) ? binding : `argument${index}`, fallback = assignment < 0 ? "" : raw.slice(assignment + 1).trim(), inferred = fallback === "true" || fallback === "false" ? "boolean" : /^-?\d+(?:\.\d+)?$/.test(fallback) ? "number" : /^['"`]/.test(fallback) ? "string" : name.startsWith("...") ? "unknown[]" : "unknown", type = parts.join(":").trim() || inferred, optional = assignment >= 0 && !name.endsWith("?") && !name.startsWith("...") ? "?" : "";
136
+ return [`${name}${optional}: ${type}`];
137
+ }).join(", ");
138
+ return `${method.name}${method.generic}(${parameters}): ${method.returns || (method.async ? "Promise<unknown>" : "unknown")}`;
139
+ }
63
140
  function extractClientMethods(source, file) {
64
- const methods = {}, scripts = [...source.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];
141
+ const methods = {}, declarations = {}, types = [], imports = [], scripts = [...source.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];
65
142
  for (const script of scripts) {
66
- if (!/\bclient\b/i.test(script[1]) || /\bcomponent\b|\bstx:component\b/i.test(script[1]))
143
+ if (/\bserver\b|\bcomponent\b|\bstx:component\b/i.test(script[1]) || /\btype=["']application\//i.test(script[1]))
67
144
  continue;
68
- let code;
69
145
  try {
70
- code = new Bun.Transpiler({ loader: "ts" }).transformSync(script[2]);
146
+ new Bun.Transpiler({ loader: "ts" }).transformSync(script[2]);
71
147
  } catch (error) {
72
148
  throw Error(`${file}: failed to transpile <script client> (${error.message})`);
73
149
  }
74
- const functionPattern = /(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g;
150
+ const extracted = /\bclient\b/i.test(script[1]) ? clientMethods(script[2]) : [], overloads = new Set(extracted.filter((method) => !method.source).map((method) => method.name));
151
+ for (const method of extracted) {
152
+ if (RESERVED_METHODS.has(method.name))
153
+ throw Error(`${file}: client ${reservedMethodMessage(method.name)}`);
154
+ if (method.source)
155
+ methods[method.name] = new Bun.Transpiler({ loader: "ts" }).transformSync(method.source).trim().replace(/^(?:export\s+)?(async\s+)?function\s+/, "$1");
156
+ if (!method.source || !overloads.has(method.name))
157
+ (declarations[method.name] ??= []).push(methodDeclaration(method));
158
+ }
159
+ for (const imported of script[2].matchAll(/^\s*import\s+(?:type\s+)?([\s\S]*?)\s+from\s*(['"])([^'"]+)\2\s*;?/gm))
160
+ imports.push({ binding: imported[1].trim(), module: imported[3] });
161
+ const masked = stripCommentsAndLiterals(script[2]), depths = bracketDepths(masked).depths, typePattern = /(?:export\s+)?(interface|type)\s+[A-Za-z_$][\w$]*/g;
75
162
  let match;
76
- while (match = functionPattern.exec(code)) {
77
- const name = match[1];
78
- if (RESERVED_METHODS.has(name))
79
- throw Error(`${file}: client ${reservedMethodMessage(name)}`);
80
- const bodyStart = functionPattern.lastIndex;
81
- let depth = 1, quote = "", escaped = !1, cursor = bodyStart;
82
- for (;cursor < code.length && depth > 0; cursor++) {
83
- const char = code[cursor];
84
- if (escaped) {
85
- escaped = !1;
86
- continue;
87
- }
88
- if (quote) {
89
- if (char === "\\")
90
- escaped = !0;
91
- else if (char === quote)
92
- quote = "";
163
+ while (match = typePattern.exec(masked)) {
164
+ if (depths[match.index] !== 0)
165
+ continue;
166
+ let cursor = typePattern.lastIndex, depth = 0;
167
+ for (;cursor < masked.length; cursor++) {
168
+ const token = masked[cursor];
169
+ if (token === "{") {
170
+ const end = skipBalanced(masked, cursor, "{", "}");
171
+ if (end < 0)
172
+ break;
173
+ cursor = end - 1;
174
+ if (match[1] === "interface" && depth === 0) {
175
+ cursor++;
176
+ break;
177
+ }
93
178
  continue;
94
179
  }
95
- if (char === '"' || char === "'" || char === "`")
96
- quote = char;
97
- else if (char === "{")
180
+ if ("([<".includes(token))
98
181
  depth++;
99
- else if (char === "}")
182
+ else if (")]>".includes(token) && !(token === ">" && masked[cursor - 1] === "="))
100
183
  depth--;
184
+ if (match[1] === "type" && depth === 0 && (token === ";" || token === `
185
+ `)) {
186
+ if (token === `
187
+ ` && /^[\s]*[|&]/.test(masked.slice(cursor + 1)))
188
+ continue;
189
+ try {
190
+ new Bun.Transpiler({ loader: "ts" }).transformSync(script[2].slice(match.index, cursor));
191
+ break;
192
+ } catch {}
193
+ }
101
194
  }
102
- if (depth !== 0)
103
- throw Error(`${file}: unterminated client function "${name}"`);
104
- const asyncPrefix = match[0].includes("async") ? "async " : "";
105
- methods[name] = `${asyncPrefix}${name}(${match[2]}) {${code.slice(bodyStart, cursor - 1)}}`;
106
- functionPattern.lastIndex = cursor;
195
+ types.push(script[2].slice(match.index, cursor).replace(/^export\s+/, "").trim());
196
+ typePattern.lastIndex = cursor + 1;
107
197
  }
108
198
  }
109
- return methods;
199
+ const referenced = Object.values(declarations).flat().join(`
200
+ `) + `
201
+ ` + types.join(`
202
+ `), usedImports = imports.filter((imported) => (imported.binding.match(/[A-Za-z_$][\w$]*/g) || []).filter((name) => !["type", "as"].includes(name)).some((name) => new RegExp(`\\b${name}\\b`).test(referenced)));
203
+ for (const imported of usedImports)
204
+ if (imported.module.startsWith(".") || path.isAbsolute(imported.module))
205
+ throw Error(`${file}: public method types import ${JSON.stringify(imported.module)} outside the generated package; declare these types in the component or import them from a published dependency`);
206
+ const typeImports = [...new Set(usedImports.map((imported) => `import type ${imported.binding.replace(/\btype\s+/g, "")} from ${JSON.stringify(imported.module)}`))];
207
+ return { methods, declarations, types: [...typeImports, ...types].join(`
208
+
209
+ `) };
110
210
  }
111
211
  function extractTemplate(source) {
112
212
  const templateMatch = source.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);
@@ -295,7 +395,7 @@ function splitTopLevel(body, separators, angles) {
295
395
  }
296
396
  if (opening.includes(char))
297
397
  depth++;
298
- else if (closing.includes(char))
398
+ else if (closing.includes(char) && !(angles && char === ">" && body[i - 1] === "="))
299
399
  depth--;
300
400
  if (depth === 0 && separators.includes(char)) {
301
401
  parts.push(current);
@@ -618,7 +718,9 @@ async function compileComponent(inputDir, entry, defaults) {
618
718
  progressive: entry.progressive ?? metadata.progressive ?? defaults.progressive ?? !0,
619
719
  properties,
620
720
  events: entry.events || metadata.events || {},
621
- methods: { ...metadataMethods, ...configuredMethods, ...extractedMethods },
721
+ methods: { ...metadataMethods, ...configuredMethods, ...extractedMethods.methods },
722
+ methodDeclarations: extractedMethods.declarations,
723
+ declarationTypes: extractedMethods.types,
622
724
  eventTypes: eventCompilation.eventTypes,
623
725
  bindings: bindingCompilation.bindings,
624
726
  slots: extractSlots(bindingCompilation.template),
@@ -1022,9 +1124,11 @@ function typeForProperty(property) {
1022
1124
  function componentDeclaration(component) {
1023
1125
  const props = Object.entries(component.properties).map(([name, property]) => ` ${name}${property.required ? "" : "?"}: ${typeForProperty(property)}`).join(`
1024
1126
  `), events = Object.entries(component.events).map(([name, event]) => ` ${JSON.stringify(name)}: CustomEvent<${event.detailType || "unknown"}>`).join(`
1025
- `), methods = Object.keys(component.methods).map((name) => ` ${name}($event?: Event): unknown`).join(`
1127
+ `), methods = Object.keys(component.methods).flatMap((name) => component.methodDeclarations[name] || [`${name}($event?: Event): unknown`]).map((signature) => ` ${signature}`).join(`
1026
1128
  `);
1027
- return `export interface ${component.name}Props {
1129
+ return `${component.declarationTypes ? `${component.declarationTypes}
1130
+
1131
+ ` : ""}export interface ${component.name}Props {
1028
1132
  ${props}
1029
1133
  }
1030
1134
 
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-zebk7htd.js";import{Ro,Pa,Ia}from"./chunk-5a0d3048.js";import"./chunk-pywz8q4k.js";import"./chunk-pffksrxb.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-60yppcbb.js";import"./chunk-3972v2g1.js";import"./chunk-tnp2ta5q.js";import"./chunk-dy7vqv1x.js";import"./chunk-has2s6zj.js";import"./chunk-qnky63y3.js";import"./chunk-rw5492e2.js";import"./chunk-3z3y475q.js";import"./chunk-fn2j7g8g.js";import"./chunk-nbvpjwj1.js";import"./chunk-38tdqbf1.js";import"./chunk-ptfhh54v.js";import"./chunk-wvtmex14.js";import"./chunk-1217683z.js";import"./chunk-q1wxgw5s.js";import"./chunk-5h9d6jew.js";import{Tu,Oa,Dh,Mh,Na,Ao,os,Da,Ma,Lh,jh,La,ja,Ba,Fa}from"./chunk-89xpfwy4.js";import"./chunk-1n7vjs3t.js";import"./chunk-3mb2pw1s.js";import"./chunk-74vp2yw4.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-3fkbbkkt.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import"./chunk-pnqdwqw9.js";import{Ro,Pa,Ia}from"./chunk-5a0d3048.js";import"./chunk-pywz8q4k.js";import"./chunk-csymxc5a.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-60yppcbb.js";import"./chunk-mm00bb1p.js";import"./chunk-tnp2ta5q.js";import"./chunk-hhbt8grm.js";import"./chunk-jcr69v95.js";import"./chunk-6mkn81pd.js";import"./chunk-rw5492e2.js";import"./chunk-1p9rb7rt.js";import"./chunk-av2vknrs.js";import"./chunk-tc36b3r4.js";import"./chunk-kx6y1cqw.js";import"./chunk-s70e5jbq.js";import"./chunk-bfvr4byj.js";import"./chunk-y48ykf1n.js";import"./chunk-q1wxgw5s.js";import"./chunk-wk2rge05.js";import{Tu,Oa,Dh,Mh,Na,Ao,os,Da,Ma,Lh,jh,La,ja,Ba,Fa}from"./chunk-9bnggqhj.js";import"./chunk-e549f7a9.js";import"./chunk-z0qxrx9r.js";import"./chunk-vvxcebpn.js";import"./chunk-4p51hk75.js";import"./chunk-a8164hnf.js";import"./chunk-6s7q8kw3.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
package/dist/craft.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-zebk7htd.js";import{Ro,Pa,Ia}from"./chunk-5a0d3048.js";import"./chunk-pywz8q4k.js";import"./chunk-pffksrxb.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-60yppcbb.js";import"./chunk-3972v2g1.js";import"./chunk-tnp2ta5q.js";import"./chunk-dy7vqv1x.js";import"./chunk-has2s6zj.js";import"./chunk-qnky63y3.js";import"./chunk-rw5492e2.js";import"./chunk-3z3y475q.js";import"./chunk-fn2j7g8g.js";import"./chunk-nbvpjwj1.js";import"./chunk-38tdqbf1.js";import"./chunk-ptfhh54v.js";import"./chunk-wvtmex14.js";import"./chunk-1217683z.js";import"./chunk-q1wxgw5s.js";import"./chunk-5h9d6jew.js";import{Tu,Oa,Dh,Mh,Na,Ao,os,Da,Ma,Lh,jh,La,ja,Ba,Fa}from"./chunk-89xpfwy4.js";import"./chunk-1n7vjs3t.js";import"./chunk-3mb2pw1s.js";import"./chunk-74vp2yw4.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-3fkbbkkt.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import"./chunk-pnqdwqw9.js";import{Ro,Pa,Ia}from"./chunk-5a0d3048.js";import"./chunk-pywz8q4k.js";import"./chunk-csymxc5a.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-60yppcbb.js";import"./chunk-mm00bb1p.js";import"./chunk-tnp2ta5q.js";import"./chunk-hhbt8grm.js";import"./chunk-jcr69v95.js";import"./chunk-6mkn81pd.js";import"./chunk-rw5492e2.js";import"./chunk-1p9rb7rt.js";import"./chunk-av2vknrs.js";import"./chunk-tc36b3r4.js";import"./chunk-kx6y1cqw.js";import"./chunk-s70e5jbq.js";import"./chunk-bfvr4byj.js";import"./chunk-y48ykf1n.js";import"./chunk-q1wxgw5s.js";import"./chunk-wk2rge05.js";import{Tu,Oa,Dh,Mh,Na,Ao,os,Da,Ma,Lh,jh,La,ja,Ba,Fa}from"./chunk-9bnggqhj.js";import"./chunk-e549f7a9.js";import"./chunk-z0qxrx9r.js";import"./chunk-vvxcebpn.js";import"./chunk-4p51hk75.js";import"./chunk-a8164hnf.js";import"./chunk-6s7q8kw3.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{ao,Xt,Ml,Vg}from"./chunk-8q37c0jm.js";import{io,Hi,Fg,zg,Hg}from"./chunk-583rbj5e.js";import{Ol,Nl,Dl,jg,Bg}from"./chunk-r0v2chpn.js";import{Ge,Nn,Vi}from"./chunk-tyvm49be.js";import{Ug,Wg,qg,Kg,co,Py}from"./chunk-srgnevws.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-npayn9fr.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{ao,Xt,Ml,Vg}from"./chunk-18a3vdnq.js";import{io,Hi,Fg,zg,Hg}from"./chunk-zfrzdje6.js";import{Ol,Nl,Dl,jg,Bg}from"./chunk-r0v2chpn.js";import{Ge,Nn,Vi}from"./chunk-tyvm49be.js";import{Ug,Wg,qg,Kg,co,Py}from"./chunk-srgnevws.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-c63027nw.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">
package/dist/ssg.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import"./chunk-9zrvh3pz.js";import{k,yl}from"./chunk-pffksrxb.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import{Dt,w}from"./chunk-zebk7htd.js";import"./chunk-60yppcbb.js";import"./chunk-3972v2g1.js";import"./chunk-tnp2ta5q.js";import{Rt,At,Pt,It,Ot,Nt}from"./chunk-dy7vqv1x.js";import{a}from"./chunk-has2s6zj.js";import{Os}from"./chunk-qnky63y3.js";import"./chunk-rw5492e2.js";import"./chunk-avfsad8j.js";import{xe,cn,ln}from"./chunk-f14pyq81.js";import"./chunk-3z3y475q.js";import{x}from"./chunk-fn2j7g8g.js";import{kt,i}from"./chunk-nbvpjwj1.js";import"./chunk-38tdqbf1.js";import"./chunk-ptfhh54v.js";import{vs}from"./chunk-wvtmex14.js";import"./chunk-1217683z.js";import"./chunk-q1wxgw5s.js";import{lc,uc,dc}from"./chunk-v4xes880.js";import{on,sr,or}from"./chunk-ymdw4fhd.js";import{an}from"./chunk-pczh82f8.js";import"./chunk-3mb2pw1s.js";import"./chunk-74vp2yw4.js";import{Q,_e}from"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-3fkbbkkt.js";import{l}from"./chunk-46pxmpeb.js";import{r,we}from"./chunk-x7redxyd.js";import{f}from"./chunk-fd1bpv35.js";import R from"fs";import m from"path";import{createHash as vt}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 Et=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ct(t,n={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(Et,(e,u,g,v)=>{let S=v.trim();if(!S)return e;if(/\bdata-stx-src=/.test(g))return e;if(n.minify)S=$t(S);let p=Ct(S);if(!s.has(p))s.set(p,S);let P=n.integrity?` data-stx-integrity="sha384-${vt("sha384").update(S).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(s,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function lt(t){if(!t.includes("data-stx-src="))return t;let n=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.exec(t))!==null)n.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(n.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=w(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let S=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!S)return t;return t.slice(0,v)+S+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let n=t.trim();if(!n)return null;let s=/^https?:\/\//i.test(n)?n:`https://${n}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let n of jt){let s=t[n];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:n}}return null}function ut(t){if(!t||typeof t!=="object")return null;let n=t,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?X(s):null}async function Tt(t){let{existsSync:n}=await import("fs"),s=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,o);if(!n(c))continue;try{let e=await import(c),u=ut(e.default??e);if(u)return u}catch{}}return null}async function dt(t={}){let n=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let o=ut(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await Tt(n);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(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
- `)}function J(t){return async()=>({paths:await t(),fallback:!1})}var Lt;function Ut(t){let n=r(t),{depths:s}=we(n),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(n))!==null){if(s[c.index]!==0)continue;let u=k(n,"(",")",o.lastIndex-1),g=n.indexOf("{",u+1),v=k(n,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(n))!==null){if(s[c.index]!==0)continue;let u=yl(n,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function pt(t){let n="read";try{let s=await Bun.file(t).text();n="parse";let o=an(s),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(r(e.attrs))).sort((e,u)=>s.indexOf(e.fullTag)-s.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(r(e.content)))continue;let u=(Lt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(r(g))&&Dt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let S=await v();n="result";let p=Array.isArray(S)?{paths:S}:S;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class ft{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,n=""){this.cacheDir=t,this.salt=n}async load(){if(this.loaded)return;let t=m.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let n=JSON.parse(await Bun.file(t).text());for(let[s,o]of Object.entries(n))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await R.promises.mkdir(this.cacheDir,{recursive:!0});let t=m.join(this.cacheDir,"build-cache.json"),n={};for(let[s,o]of this.cache)n[s]=o;await Bun.write(t,JSON.stringify(n))}getHash(t,n){let s=R.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of n)if(R.existsSync(e)){let u=R.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,n){let s=this.cache.get(t);if(!s)return null;let o=mt(n).some((u)=>R.existsSync(u)),c=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&R.existsSync(u)&&vs(R.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(n,s.dependencies??[]);if(s.hash!==e)return this.cache.delete(t),null;return s.html}set(t,n,s,o){let c=this.getHash(n,s);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:s})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let n=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return m.join(this.cacheDir,"isr",n)}async get(t){let n=this.getFilePath(t);if(!await Bun.file(n).exists())return null;try{return JSON.parse(await Bun.file(n).text())}catch{return null}}async set(t,n){let s=this.getFilePath(t);await R.promises.mkdir(m.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(n))}async invalidate(t){let n=this.getFilePath(t);if(await Bun.file(n).exists())await R.promises.unlink(n)}async invalidatePattern(t){let n=m.join(this.cacheDir,"isr");if(!R.existsSync(n))return;let s=await R.promises.readdir(n);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await R.promises.unlink(m.join(n,o))}}async needsRevalidation(t){let n=await this.get(t);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function _t(t){let n=[];if(!t.isDynamic)n.push({url:t.pattern,params:{}});else{let s=await pt(t.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${t.pattern} (${t.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),n;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),n;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);n.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return n}function mt(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let n of mt(t))if(await Bun.file(n).exists())try{let s=await import(n);if(typeof s.default==="function")return await s.default();else if(typeof s.default==="object")return s.default;else if(typeof s.getData==="function")return await s.getData();else{let{default:o,...c}=s;return c}}catch(s){console.error(`Error loading data file ${n}:`,s)}return null}async function Gt(t,n,s){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
2
+ import"./chunk-9zrvh3pz.js";import{k,yl}from"./chunk-csymxc5a.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import{Dt,w}from"./chunk-pnqdwqw9.js";import"./chunk-60yppcbb.js";import"./chunk-mm00bb1p.js";import"./chunk-tnp2ta5q.js";import{Rt,At,Pt,It,Ot,Nt}from"./chunk-hhbt8grm.js";import{a}from"./chunk-jcr69v95.js";import{Os}from"./chunk-6mkn81pd.js";import"./chunk-rw5492e2.js";import"./chunk-kkevjppm.js";import{xe,cn,ln}from"./chunk-vf91b9b9.js";import"./chunk-1p9rb7rt.js";import{x}from"./chunk-av2vknrs.js";import{kt,i}from"./chunk-tc36b3r4.js";import"./chunk-kx6y1cqw.js";import"./chunk-s70e5jbq.js";import{vs}from"./chunk-bfvr4byj.js";import"./chunk-y48ykf1n.js";import"./chunk-q1wxgw5s.js";import{lc,uc,dc}from"./chunk-v4xes880.js";import{on,sr,or}from"./chunk-ymdw4fhd.js";import{an}from"./chunk-v99hgmsx.js";import"./chunk-z0qxrx9r.js";import"./chunk-vvxcebpn.js";import{ee,_e}from"./chunk-4p51hk75.js";import"./chunk-a8164hnf.js";import"./chunk-6s7q8kw3.js";import{l}from"./chunk-46pxmpeb.js";import{r,Y}from"./chunk-z9xe3xkg.js";import{f}from"./chunk-fd1bpv35.js";import R from"fs";import m from"path";import{createHash as vt}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 Et=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ct(t,n={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(Et,(e,u,g,v)=>{let S=v.trim();if(!S)return e;if(/\bdata-stx-src=/.test(g))return e;if(n.minify)S=$t(S);let p=Ct(S);if(!s.has(p))s.set(p,S);let P=n.integrity?` data-stx-integrity="sha384-${vt("sha384").update(S).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(s,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function lt(t){if(!t.includes("data-stx-src="))return t;let n=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.exec(t))!==null)n.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(n.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=w(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let S=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!S)return t;return t.slice(0,v)+S+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let n=t.trim();if(!n)return null;let s=/^https?:\/\//i.test(n)?n:`https://${n}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let n of jt){let s=t[n];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:n}}return null}function ut(t){if(!t||typeof t!=="object")return null;let n=t,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?X(s):null}async function Tt(t){let{existsSync:n}=await import("fs"),s=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,o);if(!n(c))continue;try{let e=await import(c),u=ut(e.default??e);if(u)return u}catch{}}return null}async function dt(t={}){let n=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let o=ut(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await Tt(n);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(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
+ `)}function J(t){return async()=>({paths:await t(),fallback:!1})}var Lt;function Ut(t){let n=r(t),{depths:s}=Y(n),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(n))!==null){if(s[c.index]!==0)continue;let u=k(n,"(",")",o.lastIndex-1),g=n.indexOf("{",u+1),v=k(n,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(n))!==null){if(s[c.index]!==0)continue;let u=yl(n,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function pt(t){let n="read";try{let s=await Bun.file(t).text();n="parse";let o=an(s),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(r(e.attrs))).sort((e,u)=>s.indexOf(e.fullTag)-s.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(r(e.content)))continue;let u=(Lt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(r(g))&&Dt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let S=await v();n="result";let p=Array.isArray(S)?{paths:S}:S;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class ft{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,n=""){this.cacheDir=t,this.salt=n}async load(){if(this.loaded)return;let t=m.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let n=JSON.parse(await Bun.file(t).text());for(let[s,o]of Object.entries(n))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await R.promises.mkdir(this.cacheDir,{recursive:!0});let t=m.join(this.cacheDir,"build-cache.json"),n={};for(let[s,o]of this.cache)n[s]=o;await Bun.write(t,JSON.stringify(n))}getHash(t,n){let s=R.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of n)if(R.existsSync(e)){let u=R.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,n){let s=this.cache.get(t);if(!s)return null;let o=mt(n).some((u)=>R.existsSync(u)),c=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&R.existsSync(u)&&vs(R.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(n,s.dependencies??[]);if(s.hash!==e)return this.cache.delete(t),null;return s.html}set(t,n,s,o){let c=this.getHash(n,s);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:s})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let n=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return m.join(this.cacheDir,"isr",n)}async get(t){let n=this.getFilePath(t);if(!await Bun.file(n).exists())return null;try{return JSON.parse(await Bun.file(n).text())}catch{return null}}async set(t,n){let s=this.getFilePath(t);await R.promises.mkdir(m.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(n))}async invalidate(t){let n=this.getFilePath(t);if(await Bun.file(n).exists())await R.promises.unlink(n)}async invalidatePattern(t){let n=m.join(this.cacheDir,"isr");if(!R.existsSync(n))return;let s=await R.promises.readdir(n);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await R.promises.unlink(m.join(n,o))}}async needsRevalidation(t){let n=await this.get(t);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function _t(t){let n=[];if(!t.isDynamic)n.push({url:t.pattern,params:{}});else{let s=await pt(t.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${t.pattern} (${t.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),n;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),n;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);n.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return n}function mt(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let n of mt(t))if(await Bun.file(n).exists())try{let s=await import(n);if(typeof s.default==="function")return await s.default();else if(typeof s.default==="object")return s.default;else if(typeof s.getData==="function")return await s.getData();else{let{default:o,...c}=s;return c}}catch(s){console.error(`Error loading data file ${n}:`,s)}return null}async function Gt(t,n,s){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
4
4
  return (async function getStaticProps() {
5
5
  ${e[1]}
6
6
  })()
@@ -36,7 +36,7 @@ ${t.map((o)=>{let c=new URL(o.loc,n).href,e=` <url>
36
36
  ${s.join(`
37
37
  `)}
38
38
  </channel>
39
- </rss>`}async function Kt(t={}){let n=Date.now();ln();let s=await a(process.cwd()),o=s.build||{},c=await dt({explicit:t.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(gt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.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},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,S={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&R.existsSync(e.outputDir))await R.promises.rm(e.outputDir,{recursive:!0});await R.promises.mkdir(e.outputDir,{recursive:!0});let C=e.cacheSalt;if(!C){let{resolveUserCssConfig:d,fingerprintConfig:y}=await import("./chunk-k82hqmma.js");try{C=y(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-04pkrxse.js"),E=await b(e.publicDir,e.outputDir);if(E.count>0)console.log(`Optimized ${E.count} image(s) for responsive delivery`),C=[C,E.fingerprint].filter(Boolean).join(":");let O=new ft(e.cacheDir,C);if(e.cache)await O.load();try{let{generateCss:d}=await import("./chunk-k82hqmma.js");await d('<div class="bg-black"></div>')}catch{}Rt();let yt=s?.routeMiddleware?.dir||"middleware";await Pt(process.cwd(),yt);let V=At();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let St=s?.routeMiddleware?.global||[];dc(s?.layoutsDir,l(process.cwd()));let Z=Q(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let U=[];for(let d of Z)try{let y=await _t(d);for(let D of y)U.push({route:d,url:D.url,params:D.params,props:D.props,revalidate:D.revalidate??e.revalidate})}catch(y){let D=y instanceof Error?y:Error(String(y));u.failedCount++,u.errors.push({route:d.pattern,error:D}),await e.hooks.onError?.(D,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,D)}u.totalPages=U.length+u.failedCount,console.log(`Generating ${U.length} pages...`);let _=[],tt=[];for(let d=0;d<U.length;d+=e.concurrency)tt.push(U.slice(d,d+e.concurrency));for(let d of tt)await Promise.all(d.map(async(y)=>{let{route:D,url:h,params:M,props:xt,revalidate:nt}=y;try{await e.hooks.onPageStart?.(h);let G=await Bun.file(D.filePath).text(),A=Zt(G),bt=A?.middleware?Array.isArray(A.middleware)?A.middleware:[A.middleware]:[],it=[...St,...bt];if(it.length>0){let j=It(h,M,A||{}),N=Ot(j,null,void 0,{isServer:!0}),F=await Nt(it,N);if(F.redirect){let I=typeof F.redirect==="string"?F.redirect:F.redirect.path||F.redirect,z=Qt(String(I),h),L=te(h,e);await R.promises.mkdir(m.dirname(L),{recursive:!0}),await Bun.write(L,z),u.successCount++,u.pages.push({route:h,outputPath:L,size:Buffer.byteLength(z),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${I}`);return}if(F.abort){let I=typeof F.abort==="string"?F.abort:F.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${I}`);return}}let st=A?.validate;if(typeof st==="function")try{if(!await st({params:M})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let B=null,at=!1;if(e.cache){if(B=O.get(h,D.filePath),B)at=!0,u.cachedCount++}if(!B){let j=await wt(D,M,xt,e,s);if(B=j.html,e.failOnIncludeError&&j.includeFailures.length>0)throw Error(`${j.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
39
+ </rss>`}async function Kt(t={}){let n=Date.now();ln();let s=await a(process.cwd()),o=s.build||{},c=await dt({explicit:t.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(gt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.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},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,S={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&R.existsSync(e.outputDir))await R.promises.rm(e.outputDir,{recursive:!0});await R.promises.mkdir(e.outputDir,{recursive:!0});let C=e.cacheSalt;if(!C){let{resolveUserCssConfig:d,fingerprintConfig:y}=await import("./chunk-ba86dkhs.js");try{C=y(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-tahw02kf.js"),E=await b(e.publicDir,e.outputDir);if(E.count>0)console.log(`Optimized ${E.count} image(s) for responsive delivery`),C=[C,E.fingerprint].filter(Boolean).join(":");let O=new ft(e.cacheDir,C);if(e.cache)await O.load();try{let{generateCss:d}=await import("./chunk-ba86dkhs.js");await d('<div class="bg-black"></div>')}catch{}Rt();let yt=s?.routeMiddleware?.dir||"middleware";await Pt(process.cwd(),yt);let V=At();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let St=s?.routeMiddleware?.global||[];dc(s?.layoutsDir,l(process.cwd()));let Q=ee(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Q.length} routes`);let U=[];for(let d of Q)try{let y=await _t(d);for(let D of y)U.push({route:d,url:D.url,params:D.params,props:D.props,revalidate:D.revalidate??e.revalidate})}catch(y){let D=y instanceof Error?y:Error(String(y));u.failedCount++,u.errors.push({route:d.pattern,error:D}),await e.hooks.onError?.(D,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,D)}u.totalPages=U.length+u.failedCount,console.log(`Generating ${U.length} pages...`);let _=[],tt=[];for(let d=0;d<U.length;d+=e.concurrency)tt.push(U.slice(d,d+e.concurrency));for(let d of tt)await Promise.all(d.map(async(y)=>{let{route:D,url:h,params:M,props:xt,revalidate:nt}=y;try{await e.hooks.onPageStart?.(h);let G=await Bun.file(D.filePath).text(),A=Zt(G),bt=A?.middleware?Array.isArray(A.middleware)?A.middleware:[A.middleware]:[],it=[...St,...bt];if(it.length>0){let j=It(h,M,A||{}),N=Ot(j,null,void 0,{isServer:!0}),F=await Nt(it,N);if(F.redirect){let I=typeof F.redirect==="string"?F.redirect:F.redirect.path||F.redirect,z=Qt(String(I),h),L=te(h,e);await R.promises.mkdir(m.dirname(L),{recursive:!0}),await Bun.write(L,z),u.successCount++,u.pages.push({route:h,outputPath:L,size:Buffer.byteLength(z),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${I}`);return}if(F.abort){let I=typeof F.abort==="string"?F.abort:F.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${I}`);return}}let st=A?.validate;if(typeof st==="function")try{if(!await st({params:M})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let B=null,at=!1;if(e.cache){if(B=O.get(h,D.filePath),B)at=!0,u.cachedCount++}if(!B){let j=await wt(D,M,xt,e,s);if(B=j.html,e.failOnIncludeError&&j.includeFailures.length>0)throw Error(`${j.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
40
40
  ${j.includeFailures.join(`
41
41
  `)}
42
42
  Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&j.serverScriptFailures.length>0)throw Error(`${j.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
@@ -65,7 +65,7 @@ ${d}`)}if(e.cache)await O.save();if(e.generate404){let d=m.join(e.pagesDir,"404.
65
65
  <a href="/">Go home</a>
66
66
  </div>
67
67
  </body>
68
- </html>`)}for(let d of[500]){let y=m.join(e.pagesDir,`${d}.stx`);if(await Bun.file(y).exists()){let D=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},M=await i(await Bun.file(y).text(),{},y,h,D);await Bun.write(m.join(e.outputDir,`${d}.html`),M)}}let K=m.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,y={...s,minifyClient:!0,debug:!1,cache:!1},D=await i(await Bun.file(K).text(),{},K,y,d);await Bun.write(m.join(e.outputDir,"error.html"),D)}if(e.sitemap&&_.length>0){let d=Jt(_,e.domain),y=m.join(e.outputDir,"sitemap.xml");await Bun.write(y,d),u.sitemapPath=y,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},y=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],D=Os({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...y.length>0?{disallow:y}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(m.join(e.outputDir,"robots.txt"),D),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},y=[];if(d.getItems)y=await d.getItems();let D=Vt(d,y),h=m.join(e.outputDir,"rss.xml");await Bun.write(h,D),u.rssPath=h,console.log(`Generated rss.xml with ${y.length} items`)}let W=lc(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=uc(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&R.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let rt=or();if(rt)await Y(rt,m.join(e.outputDir,sr)),console.log(`Copied assets from ${on}`)}catch(C){throw await e.hooks.onError?.(C),C}if(u.buildTime=Date.now()-n,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let C={generatedChunks:g.size,totalBytes:v,chunks:S,pages:p};await Bun.write(m.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(C,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
68
+ </html>`)}for(let d of[500]){let y=m.join(e.pagesDir,`${d}.stx`);if(await Bun.file(y).exists()){let D=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},M=await i(await Bun.file(y).text(),{},y,h,D);await Bun.write(m.join(e.outputDir,`${d}.html`),M)}}let K=m.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,y={...s,minifyClient:!0,debug:!1,cache:!1},D=await i(await Bun.file(K).text(),{},K,y,d);await Bun.write(m.join(e.outputDir,"error.html"),D)}if(e.sitemap&&_.length>0){let d=Jt(_,e.domain),y=m.join(e.outputDir,"sitemap.xml");await Bun.write(y,d),u.sitemapPath=y,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},y=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],D=Os({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...y.length>0?{disallow:y}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(m.join(e.outputDir,"robots.txt"),D),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},y=[];if(d.getItems)y=await d.getItems();let D=Vt(d,y),h=m.join(e.outputDir,"rss.xml");await Bun.write(h,D),u.rssPath=h,console.log(`Generated rss.xml with ${y.length} items`)}let W=lc(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=uc(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&R.existsSync(e.publicDir))await Z(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let rt=or();if(rt)await Z(rt,m.join(e.outputDir,sr)),console.log(`Copied assets from ${on}`)}catch(C){throw await e.hooks.onError?.(C),C}if(u.buildTime=Date.now()-n,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let C={generatedChunks:g.size,totalBytes:v,chunks:S,pages:p};await Bun.write(m.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(C,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
69
69
  Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
70
70
  Build complete!
71
71
  Total: ${u.totalPages} pages
@@ -73,7 +73,7 @@ Build complete!
73
73
  Cached: ${u.cachedCount}
74
74
  Failed: ${u.failedCount}
75
75
  Time: ${u.buildTime}ms${P}
76
- `),u}async function Y(t,n){await R.promises.mkdir(n,{recursive:!0});let s=await R.promises.readdir(t,{withFileTypes:!0});for(let o of s){let c=m.join(t,o.name),e=m.join(n,o.name);if(o.isDirectory())await R.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await R.promises.copyFile(c,e)}}function Xt(t={}){let n=t.cacheDir||l(process.cwd(),"ssg-cache"),s=new ht(n),o=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=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=Q(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,C)=>{v[P]=g[C+1]});let S=await a(),{html:p}=await wt(u,v,{},t,S);await s.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:Wt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Yt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let n=await Bun.file(t).text(),s=n.match(/^---\n([\s\S]*?)\n---/),o={},c=n;if(s){let S=s[1];c=n.slice(s[0].length).trim();for(let p of S.split(`
76
+ `),u}async function Z(t,n){await R.promises.mkdir(n,{recursive:!0});let s=await R.promises.readdir(t,{withFileTypes:!0});for(let o of s){let c=m.join(t,o.name),e=m.join(n,o.name);if(o.isDirectory())await R.promises.mkdir(e,{recursive:!0}),await Z(c,e);else await R.promises.copyFile(c,e)}}function Xt(t={}){let n=t.cacheDir||l(process.cwd(),"ssg-cache"),s=new ht(n),o=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=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=ee(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,C)=>{v[P]=g[C+1]});let S=await a(),{html:p}=await wt(u,v,{},t,S);await s.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:Wt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Yt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let n=await Bun.file(t).text(),s=n.match(/^---\n([\s\S]*?)\n---/),o={},c=n;if(s){let S=s[1];c=n.slice(s[0].length).trim();for(let p of S.split(`
77
77
  `)){let P=p.indexOf(":");if(P>0){let C=p.slice(0,P).trim(),b=p.slice(P+1).trim();if(b==="true")b=!0;else if(b==="false")b=!1;else if(/^\d+$/.test(b))b=parseInt(b,10);else if(/^\d+\.\d+$/.test(b))b=parseFloat(b);else if(b.startsWith("[")&&b.endsWith("]"))b=b.slice(1,-1).split(",").map((E)=>E.trim().replace(/^['"]|['"]$/g,""));o[C]=b}}}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>"),u=[],g=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=g.exec(e))!==null){let S=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:S})}return{content:e,data:o,toc:u}}}}function Zt(t){return kt(t)}function Qt(t,n){return`<!DOCTYPE html>
78
78
  <html>
79
79
  <head>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.871",
4
+ "version": "0.2.872",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -127,14 +127,14 @@
127
127
  },
128
128
  "dependencies": {
129
129
  "@stacksjs/clapp": "^0.2.17",
130
- "@stacksjs/desktop": "0.2.871",
131
- "@stacksjs/sanitizer": "0.2.871",
130
+ "@stacksjs/desktop": "0.2.872",
131
+ "@stacksjs/sanitizer": "0.2.872",
132
132
  "@stacksjs/ts-css": "^0.3.21",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
134
  "@types/dom-speech-recognition": "^0.0.12",
135
- "bun-plugin-stx": "0.2.871",
135
+ "bun-plugin-stx": "0.2.872",
136
136
  "bunfig": "^0.15.21",
137
- "stx-router": "0.2.871",
137
+ "stx-router": "0.2.872",
138
138
  "ts-broadcasting": "^0.0.13",
139
139
  "ts-images": "^0.2.22",
140
140
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{G}from"./chunk-zebk7htd.js";function n(t){return G(t)}
3
- export{n};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{io,Hi,Fg,zg,Hg}from"./chunk-583rbj5e.js";import"./chunk-8q37c0jm.js";export{zg as generateManifestLink,io as generatePwaTags,Fg as generateSwRegistrationScript,Hg as generateThemeColorMeta,Hi as injectPwaTags};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{lm}from"./chunk-xga3xhzr.js";import"./chunk-nbvpjwj1.js";import"./chunk-fn2j7g8g.js";import"./chunk-ptfhh54v.js";import"./chunk-q1wxgw5s.js";import"./chunk-38tdqbf1.js";import"./chunk-3mb2pw1s.js";import"./chunk-1217683z.js";import"./chunk-74vp2yw4.js";import"./chunk-wvtmex14.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-3z3y475q.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{lm as startInteractive};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ya,mm,ba,hm,Yl,Zl,ym,bm}from"./chunk-5kc0r06s.js";import"./chunk-n16ba3wz.js";import"./chunk-f14pyq81.js";import"./chunk-avfsad8j.js";import"./chunk-9zrvh3pz.js";import"./chunk-wvtmex14.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import{lt,gg}from"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{ya as buildScriptVirtualFile,mm as buildVirtualSource,lt as extractScriptBlocks,gg as extractTemplateExpressions,Yl as findRuntimeTypeDeclarations,Zl as findStxModuleDeclarations,bm as formatTypecheckDiagnostics,hm as sourcePathFor,ym as typecheckStxFiles,ba as virtualPathFor};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{dm}from"./chunk-jafn6jh0.js";import"./chunk-hcp8qese.js";import"./chunk-pczh82f8.js";import"./chunk-avfsad8j.js";import"./chunk-3mb2pw1s.js";import"./chunk-80x7c8d8.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{dm as startProductionServer};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{La,ja,Ba,Fa,Bh}from"./chunk-89xpfwy4.js";import"./chunk-pywz8q4k.js";import"./chunk-1n7vjs3t.js";import"./chunk-5h9d6jew.js";import"./chunk-nbvpjwj1.js";import"./chunk-fn2j7g8g.js";import"./chunk-ptfhh54v.js";import"./chunk-q1wxgw5s.js";import"./chunk-38tdqbf1.js";import"./chunk-3mb2pw1s.js";import"./chunk-1217683z.js";import"./chunk-74vp2yw4.js";import"./chunk-wvtmex14.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-3z3y475q.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{La as buildNative,Bh as default,ja as findCraftBinary,Fa as getAvailableFormats,Ba as getAvailableTargets};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{um}from"./chunk-gqjt1va8.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{um as buildApp};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ym,Aa,_u,Zm,Qm,eh,th,nh,Cu,Eu,rh,sh,oh,ih}from"./chunk-1ptjecaz.js";import"./chunk-nbvpjwj1.js";import"./chunk-fn2j7g8g.js";import"./chunk-ptfhh54v.js";import"./chunk-q1wxgw5s.js";import"./chunk-38tdqbf1.js";import"./chunk-3mb2pw1s.js";import"./chunk-1217683z.js";import"./chunk-74vp2yw4.js";import"./chunk-wvtmex14.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-3z3y475q.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{_u as SUSPENSE_RESOLVER_RUNTIME,Aa as buildSuspenseResolveScript,nh as createStreamRenderer,eh as extractStreamBoundaries,ih as generateHydrationRuntime,Eu as islandDirective,sh as processSectionDirectives,Qm as processStreamDirectives,rh as registerStreamingDirectives,Zm as renderStreamingPage,Ym as streamTemplate,th as streamTemplateSimple,oh as streamToResponse,Cu as streamingSuspenseDirective};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{xh,Co,Sh,kh,_h,Ch}from"./chunk-c8d5cv6w.js";import"./chunk-f14pyq81.js";import"./chunk-avfsad8j.js";import"./chunk-9zrvh3pz.js";import"./chunk-wvtmex14.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Ch as clearStoreCache,xh as getStoreScript,_h as getStoreScriptFor,kh as pageStoresAll,Co as storesRead,Sh as storesReadInFiles};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{qh,Xf,tt,wc,Kh,gs,ms,hs}from"./chunk-ptfhh54v.js";import"./chunk-38tdqbf1.js";import"./chunk-3mb2pw1s.js";import"./chunk-74vp2yw4.js";import"./chunk-az07qe58.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Kh as clearOnceStore,wc as onceStore,tt as partialsCache,gs as processIncludes,ms as processStackPushDirectives,hs as processStackReplacements,qh as resetUnscopedSignalWarnings,Xf as topLevelElements};
@@ -1,20 +0,0 @@
1
- // @bun
2
- import{ar,Oe}from"./chunk-9zrvh3pz.js";import{K,S,Cr,Vs,T}from"./chunk-zebk7htd.js";import{a,M}from"./chunk-has2s6zj.js";import{Fo}from"./chunk-avfsad8j.js";import{at}from"./chunk-n3jw3xpj.js";import{l}from"./chunk-46pxmpeb.js";import{r,we}from"./chunk-x7redxyd.js";import d from"path";import j from"fs";import{AsyncLocalStorage as ot}from"async_hooks";import{randomUUID as bt}from"crypto";var $t=11;function J(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||Fo(t,e,n)}var lt=2;function Nf(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):l(t,"bundle-cache")}function nt(t,e){let n=t;for(let i of wt(e))if(i!==d.sep)n=n.split(i).join("\x00root");return n}var st=new Map;function wt(t){let e=d.resolve(t),n=st.get(e);if(!n){let i=e;try{i=j.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((c,p)=>p.length-c.length),st.set(e,n)}return n}function St(t,e){try{let n=j.statSync(t),i=d.resolve(e),c=t.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,t):t,...c?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(j.readFileSync(t)).toString(36)}}catch{return null}}function ct(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function vt(t,e){for(let n of t){let i=ct(n,e);try{let c=j.statSync(i);if(c.size!==n.size)return!1;if(c.mtimeMs!==n.mtimeMs&&Bun.hash(j.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ut=new Map,Bt=100;function Df(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function jt(t){let e=G.get(t)??0;if(e>0&&e<Bt){G.set(t,e+1);return}G.set(t,1);try{let n=(await j.promises.readdir(t)).filter((o)=>o.endsWith(".js")),i=Df();if(n.length<=i)return;let p=(await Promise.all(n.map(async(o)=>{try{return{name:o,at:(await j.promises.stat(d.join(t,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,b)=>b.at-o.at);for(let o of p.slice(i)){let b=o.name.slice(0,-3);await j.promises.rm(d.join(t,`${b}.js`),{force:!0}),await j.promises.rm(d.join(t,`${b}.deps.json`),{force:!0})}N("pruned bundle cache to",i,"entries")}catch{}}function xe(t){return ut.get(t)??[]}function q(t,e){if(t)ut.set(t,e)}function Mf(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function N(...t){if(Mf())console.log("[stx:bundler]",...t)}var Y=[];function pc(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function cn(){return Y.slice()}function ln(){Y.length=0}var Z;function Fh(t){Z=t}function fc(){if(Z)return Z;try{let t=M.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function un(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let c=n[1];if(!Q.some((o)=>o.test(c)))return N("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let c=n[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!Q.some((o)=>o.test(c)))return N("detected side-effect import:",c),!0}return!1}var ir="stx-module:",Et=/\.(?:[cm]?[jt]sx?|json)$/i;function Lf(t,e){return d.relative(t,e).split(d.sep).join("/")}function jf(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,c,p)=>{let o=e.get(p);return o&&!p.startsWith(ir)?`${i}${c}${o}${c}`:n})}function Bf(t,e){let n=0,i=(p)=>{let o=`__stxMod${n++}`,b=JSON.stringify(p);return e.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let b of p.split(",")){let C=b.trim();if(!C)continue;let R=C.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!R)continue;let w=R[1].startsWith('"')?JSON.parse(R[1]):R[1],f=R[2]??w;e.push(`var ${f} = ${o}[${JSON.stringify(w)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,b)=>{let C=b.slice(ir.length),R=i(C),w=o.trim(),f=w.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!w.startsWith("{")&&!w.startsWith("*"))e.push(`var ${f[1]} = ${R}.default;`),w=w.slice(f[0].length).trim();let v=w.match(/^\*\s*as\s+([\w$]+)$/);if(v)e.push(`var ${v[1]} = ${R};`);else if(w.startsWith("{"))c(w.replace(/^\{|\}$/g,""),R);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(ir.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(j.existsSync(n)&&j.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var X=new ot;function ds(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,c]of[...t].sort(([p],[o])=>p<o?-1:p>o?1:0))n.update(`${i}\x00${c}\x00`);return X.run({modules:t,key:n.digest("hex").slice(0,12)},e)}var dt=new ot;function Ff(t){return dt.run(!0,t)}function zf(){return dt.getStore()===!0}function gc(t){if(!zf())return;throw Error(`The client script of ${t} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function dn(){return X.getStore()?.key??""}function pt(t,e,n,i,c,p,o=new Map,b,C,R){let w=new Map([[n,i],...R??[]]),f=(B)=>B!==void 0&&w.has(B),v=(B,s,u)=>{if(J(s,t,b))return null;if(!p||!f(B)||!Et.test(s))return null;try{if(!j.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(s);let E=`${ir}${Lf(process.cwd(),s)}`;return o.set(u,E),{path:E,external:!0}},y=(B,s)=>{let u=f(B)?e:d.dirname(B),E=d.resolve(u,s);return rt(E)??E};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),B.onResolve({filter:/^\//},(s)=>{if(f(s.path))return{path:s.path};let u=rt(s.path);if(u){let E=v(s.importer,u,s.path);if(E)return E;if(!f(u))c.add(u);return{path:u}}return{path:s.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(s)=>{let u=y(s.importer,s.path),E=v(s.importer,u,s.path);if(E)return E;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(s)=>{let u=d.resolve(t,s.path.slice(2)),E=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let h of E)if(j.existsSync(h)&&j.statSync(h,{throwIfNoEntry:!1})?.isFile()){let D=v(s.importer,h,s.path);if(D)return D;return N(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",h),c.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(!f(s.importer))return;let u=`${ir}npm:${s.path}`;return o.set(s.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(w.has(s.path))return{contents:w.get(s.path),loader:"ts"};if(J(s.path,t,b))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let u=d.extname(s.path).toLowerCase(),E=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(s.path))c.add(s.path);let h=C?.get(s.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:j.readFileSync(s.path,"utf8"),loader:E}})}}}var H=new Map,z=S(64),it=Symbol.for("stx.client-bundle-build-queue");function Hf(t){let e=globalThis,i=(e[it]??Promise.resolve()).then(t,t);return e[it]=i.then(()=>{return},()=>{return}),i}async function pn(t,e,n={}){let i=n.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=n.minify??!1,o=n.externalizeUserModules??!0,b=n.expose?.length?[...new Set(n.expose)].sort():void 0,C=n.cacheDir||Nf(i),R=X.getStore(),w=new Bun.CryptoHasher("md5");w.update(`${$t}\x00${at()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${b?b.join(","):"*"}\x00${p?"minified":"readable"}\x00${R?.key??""}\x00${nt(t,i)}\x00${nt(e,i)}`);let f=w.digest("hex").slice(0,12),v=d.join(C,`${f}.js`),y=z.get(v);if(y){if(Vs(y.files)&&y.files.every((h)=>!J(h.path,i,c))){N("memo hit:",f);let h=y.files.map((D)=>D.path);return q(e,h),n.collectInputs?.push(...h),y.code}z.delete(v),N("memo invalidated by dep change:",f)}let B=d.join(C,`${f}.deps.json`),s=Bun.file(v);if(await s.exists()){let h=Bun.file(B),D=!1,k=null;if(await h.exists())try{let O=JSON.parse(await h.text());if(O.metadataVersion===lt&&Array.isArray(O.files)&&vt(O.files,i))k=Cr(O.files.map((g)=>ct(g,i))),D=k.length===O.files.length&&!k.some((g)=>J(g.path,i,c))}catch{D=!1}if(D){if(N("cache hit:",f),k)q(e,k.map((U)=>U.path)),n.collectInputs?.push(...k.map((U)=>U.path));let O=await s.text(),g=new Date;if(j.promises.utimes(v,g,g).catch(()=>{}),k)z.set(v,{code:O,files:k});return O}N("cache invalidated by dep change:",f)}let u=H.get(f);if(u){let h=await u;if(n.collectInputs)n.collectInputs.push(...(z.get(v)?.files??[]).map((D)=>D.path));return h}gc(e);let E=Hf(()=>_t(t,e,{projectRoot:i,minify:p,cacheDir:C,hash:f,cachePath:v,depsPath:B,collectInputs:n.collectInputs,externalizeUserModules:o,serverApi:c,expose:b,throwOnFailure:n.throwOnFailure,substitutes:R?.modules}));H.set(f,E);try{return await E}finally{H.delete(f)}}function mc(t){return`${t}-${process.pid}-${bt()}`}async function zh(t,e){let{projectRoot:n}=e,i=mc(new Bun.CryptoHasher("md5").update([...t.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(n,"bundle-tmp"),"out",i);j.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,b=0;for(let[f,v]of t){let y=d.join(n,`.stx-split-${i}-${b++}.ts`);p.set(y,v),o.set(d.basename(y).replace(/\.ts$/,""),f)}let[C,R]=[...p][0],w=new Set;gc(e.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[pt(n,d.dirname(e.filePath),C,R,w,!1,new Map,void 0,X.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...T()},root:n});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let B=d.basename(y.path);if(y.kind==="entry-point"){let s=o.get(B.replace(/\.js$/,""));if(s!==void 0)v.entries.set(s,await y.text())}else if(y.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await y.text())}return e.collectInputs?.push(...w),v}finally{try{j.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function _t(t,e,n){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:b,depsPath:C,externalizeUserModules:R}=n,w=l(i,"bundle-tmp"),f=mc(o),v=d.join(i,`.stx-client-${f}.ts`),y=d.join(w,"out",f);j.mkdirSync(y,{recursive:!0});let B=d.dirname(e),s=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,E=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=r(t),{depths:D,balanced:k}=we(h),O=(F)=>!k||D[F]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((F)=>{let m=Mt(F);if(m)s.add(m)});else if(g[3])s.add(g[3])}while((g=E.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;s.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!O(g.index))continue;let F=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(F&&Q.some((m)=>m.test(F)))continue;if(g[1])s.add(g[1]);if(g[2])s.add(g[2]);for(let m of(g[3]??"").split(",")){let _=m.trim();if(!_||/^type\s/.test(_))continue;let L=/\bas\s+(\w+)\s*$/.exec(_)?.[1]??/^\w+$/.exec(_)?.[0];if(L)s.add(L)}}for(let F of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of F[1].split(",")){let _=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(_)s.delete(_)}let ft=s.size>0?`
3
- export { ${[...s].join(", ")} }`:"";N("bundling:",o,"from:",d.basename(e));let tt=new Set,et=new Map;try{let F=await Bun.build({entrypoints:[v],outdir:y,target:"browser",format:"esm",minify:c?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[pt(i,B,v,t+ft,tt,R,et,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":c?'"production"':'"development"',...T()},root:i});if(!F.success){let I=F.logs.filter((A)=>A.level==="error").map((A)=>A.message).join(", ")||`Unable to bundle ${d.basename(e)}`,P=ar(F.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",I),pc(e||"",I,P),n.throwOnFailure||fc()==="error")throw Error(I);return t}let m="";for(let x of F.outputs){m=await x.text();break}let _=[];for(let x of m.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of x[1].split(",")){let P=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(P){_.push([P[2],P[1]]);continue}let A=I.trim();if(/^[A-Za-z_$][\w$]*$/.test(A))_.push([A,A])}if(n.expose){let x=new Set(n.expose);for(let I=_.length-1;I>=0;I--)if(!x.has(_[I][0]))_.splice(I,1)}let L=[];m=Bf(jf(m,et),L);let mt=m.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(m=m.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),c&&m)try{m=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(m)}catch{}let V=`__stxBundle_${o}`,gt=new Set(K(t,!0).split(",").map((x)=>x.trim())),ht=_.map(([x,I])=>`get ${JSON.stringify(x)}() { return ${I} }${gt.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${I}) { ${I} = __stxValue_${I} }`:""}`).join(", "),xt=_.map(([x])=>`var ${x} = undefined;`).join(`
4
- `),yt=_.map(([x])=>`${x} = ${V}[${JSON.stringify(x)}];`).join(`
5
- `);if(m=`${mt.join(`
6
- `)}
7
- ${xt}
8
- var ${V} = (function() {
9
- ${L.join(`
10
- `)}
11
- ${m}
12
- return { ${ht} };
13
- })();
14
- ${yt}
15
- var __stxLiveBindings = typeof __stxLiveBindings === 'undefined' ? {} : __stxLiveBindings;
16
- Object.keys(${V}).forEach(function(name) {
17
- if (!Object.prototype.hasOwnProperty.call(__stxLiveBindings, name))
18
- Object.defineProperty(__stxLiveBindings, name, Object.getOwnPropertyDescriptor(${V}, name));
19
- });`.trim(),N("bundled:",o,"output:",m.length,"bytes"),s.size>0&&_.length===0)return console.warn(`[stx:bundler] dropped every binding for ${d.basename(e)} (${o}); serving the unbundled source and not caching this result`),t;j.mkdirSync(p,{recursive:!0}),await Bun.write(b,m);let W=Cr(tt);return await Bun.write(C,JSON.stringify({metadataVersion:lt,files:W.map((x)=>St(x.path,i)).filter((x)=>x!==null)})),q(e,W.map((x)=>x.path)),n.collectInputs?.push(...W.map((x)=>x.path)),z.set(b,{code:m,files:W}),await jt(p),m}catch(F){let m=ar(F,e||void 0),_=Oe(F,e||void 0);if(console.warn(`[stx:bundler] error: ${_}`),pc(e||"",_,m),n.throwOnFailure||fc()==="error")throw F;return t}finally{try{j.rmSync(y,{recursive:!0,force:!0})}catch{}}}function Mt(t){let e=t.trim();if(!e)return null;let n=e.indexOf("=");if(n!==-1)e=e.slice(0,n).trim();let i=e.indexOf(":");if(i!==-1)e=e.slice(i+1).trim();if(e.startsWith("..."))e=e.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(e)?e:null}
20
- export{Nf,Df,xe,Mf,pc,cn,ln,Fh,fc,un,ir,Lf,jf,Bf,ds,Ff,zf,gc,dn,Hf,pn,mc,zh};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ca,eu}from"./chunk-vrcr4b13.js";import"./chunk-k7m8659h.js";import"./chunk-5h9d6jew.js";export{eu as createImageHandler,Ca as handleImageRequest};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{U,rg,ri,$c,a,M,iy,ay}from"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{M as config,U as defaultConfig,iy as defineStxConfig,ri as discoverConfig,a as loadStxConfig,$c as resolveInstalledPackage,rg as resolveStxDirectories,ay as validateConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ws,Jf,Ko,Yf}from"./chunk-1217683z.js";import"./chunk-74vp2yw4.js";import"./chunk-wvtmex14.js";import"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import{jt}from"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Yf as declareBareLoopHead,jt as parseLoopBinding,Jf as processLoops,Ko as processLoopsAsync,ws as reportDeferredLoopWarnings};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Fl,zl}from"./chunk-msvh8rda.js";import"./chunk-v37zmez0.js";import"./chunk-xga3xhzr.js";import"./chunk-gqjt1va8.js";import"./chunk-jafn6jh0.js";import"./chunk-nack2xs5.js";import"./chunk-ce49k18q.js";import"./chunk-5kc0r06s.js";import"./chunk-gkdgg83x.js";import"./chunk-hcp8qese.js";import"./chunk-6ftee542.js";import"./chunk-vrcr4b13.js";import"./chunk-ew5cey88.js";import"./chunk-a3rqpyt8.js";import"./chunk-k7m8659h.js";import"./chunk-ysfeg3cn.js";import"./chunk-01mwbg1r.js";import"./chunk-55zq2ha8.js";import"./chunk-hev4t4d5.js";import"./chunk-8tk8yf91.js";import"./chunk-5qfrnjkd.js";import"./chunk-1ptjecaz.js";import"./chunk-qcxrcypb.js";import"./chunk-gbtbfg7e.js";import"./chunk-cqhwzd9y.js";import"./chunk-j1efsjsb.js";import"./chunk-c8d5cv6w.js";import"./chunk-n16ba3wz.js";import"./chunk-2sw68zck.js";import"./chunk-1n7vjs3t.js";import"./chunk-5h9d6jew.js";import"./chunk-v4xes880.js";import{an}from"./chunk-pczh82f8.js";import{Ff}from"./chunk-f14pyq81.js";import"./chunk-avfsad8j.js";import"./chunk-9zrvh3pz.js";import{Ne,i}from"./chunk-nbvpjwj1.js";import"./chunk-fn2j7g8g.js";import"./chunk-ptfhh54v.js";import"./chunk-q1wxgw5s.js";import"./chunk-38tdqbf1.js";import"./chunk-3mb2pw1s.js";import"./chunk-1217683z.js";import"./chunk-74vp2yw4.js";import"./chunk-wvtmex14.js";import{_e}from"./chunk-80x7c8d8.js";import"./chunk-az07qe58.js";import{hr,yr}from"./chunk-3z3y475q.js";import{$s,U,a}from"./chunk-has2s6zj.js";import"./chunk-3fkbbkkt.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-qnky63y3.js";import"./chunk-dy7vqv1x.js";import{L,h,He}from"./chunk-zebk7htd.js";import"./chunk-3972v2g1.js";import"./chunk-60yppcbb.js";import"./chunk-pffksrxb.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";import{Ui}from"./chunk-fd1bpv35.js";import"./chunk-40h07m5w.js";import"./chunk-7cvbz4eq.js";export{$s as buildWebComponents,yr as cacheTemplate,hr as checkCache,an as classifyAllScripts,Fl as createMiddleware,zl as createRoute,U as defaultConfig,h as extractVariables,L as findSfcTemplateBlock,_e as injectRouterScript,Ui as insertBeforeBodyClose,a as loadStxConfig,He as processClientScript,i as processDirectives,Ne as readMarkdownFile,Ff as withinBundlerCallback};