@stacksjs/stx 0.2.563 → 0.2.565
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.
- package/dist/app-shell.d.ts +3 -0
- package/dist/app-shell.js +27 -3
- package/dist/{chunk-2tm3vzm7.js → chunk-01s01ten.js} +5 -5
- package/dist/chunk-04qvjcsr.js +2 -0
- package/dist/chunk-125rc958.js +3 -0
- package/dist/chunk-15g5sc0p.js +3 -0
- package/dist/{chunk-171xv81z.js → chunk-18270qgd.js} +2 -2
- package/dist/{chunk-g6cwhsb4.js → chunk-1hrj0t0j.js} +11 -11
- package/dist/chunk-1zfg1kd5.js +2 -0
- package/dist/chunk-203rr1c8.js +3 -0
- package/dist/{chunk-xb739v4r.js → chunk-2ernwctg.js} +6 -6
- package/dist/chunk-2xbrrc5a.js +2 -0
- package/dist/chunk-2yypassp.js +2 -0
- package/dist/{chunk-fgmv8f14.js → chunk-325p135t.js} +12 -12
- package/dist/{chunk-v1m9nrn9.js → chunk-36aj0yzt.js} +1 -1
- package/dist/chunk-375skn32.js +2 -0
- package/dist/{chunk-qmza4327.js → chunk-39tkfkp7.js} +3 -3
- package/dist/{chunk-jjwg83xv.js → chunk-3hkv4e7t.js} +1 -1
- package/dist/chunk-3wyxe996.js +2 -0
- package/dist/chunk-4mmdpb46.js +2 -0
- package/dist/chunk-4q5d5r7s.js +2 -0
- package/dist/{chunk-mtdx75j5.js → chunk-4zb2ga7p.js} +2 -2
- package/dist/{chunk-vb1w9wy4.js → chunk-55hfvmvv.js} +13 -13
- package/dist/{chunk-7t05bpf7.js → chunk-5grx48s2.js} +2 -2
- package/dist/{chunk-7wfh2hqy.js → chunk-5s555c1r.js} +4 -4
- package/dist/chunk-5ytg0wbc.js +2 -0
- package/dist/{chunk-8227vfw0.js → chunk-68b64sj4.js} +1 -1
- package/dist/chunk-6qyters0.js +2 -0
- package/dist/{chunk-6bxy1b9q.js → chunk-6sf4v894.js} +5 -5
- package/dist/{chunk-yp00nht2.js → chunk-6vnnx536.js} +2 -2
- package/dist/chunk-6yn90mq9.js +2 -0
- package/dist/chunk-7d2vyre0.js +2 -0
- package/dist/{chunk-r4199q6x.js → chunk-7m0r2qs2.js} +2 -2
- package/dist/chunk-7pewegtw.js +2 -0
- package/dist/chunk-7w0qa3n0.js +2 -0
- package/dist/{chunk-5fx8m234.js → chunk-7wyyjdks.js} +2 -2
- package/dist/{chunk-nd8v4xgb.js → chunk-7ze47qgv.js} +5 -5
- package/dist/{chunk-x8rx0s3h.js → chunk-8afnq4qx.js} +3 -3
- package/dist/{chunk-gxtk4fbm.js → chunk-8cpqy9ea.js} +1726 -1726
- package/dist/{chunk-97vj2cqz.js → chunk-8cs45k3f.js} +3 -3
- package/dist/chunk-8d788kvt.js +2 -0
- package/dist/{chunk-s040j1bv.js → chunk-8nr1kras.js} +6 -6
- package/dist/{chunk-912cj8pq.js → chunk-8txqk9nq.js} +2 -2
- package/dist/chunk-90qywh24.js +31 -0
- package/dist/{chunk-nda4xq79.js → chunk-9tcvkbb5.js} +2 -2
- package/dist/{chunk-vpmb8gcc.js → chunk-9ya4tdpz.js} +4 -4
- package/dist/{chunk-n1cqg89v.js → chunk-b76jbdtk.js} +2 -2
- package/dist/chunk-bdhtq3vs.js +2 -0
- package/dist/chunk-brnapchc.js +2 -0
- package/dist/chunk-c765y72x.js +18 -0
- package/dist/chunk-c78327kx.js +2 -0
- package/dist/chunk-cbyh8fhn.js +4 -0
- package/dist/chunk-d19w3e4x.js +2 -0
- package/dist/{chunk-jen9yg68.js → chunk-d1mqedk0.js} +7 -7
- package/dist/{chunk-6v1gwdbv.js → chunk-d4ybwtqt.js} +2 -2
- package/dist/chunk-da649d3k.js +2 -0
- package/dist/chunk-da9avgd9.js +2 -0
- package/dist/chunk-dkyjw3hc.js +3 -0
- package/dist/{chunk-ff61d2wr.js → chunk-dmf1jmge.js} +3 -3
- package/dist/chunk-e3njkecx.js +2 -0
- package/dist/chunk-efzc1nw8.js +2 -0
- package/dist/{chunk-h23bjqn1.js → chunk-ev3qnr9q.js} +31 -31
- package/dist/{chunk-y0pbnxjg.js → chunk-f46a7pvn.js} +2 -2
- package/dist/{chunk-azb58ven.js → chunk-ffxwsa94.js} +2 -2
- package/dist/chunk-fm4w1r9e.js +2 -0
- package/dist/{chunk-8jc86h7n.js → chunk-fpa1nq88.js} +2 -2
- package/dist/{chunk-tc2z8t2q.js → chunk-g1epk002.js} +5 -5
- package/dist/{chunk-8a4g0mex.js → chunk-g8tx0yf8.js} +7 -7
- package/dist/chunk-gan95hj0.js +2 -0
- package/dist/{chunk-e124cgb6.js → chunk-ghnkphy4.js} +2 -2
- package/dist/{chunk-m5fw8jq1.js → chunk-gjx5256r.js} +5 -5
- package/dist/chunk-hg7amzgz.js +2 -0
- package/dist/chunk-hmk7z0z6.js +2 -0
- package/dist/chunk-hn105xy3.js +2 -0
- package/dist/{chunk-8nwzd6eg.js → chunk-jbmhdyzz.js} +3 -3
- package/dist/chunk-jq079mrx.js +2 -0
- package/dist/chunk-jr149mmp.js +2 -0
- package/dist/{chunk-v79qs0qh.js → chunk-jra9r8fq.js} +1 -1
- package/dist/{chunk-zmq9hwta.js → chunk-k2dgwy05.js} +2 -2
- package/dist/chunk-k50k9zbw.js +2 -0
- package/dist/{chunk-xab6b4mt.js → chunk-kch9a9v1.js} +2 -2
- package/dist/chunk-kwxy0e3r.js +2 -0
- package/dist/chunk-kza3nxr0.js +2 -0
- package/dist/{chunk-g12j8ahm.js → chunk-m6m19hwd.js} +4 -4
- package/dist/{chunk-a5kaw8sc.js → chunk-m8qgr307.js} +8 -8
- package/dist/chunk-m9cmc6np.js +2 -0
- package/dist/chunk-m9r4x7e6.js +2 -0
- package/dist/chunk-mahv855w.js +2 -0
- package/dist/{chunk-27t55gtk.js → chunk-mb59b499.js} +6 -6
- package/dist/chunk-mbwdn96z.js +2 -0
- package/dist/chunk-mdxg95mq.js +2 -0
- package/dist/{chunk-2m91qmby.js → chunk-mm1vvk49.js} +5 -5
- package/dist/chunk-mqje968d.js +2 -0
- package/dist/{chunk-pp9jgyb6.js → chunk-mt8sew7a.js} +10 -10
- package/dist/{chunk-7gdvp6py.js → chunk-n1xcmhjw.js} +3 -3
- package/dist/chunk-n2g9mj2h.js +2 -0
- package/dist/chunk-n2nha538.js +2 -0
- package/dist/{chunk-f92hq39b.js → chunk-n6va14bt.js} +2 -2
- package/dist/chunk-nebw444s.js +2 -0
- package/dist/{chunk-gbx3gx8a.js → chunk-nm0y4qjg.js} +4 -4
- package/dist/chunk-nmt7kw0e.js +2 -0
- package/dist/chunk-pq8mz4ma.js +2 -0
- package/dist/chunk-pxcmv1xz.js +2 -0
- package/dist/chunk-pxes1ft6.js +2 -0
- package/dist/{chunk-v09hk0j6.js → chunk-pzasxhwz.js} +1 -1
- package/dist/{chunk-v2b8pa86.js → chunk-q94wdmdp.js} +3 -3
- package/dist/chunk-qajc13zq.js +2 -0
- package/dist/{chunk-1c4t7ncb.js → chunk-qj4j547f.js} +2 -2
- package/dist/chunk-qtnqmw1n.js +2 -0
- package/dist/chunk-r3zdgeah.js +2 -0
- package/dist/{chunk-4r7s3862.js → chunk-r47cs92n.js} +2 -2
- package/dist/chunk-r5htacg5.js +2 -0
- package/dist/chunk-rf2rwddd.js +2 -0
- package/dist/{chunk-1xgs9gd5.js → chunk-rgage0vm.js} +2 -2
- package/dist/{chunk-1zeqghsw.js → chunk-s1xxkzc9.js} +9 -9
- package/dist/chunk-s833fbvf.js +2 -0
- package/dist/{chunk-tqnh98j7.js → chunk-saf7kypg.js} +3 -3
- package/dist/chunk-sgvszh9s.js +2 -0
- package/dist/{chunk-emta09j6.js → chunk-ss78553t.js} +1 -1
- package/dist/chunk-t5r3s1wj.js +2 -0
- package/dist/{chunk-bqdsc6rm.js → chunk-tc01jkfc.js} +1 -1
- package/dist/{chunk-p2mxsjv1.js → chunk-tfeenp4h.js} +10 -10
- package/dist/chunk-tjprg6kq.js +2 -0
- package/dist/{chunk-hj67a88k.js → chunk-tsmbstj6.js} +7 -7
- package/dist/chunk-v0dzrwg8.js +2 -0
- package/dist/chunk-vtz9empe.js +2 -0
- package/dist/chunk-wa6nzq5b.js +2 -0
- package/dist/{chunk-3nc2fr4q.js → chunk-wm11csdm.js} +2 -2
- package/dist/{chunk-xj45mw7v.js → chunk-wsdn5fxe.js} +3 -3
- package/dist/{chunk-ah7h9q0x.js → chunk-wwn9dh6p.js} +2 -2
- package/dist/{chunk-yn3kp3qy.js → chunk-wy4hfmjs.js} +5 -5
- package/dist/{chunk-qfc912e5.js → chunk-xfpfs9zq.js} +2 -2
- package/dist/chunk-xw8kzm6b.js +2834 -0
- package/dist/chunk-xyhg70x9.js +63 -0
- package/dist/{chunk-w8q1xp9e.js → chunk-ymdy7b8z.js} +2 -2
- package/dist/chunk-ytdzgctp.js +2 -0
- package/dist/{chunk-wk85dz07.js → chunk-z06npyzn.js} +3 -3
- package/dist/chunk-z2n1rtj5.js +2 -0
- package/dist/cli.js +22 -22
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/database.js +2 -2
- package/dist/native/components/primitives.d.ts +20 -4
- package/dist/native/index.d.ts +3 -0
- package/dist/native/primitives/Map.stx +2 -1
- package/dist/native/prop-names.js +3 -0
- package/dist/native/runtime/craft-bridge.js +24 -11
- package/dist/native/runtime/craft.d.ts +6 -5
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +11 -11
- package/dist/stx.d.ts +1 -1028
- package/dist/variable-extractor.js +2 -2
- package/package.json +5 -5
- package/stx.d.ts +2 -0
- package/dist/chunk-00dp53cx.js +0 -2
- package/dist/chunk-0pvn63x7.js +0 -2
- package/dist/chunk-0vpmdhfm.js +0 -2
- package/dist/chunk-10jwyvm0.js +0 -2
- package/dist/chunk-1ena03xn.js +0 -2
- package/dist/chunk-2bpj2dsh.js +0 -2
- package/dist/chunk-31ez1sq0.js +0 -2
- package/dist/chunk-3m2h76cz.js +0 -2
- package/dist/chunk-3n26hf93.js +0 -2
- package/dist/chunk-3nk8cnrm.js +0 -3
- package/dist/chunk-3tccqahy.js +0 -2
- package/dist/chunk-40fqmb3q.js +0 -2
- package/dist/chunk-45tq56qf.js +0 -2
- package/dist/chunk-46wykvrs.js +0 -2
- package/dist/chunk-4cmqjmqr.js +0 -3
- package/dist/chunk-56mkcxvb.js +0 -2
- package/dist/chunk-56wcmck6.js +0 -2
- package/dist/chunk-5eyf2zeg.js +0 -2
- package/dist/chunk-68ph8r20.js +0 -2
- package/dist/chunk-6bcvd3pg.js +0 -2
- package/dist/chunk-6n8jzdnm.js +0 -18
- package/dist/chunk-6va8wt88.js +0 -2
- package/dist/chunk-7acxdp9r.js +0 -2
- package/dist/chunk-7h324n17.js +0 -2
- package/dist/chunk-8fpz04kx.js +0 -2
- package/dist/chunk-8fwczr4s.js +0 -63
- package/dist/chunk-9skdekv5.js +0 -2
- package/dist/chunk-c3v5zmnq.js +0 -2
- package/dist/chunk-ce7zwt4v.js +0 -2
- package/dist/chunk-cp4dr9ch.js +0 -2
- package/dist/chunk-d7mfkc61.js +0 -2
- package/dist/chunk-d8fhthyf.js +0 -2
- package/dist/chunk-dekpf1ry.js +0 -2
- package/dist/chunk-dyavx9a1.js +0 -2
- package/dist/chunk-dz7v901d.js +0 -2
- package/dist/chunk-e099d50m.js +0 -2
- package/dist/chunk-e473tm1d.js +0 -2
- package/dist/chunk-eeadhr78.js +0 -2
- package/dist/chunk-evwj0k99.js +0 -2834
- package/dist/chunk-f11sx09b.js +0 -3
- package/dist/chunk-fdkyvr7y.js +0 -2
- package/dist/chunk-fqge0zn8.js +0 -2
- package/dist/chunk-fz7dxc1q.js +0 -2
- package/dist/chunk-hp8g2q2n.js +0 -2
- package/dist/chunk-hpeg9erh.js +0 -3
- package/dist/chunk-hv2kxb94.js +0 -2
- package/dist/chunk-j9c0yam7.js +0 -2
- package/dist/chunk-k9nd7z8j.js +0 -2
- package/dist/chunk-m7jmpech.js +0 -2
- package/dist/chunk-m7ktr4xn.js +0 -2
- package/dist/chunk-mjdyyekx.js +0 -4
- package/dist/chunk-njrakvz7.js +0 -2
- package/dist/chunk-nr5jf1hp.js +0 -2
- package/dist/chunk-qd7bqhm3.js +0 -2
- package/dist/chunk-qprkb5qe.js +0 -2
- package/dist/chunk-schxd5k5.js +0 -2
- package/dist/chunk-sn5c0x7q.js +0 -2
- package/dist/chunk-sx4wmprc.js +0 -2
- package/dist/chunk-t94z65ry.js +0 -2
- package/dist/chunk-vakryadj.js +0 -2
- package/dist/chunk-vgge9rf4.js +0 -2
- package/dist/chunk-w36w5jgs.js +0 -30
- package/dist/chunk-wzymzex7.js +0 -2
- package/dist/chunk-x07x8hzs.js +0 -2
- package/dist/chunk-z9q5p39g.js +0 -2
- package/dist/chunk-zfypzka2.js +0 -2
- package/dist/chunk-zh0jbzvk.js +0 -2
- package/dist/chunk-zpf9he2x.js +0 -2
- package/dist/chunk-zpftj8s8.js +0 -2
package/dist/app-shell.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ContainerRegion } from './fragment-container';
|
|
1
2
|
import type { StxOptions } from './types';
|
|
2
3
|
export type { LayoutMetadata } from 'stx-router/layout-metadata';
|
|
3
4
|
/**
|
|
@@ -59,6 +60,8 @@ export declare function isChromeInstanceScript(html: string, script: string, con
|
|
|
59
60
|
* Check if a request is an SPA navigation request (from the stx router).
|
|
60
61
|
*/
|
|
61
62
|
export declare function isSpaNavigation(request: Request): boolean;
|
|
63
|
+
/** Page dependencies outside the swap container still belong to its fragment. */
|
|
64
|
+
export declare function externalScriptsOutsideContainer(html: string, container: ContainerRegion): string[];
|
|
62
65
|
/**
|
|
63
66
|
* Extract the inner content of the router container element from a full HTML
|
|
64
67
|
* document, preserving page styles and route state found in `<head>`.
|
package/dist/app-shell.js
CHANGED
|
@@ -2,6 +2,7 @@ var {require}=import.meta;import path from "node:path";
|
|
|
2
2
|
import { classifyAllScripts } from "./script-classifier.js";
|
|
3
3
|
import { startsDocument } from "./document-shell.js";
|
|
4
4
|
import { findContainerRegion } from "./fragment-container.js";
|
|
5
|
+
import { matchScriptElement, scanAtElementPosition } from "./html-masking.js";
|
|
5
6
|
import { isDevelopment } from "./env.js";
|
|
6
7
|
import { isSpaNavRequest } from "./spa-nav.js";
|
|
7
8
|
export { extractLayoutMetadata } from "stx-router/layout-metadata";
|
|
@@ -183,6 +184,26 @@ export function isChromeInstanceScript(html, script, containerStart, containerEn
|
|
|
183
184
|
export function isSpaNavigation(request) {
|
|
184
185
|
return isSpaNavRequest(request);
|
|
185
186
|
}
|
|
187
|
+
export function externalScriptsOutsideContainer(html, container) {
|
|
188
|
+
const scripts = [], seen = new Set;
|
|
189
|
+
for (const element of scanAtElementPosition(html, matchScriptElement)) {
|
|
190
|
+
if (element.start >= container.start && element.start < container.end)
|
|
191
|
+
continue;
|
|
192
|
+
const opening = element.token.match(/^<script\b((?:"[^"]*"|'[^']*'|[^'">])*)>/i)?.[1] ?? "", attrs = new Map;
|
|
193
|
+
for (const attr of opening.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))
|
|
194
|
+
attrs.set(attr[1].toLowerCase(), attr[2] ?? attr[3] ?? attr[4] ?? "");
|
|
195
|
+
const src = attrs.get("src")?.trim(), type = attrs.get("type")?.trim().toLowerCase();
|
|
196
|
+
if (!src || attrs.has("server") || type && !["module", "text/javascript", "application/javascript"].includes(type))
|
|
197
|
+
continue;
|
|
198
|
+
if (attrs.has("data-stx-runtime") || attrs.has("data-stx-router") || /^\/_stx\/(?:runtime|router)(?:\.[a-f0-9]{16})?\.js(?:[?#]|$)/i.test(src))
|
|
199
|
+
continue;
|
|
200
|
+
if (isChromeInstanceScript(html, element.token, container.start, container.end) || seen.has(element.token))
|
|
201
|
+
continue;
|
|
202
|
+
seen.add(element.token);
|
|
203
|
+
scripts.push(element.token);
|
|
204
|
+
}
|
|
205
|
+
return scripts;
|
|
206
|
+
}
|
|
186
207
|
export function extractContainerContent(html, containerSelector = "main") {
|
|
187
208
|
const trimmed = html.trim(), headStyles = [], headScripts = [], headMatch = trimmed.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);
|
|
188
209
|
if (headMatch) {
|
|
@@ -200,7 +221,7 @@ export function extractContainerContent(html, containerSelector = "main") {
|
|
|
200
221
|
const containerRegion = findContainerRegion(trimmed, containerSelector);
|
|
201
222
|
if (!containerRegion)
|
|
202
223
|
return stripDocumentWrapper(html);
|
|
203
|
-
const { tagName: tag, start: openEnd, end: closeIdx } = containerRegion, innerContent = trimmed.slice(openEnd, closeIdx).trim(), bodyScripts = [], bodyOpenMatch = trimmed.match(/<body\b[^>]*>/i), bodyCloseIdx = trimmed.lastIndexOf("</body>");
|
|
224
|
+
const externalScripts = externalScriptsOutsideContainer(trimmed, containerRegion), externalSet = new Set(externalScripts), { tagName: tag, start: openEnd, end: closeIdx } = containerRegion, innerContent = trimmed.slice(openEnd, closeIdx).trim(), bodyScripts = [], bodyOpenMatch = trimmed.match(/<body\b[^>]*>/i), bodyCloseIdx = trimmed.lastIndexOf("</body>");
|
|
204
225
|
if (bodyOpenMatch && bodyOpenMatch.index !== void 0 && bodyCloseIdx !== -1) {
|
|
205
226
|
const regions = [
|
|
206
227
|
[bodyOpenMatch.index + bodyOpenMatch[0].length, containerRegion.openIndex],
|
|
@@ -222,12 +243,15 @@ export function extractContainerContent(html, containerSelector = "main") {
|
|
|
222
243
|
const parts = [];
|
|
223
244
|
if (headStyles.length > 0)
|
|
224
245
|
parts.push(headStyles.join(`
|
|
246
|
+
`));
|
|
247
|
+
if (externalScripts.length > 0)
|
|
248
|
+
parts.push(externalScripts.join(`
|
|
225
249
|
`));
|
|
226
250
|
if (headScripts.length > 0)
|
|
227
|
-
parts.push(headScripts.join(`
|
|
251
|
+
parts.push(headScripts.filter((script) => !externalSet.has(script)).join(`
|
|
228
252
|
`));
|
|
229
253
|
if (bodyScripts.length > 0)
|
|
230
|
-
parts.push(bodyScripts.join(`
|
|
254
|
+
parts.push(bodyScripts.filter((script) => !externalSet.has(script)).join(`
|
|
231
255
|
`));
|
|
232
256
|
parts.push(innerContent);
|
|
233
257
|
return parts.join(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function
|
|
4
|
-
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...
|
|
5
|
-
`));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function
|
|
6
|
-
export{
|
|
2
|
+
import{Y}from"./chunk-ev3qnr9q.js";import{pe,C}from"./chunk-ghnkphy4.js";import{_i}from"./chunk-dmf1jmge.js";import{a}from"./chunk-203rr1c8.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function St(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Xr(s,l){let o=a(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:p}=Y(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
|
+
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Jr(s,l,o={}){let i=St(s,o);await Xr(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
+
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...Y(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Yr(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Od(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=St(s,o);return await Xr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=St(s,o);await Xr(s,t);let{loadStxConfig:e}=await import("./chunk-n2g9mj2h.js"),p=C((await e(s)).runtimeConfig);return await pe(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
|
+
`));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Zr(s,l,o){if(_i(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
|
|
6
|
+
export{St,Xr,Jr,Yr,Od,Zr};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{gd,Eo,Ua,md,hd,yd,bd,wd,Va,Wa,vd,xd,Sd,kd}from"./chunk-mb59b499.js";import"./chunk-xw8kzm6b.js";import"./chunk-8afnq4qx.js";import"./chunk-4zb2ga7p.js";import"./chunk-dmf1jmge.js";import"./chunk-8txqk9nq.js";import"./chunk-ghnkphy4.js";import"./chunk-mt8sew7a.js";import"./chunk-1hrj0t0j.js";import"./chunk-m8qgr307.js";import"./chunk-d4ybwtqt.js";import"./chunk-7m0r2qs2.js";import"./chunk-ev3qnr9q.js";import"./chunk-rgage0vm.js";export{Ua as SUSPENSE_RESOLVER_RUNTIME,Eo as buildSuspenseResolveScript,wd as createStreamRenderer,yd as extractStreamBoundaries,kd as generateHydrationRuntime,Wa as islandDirective,xd as processSectionDirectives,hd as processStreamDirectives,vd as registerStreamingDirectives,md as renderStreamingPage,gd as streamTemplate,bd as streamTemplateSimple,Sd as streamToResponse,Va as streamingSuspenseDirective};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{M,de}from"./chunk-xw8kzm6b.js";import{pe,C,Ye}from"./chunk-ghnkphy4.js";import{nt,Y,Ee}from"./chunk-ev3qnr9q.js";import{Ie,se,_,oe,ho,Rr,yo,Lt}from"./chunk-90qywh24.js";import{Yr}from"./chunk-01s01ten.js";import{jt}from"./chunk-b76jbdtk.js";import K from"fs";import P from"path";var{serve:me}=globalThis.Bun;import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),ne=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],re=["text/event-stream","multipart/x-mixed-replace"],ae=1024;function ie(t){if(!t)return!1;let e=t.toLowerCase();if(re.some((o)=>e.startsWith(o)))return!1;return ne.some((o)=>e.startsWith(o))}function ce(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ue(t){if(!t)return null;let e=ce(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function le(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function Mt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ie(e.headers.get("content-type")))return e;let r=ue(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ae))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),le(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${se(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var fe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function sl(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=ho(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=jt(r.routeRules),f=new G,h=Yr(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ye(i.html,m);b.set(n.pattern,i),v.set(n.pattern,Ee(i.html)),E.set(n.pattern,de(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Ye(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=Y(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=me({port:o,async fetch(n){return Mt(n,await pe(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=fe[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=se(n),w=null,q={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!w){let p=nt(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Ie}}})}}let d=Rr(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await Lt(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return yo(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-04qvjcsr.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=Ee(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",de(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?oe(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=Ee(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",de(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(oe(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
|
+
export{Mt,sl};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p,c}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{p,c}from"./chunk-m8qgr307.js";import{b}from"./chunk-xw8kzm6b.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=x(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let l=i.lastIndexOf(u);if(l!==-1)i.splice(l);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),h=g||w.has(u)?-1:N(t,u,s);if(h===-1)o.push({start:n,end:s,slotName:l,element:m}),e=s;else o.push({start:n,end:h,slotName:l,element:m+t.slice(s,h)}),e=h;continue}if(!g&&!w.has(u)){if(i.push(u),u==="script"||u==="style"){let l=t.toLowerCase().indexOf(`</${u}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let l=i.lastIndexOf(g);if(l!==-1)i.splice(l);e=s;continue}if(g==="template"&&i.length===0){let l=a.match(r);if(l){let m=y(t,s);if(m!==-1){let h=l[1]||l[2]||l[3];o.push({start:n,end:m,slotName:h,content:t.slice(s,m-11).trim(),propsBinding:l[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!w.has(g)){if(i.push(g),g==="script"||g==="style"){let l=t.toLowerCase().indexOf(`</${g}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function fa(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function _l(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function ga(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((l)=>l.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return b(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return c(t,Object.keys(o))(...Object.values(o))}catch{return}}async function ma(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",l=f||"",m={},h=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,S;while((S=h.exec(l))!==null){let E=S[1],R=S[2];m[E]=k(R,i)}return await ga(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function Tl(t){let o=fa(t);return{defaultSlot:o.default,namedSlots:o.named}}async function $l(t,o,i,r){return await ma(t,{default:o,named:i},r)}
|
|
3
|
+
export{fa,_l,ga,ma,Tl,$l};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,i,
|
|
3
|
-
`:l==="t"?"\t":l;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[a+1]==="{")return null;s+=o}return s}var ue=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function
|
|
4
|
-
${s}${e.slice(r)}`}var N=
|
|
5
|
-
${o[0]}${e.slice(r,o.index)}${e.slice(l,a)}${e.slice(a)}`}function
|
|
6
|
-
${n[0]}${s.slice(a)}`}var Y="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",
|
|
7
|
-
`}function Ie(e){let n=[],r=0;while(r<e.length){let o=e.slice(r),l=o.match(/^\s+/);if(l){r+=l[0].length;continue}if(o.startsWith("<!--")){let h=e.indexOf("-->",r);if(h===-1)break;r=h+3;continue}let u=o.match(/^<script\b[^>]*>/i);if(u){let h=e.toLowerCase().indexOf("</script>",r+u[0].length);if(h===-1)break;r=h+9;continue}let p=o.match(/^<link\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let d=o.match(/^<meta\b[^>]*>/i);if(d){n.push(d[0]),r+=d[0].length;continue}let f=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(f){n.push(f[0]),r+=f[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let s="",a=0;while(a<e.length&&a<r){let o=e.slice(a),l=o.match(/^<link\b[^>]*>/i);if(l&&n.includes(l[0])){a+=l[0].length;continue}let u=o.match(/^<meta\b[^>]*>/i);if(u&&n.includes(u[0])){a+=u[0].length;continue}let p=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(p&&n.includes(p[0])){a+=p[0].length;continue}s+=e[a],a++}return s+=e.slice(r),{body:s,hoisted:n}}function _e(e,n={},r={}){let{title:s="stx App",lang:a="en",meta:o=[],link:l=[],script:u=[],headRaw:p="",htmlAttrs:d={},bodyClass:f="",bodyAttrs:h={}}=n,m=r.title||s,
|
|
2
|
+
import{t,i,xn,dr,Ce,c}from"./chunk-m8qgr307.js";import U from"path";function S(e,n,r,s=0){let a=0,o=s,l=null,u=0,p=!1;while(o<e.length){let d=e[o];if(l&&p){p=!1,o++;continue}if(l&&d==="\\"){p=!0,o++;continue}if(p=!1,(d==='"'||d==="'"||d==="`")&&!l){l=d,o++;continue}if(d===l&&l!=="`"){l=null,o++;continue}if(l==="`"&&d==="$"&&e[o+1]==="{"){u++,o+=2;continue}if(u>0&&d==="}"){u--,o++;continue}if(d==="`"&&l==="`"&&u===0){l=null,o++;continue}if(l){o++;continue}if(d===n)a++;else if(d===r){if(a--,a===0)return o}o++}return-1}function Ds(e,n){let r=[];n.lastIndex=0;let s;while((s=n.exec(e))!==null){let a=s.index,o=a+s[0].length-1,l=S(e,"(",")",o);if(l===-1){r.push({start:a,end:-1,args:"",call:e.slice(a,Math.min(e.length,a+80))}),n.lastIndex=o+1;continue}r.push({start:a,end:l+1,args:e.slice(o+1,l),call:e.slice(a,l+1)}),n.lastIndex=l+1}return r}function Ze(e,n,r,s){let a="",o=0;for(let l of Ds(e,n)){if(a+=e.slice(o,l.start),l.end===-1){a+=s(l.call),o=l.start;continue}a+=r(l.args,l.call),o=l.end}return a+e.slice(o)}function Qe(e){let n=[],r=0,s=null,a="";for(let o=0;o<e.length;o++){let l=e[o];if(s){if(a+=l,l==="\\"&&o+1<e.length){a+=e[++o];continue}if(l===s)s=null;continue}if(l==="'"||l==='"'||l==="`")s=l;else if(l==="("||l==="["||l==="{")r++;else if(l===")"||l==="]"||l==="}")r--;else if(l===","&&r===0){n.push(a.trim()),a="";continue}a+=l}if(a.trim())n.push(a.trim());return n}function O(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let s="";for(let a=1;a<n.length-1;a++){let o=n[a];if(o==="\\"&&a+1<n.length-1){let l=n[++a];s+=l==="n"?`
|
|
3
|
+
`:l==="t"?"\t":l;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[a+1]==="{")return null;s+=o}return s}var ue=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function et(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let s=xn(r);if(s)return{ok:!1,message:`the expression is not allowed (${s})`,code:t.UNSAFE_EXPRESSION};let a=dr(n),o;try{o=c(r,Object.keys(a))(...Object.values(a))}catch(u){return{ok:!1,message:`the expression could not be evaluated: ${u instanceof Error?u.message:String(u)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let l=[...new Set(Ce(r))].filter((u)=>!ue.has(u)&&!(u in a)&&!(u in globalThis));if(l.length>0)return{ok:!1,message:`${l.map((p)=>`"${p}"`).join(", ")} ${l.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:o}}function fe(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function Se(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function V(e){if(!e)return"";return U.isAbsolute(e)?U.relative(process.cwd(),e)||e:e}function M(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function E(e,n,r,s,a=t.EVALUATION_ERROR){let o=s?` in ${V(s)}`:"";return console.warn(`[stx] ${M(n)}${o}: ${r}`),i(e,`${M(n)}: ${r}`,a)}function ir(e,n,r){let s=r?` in ${V(r)}`:"";console.warn(`[stx] ${M(e)}${s}: ${n}`)}function Ms(){return{afterOpen:[],beforeClose:[]}}function pe(e){return e.afterOpen.length>0||e.beforeClose.length>0}function Ai(e,n){if(!pe(n))return e;let r=n.afterOpen.join(""),s=n.beforeClose.join(""),a=e.lastIndexOf("</head>"),o=r?gn(e):null,l=s&&a!==-1?a:null;if(o===null&&l===null)return e;if(o!==null&&l!==null)return`${e.slice(0,o)}${r}${e.slice(o,l)}${s}${e.slice(l)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,l)}${s}${e.slice(l)}`}var K=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function gn(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return null;let r=n.index+n[0].length;K.lastIndex=r;let s=K.exec(e);return s?r+s[0].length:r}var L="data-stx-color-mode-boot",F="__STX_COLOR_MODE__",de=new Set(["light","dark","auto","system"]),he=new Set(["auto","system"]),ye=/^[a-z][\w:-]*$/i,be=/^[\w-]+$/;function Te(e){let n=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",s=e.darkClass===void 0?"dark":e.darkClass,a=e.attribute??null,o=e.autoValue??null,l=e.respectExisting===!0;if(typeof n!=="string"||n.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!de.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(s!==null&&(typeof s!=="string"||!be.test(s)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(s)}`);if(a!==null&&(typeof a!=="string"||!ye.test(a)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(a)}`);if(o!==null&&!he.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(s===null&&a===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(l&&a===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:n,initialMode:r==="system"?"auto":r,darkClass:s,attribute:a,autoValue:o,respectExisting:l}}function ve(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function D(e={}){let n=Te(e),r=ve(n),s=`(function(){"use strict";var o=window.${F};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${F}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${L}>${s}</script>`}function mn(e,n={}){if(e.includes(L))return e;let r=N(e);if(r===null)return e;let s=D(n);return`${e.slice(0,r)}
|
|
4
|
+
${s}${e.slice(r)}`}var N=gn,Ee=new RegExp(`<script\\b[^>]*\\b${L}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),W=/<meta\b[^>]*\bcharset\b[^>]*>/gi,q=/<\/head>/gi;function xe(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return e;let r=n.index+n[0].length;q.lastIndex=r;let s=q.exec(e),a=s?s.index:e.length;W.lastIndex=r;let o=W.exec(e);if(!o||o.index>=a)return e;if(e.slice(r,o.index).trim()==="")return e;let l=o.index+o[0].length;return`${e.slice(0,r)}
|
|
5
|
+
${o[0]}${e.slice(r,o.index)}${e.slice(l,a)}${e.slice(a)}`}function Pi(e){return Ae(xe(e))}function Ae(e){let n=Ee.exec(e);if(!n)return e;let r=N(e);if(r===null)return e;if(n.index<=r||e.slice(r,n.index).trim()==="")return e;let s=e.slice(0,n.index)+e.slice(n.index+n[0].length),a=N(s);if(a===null)return e;return`${s.slice(0,a)}
|
|
6
|
+
${n[0]}${s.slice(a)}`}var Y="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",C="data-stx-html-attrs",R="data-stx-html-class",G=/^[A-Za-z_:][\w:.-]*$/;function y(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function we(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ke(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function $e(e){let n=/^\s*<meta\b([^>]*)>/i.exec(e);if(!n)return null;let r={};for(let s of n[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[s[1].toLowerCase()]=s[2]??s[3]??s[4]??"";return r}function k(e,n){return Object.entries(e).filter(([r])=>!n?.(r)).map(([r,s])=>`${r}="${y(String(s))}"`).join(" ")}function I(e){let n=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?n.replace(/<\//g,"<\\/"):n}function J(e){let n=k(e,(r)=>r==="content");return`<script${n?` ${n}`:""}>${I(e)}</script>`}function Re(e={},n="en"){let r=[],s=[],a="",o=n;for(let[u,p]of Object.entries(e||{})){if(p==null)continue;let d=u.trim();if(!G.test(d))continue;let f=d.toLowerCase();if(f==="lang"){o=String(p);continue}if(f==="class"){a=String(p).trim();continue}r.push(` ${d}="${y(String(p))}"`),s.push(d)}let l=` lang="${y(o)}"`;if(a)l+=` class="${y(a)}"`;if(l+=r.join(""),a)l+=` ${R}="${y(a)}"`;if(s.length)l+=` ${C}="${y(s.join(" "))}"`;return l}function Ii(e={},n={}){let r={...e,...n};if(e.class&&n.class){let s=e.class.split(/\s+/).filter(Boolean);for(let a of n.class.split(/\s+/).filter(Boolean))if(!s.includes(a))s.push(a);r.class=s.join(" ")}return r}function hn(e,n={}){if(!n||Object.keys(n).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let s={},a=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,l;while((l=o.exec(r[1]))!==null){let f=l[1];if(!(f in s))a.push(f);s[f]=l[2]??l[3]??l[4]??""}let u=[],p=[];for(let[f,h]of Object.entries(n)){if(h==null)continue;let m=f.trim();if(!G.test(m))continue;let w=m.toLowerCase();if(w==="class"){let x=(s.class||"").split(/\s+/).filter(Boolean);for(let A of String(h).split(/\s+/).filter(Boolean))if(!x.includes(A))x.push(A),u.push(A);if(!("class"in s))a.push("class");s.class=x.join(" ");continue}if(!(m in s))a.push(m);if(s[m]=String(h),w!=="lang")p.push(m)}if(u.length){if(!(R in s))a.push(R);s[R]=u.join(" ")}if(p.length){if(!(C in s))a.push(C);s[C]=p.join(" ")}let d=a.map((f)=>` ${f}="${y(s[f])}"`).join("");return e.replace(r[0],()=>`<html${d}>`)}function Oi(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${Y}
|
|
7
|
+
`}function Ie(e){let n=[],r=0;while(r<e.length){let o=e.slice(r),l=o.match(/^\s+/);if(l){r+=l[0].length;continue}if(o.startsWith("<!--")){let h=e.indexOf("-->",r);if(h===-1)break;r=h+3;continue}let u=o.match(/^<script\b[^>]*>/i);if(u){let h=e.toLowerCase().indexOf("</script>",r+u[0].length);if(h===-1)break;r=h+9;continue}let p=o.match(/^<link\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let d=o.match(/^<meta\b[^>]*>/i);if(d){n.push(d[0]),r+=d[0].length;continue}let f=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(f){n.push(f[0]),r+=f[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let s="",a=0;while(a<e.length&&a<r){let o=e.slice(a),l=o.match(/^<link\b[^>]*>/i);if(l&&n.includes(l[0])){a+=l[0].length;continue}let u=o.match(/^<meta\b[^>]*>/i);if(u&&n.includes(u[0])){a+=u[0].length;continue}let p=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(p&&n.includes(p[0])){a+=p[0].length;continue}s+=e[a],a++}return s+=e.slice(r),{body:s,hoisted:n}}function _e(e,n={},r={}){let{title:s="stx App",lang:a="en",meta:o=[],link:l=[],script:u=[],headRaw:p="",htmlAttrs:d={},bodyClass:f="",bodyAttrs:h={}}=n,m=r.title||s,w=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],x=new Set(o.map(ke).filter(Boolean)),{body:A,hoisted:B}=Ie(e),te=new Set(B.flatMap((g)=>{let v=$e(g);return v?[ke(v)].filter(Boolean):[]})),ne=[...w.filter((g)=>!x.has(ke(g))),...o].filter((g)=>!te.has(ke(g))).map((g)=>` <meta ${k(g)}>`).join(`
|
|
8
8
|
`),re=l.map((g)=>` <link ${k(g)}>`).join(`
|
|
9
9
|
`),ie=u.map((g)=>{if(g.src)return` <script ${k(g,(v)=>v==="content")}></script>`;if(g.content)return` ${J(g)}`;return""}).filter(Boolean).join(`
|
|
10
|
-
`),se=Re(d,a),oe=Object.entries(h).map(([g,v])=>` ${g}="${y(String(v))}"`).join(""),ae=f?` class="${y(f)}"`:"",le=[ne,r.colorMode?` ${D(r.colorMode)}`:"",` <title>${r.titleIsHtml?m:
|
|
10
|
+
`),se=Re(d,a),oe=Object.entries(h).map(([g,v])=>` ${g}="${y(String(v))}"`).join(""),ae=f?` class="${y(f)}"`:"",le=[ne,r.colorMode?` ${D(r.colorMode)}`:"",` <title>${r.titleIsHtml?m:we(m)}</title>`,` ${Y}`,re,ie,p?` ${p}`:"",...(r.styles||[]).map((g)=>` ${g}`),...B.map((g)=>` ${g}`),...(r.headScripts||[]).map((g)=>` ${g}`),r.headStack||""].filter(Boolean),ce=[A,...(r.bodyScripts||[]).map((g)=>g),r.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
|
|
11
11
|
<html${se}>
|
|
12
12
|
<head>
|
|
13
13
|
${le.join(`
|
|
@@ -17,8 +17,8 @@ ${le.join(`
|
|
|
17
17
|
${ce.join(`
|
|
18
18
|
`)}
|
|
19
19
|
</body>
|
|
20
|
-
</html>`}var H=/\s+/y,j=/<(script|style)\b[^>]*>/iy,Me=/<\/script>/gi,Oe=/<\/style>/gi,z=/<!DOCTYPE\b/iy,X=/<html[\s>]/iy;function
|
|
20
|
+
</html>`}var H=/\s+/y,j=/<(script|style)\b[^>]*>/iy,Me=/<\/script>/gi,Oe=/<\/style>/gi,z=/<!DOCTYPE\b/iy,X=/<html[\s>]/iy;function Pt(e){let n=0;while(n<e.length){if(H.lastIndex=n,H.exec(e)){n=H.lastIndex;continue}if(e.startsWith("<!--",n)){let a=e.indexOf("-->",n);if(a===-1)return!1;n=a+3;continue}j.lastIndex=n;let s=j.exec(e);if(s){let a=s[1].toLowerCase()==="script"?Me:Oe;a.lastIndex=j.lastIndex;let o=a.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(z.lastIndex=n,z.test(e))return!0;return X.lastIndex=n,X.test(e)}return!1}function Ns(e){return Pt(e)}function Di(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:s=[],link:a=[],script:o=[],headRaw:l=""}=n,u=e.slice(0,r),p=[];for(let d of s){let f=ke(d);if(f&&u.includes(f))continue;p.push(` <meta ${k(d)}>`)}for(let d of a){if(d.href&&u.includes(`href="${d.href}"`))continue;p.push(` <link ${k(d)}>`)}for(let d of o)if(d.src){if(u.includes(`src="${d.src}"`))continue;p.push(` <script ${k(d,(f)=>f==="content")}></script>`)}else if(d.content){if(u.includes(I(d)))continue;p.push(` ${J(d)}`)}if(l&&!u.includes(l))p.push(` ${l}`);if(p.length===0)return e;return`${e.slice(0,r)}${p.join(`
|
|
21
21
|
`)}
|
|
22
|
-
${e.slice(r)}`}function
|
|
23
|
-
`)}function
|
|
24
|
-
`,"")),headContent:n.trim()}}function
|
|
22
|
+
${e.slice(r)}`}function yn(e,n={},r={},s){if(s??Ns(e))return e;return _e(e,n,r)}var Ne=["og:","article:","book:","profile:","fb:","music:","video:"],Le=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function bn(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=De(e[0],n);if(typeof r!=="string")return r;let s;if(e.length===2){let o=He(e[1],n);if(typeof o!=="string")return o;s=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,l=n.openGraph,u=n[o]??(Se(l)?l[o]:void 0);s=u===void 0||u===null||typeof u==="object"?"":String(u)}if(!s)return{kind:"empty"};return{kind:"tag",tag:Ne.some((o)=>r.startsWith(o))?{property:r,content:s}:{name:r,content:s}}}function De(e,n){let r=O(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(Le.test(e.trim()))return e.trim();let s=et(e,n);if(!s.ok)return{kind:"error",message:`meta name: ${s.message}`,code:s.code};if(typeof s.value!=="string"||!s.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${fe(s.value)}`,code:t.TYPE_ERROR};return s.value}function He(e,n){let r=O(e);if(r!==null)return r;let s=et(e,n);if(!s.ok)return{kind:"error",message:s.message,code:s.code};let a=s.value;if(a===void 0||a===null||a===!1)return"";if(Array.isArray(a))return a.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof a==="object"&&!(a instanceof Date))return{kind:"error",message:`the content must be text, got ${fe(a)}`,code:t.TYPE_ERROR};return String(a)}var wn=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],ar=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],ee={links:"link",metas:"meta",scripts:"script",styles:"style"},Z=new Set,Q=new WeakMap;function P(e){if(Z.has(e))return;Z.add(e),console.warn(e)}function je(e,n){let r=Array.from({length:n.length+1},(s,a)=>a);for(let s=1;s<=e.length;s++){let a=r[0];r[0]=s;for(let o=1;o<=n.length;o++){let l=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,a+(e[s-1]===n[o-1]?0:1)),a=l}}return r[n.length]}function Pe(e,n){let r=e.toLowerCase(),s=n.find((p)=>p.toLowerCase()===r);if(s)return s;let a=ee[r];if(a&&n.includes(a))return a;let o,l=1/0;for(let p of n){let d=je(r,p.toLowerCase());if(d<l)o=p,l=d}let u=Math.min(e.length,o?.length??0)<=4?1:2;return l<=u?o:void 0}function ge(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=Q.get(e);if(r)return r;let{known:s,source:a}=n,o=e;for(let l of Object.keys(e)){if(s.includes(l))continue;let u=ee[l];if(u&&s.includes(u)&&Array.isArray(e[l])){if(o===e)o={...e};let d=Array.isArray(o[u])?o[u]:[];o[u]=[...d,...e[l]],delete o[l],P(`[stx] ${a}.${l} is not a head key; reading it as ${a}.${u}. Rename it to \`${u}\`.`);continue}if(/^styles?$/.test(l)&&!s.includes("style")){P(`[stx] ${a}.${l} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=Pe(l,s);P(p?`[stx] ${a}.${l} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${a}.${l} is not a head key and is ignored. Known keys: ${s.join(", ")}.`)}return Q.set(e,o),o}var b={},Be=[],_={};function Ls(){return b}function du(){return _}function uu(){b={},Be.length=0,_={}}function Mi(e){b=me(b,ge(e,{known:ar,source:"useHead()"}))}function me(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function Uc(e){Mi(cr(e))}function cr(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,s=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(s)n.push({property:"og:description",content:s});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let a=e.twitterTitle??e.title,o=e.twitterDescription??e.description,l=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(a)n.push({name:"twitter:title",content:a});if(o)n.push({name:"twitter:description",content:o});if(l){n.push({name:"twitter:image",content:l});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let p of e.articleTags)n.push({property:"article:tag",content:p});let u=[];if(e.canonical)u.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:u}}function pu(e){if(_={..._,...e},e.title||e.description)Uc({title:e.title,description:e.description})}function fu(e){let n=typeof e==="function"?e():e;Mi({title:n})}function gu(e=b){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${T(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([s,a])=>`${s}="${T(a)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let s=Object.entries(r).filter(([a,o])=>o!==void 0).map(([a,o])=>`${a==="httpEquiv"?"http-equiv":a}="${T(String(o))}"`).join(" ");n.push(`<meta ${s}>`)}for(let r of e.link||[]){let s=Object.entries(r).filter(([a,o])=>o!==void 0).map(([a,o])=>`${a}="${T(String(o))}"`).join(" ");n.push(`<link ${s}>`)}for(let r of e.script||[]){let{content:s,...a}=r,o=Object.entries(a).filter(([l,u])=>u!==void 0).map(([l,u])=>{if(typeof u==="boolean")return u?l:"";return`${l}="${T(String(u))}"`}).filter(Boolean).join(" ");if(s)n.push(`<script ${o}>${I(r)}</script>`);else n.push(`<script ${o}></script>`)}for(let r of e.style||[]){let s=r.type?` type="${r.type}"`:"";n.push(`<style${s}>${r.content}</style>`)}return n.join(`
|
|
23
|
+
`)}function mu(e=b){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${T(r)}"`).join(" ")}function hu(e=b){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${T(r)}"`).join(" ")}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function yu(e=b){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let s=document.querySelector(r);if(!s){if(s=document.createElement("meta"),n.name)s.setAttribute("name",n.name);if(n.property)s.setAttribute("property",n.property);document.head.appendChild(s)}s.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,s=document.querySelector(r);if(!s)s=document.createElement("link"),document.head.appendChild(s);for(let[a,o]of Object.entries(n))if(o!==void 0)s.setAttribute(a,String(o))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let s of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(s);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function bu(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(s,a)=>(n+=a.trim()+`
|
|
24
|
+
`,"")),headContent:n.trim()}}function wu(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,s,a,o)=>{let l=s?a:n[(o||"").trim()]??o,u=n.__stx_runtime_head??{};return n.__stx_runtime_head=me(u,{title:l}),""})}function vu(e,n,r=""){if(!e.includes("@meta"))return e;return Ze(e,/(?<![\w$@])@meta\s*\(/g,(s,a)=>{let o=bn(Qe(s),n);if(o.kind==="error")return E("Meta",a,o.message,r,o.code);if(o.kind==="tag"){let l=n.__stx_runtime_head??{};n.__stx_runtime_head=me(l,{meta:[o.tag]})}return""},(s)=>E("Meta",s,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{S,Ds,Ze,Qe,et,fe,Se,E,ir,Ms,Ai,gn,mn,Pi,ke,Ii,hn,Oi,Pt,Ns,Di,yn,bn,wn,ar,ge,Ls,du,uu,Mi,me,Uc,cr,pu,fu,gu,mu,hu,yu,bu,wu,vu};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import i from"path";var Rt=".stx",o="STX_DIR",e=null;function Ri(t){e=t?.trim()||null}function un(){return process.env[o]?.trim()||e||Rt}function a(t=process.cwd(),...n){let r=un();return i.isAbsolute(r)?i.join(r,...n):i.join(t,r,...n)}function pn(t){if(!t||i.isAbsolute(t))return t;let n=t.replace(/\\/g,"/");if(n!==Rt&&!n.startsWith(`${Rt}/`))return t;let r=n.slice(Rt.length+1);return r?i.join(un(),r):un()}
|
|
3
|
+
export{Rt,Ri,un,a,pn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
2
|
+
function So(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="id",dynamicHeight:d=!1,estimatedItemHeight:g=l,direction:x="vertical"}=c,e=[...v],t=0,n=new Map;function f(){if(d)return h();let i=Math.max(0,Math.floor(t/l)-s),r=Math.ceil(u/l),m=Math.min(e.length-1,i+r+s*2);return{startIndex:i,endIndex:m}}function h(){let i=0,r=0,m=e.length-1;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+M>t){r=Math.max(0,p-s);break}i+=M}i=0;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+=M,i>t+u){m=Math.min(e.length-1,p+s);break}}return{startIndex:r,endIndex:m}}function w(){if(d){let i=0;for(let r=0;r<e.length;r++)i+=n.get(r)||g;return i}return e.length*l}function y(i){if(d){let r=0;for(let m=0;m<i;m++)r+=n.get(m)||g;return r}return i*l}function S(){let{startIndex:i,endIndex:r}=f();return{startIndex:i,endIndex:r,scrollTop:t,totalHeight:w(),visibleItems:e.slice(i,r+1),itemHeights:new Map(n)}}function L(i,r="auto"){let m=y(i);a(m,r)}function a(i,r="auto"){t=Math.max(0,Math.min(i,w()-u))}function o(){f()}function H(i){e=[...i],n.clear(),o()}function I(){e=[],n.clear()}return{scrollToIndex:L,scrollToOffset:a,getState:S,refresh:o,setItems:H,destroy:I}}function ko(v,c={},l){let u=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualList: items "${x}" not found or not an array -->`;let t={itemHeight:50,containerHeight:400,overscan:3};if(d)try{let a=d.trim(),o=Function(`return ${a}`)();t={...t,...o}}catch{}let n=`vlist-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(t.containerHeight/t.itemHeight),h=t.overscan||3,w=0,y=Math.min(e.length-1,f+h),S="";for(let a=w;a<=y&&a<e.length;a++){let o=e[a],H=g.replace(/\{\{\s*item\s*\}\}/g,typeof o==="object"?JSON.stringify(o):String(o)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,i)=>{if(typeof o==="object"&&o!==null)return String(o[i]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(a));S+=`
|
|
3
3
|
<div class="virtual-item ${t.itemClass||""}"
|
|
4
4
|
style="position: absolute; top: ${a*t.itemHeight}px; height: ${t.itemHeight}px; width: 100%;"
|
|
5
5
|
data-index="${a}">
|
|
@@ -76,7 +76,7 @@ function xo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
76
76
|
};
|
|
77
77
|
})();
|
|
78
78
|
</script>
|
|
79
|
-
`})}function
|
|
79
|
+
`})}function Ca(){return`
|
|
80
80
|
.virtual-list-container {
|
|
81
81
|
position: relative;
|
|
82
82
|
overflow-y: auto;
|
|
@@ -124,7 +124,7 @@ function xo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
124
124
|
0% { background-position: 200% 0; }
|
|
125
125
|
100% { background-position: -200% 0; }
|
|
126
126
|
}
|
|
127
|
-
`}function
|
|
127
|
+
`}function Ea(v,c){let l=null,u=()=>{if(!l)l=So(v(),c);return l};return{visibleItems:()=>u().getState().visibleItems,totalHeight:()=>u().getState().totalHeight,containerProps:()=>({style:{height:`${c.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(s)=>{let b=s.target;if(l)l.scrollToOffset(b.scrollTop)}}),itemProps:(s)=>({style:{position:"absolute",top:`${s*c.itemHeight}px`,height:`${c.itemHeight}px`,width:"100%"},"data-index":s}),scrollToIndex:(s)=>{u().scrollToIndex(s)}}}function _a(v,c={},l){let u=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return v.replace(u,(s,b,d,g,x)=>{let e=b.trim(),t=c[e];if(!t||!Array.isArray(t))return`<!-- infiniteList: items "${e}" not found or not an array -->`;let n={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(d)try{let w=Function(`return ${d.trim()}`)();n={...n,...w}}catch{}let f=`ilist-${Math.random().toString(36).substring(2,9)}`,h=ko(`@virtualList(${e}, ${JSON.stringify({itemHeight:n.itemHeight,containerHeight:n.containerHeight,overscan:n.overscan,containerClass:n.containerClass})})${g}@endvirtualList`,c);return h=h.replace("</script>",`
|
|
128
128
|
// Infinite scroll detection
|
|
129
129
|
container.addEventListener('scroll', function() {
|
|
130
130
|
const scrollBottom = container.scrollTop + container.clientHeight;
|
|
@@ -142,7 +142,7 @@ function xo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
142
142
|
${x}
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
|
-
`})}function
|
|
145
|
+
`})}function Ta(v,c={},l){let u=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${x}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),h=f*(t.rowHeight+(t.gap||0)),w=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,S=0,L=Math.min(f-1,w+y),a="";for(let o=S;o<=L;o++)for(let H=0;H<t.columns;H++){let I=o*t.columns+H;if(I>=e.length)break;let i=e[I],r=H*(100/t.columns),m=o*(t.rowHeight+(t.gap||0)),p=g.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,T)=>{if(typeof i==="object"&&i!==null)return String(i[T]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(I));a+=`
|
|
146
146
|
<div class="virtual-grid-item"
|
|
147
147
|
style="position: absolute; top: ${m}px; left: ${r}%; width: calc(${100/t.columns}% - ${t.gap||0}px); height: ${t.rowHeight}px;"
|
|
148
148
|
data-index="${I}">
|
|
@@ -212,5 +212,5 @@ function xo(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
212
212
|
});
|
|
213
213
|
})();
|
|
214
214
|
</script>
|
|
215
|
-
`})}var
|
|
216
|
-
export{
|
|
215
|
+
`})}var Nl={createVirtualList:So,processVirtualListDirectives:ko,processInfiniteListDirectives:_a,processVirtualGridDirectives:Ta,generateVirtualListCSS:Ca,useVirtualList:Ea};
|
|
216
|
+
export{So,ko,Ca,Ea,_a,Ta,Nl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Dr,Mr,Nr,xa,Lr,jr,Sa,Br,Fr,xo,ka}from"./chunk-jbmhdyzz.js";export{Dr as VideoProcessorCache,xo as analyzeVideo,xa as clearVideoCache,Fr as generateDASHManifest,Br as generateHLSManifest,Lr as generatePoster,Sa as generateSpriteSheet,jr as generateThumbnails,Mr as getCachedVideoResult,ka as processVideo,Nr as setCachedVideoResult};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ao,Po,Io,Ad}from"./chunk-55hfvmvv.js";import"./chunk-c765y72x.js";import"./chunk-saf7kypg.js";import"./chunk-xw8kzm6b.js";import"./chunk-8afnq4qx.js";import"./chunk-4zb2ga7p.js";import"./chunk-dmf1jmge.js";import"./chunk-8txqk9nq.js";import"./chunk-ghnkphy4.js";import"./chunk-mt8sew7a.js";import"./chunk-1hrj0t0j.js";import"./chunk-m8qgr307.js";import"./chunk-d4ybwtqt.js";import"./chunk-7m0r2qs2.js";import"./chunk-ev3qnr9q.js";import"./chunk-rgage0vm.js";export{Ao as buildNative,Ad as default,Io as getAvailableFormats,Po as getAvailableTargets};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y}from"./chunk-
|
|
2
|
+
import{y}from"./chunk-7m0r2qs2.js";import{G,We,cs,ls,ni,ri,si,oi,Kn,ds,ii,ai,ci,$t,o}from"./chunk-xw8kzm6b.js";import{zr}from"./chunk-d1mqedk0.js";import{a}from"./chunk-203rr1c8.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=$t.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
|
|
3
3
|
`).length;s.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
|
-
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function se(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...x].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function
|
|
5
|
-
`.repeat(e.startLine-1):"",i=
|
|
4
|
+
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function se(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...x].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function ia(e,t="",s=""){let u=e.startLine>1?`
|
|
5
|
+
`.repeat(e.startLine-1):"",i=ds(e)+ls(cs(e.code)),l=e.kind==="client"||e.kind==="plain"?si(t,e.code):"";return Kn(`${u+i}
|
|
6
6
|
${l}
|
|
7
7
|
export {}
|
|
8
8
|
`,s)}var $e=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function ve(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],s=new Set(y),u=[];for(let{file:i,names:l}of e){let g=JSON.stringify(i.replace(/\\/g,"/").replace(/\.ts$/,""));u.push(` export * from ${g}`);for(let m of l){if(s.has(m)||$e.has(m))continue;s.add(m),t.push(`declare const ${m}: typeof import(${g})[${JSON.stringify(m)}]`)}}return t.push("declare module '@composables' {",...u,"}"),t.join(`
|
|
9
|
-
`)}function
|
|
9
|
+
`)}function co(e,t,s){return`${e}.__stx_${t}${s}.ts`}function cl(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function aa(){return re("stx.d.ts")}function ca(){return re("stx-module.d.ts")}function re(e){for(let t of[h.resolve(import.meta.dir,"..",e),h.resolve(import.meta.dir,"..","..",e)])if(M(t))return t;return null}var Te=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function De(e){return e>=1000&&e<2000}function oe(e){let t="",s=!1,u=!1;for(let i=0;i<e.length;i++){let l=e[i];if(s){if(t+=l,u)u=!1;else if(l==="\\")u=!0;else if(l==='"')s=!1;continue}if(l==='"'){s=!0,t+=l;continue}if(l==="/"&&e[i+1]==="/"){while(i<e.length&&e[i]!==`
|
|
10
10
|
`)i++;t+=`
|
|
11
|
-
`;continue}if(l==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(oe(K(e,"utf8")))}catch{return}}function Oe(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(M(r)){s=r;break}let f=h.dirname(t);if(f===t)break;t=f}if(!s)return{};let u=new Set,i=s,l,g,m=s;while(i&&!u.has(i)){u.add(i);let r;try{r=JSON.parse(oe(K(i,"utf8")))}catch{break}let f=r?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,m=i;if(!g&&typeof f.baseUrl==="string")g=h.resolve(h.dirname(i),f.baseUrl);if(l&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!l)return{};let S=g??h.dirname(m),x={};for(let[r,f]of Object.entries(l)){if(!Array.isArray(f))continue;x[r]=f.map((p)=>typeof p==="string"&&!h.isAbsolute(p)?h.resolve(S,p):p)}return{paths:x}}async function
|
|
12
|
-
`);for(let d of ie(c,b))S.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(s&&k){let d=b.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>
|
|
13
|
-
`),ve(await
|
|
14
|
-
`),_=`${a()}/typecheck`;await Bun.$`rm -rf ${_}`.quiet().nothrow(),await Bun.$`mkdir -p ${_}`.quiet().nothrow(),await Bun.write(
|
|
15
|
-
`)){let b=c.match(Te);if(!b)continue;if(
|
|
16
|
-
${
|
|
11
|
+
`;continue}if(l==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(oe(K(e,"utf8")))}catch{return}}function Oe(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(M(r)){s=r;break}let f=h.dirname(t);if(f===t)break;t=f}if(!s)return{};let u=new Set,i=s,l,g,m=s;while(i&&!u.has(i)){u.add(i);let r;try{r=JSON.parse(oe(K(i,"utf8")))}catch{break}let f=r?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,m=i;if(!g&&typeof f.baseUrl==="string")g=h.resolve(h.dirname(i),f.baseUrl);if(l&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!l)return{};let S=g??h.dirname(m),x={};for(let[r,f]of Object.entries(l)){if(!Array.isArray(f))continue;x[r]=f.map((p)=>typeof p==="string"&&!h.isAbsolute(p)?h.resolve(S,p):p)}return{paths:x}}async function ll(e,t={}){let s=t.client!==!1,u=t.server!==!1,i=t.templates!==!1,l=t.componentsDir??(i?(await o()).componentsDir:void 0),g=new Map,m=new Map,S=[],x=[],r=0,f=0,p=aa();for(let n of e){let c=await Bun.file(n).text(),b=We(c).filter((d)=>{if(d.kind==="server")return u;return s}),k=We(c).filter((d)=>d.kind==="server").map((d)=>d.code).join(`
|
|
12
|
+
`);for(let d of ie(c,b))S.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(s&&k){let d=b.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>oi(k,O.code)))];if(E.length>0)m.set(n,{names:E,line:d[0].startLine,kind:d[0].kind})}let D=h.dirname(h.resolve(n)),v=i?ii(c,{runtimeGlobals:!p,originDir:D,filePath:h.resolve(n),componentsDir:l}):null,R=v?[...v.lineMap.values()].filter((d)=>d.expression).length:0;if(b.length===0&&R===0)continue;if(x.push(n),r+=b.length,f+=R,b.forEach((d,E)=>{g.set(co(n,d.kind,E),{source:ia(d,k,D),origin:n,kind:d.kind})}),v&&R>0)g.set(co(n,"template",0),{source:v.text,origin:n,kind:"template",virtual:v})}if(g.size===0)return{diagnostics:S,checkedFiles:x,blockCount:0,expressionCount:0};let w=(t.extraLibs??[]).map((n)=>h.resolve(n)),ce=se(e.length>0?h.dirname(h.resolve(e[0])):process.cwd(),Ee,M);for(let n of ce?.libs??[])if(!w.includes(n)&&M(n))w.push(n);if(p)w.push(p);let X=p?ca():null;if(X)w.push(X);let F=`${a()}/typecheck/__stx_globals.d.ts`,ae=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",ni(p?ri(K(p,"utf8")):void 0),...p?[]:["declare const window: any",...y.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...G.map((n)=>`declare const ${n}: any`)].join(`
|
|
13
|
+
`),ve(await zr())].filter(Boolean).join(`
|
|
14
|
+
`),_=`${a()}/typecheck`;await Bun.$`rm -rf ${_}`.quiet().nothrow(),await Bun.$`mkdir -p ${_}`.quiet().nothrow(),await Bun.write(F,ae);let N=new Map,le=0;for(let[n,c]of g){let b=`${le++}_${n.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${_}/${b}`,c.source),N.set(b,c)}let ue={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...Oe(e.length>0?h.dirname(h.resolve(e[0])):process.cwd()),...t.compilerOptions??{}},V=async(n,c)=>{let b=`${_}/tsconfig${c===1?"":`.${c}`}.json`;await Bun.write(b,JSON.stringify({compilerOptions:ue,files:n.map((D)=>`${_}/${D}`).concat(F,...w)},null,2));let k=Bun.spawnSync(["bun","x","tsc","-p",b,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(k.stdout)+new TextDecoder().decode(k.stderr),exitCode:k.exitCode??0}},J=await V([...N.keys()],1),U=J.output,I=[],W=J.exitCode,z=0,pe=new Set(w.map((n)=>n.split("/").pop())),q=0,B=new Set,H=(n)=>{for(let c of n.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
|
|
15
|
+
`)){let b=c.match(Te);if(!b)continue;if(z++,pe.has(b[1].split("/").pop()))q++;let[,k,D,v,R,d,E]=b,O=k.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Y;if(C.virtual){let P=ci(C.virtual,A,L);if(!P?.expression)continue;if(ai(P,Number(d)))continue;A=P.line,L=P.column,Y=P.expression.code.trim()}I.push({file:C.origin,line:A,column:L,code:Number(d),message:E,category:R==="error"?"error":"warning",blockKind:C.kind,expression:Y})}};H(U);let de=z,fe=q;if(B.size>0&&B.size<N.size){let n=[...N.keys()].filter((c)=>!B.has(c));H((await V(n,2)).output)}if(s)for(let[n,c]of m){if(c.names.length===0)continue;I.push({file:n,line:c.line,column:1,code:0,message:`${c.names.length===1?"1 value reaches":`${c.names.length} values reach`} this block on the implicit bridge and ${c.names.length===1?"is":"are"} untyped: ${c.names.join(", ")}. Declare them with defineClientPayload({ ${c.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:c.kind})}I.push(...S);let Z=new Set,j=I.filter((n)=>{let c=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(Z.has(c))return!1;return Z.add(c),!0});j.sort((n,c)=>n.file.localeCompare(c.file)||n.line-c.line||n.column-c.column);let Q=fe>0&&j.length===0,ge=Q||W!==0&&de===0?`${Q?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${W} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
|
|
16
|
+
${U.trim().split(`
|
|
17
17
|
`).slice(0,12).join(`
|
|
18
|
-
`)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:x,blockCount:r,expressionCount:f,failure:ge}}function
|
|
18
|
+
`)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:x,blockCount:r,expressionCount:f,failure:ge}}function dl(e){return e.map((t)=>{let s=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${s}`}).join(`
|
|
19
19
|
`)}
|
|
20
|
-
export{
|
|
20
|
+
export{ia,co,cl,aa,ca,ll,dl};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
2
|
+
import{s}from"./chunk-5s555c1r.js";function y(e,n,i=240){return e.slice(n,n+i)}var v=[{rule:"route-params",pattern:/\blocation\s*\.\s*pathname\s*\.\s*(?:match|split)\s*\(/g,primitive:"useRoute() / useRouteParams() / useRouteParam(name)",why:"parsing the URL by hand re-implements the router and does not update on SPA navigation"},{rule:"alert",pattern:/(?<![.#\w$])(?:(?:window|globalThis)\s*\.\s*)?alert\s*\(/g,primitive:"stxAlert(message)",why:"themed, focus-trapped and non-blocking \u2014 but `await` it if the code after it "+"depended on the native dialog blocking until dismissal",reject:(e)=>/\b(?:async\s+)?function\s+alert\s*\(/.test(e)||/\b(?:const|let|var)\s+alert\s*=/.test(e)},{rule:"search-params",pattern:/new\s+URLSearchParams\s*\(/g,primitive:"useSearchParams()",why:"reactive, and writes back through the router instead of history.replaceState",reject:(e,n)=>{let i=e.indexOf("(",n);if(i===-1)return!0;let o=e.slice(i+1,e.indexOf(")",i)+1);return!/\b(?:location|search|href|url)\b/i.test(o)}},{rule:"navigate",pattern:/\blocation\s*\.\s*(?:assign|replace)\s*\(|\blocation\s*\.\s*href\s*=/g,primitive:"navigate(path) / goBack()",why:"a full document load throws away every store and the scroll position; navigate() is an SPA transition",reject:(e,n)=>/^[^\n]*?(?:['"`]\s*)?(?:mailto:|tel:|sms:|https?:\/\/|\/\/)/.test(y(e,n,160))},{rule:"fetch",pattern:/new\s+AbortController\s*\(/g,primitive:"useFetch(url) / useAsyncData(key, fn)",why:"cancellation, loading and error state are already wired; hand-rolling them is where the races live"},{rule:"polling",pattern:/setInterval\s*\(/g,primitive:"useEventSource() / useSSE() / useWebSocket() / useChannel()",why:"polling burns requests and lags; the push primitives are delivered",reject:(e,n)=>!/\bfetch\s*\(|\$fetch\b|useFetch\b|\.get\s*\(|axios\b/.test(y(e,n))},{rule:"debounce",pattern:/\bclearTimeout\s*\(/g,primitive:"useDebounce(fn, ms) / useThrottle(fn, ms)",why:"a hand-held timer handle per call site is the usual source of stale-result bugs",requires:(e)=>/setTimeout\s*\(/.test(e)},{rule:"click-outside",pattern:/document\s*\.\s*addEventListener\s*\(\s*['"](?:click|mousedown|pointerdown)['"]/g,primitive:"useClickOutside(ref, fn)",why:"the document-level listener plus the blur race is exactly what this composable exists to remove"},{rule:"focus",pattern:/\.\s*(?:getElementById|querySelector)\s*\([^)]*\)\s*(?:\?\.)?\s*\.?focus\s*\(/g,primitive:"useFocus(ref) with x-ref",why:"a query by id breaks under nested scopes and SPA navigation; a ref does not"},{rule:"clipboard",pattern:/navigator\s*\.\s*(?:clipboard|share)\b/g,primitive:"useClipboard() / useShare()",why:"permission state, the copied flag and the unsupported-browser fallback are already handled"},{rule:"watch",pattern:/\beffect\s*\(\s*\(\s*\)\s*=>\s*\{[^}]*\bvoid\s+\w+\s*\(\s*\)/g,primitive:"watch(source, cb) / watchMultiple([...], cb)",why:"the `void a(); void b()` dance is a manual dependency list; watch takes one directly"}],C=["confirm","tooltip",...v.map((e)=>e.rule)];function g(e,n){let i=1;for(let o=0;o<n;o++)if(e[o]===`
|
|
3
3
|
`)i++;return i}function b(e,n){let i=e.lastIndexOf(`
|
|
4
4
|
`,n)+1,o=e.indexOf(`
|
|
5
5
|
`,n);return e.slice(i,o===-1?e.length:o).trim().slice(0,120)}function S(e,n){let i=e.slice(0,n),o=i.lastIndexOf("function"),l=i.lastIndexOf("=>"),r=Math.max(o,l);if(r===-1)return!1;let t=e.slice(Math.max(0,r-120),r);return/\basync\b[^;{}]*$/.test(t)}function k(e){return/\b(?:async\s+)?function\s+confirm\s*\(/.test(e)||/\b(?:const|let|var)\s+confirm\s*=/.test(e)||/\bimport\s*\{[^}]*\bconfirm\b[^}]*\}/.test(e)}function A(e,n,i){if(k(e))return e;let o=/(^|[^\w$.])(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(/g,l=m(e),r="",t=0,a;while((a=o.exec(l))!==null){let c=a.index+a[1].length,u=g(e,c),d=b(e,c);if(/stxConfirm\s*\($/.test(e.slice(0,c+8)))continue;let p=S(e,c);if(i.push({file:n,line:u,rule:"confirm",applied:p,snippet:d,reason:p?void 0:"stxConfirm() returns a Promise and native confirm() is synchronous, so this needs `await` inside an async function. Rewriting it here would make the condition always true."}),p)r+=e.slice(t,c)+"await stxConfirm(",t=c+(a[0].length-a[1].length)}return r+e.slice(t)}function E(e,n,i){let o=/(<[a-z][\w-]*\b[^>]*?)\stitle=(["'])(.*?)\2/gis,l=R(e),r="",t=0,a;while((a=o.exec(l))!==null){let[c,u,d,p]=a,h=g(e,a.index),f=b(e,a.index),w=u.match(/^<([A-Za-z][\w-]*)/)?.[1]??"";if(/^[A-Z]/.test(w)){i.push({file:n,line:h,rule:"tooltip",applied:!1,snippet:f,reason:`\`title\` on <${w}> is a component prop, not an HTML attribute \u2014 `+"adding x-tooltip here would put a tooltip on a component and may duplicate text it already renders."});continue}if(/\bx-tooltip[=\s]/.test(u)||p.trim()===""){i.push({file:n,line:h,rule:"tooltip",applied:!1,snippet:f,reason:/\bx-tooltip[=\s]/.test(u)?"already has x-tooltip":"empty title"});continue}i.push({file:n,line:h,rule:"tooltip",applied:!0,snippet:f}),r+=e.slice(t,a.index)+`${u} x-tooltip=${d}${p}${d} title=${d}${p}${d}`,t=a.index+c.length}return r+e.slice(t)}function R(e){return e.replace(/<!--[\s\S]*?-->/g,(n)=>n.replace(/[^\n]/g," ")).replace(/\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function F(e){let n=(i)=>i.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,n).replace(/\/\/[^\n]*/g,n)}function m(e,n=!1){let i=R(e);return(n?F(i):s(i)).replace(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,(l,r)=>/\bclient\b/i.test(r)?l:l.replace(/[^\n]/g," "))}function O(e,n,i,o){let l=m(e),r=m(e,!0);for(let t of v){if(!i.includes(t.rule))continue;if(t.requires&&!t.requires(e))continue;t.pattern.lastIndex=0;let a,c=/['"]/.test(t.pattern.source)?r:l;t.pattern.lastIndex=0;while((a=t.pattern.exec(c))!==null){if(t.reject?.(e,a.index))continue;o.push({file:n,line:g(e,a.index),rule:t.rule,applied:!1,snippet:b(e,a.index),reason:`${t.primitive} \u2014 ${t.why}`})}}}function q(e,n={}){let i=n.rules??C,o=n.file??"<source>",l=[];O(e,o,i,l);let r=e;if(i.includes("confirm"))r=A(r,o,l);if(i.includes("tooltip"))r=E(r,o,l);l.sort((c,u)=>c.line-u.line);let t=new Set,a=l.filter((c)=>{let u=`${c.rule}:${c.line}`;if(t.has(u))return!1;return t.add(u),!0});return{code:r,findings:a}}var x=new Set(["confirm","tooltip"]);function I(e,n){if(e.length===0)return"No hand-rolled equivalents found.";let i=e.filter((t)=>t.applied),o=e.filter((t)=>!t.applied&&x.has(t.rule)),l=e.filter((t)=>!t.applied&&!x.has(t.rule)),r=[];if(i.length>0){r.push(n?`Rewrote ${i.length} site(s):`:`Would rewrite ${i.length} site(s) (pass --fix):`);for(let t of i)r.push(` ${t.file}:${t.line} [${t.rule}] ${t.snippet}`)}if(o.length>0){r.push("",`Needs a human \u2014 ${o.length} site(s):`);for(let t of o)r.push(` ${t.file}:${t.line} [${t.rule}] ${t.snippet}
|
|
@@ -45,12 +45,12 @@ var p=0;function f(){return`stx-teleport-${++p}`}function g(t){let e=t.split(","
|
|
|
45
45
|
});
|
|
46
46
|
})();
|
|
47
47
|
</script>
|
|
48
|
-
`}function
|
|
48
|
+
`}function Ul(t,e,l){p=0;let o=/@teleport\s*\(([^)]+)\)\s*([\s\S]*?)@endteleport/g;return t.replace(o,(r,s,d)=>{let a=f(),{target:u,disabled:n}=g(s),c=d.trim();if(n)try{let i=!1;if(n==="true")i=!0;else if(n==="false")i=!1;else if(n in e)i=Boolean(e[n]);if(i)return`<div class="stx-teleport-inline" data-teleport-disabled>${c}</div>`}catch{}let m=h(a,u);return`
|
|
49
49
|
<div id="${a}" class="stx-teleport-source" style="display: none;">
|
|
50
50
|
<template>${c}</template>
|
|
51
51
|
</div>
|
|
52
52
|
${m}
|
|
53
|
-
`})}function
|
|
53
|
+
`})}function Vl(){return`
|
|
54
54
|
<script>
|
|
55
55
|
(function() {
|
|
56
56
|
// Common teleport targets
|
|
@@ -68,4 +68,4 @@ var p=0;function f(){return`stx-teleport-${++p}`}function g(t){let e=t.split(","
|
|
|
68
68
|
})();
|
|
69
69
|
</script>
|
|
70
70
|
`}
|
|
71
|
-
export{
|
|
71
|
+
export{Ul,Vl};
|