@stacksjs/stx 0.2.838 → 0.2.839
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/builtins/image-delivery.js +7 -3
- package/dist/chunk-02cntwd8.js +2 -0
- package/dist/chunk-07hvjvj1.js +2 -0
- package/dist/{chunk-gh62p9mx.js → chunk-11y84h2d.js} +2 -2
- package/dist/{chunk-3bjnrmha.js → chunk-1b1ntgt7.js} +2 -2
- package/dist/{chunk-z25w7kmr.js → chunk-1m16mvt4.js} +4 -4
- package/dist/{chunk-6s3hgq9z.js → chunk-1zfxmjrf.js} +32 -32
- package/dist/{chunk-4ntm3dtk.js → chunk-23r3rby6.js} +2 -2
- package/dist/chunk-23zzbsms.js +2 -0
- package/dist/{chunk-ya6bp08c.js → chunk-2fj5zev7.js} +1 -1
- package/dist/{chunk-29f6vmyz.js → chunk-2j5yane9.js} +4 -4
- package/dist/chunk-2pgc087j.js +2 -0
- package/dist/{chunk-wzjdq7d6.js → chunk-31cnrpd1.js} +9 -9
- package/dist/{chunk-ac9ncbfw.js → chunk-321e41ck.js} +3 -3
- package/dist/{chunk-ckasfph2.js → chunk-3tydmgwh.js} +5 -5
- package/dist/chunk-41sh9y5w.js +2 -0
- package/dist/chunk-4654xm1h.js +2 -0
- package/dist/{chunk-amg6kr1p.js → chunk-4657mnht.js} +4 -4
- package/dist/{chunk-s33andzg.js → chunk-4dxq7ft1.js} +2 -2
- package/dist/chunk-4eagsz5d.js +2 -0
- package/dist/{chunk-f7jgda7x.js → chunk-4j08cbjd.js} +5 -5
- package/dist/{chunk-j59js1nh.js → chunk-4w3qpewn.js} +3 -3
- package/dist/{chunk-tx8wk6h7.js → chunk-4y6hes3h.js} +2 -2
- package/dist/chunk-53j9wakh.js +2 -0
- package/dist/{chunk-gw83680k.js → chunk-5hmm01av.js} +5 -5
- package/dist/chunk-5t93dqft.js +2 -0
- package/dist/{chunk-2x9zhezb.js → chunk-6wrf6302.js} +2 -2
- package/dist/chunk-78nsbzcm.js +2 -0
- package/dist/{chunk-1zxahmnh.js → chunk-7cg2f588.js} +1 -1
- package/dist/chunk-7ka7pvj9.js +2 -0
- package/dist/chunk-7m0r7mq9.js +2 -0
- package/dist/chunk-7mz6ze0x.js +2 -0
- package/dist/{chunk-ckg6q98b.js → chunk-7t57cnz9.js} +5 -5
- package/dist/chunk-7t9951at.js +2 -0
- package/dist/{chunk-jr0r5pzw.js → chunk-7vhm0jj5.js} +2 -2
- package/dist/{chunk-vfj9wp11.js → chunk-8370x30n.js} +2 -2
- package/dist/chunk-8913k8g7.js +3 -0
- package/dist/{chunk-txd2js5v.js → chunk-89d3h8mp.js} +14 -14
- package/dist/chunk-8byydry7.js +2 -0
- package/dist/chunk-8c363c2r.js +2 -0
- package/dist/chunk-8em568fw.js +2 -0
- package/dist/{chunk-ax624h16.js → chunk-8h0pnn5p.js} +6 -6
- package/dist/{chunk-em8tv6nz.js → chunk-8pj4v1eh.js} +2 -2
- package/dist/{chunk-b1m41fwr.js → chunk-8q3pyq6a.js} +3 -3
- package/dist/{chunk-z0ynyz62.js → chunk-8qbp5skx.js} +7 -7
- package/dist/chunk-8w0n2rae.js +2 -0
- package/dist/{chunk-nmvhktsg.js → chunk-8y3f5fyg.js} +6 -6
- package/dist/chunk-8z3yjex0.js +2 -0
- package/dist/chunk-8zzepd7g.js +2 -0
- package/dist/{chunk-c3dg8qdn.js → chunk-97k72dfh.js} +2 -2
- package/dist/chunk-98258444.js +2 -0
- package/dist/{chunk-s53wjw7y.js → chunk-9xps62ek.js} +2 -2
- package/dist/{chunk-52g026sc.js → chunk-a1s5wqw4.js} +2 -2
- package/dist/{chunk-myje6fhm.js → chunk-a9tzjqny.js} +5 -5
- package/dist/{chunk-4sv740a5.js → chunk-aekq1zyn.js} +6 -6
- package/dist/chunk-aywvbcae.js +2 -0
- package/dist/chunk-aza2zrhk.js +54 -0
- package/dist/chunk-b0fkvrat.js +2 -0
- package/dist/chunk-b6w3457c.js +2 -0
- package/dist/{chunk-fvgk1w9s.js → chunk-bp918end.js} +2 -2
- package/dist/chunk-bq7qcndg.js +3 -0
- package/dist/chunk-c18pafmf.js +3 -0
- package/dist/chunk-c2v38ghp.js +2 -0
- package/dist/{chunk-c9vxm8yq.js → chunk-ca3c5qx2.js} +31 -31
- package/dist/chunk-cax1wts7.js +2 -0
- package/dist/{chunk-evgghnjc.js → chunk-cw1ar3dq.js} +4 -4
- package/dist/{chunk-bky02g7k.js → chunk-d0dzzpfx.js} +2 -2
- package/dist/{chunk-29bt1fbn.js → chunk-d1vkjxb1.js} +5 -5
- package/dist/chunk-d2mdh669.js +2 -0
- package/dist/chunk-d44g9sek.js +2 -0
- package/dist/chunk-d5vr9g4b.js +2 -0
- package/dist/{chunk-yw1s8kyj.js → chunk-dgn87554.js} +4 -4
- package/dist/{chunk-t2vmk8tf.js → chunk-efdfkfp1.js} +3 -3
- package/dist/{chunk-33czswpt.js → chunk-f1hkagxk.js} +3 -3
- package/dist/chunk-f69cmsz9.js +2 -0
- package/dist/{chunk-55e46spy.js → chunk-g7rsd8st.js} +5 -5
- package/dist/chunk-gaxx0z19.js +2 -0
- package/dist/chunk-gft9pg9n.js +2 -0
- package/dist/{chunk-917v0bar.js → chunk-gpschnvk.js} +12 -12
- package/dist/chunk-h8h79939.js +2 -0
- package/dist/{chunk-q5pwvr98.js → chunk-jc5y35b7.js} +1 -1
- package/dist/{chunk-cwfavkk0.js → chunk-jjyt3tsv.js} +2 -2
- package/dist/{chunk-wfsa28e7.js → chunk-jzh0n2ct.js} +9 -9
- package/dist/{chunk-vfxkn1pe.js → chunk-kd6r7z27.js} +3 -3
- package/dist/chunk-ksc83y9t.js +2 -0
- package/dist/{chunk-zj4s3rnw.js → chunk-ksr6c2kh.js} +5 -5
- package/dist/{chunk-rnm8ejpz.js → chunk-m5bj2jnb.js} +2 -2
- package/dist/chunk-mad4g0yx.js +2 -0
- package/dist/{chunk-b7tb00nz.js → chunk-mhyd24bg.js} +2 -2
- package/dist/chunk-mtjt2z77.js +2 -0
- package/dist/{chunk-5w0cf32p.js → chunk-mv49hr9y.js} +1 -1
- package/dist/{chunk-65tptp4x.js → chunk-mzj71r0m.js} +2 -2
- package/dist/chunk-n7pvz99f.js +2 -0
- package/dist/chunk-n8a4jm0p.js +3 -0
- package/dist/chunk-nb2tedk0.js +2 -0
- package/dist/chunk-ndyj1d0z.js +2 -0
- package/dist/{chunk-n4qznmkm.js → chunk-ngnr831a.js} +5 -5
- package/dist/chunk-nhk0aat9.js +2 -0
- package/dist/{chunk-64eeb5p5.js → chunk-nk7nxzxf.js} +2 -2
- package/dist/chunk-np6h1ct6.js +2 -0
- package/dist/{chunk-pft65534.js → chunk-nsnzgdjt.js} +1 -1
- package/dist/{chunk-3yggtch5.js → chunk-p83h2dbg.js} +10 -10
- package/dist/{chunk-dv11h4f0.js → chunk-p9d2txcg.js} +1 -1
- package/dist/chunk-phxkmjnw.js +2 -0
- package/dist/chunk-pjkdn8zf.js +2 -0
- package/dist/{chunk-20mmryy5.js → chunk-pqg6j26p.js} +3 -3
- package/dist/{chunk-xtqapjz3.js → chunk-q0s0kc66.js} +2 -2
- package/dist/chunk-q88w2rv9.js +2 -0
- package/dist/{chunk-v3xyb3ws.js → chunk-qfvddpcg.js} +2 -2
- package/dist/{chunk-e75dntfb.js → chunk-qk079ca7.js} +2 -2
- package/dist/{chunk-11fn3hgv.js → chunk-r0ssa1xd.js} +2 -2
- package/dist/chunk-r5bhgyes.js +2 -0
- package/dist/chunk-rdn1d4bf.js +42 -0
- package/dist/{chunk-7bvvv74e.js → chunk-rk2ex6qx.js} +3 -3
- package/dist/chunk-rmc6dfj4.js +2 -0
- package/dist/chunk-rsn9rh07.js +2 -0
- package/dist/chunk-rt29w5ns.js +2 -0
- package/dist/chunk-ryrdx5mw.js +2 -0
- package/dist/chunk-rzfbffnv.js +2 -0
- package/dist/chunk-s85chp3w.js +2 -0
- package/dist/chunk-s92f8w68.js +2 -0
- package/dist/chunk-sm9f980t.js +2 -0
- package/dist/chunk-st75663x.js +2 -0
- package/dist/chunk-sv2d6nfe.js +2 -0
- package/dist/{chunk-7k9yahng.js → chunk-t0jed809.js} +6 -6
- package/dist/{chunk-s5dhvnnd.js → chunk-t3p0jy0s.js} +6 -6
- package/dist/{chunk-f49x34sr.js → chunk-v3q126ys.js} +2 -2
- package/dist/{chunk-fzdgevxr.js → chunk-v49rvx9y.js} +56 -56
- package/dist/{chunk-kw5gra2z.js → chunk-v4ybemgb.js} +2 -2
- package/dist/chunk-vcx6dy59.js +2 -0
- package/dist/{chunk-mvehmtap.js → chunk-vr6qa0g2.js} +14 -14
- package/dist/chunk-w5h67xec.js +2 -0
- package/dist/{chunk-vyv76w55.js → chunk-wbgc2n04.js} +2 -2
- package/dist/{chunk-d689fbv1.js → chunk-whmqfr3y.js} +6 -6
- package/dist/{chunk-nyg0nbjj.js → chunk-x110ssw2.js} +3 -3
- package/dist/{chunk-sfsek961.js → chunk-x4f7efgp.js} +3 -3
- package/dist/chunk-x5wkbcsf.js +2 -0
- package/dist/{chunk-w0a6yz73.js → chunk-xbcnnk8x.js} +5 -5
- package/dist/{chunk-84nw3921.js → chunk-xmsf1bnx.js} +3 -3
- package/dist/{chunk-trwe0mfa.js → chunk-xvhxxj4g.js} +103 -103
- package/dist/{chunk-38ncpvww.js → chunk-xx3reejx.js} +2 -2
- package/dist/chunk-y64qhgv1.js +2 -0
- package/dist/{chunk-52t0qpx6.js → chunk-y68xstqy.js} +1 -1
- package/dist/chunk-yg5a54pj.js +2 -0
- package/dist/chunk-yjskeqaj.js +2 -0
- package/dist/{chunk-nm26vnzd.js → chunk-yn17484y.js} +6 -6
- package/dist/{chunk-r32q8mjw.js → chunk-ynf16yz4.js} +3 -3
- package/dist/chunk-yxqzarzh.js +2 -0
- package/dist/chunk-z4g64re8.js +3 -0
- package/dist/{chunk-ms3v5nat.js → chunk-zg44cf8a.js} +7 -7
- package/dist/{chunk-s6r54dyf.js → chunk-zjqvbcwa.js} +2 -2
- package/dist/{chunk-0rvntfhj.js → chunk-zvy88beh.js} +3 -3
- package/dist/{chunk-jstrmqna.js → chunk-zyeg9t2t.js} +2 -2
- package/dist/cli.js +20 -20
- package/dist/compression.js +3 -3
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/dev-server/port-utils.js +2 -1
- package/dist/expressions.js +1 -1
- package/dist/html-masking.d.ts +2 -0
- package/dist/html-masking.js +23 -0
- package/dist/image-optimization/processor.js +2 -2
- package/dist/includes.js +5 -4
- package/dist/misc-directives.js +2 -2
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +6 -6
- package/dist/utils.js +16 -13
- package/package.json +5 -5
- package/dist/chunk-0a36jnq4.js +0 -2
- package/dist/chunk-0c02182b.js +0 -42
- package/dist/chunk-0rnfywsx.js +0 -2
- package/dist/chunk-1bpx9b0m.js +0 -2
- package/dist/chunk-1g6xxftp.js +0 -2
- package/dist/chunk-2fcg7aws.js +0 -2
- package/dist/chunk-2nxxhcyy.js +0 -2
- package/dist/chunk-4wgfqa56.js +0 -2
- package/dist/chunk-5p6x0ztt.js +0 -2
- package/dist/chunk-6aak0b7c.js +0 -2
- package/dist/chunk-6c6m6p9t.js +0 -3
- package/dist/chunk-6g8byhwn.js +0 -2
- package/dist/chunk-70akxpk5.js +0 -2
- package/dist/chunk-72gq0ywg.js +0 -2
- package/dist/chunk-72n804gy.js +0 -2
- package/dist/chunk-7efkc3gk.js +0 -2
- package/dist/chunk-88zc5chj.js +0 -2
- package/dist/chunk-8gg8gn87.js +0 -2
- package/dist/chunk-8wv2p899.js +0 -2
- package/dist/chunk-9w3r1ch2.js +0 -3
- package/dist/chunk-a1hxz8q4.js +0 -2
- package/dist/chunk-a579jdwb.js +0 -2
- package/dist/chunk-ahd8jdzx.js +0 -2
- package/dist/chunk-aqrx322x.js +0 -2
- package/dist/chunk-ay7ggc4k.js +0 -2
- package/dist/chunk-bc4x45vx.js +0 -2
- package/dist/chunk-c77vxvp3.js +0 -2
- package/dist/chunk-c7hw37ww.js +0 -2
- package/dist/chunk-cfrgrnej.js +0 -2
- package/dist/chunk-cw8vpk41.js +0 -2
- package/dist/chunk-d96b9qgj.js +0 -2
- package/dist/chunk-db1c0c3c.js +0 -2
- package/dist/chunk-f6vzn90z.js +0 -2
- package/dist/chunk-fd3815fe.js +0 -2
- package/dist/chunk-gtj8wy95.js +0 -2
- package/dist/chunk-h4tbpr7p.js +0 -2
- package/dist/chunk-h5aaq0j8.js +0 -2
- package/dist/chunk-j0j4p9t1.js +0 -2
- package/dist/chunk-j0w048sj.js +0 -2
- package/dist/chunk-jvg9e6t6.js +0 -2
- package/dist/chunk-k761q7s7.js +0 -2
- package/dist/chunk-m3tnxk01.js +0 -2
- package/dist/chunk-mdtysd2d.js +0 -2
- package/dist/chunk-nmtya57z.js +0 -3
- package/dist/chunk-nxfyjw59.js +0 -2
- package/dist/chunk-pe5qqem0.js +0 -2
- package/dist/chunk-pwv77cyb.js +0 -2
- package/dist/chunk-qs0vtav5.js +0 -2
- package/dist/chunk-qv21bsa1.js +0 -2
- package/dist/chunk-rrba4t7k.js +0 -2
- package/dist/chunk-s3j5vxy9.js +0 -3
- package/dist/chunk-ssrxqj55.js +0 -2
- package/dist/chunk-t612xpa4.js +0 -2
- package/dist/chunk-tesbhpbp.js +0 -2
- package/dist/chunk-tkgkdf93.js +0 -2
- package/dist/chunk-tvw571ab.js +0 -2
- package/dist/chunk-txzap6yn.js +0 -2
- package/dist/chunk-vhrq4xjf.js +0 -2
- package/dist/chunk-vqpypnys.js +0 -2
- package/dist/chunk-vv3w8z4v.js +0 -2
- package/dist/chunk-vypnjn9g.js +0 -3
- package/dist/chunk-w39cfxa6.js +0 -2
- package/dist/chunk-wj937ceq.js +0 -2
- package/dist/chunk-xbavxkm5.js +0 -2
- package/dist/chunk-xrspzeqx.js +0 -2
- package/dist/chunk-y41hhypj.js +0 -2
- package/dist/chunk-yv9589qr.js +0 -54
- package/dist/chunk-z0yq548d.js +0 -2
- package/dist/chunk-zfjbwp54.js +0 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import crypto from "node:crypto";
|
|
4
|
-
import { generatePlaceholder as tsGeneratePlaceholder, processImage as tsProcessImage } from "ts-images";
|
|
5
4
|
import { createTempDir, removeTempDir, withTempDir } from "../temp-dir.js";
|
|
6
5
|
export const DEFAULT_WIDTHS = [320, 640, 768, 1024, 1280, 1536, 1920], DEFAULT_FORMATS = ["webp", "jpeg"], DEFAULT_QUALITY = 80;
|
|
7
6
|
const IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".webp", ".avif", ".gif", ".svg"], MIME_TYPES = {
|
|
@@ -158,6 +157,7 @@ export async function resizeAndConvert(buffer, options) {
|
|
|
158
157
|
}
|
|
159
158
|
return instance.toBuffer();
|
|
160
159
|
}
|
|
160
|
+
const { processImage: tsProcessImage } = await import("ts-images");
|
|
161
161
|
return await withTempDir("img", async (dir) => {
|
|
162
162
|
const tempOut = path.join(dir, `out.${options.format}`);
|
|
163
163
|
await tsProcessImage({
|
|
@@ -187,7 +187,7 @@ async function generatePlaceholder(buffer, type) {
|
|
|
187
187
|
}).catch(() => ({ dominant: { r: 128, g: 128, b: 128 } }));
|
|
188
188
|
return `rgb(${dominant.r}, ${dominant.g}, ${dominant.b})`;
|
|
189
189
|
}
|
|
190
|
-
const meta = await getImageMetadata(buffer), scratch = createTempDir("ph"), tempIn = path.join(scratch, `in.${meta.format === "unknown" ? "bin" : meta.format}`);
|
|
190
|
+
const { generatePlaceholder: tsGeneratePlaceholder } = await import("ts-images"), meta = await getImageMetadata(buffer), scratch = createTempDir("ph"), tempIn = path.join(scratch, `in.${meta.format === "unknown" ? "bin" : meta.format}`);
|
|
191
191
|
try {
|
|
192
192
|
await Bun.write(tempIn, buffer);
|
|
193
193
|
const tsStrategy = type === "blur" ? "blur" : type === "thumbhash" ? "thumbhash" : "dominant-color", ph = await tsGeneratePlaceholder(tempIn, {
|
package/dist/includes.js
CHANGED
|
@@ -7,6 +7,7 @@ import { existsSync } from "node:fs";
|
|
|
7
7
|
import { processConditionals } from "./conditionals.js";
|
|
8
8
|
import { isProduction, isTest } from "./env.js";
|
|
9
9
|
import { findBodyOpenTag, replaceBodyOpenTag } from "./find-body-tag.js";
|
|
10
|
+
import { skipLeadingHtmlTrivia } from "./html-masking.js";
|
|
10
11
|
import { processExpressions, usesSignalsInScript } from "./expressions.js";
|
|
11
12
|
import { buildRuntimeGlobalsDestructure } from "./runtime-globals.js";
|
|
12
13
|
import { rendersAsElement } from "./component-renderer.js";
|
|
@@ -260,14 +261,14 @@ function addScopeToRootElement(html, scopeId) {
|
|
|
260
261
|
root: "body"
|
|
261
262
|
};
|
|
262
263
|
}
|
|
263
|
-
const elementMatch = html.match(/^(
|
|
264
|
+
const leadingLen = skipLeadingHtmlTrivia(html), elementMatch = html.slice(leadingLen).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);
|
|
264
265
|
if (elementMatch) {
|
|
265
|
-
const rootTag = elementMatch[
|
|
266
|
+
const rootTag = elementMatch[1] + elementMatch[2], root = elementMatch[1].slice(1), existingScope = rootTag.match(/data-stx-scope="([^"]*)"/);
|
|
266
267
|
if (existingScope)
|
|
267
268
|
return { html, mergedIntoExisting: existingScope[1], stamped: !0, root };
|
|
268
|
-
const before =
|
|
269
|
+
const before = html.slice(0, leadingLen), tagStart = elementMatch[1], afterTag = elementMatch[2];
|
|
269
270
|
return {
|
|
270
|
-
html: `${before}${tagStart} data-stx-scope="${scopeId}"${afterTag}${html.slice(elementMatch[0].length)}`,
|
|
271
|
+
html: `${before}${tagStart} data-stx-scope="${scopeId}"${afterTag}${html.slice(leadingLen + elementMatch[0].length)}`,
|
|
271
272
|
mergedIntoExisting: null,
|
|
272
273
|
stamped: !0,
|
|
273
274
|
root
|
package/dist/misc-directives.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { errorLogger } from "./error-handling.js";
|
|
2
|
-
import { mightContainOwnTextMustache, scanAtElementPosition } from "./html-masking.js";
|
|
2
|
+
import { mightContainOwnTextMustache, scanAtElementPosition, skipLeadingHtmlTrivia } from "./html-masking.js";
|
|
3
3
|
import { createSafeFunction, isExpressionSafe } from "./safe-evaluator.js";
|
|
4
4
|
import { contentKey, renderMemo } from "./render-memo.js";
|
|
5
5
|
export function processJsonDirective(template, context) {
|
|
@@ -119,7 +119,7 @@ export function processMemoDirective(template) {
|
|
|
119
119
|
const depsExpr = output.slice(exprStart, i - 1).trim(), afterOpen = i, tail = output.slice(afterOpen), endIdx = tail.indexOf("@endmemo");
|
|
120
120
|
if (endIdx === -1)
|
|
121
121
|
continue;
|
|
122
|
-
const blockInner = tail.slice(0, endIdx), blockEnd = afterOpen + endIdx + 8,
|
|
122
|
+
const blockInner = tail.slice(0, endIdx), blockEnd = afterOpen + endIdx + 8, leadingLen = skipLeadingHtmlTrivia(blockInner), rest = blockInner.slice(leadingLen), trailing = blockInner.match(/(\s*)$/), trailingLen = trailing ? trailing[0].length : 0, body = rest.slice(0, rest.length - trailingLen), firstTagMatch = body.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/);
|
|
123
123
|
let replacement;
|
|
124
124
|
if (firstTagMatch) {
|
|
125
125
|
const [fullMatch, tagName, attrs = "", selfClose] = firstTagMatch, newOpenTag = `<${tagName}${attrs} data-stx-memo="${depsExpr}"${selfClose}>`;
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
2
|
+
import{no,Ut,Cl,Ag}from"./chunk-dgn87554.js";import{to,Ni,Tg,$g,Rg}from"./chunk-8qbp5skx.js";import{Sl,kl,_l,Cg,Eg}from"./chunk-8pj4v1eh.js";import{We,An,Mi}from"./chunk-rk2ex6qx.js";import{Pg,Ig,Og,Ng,ro,hy}from"./chunk-a1s5wqw4.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-8z3yjex0.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
|
|
|
233
233
|
}, 5000);
|
|
234
234
|
</script>
|
|
235
235
|
</body>
|
|
236
|
-
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=We(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=
|
|
236
|
+
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=We(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=no(n,t);if(a){let s=Ut(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return Ni(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,kl as auditBuildOutput,Sl as auditConfig,re as buildPwaAssets,_l as calculateAuditResult,Eg as formatAuditResult,Mi as formatSize,j as generateManifest,_ as generateManifestJson,$g as generateManifestLink,F as generateOfflinePage,We as generatePrecacheManifest,An as generatePrecacheManifestJs,M as generatePwaIcons,to as generatePwaTags,no as generateServiceWorker,Ag as generateServiceWorkerAuto,Tg as generateSwRegistrationScript,Rg as generateThemeColorMeta,N as getExpectedIconPaths,Ut as getServiceWorkerFileName,Ni as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Cl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,ro as pwaDirectives,Pg as pwaInstallDirective,Og as pwaOfflineDirective,Ng as pwaPushDirective,Ig as pwaUpdateDirective,hy as registerPwaDirectives,Cg as runPwaAudit,D as validateManifest};
|
package/dist/ssg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
3
|
-
`)}function J(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=me(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,l;while((l=o.exec(r))!==null){if(n[l.index]!==0)continue;let u=x(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=x(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(l.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((l=e.exec(r))!==null){if(n[l.index]!==0)continue;let u=
|
|
2
|
+
import"./chunk-4y6hes3h.js";import{x,il}from"./chunk-89d3h8mp.js";import"./chunk-23r3rby6.js";import"./chunk-zjqvbcwa.js";import{At,y}from"./chunk-xvhxxj4g.js";import"./chunk-8370x30n.js";import"./chunk-jjyt3tsv.js";import"./chunk-11y84h2d.js";import{_t,Ct,Et,Tt,$t,Rt}from"./chunk-2j5yane9.js";import{a}from"./chunk-p83h2dbg.js";import{$s}from"./chunk-zg44cf8a.js";import"./chunk-4657mnht.js";import"./chunk-ksr6c2kh.js";import{ye,nn,rn}from"./chunk-cw1ar3dq.js";import"./chunk-mzj71r0m.js";import{b}from"./chunk-31cnrpd1.js";import{bt,i}from"./chunk-1zfxmjrf.js";import"./chunk-rdn1d4bf.js";import"./chunk-aza2zrhk.js";import{ms}from"./chunk-jzh0n2ct.js";import"./chunk-4w3qpewn.js";import"./chunk-4dxq7ft1.js";import{ec,tc,nc}from"./chunk-321e41ck.js";import{en,er,tr}from"./chunk-c18pafmf.js";import{tn}from"./chunk-xx3reejx.js";import"./chunk-n8a4jm0p.js";import"./chunk-1b1ntgt7.js";import{G,ve}from"./chunk-aekq1zyn.js";import"./chunk-2fj5zev7.js";import"./chunk-efdfkfp1.js";import{c}from"./chunk-z4g64re8.js";import{s,me}from"./chunk-x4f7efgp.js";import D from"fs";import f from"path";import{createHash as vt}from"crypto";function Pt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Dt(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(kt,(e,u,g,v)=>{let w=v.trim();if(!w)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)w=Pt(w);let p=Dt(w);if(!n.has(p))n.set(p,w);let P=r.integrity?` data-stx-integrity="sha384-${vt("sha384").update(w).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),l=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:l}}var It=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)r.set(o[1],o[2]);let l=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(It.has(r.get(u[1])||""))l.add(u[2]);let g=/<\/head\s*>/iy,v=y(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(l.size===0||v===-1)return t;let w=Array.from(l).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!w)return t;return t.slice(0,v)+w+t.slice(v)}var Bt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let r=t.trim();if(!r)return null;let n=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(n).origin+new URL(n).pathname.replace(/\/$/,"")}catch{return null}}function jt(t){for(let r of Bt){let n=t[r];if(!n)continue;let o=X(n);if(o)return{url:o,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,n=r.site?.url??r.url??r.app?.url;return typeof n==="string"?X(n):null}async function Ft(t){let{existsSync:r}=await import("fs"),n=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let l=n.resolve(t,o);if(!r(l))continue;try{let e=await import(l),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),n=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let l=await Ft(r);if(l)return{url:l,source:"site.config",via:"url"};let e=jt(n);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
|
+
`)}function J(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=me(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,l;while((l=o.exec(r))!==null){if(n[l.index]!==0)continue;let u=x(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=x(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(l.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((l=e.exec(r))!==null){if(n[l.index]!==0)continue;let u=il(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let r="read";try{let n=await Bun.file(t).text();r="parse";let o=tn(n),l=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(s(e.attrs))).sort((e,u)=>n.indexOf(e.fullTag)-n.indexOf(u.fullTag));for(let e of l){if(!/\bgetStaticPaths\b/.test(s(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(s(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(s(g))&&At(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let w=await v();r="result";let p=Array.isArray(w)?{paths:w}:w;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(n){return{kind:"error",phase:r,error:n instanceof Error?n:Error(String(n))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[n,o]of Object.entries(r))this.cache.set(n,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),r={};for(let[n,o]of this.cache)r[n]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let n=D.statSync(t),o=`${this.salt}|${t}:${n.mtimeMs}`;for(let e of r)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let l=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);l=(l<<5)-l+u,l=l&l}return Math.abs(l).toString(36)}get(t,r){let n=this.cache.get(t);if(!n)return null;let o=ft(r).some((u)=>D.existsSync(u)),l=[r,...n.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ms(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||l)return this.cache.delete(t),null;let e=this.getHash(r,n.dependencies??[]);if(n.hash!==e)return this.cache.delete(t),null;return n.html}set(t,r,n,o){let l=this.getHash(r,n);this.cache.set(t,{hash:l,html:o,generatedAt:Date.now(),dependencies:n})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let n=this.getFilePath(t);await D.promises.mkdir(f.dirname(n),{recursive:!0}),await Bun.write(n,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await D.promises.unlink(r)}async invalidatePattern(t){let r=f.join(this.cacheDir,"isr");if(!D.existsSync(r))return;let n=await D.promises.readdir(r);for(let o of n){let l=o.replace(/_/g,"/").replace(".json","");if(t.test(l))await D.promises.unlink(f.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function Ut(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let n=await gt(t.filePath);if(n.kind==="error")throw Error(`getStaticPaths ${n.phase} failed for ${t.pattern} (${t.filePath}): ${n.error.message}`,{cause:n.error});if(n.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let o=n.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let l of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(l.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:l.params,props:l.props,revalidate:l.revalidate})}}return r}function ft(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let r of ft(t))if(await Bun.file(r).exists())try{let n=await import(r);if(typeof n.default==="function")return await n.default();else if(typeof n.default==="object")return n.default;else if(typeof n.getData==="function")return await n.getData();else{let{default:o,...l}=n;return l}}catch(n){console.error(`Error loading data file ${r}:`,n)}return null}async function Gt(t,r,n){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let l=o[1];if(!l.includes("getStaticProps"))return null;try{let e=l.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
|
|
4
4
|
return (async function getStaticProps() {
|
|
5
5
|
${e[1]}
|
|
6
6
|
})()
|
|
@@ -37,7 +37,7 @@ ${t.map((o)=>{let l=new URL(o.loc,r).href,e=` <url>
|
|
|
37
37
|
${n.join(`
|
|
38
38
|
`)}
|
|
39
39
|
</channel>
|
|
40
|
-
</rss>`}async function Vt(t={}){let r=Date.now();
|
|
40
|
+
</rss>`}async function Vt(t={}){let r=Date.now();rn();let n=await a(process.cwd()),o=n.build||{},l=await ut({explicit:t.domain||o.domain,stxConfig:n});if(l.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:l.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||c(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,w={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-w5h67xec.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:S}=await import("./chunk-ndyj1d0z.js"),R=await S(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-w5h67xec.js");await d('<div class="bg-black"></div>')}catch{}_t();let wt=n?.routeMiddleware?.dir||"middleware";await Et(process.cwd(),wt);let V=Ct();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let yt=n?.routeMiddleware?.global||[];nc(n?.layoutsDir,c(process.cwd()));let Z=G(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:N,props:St,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=Yt(A),xt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...yt,...xt];if(nt.length>0){let B=Tt(h,N,O||{}),L=$t(B,null,void 0,{isServer:!0}),j=await Rt(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,z=Zt(String(C),h),U=Qt(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,z),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(z),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
|
|
41
41
|
const validate = ${it[1]};
|
|
42
42
|
return validate(route);
|
|
43
43
|
`)({params:N})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await mt(k,N,St,e,n);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
@@ -46,7 +46,7 @@ ${n.join(`
|
|
|
46
46
|
Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&B.serverScriptFailures.length>0)throw Error(`${B.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
|
|
47
47
|
${B.serverScriptFailures.join(`
|
|
48
48
|
`)}
|
|
49
|
-
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)T.set(h,k.filePath,B.dependencies,I)}let H;if(e.trailingSlash)H=f.join(e.outputDir,h,"index.html");else H=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:L}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(L.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of L){let z=f.join(j,`${C.hash}.js`);if(!await Bun.file(z).exists())await Bun.write(z,C.code);if(!g.has(C.hash)){g.add(C.hash);let U=Buffer.byteLength(C.code,"utf8");v+=U,w[C.hash]={bytes:U,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=L.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(H),{recursive:!0}),await Bun.write(H,I),!Wt(h,I,O,e.sitemapExclude))_.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:H,size:Buffer.byteLength(I,"utf8"),cached:st};if(rt!==!1)at.revalidateAt=Date.now()+rt*1000;u.pages.push(at),u.successCount++,await e.hooks.onPageEnd?.(h,I)}catch(A){u.failedCount++,u.errors.push({route:h,error:A}),await e.hooks.onError?.(A,h),console.error(`Error generating ${h}:`,A)}}));let tt=
|
|
49
|
+
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)T.set(h,k.filePath,B.dependencies,I)}let H;if(e.trailingSlash)H=f.join(e.outputDir,h,"index.html");else H=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:L}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(L.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of L){let z=f.join(j,`${C.hash}.js`);if(!await Bun.file(z).exists())await Bun.write(z,C.code);if(!g.has(C.hash)){g.add(C.hash);let U=Buffer.byteLength(C.code,"utf8");v+=U,w[C.hash]={bytes:U,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=L.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(H),{recursive:!0}),await Bun.write(H,I),!Wt(h,I,O,e.sitemapExclude))_.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:H,size:Buffer.byteLength(I,"utf8"),cached:st};if(rt!==!1)at.revalidateAt=Date.now()+rt*1000;u.pages.push(at),u.successCount++,await e.hooks.onPageEnd?.(h,I)}catch(A){u.failedCount++,u.errors.push({route:h,error:A}),await e.hooks.onError?.(A,h),console.error(`Error generating ${h}:`,A)}}));let tt=nn();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
|
|
50
50
|
`);throw Error(`Client script bundling failed:
|
|
51
51
|
${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.join(e.pagesDir,"404.stx");if(await Bun.file(d).exists()){let m=new Set,k={...n,minifyClient:!0,debug:!1,cache:!1},h=await i(await Bun.file(d).text(),{},d,k,m);await Bun.write(f.join(e.outputDir,"404.html"),h)}else await Bun.write(f.join(e.outputDir,"404.html"),`<!DOCTYPE html>
|
|
52
52
|
<html lang="en">
|
|
@@ -69,7 +69,7 @@ ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.join(e.pagesDir,"404.
|
|
|
69
69
|
<a href="/">Go home</a>
|
|
70
70
|
</div>
|
|
71
71
|
</body>
|
|
72
|
-
</html>`)}for(let d of[500]){let m=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...n,minifyClient:!0,debug:!1,cache:!1},N=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),N)}}let K=f.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,m={...n,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(K).text(),{},K,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&_.length>0){let d=qt(_,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],k
|
|
72
|
+
</html>`)}for(let d of[500]){let m=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...n,minifyClient:!0,debug:!1,cache:!1},N=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),N)}}let K=f.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,m={...n,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(K).text(),{},K,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&_.length>0){let d=qt(_,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],k=$s({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...m.length>0?{disallow:m}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(f.join(e.outputDir,"robots.txt"),k),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(d.getItems)m=await d.getItems();let k=Jt(d,m),h=f.join(e.outputDir,"rss.xml");await Bun.write(h,k),u.rssPath=h,console.log(`Generated rss.xml with ${m.length} items`)}let W=ec(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=tc(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&D.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let et=tr();if(et)await Y(et,f.join(e.outputDir,er)),console.log(`Copied assets from ${en}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-r,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let E={generatedChunks:g.size,totalBytes:v,chunks:w,pages:p};await Bun.write(f.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
|
|
73
73
|
Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
74
74
|
Build complete!
|
|
75
75
|
Total: ${u.totalPages} pages
|
|
@@ -90,4 +90,4 @@ Build complete!
|
|
|
90
90
|
<p>Redirecting to <a href="${t}">${t}</a>...</p>
|
|
91
91
|
<script>window.location.replace('${t}')</script>
|
|
92
92
|
</body>
|
|
93
|
-
</html>`}function
|
|
93
|
+
</html>`}function Qt(t,r){if(t==="/"||t==="")return f.join(r.outputDir,"index.html");let n=t.replace(/^\/|\/$/g,"");if(r.trailingSlash)return f.join(r.outputDir,n,"index.html");return f.join(r.outputDir,`${n}.html`)}var je={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:J,createMarkdownLoader:Xt};export{Kt as createISRHandler,Xt as createMarkdownLoader,Nt as declaresPageAction,je as default,J as defineStaticPaths,Vt as generateStaticSite,Wt as isExcludedFromSitemap};
|
package/dist/utils.js
CHANGED
|
@@ -21,7 +21,7 @@ import { isUsableParamName } from "./safe-evaluator.js";
|
|
|
21
21
|
import { processScopedStyles } from "./style-scoping.js";
|
|
22
22
|
import { findSfcTemplateBlock } from "./sfc-template.js";
|
|
23
23
|
import { importOnce } from "./lazy-module.js";
|
|
24
|
-
import { scanAtElementPosition, stashScriptElements } from "./html-masking.js";
|
|
24
|
+
import { scanAtElementPosition, skipLeadingHtmlTrivia, stashScriptElements } from "./html-masking.js";
|
|
25
25
|
import { hasReactiveDirectives } from "./reactive.js";
|
|
26
26
|
import { markProjectedRefs, markProjectedSlotRoots } from "./misc-directives.js";
|
|
27
27
|
import { collectBlockDeclarations } from "./stx-virtual-ts.js";
|
|
@@ -517,10 +517,10 @@ const WRAPPER_HOISTED_OUT_BY_PARSER = new Set([
|
|
|
517
517
|
"span"
|
|
518
518
|
]);
|
|
519
519
|
export function scopeOnRootElement(html, attrs) {
|
|
520
|
-
const opening = html.match(
|
|
520
|
+
const leadingLen = skipLeadingHtmlTrivia(html), opening = html.slice(leadingLen).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);
|
|
521
521
|
if (!opening)
|
|
522
522
|
return null;
|
|
523
|
-
const tag = opening[
|
|
523
|
+
const tag = opening[1].toLowerCase();
|
|
524
524
|
if (!WRAPPER_HOISTED_OUT_BY_PARSER.has(tag))
|
|
525
525
|
return null;
|
|
526
526
|
const matcher = new RegExp(`<\\/?${tag}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`, "iy"), tokens = scanAtElementPosition(html, (source, index) => {
|
|
@@ -543,7 +543,7 @@ export function scopeOnRootElement(html, attrs) {
|
|
|
543
543
|
}
|
|
544
544
|
if (!complete)
|
|
545
545
|
return null;
|
|
546
|
-
const insertAt = opening[0].length;
|
|
546
|
+
const insertAt = leadingLen + opening[0].length;
|
|
547
547
|
return html.slice(0, insertAt) + attrs + html.slice(insertAt);
|
|
548
548
|
}
|
|
549
549
|
function isInsideFrameworkComponentsDir(dir, options) {
|
|
@@ -748,7 +748,7 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
748
748
|
for (const dir of options.additionalComponentsDirs ?? [])
|
|
749
749
|
if (dir && !searchDirs.includes(dir))
|
|
750
750
|
searchDirs.push(dir);
|
|
751
|
-
const checkedControl = options._nativeHostAttrs && /^(?:checkbox|switch)$/i.test(baseName), eventNames = (renderMetadata?.events ?? []).map((name) => name.replace(/^@/, "").split(".")[0].toLowerCase().replace(/-/g, "")), usesChecked = Object.hasOwn(props, "checked") || Boolean(renderMetadata?.reactiveProps?.includes("checked")), usesValue = Object.hasOwn(props, "value") || Boolean(renderMetadata?.reactiveProps?.includes("value")), sharedCheckedUsage = !eventNames.includes("valuechange") && (usesChecked || eventNames.includes("change") && !usesValue), textInput = options._nativeHostAttrs && /^textinput$/i.test(baseName), sharedTextInputUsage = eventNames.includes("update:value") && !eventNames.includes("input"), video = options._nativeHostAttrs && /^video$/i.test(baseName), image = options._nativeHostAttrs && /^image$/i.test(baseName), sharedImageUsage = usesSharedImageApi([...Object.keys(props), ...renderMetadata?.reactiveProps ?? []], renderMetadata?.events, props), usesSrc = Object.hasOwn(props, "src") || Boolean(renderMetadata?.reactiveProps?.includes("src")), usesSource = Object.hasOwn(props, "source") || Boolean(renderMetadata?.reactiveProps?.includes("source")), sharedVideoUsage = video && (usesSrc || usesSource) && (renderMetadata?.events ?? []).every((event) => /^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(event.replace(/^@/, "").split(".")[0])), sharedButtonVariants = new Set(["", "primary", "secondary", "outline", "ghost", "danger"]), buttonVariant = typeof props.variant === "string" ? props.variant.trim().toLowerCase() : "", nativeButtonUsage = options._nativeHostAttrs && /^button$/i.test(baseName) && !sharedButtonVariants.has(buttonVariant),
|
|
751
|
+
const checkedControl = options._nativeHostAttrs && /^(?:checkbox|switch)$/i.test(baseName), eventNames = (renderMetadata?.events ?? []).map((name) => name.replace(/^@/, "").split(".")[0].toLowerCase().replace(/-/g, "")), usesChecked = Object.hasOwn(props, "checked") || Boolean(renderMetadata?.reactiveProps?.includes("checked")), usesValue = Object.hasOwn(props, "value") || Boolean(renderMetadata?.reactiveProps?.includes("value")), sharedCheckedUsage = !eventNames.includes("valuechange") && (usesChecked || eventNames.includes("change") && !usesValue), textInput = options._nativeHostAttrs && /^textinput$/i.test(baseName), sharedTextInputUsage = eventNames.includes("update:value") && !eventNames.includes("input"), video = options._nativeHostAttrs && /^video$/i.test(baseName), image = options._nativeHostAttrs && /^image$/i.test(baseName), sharedImageUsage = usesSharedImageApi([...Object.keys(props), ...renderMetadata?.reactiveProps ?? []], renderMetadata?.events, props), usesSrc = Object.hasOwn(props, "src") || Boolean(renderMetadata?.reactiveProps?.includes("src")), usesSource = Object.hasOwn(props, "source") || Boolean(renderMetadata?.reactiveProps?.includes("source")), sharedVideoUsage = video && (usesSrc || usesSource) && (renderMetadata?.events ?? []).every((event) => /^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(event.replace(/^@/, "").split(".")[0])), sharedButtonVariants = new Set(["", "primary", "secondary", "outline", "ghost", "danger"]), buttonVariant = typeof props.variant === "string" ? props.variant.trim().toLowerCase() : "", nativeButtonUsage = options._nativeHostAttrs && /^button$/i.test(baseName) && !sharedButtonVariants.has(buttonVariant), nameHasSharedCounterpart = options._targetComponentFallbackNames?.some((name) => name.toLowerCase() === baseName.toLowerCase()) ?? !1, targetIsFallback = nameHasSharedCounterpart && (!checkedControl || sharedCheckedUsage) && (!textInput || sharedTextInputUsage) && (!video || sharedVideoUsage) && (!image || sharedImageUsage) && !nativeButtonUsage;
|
|
752
752
|
for (const dir of targetIsFallback ? [] : options._targetComponentDirs ?? [])
|
|
753
753
|
if (dir && !searchDirs.includes(dir))
|
|
754
754
|
searchDirs.push(dir);
|
|
@@ -763,10 +763,10 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
763
763
|
for (const fallback of fallbackDirs)
|
|
764
764
|
if (!searchDirs.includes(fallback))
|
|
765
765
|
searchDirs.push(fallback);
|
|
766
|
-
if (
|
|
767
|
-
const
|
|
768
|
-
if (
|
|
769
|
-
const hostDirs = searchDirs.slice(packageDirCount).map((dir) => path.isAbsolute(dir) ? dir : path.resolve(resolveBase, dir)), overrideKey = `${baseName}\x00${hostDirs.join("\x00")}`;
|
|
766
|
+
if (nameHasSharedCounterpart) {
|
|
767
|
+
const selected = (targetIsFallback ? options._pluginComponentDirs ?? [] : options._targetComponentDirs ?? []).filter((dir) => typeof dir === "string" && dir.length > 0);
|
|
768
|
+
if (selected.length) {
|
|
769
|
+
const hostDirs = searchDirs.slice(packageDirCount).map((dir) => path.isAbsolute(dir) ? dir : path.resolve(resolveBase, dir)).filter((dir) => !selected.includes(dir)), overrideKey = `${baseName}\x00${hostDirs.join("\x00")}`;
|
|
770
770
|
let overridden = convergedOverrideCache.get(overrideKey);
|
|
771
771
|
if (overridden === void 0) {
|
|
772
772
|
overridden = !1;
|
|
@@ -782,9 +782,12 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
782
782
|
convergedOverrideCache.set(overrideKey, overridden);
|
|
783
783
|
}
|
|
784
784
|
if (!overridden) {
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
785
|
+
for (const dir of selected) {
|
|
786
|
+
const at = searchDirs.indexOf(dir);
|
|
787
|
+
if (at >= 0)
|
|
788
|
+
searchDirs.splice(at, 1);
|
|
789
|
+
}
|
|
790
|
+
searchDirs.splice(packageDirCount, 0, ...selected);
|
|
788
791
|
}
|
|
789
792
|
}
|
|
790
793
|
}
|
|
@@ -1125,7 +1128,7 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
1125
1128
|
try {
|
|
1126
1129
|
propsJson = ` data-stx-props="${escapeAttr(JSON.stringify(props))}"`;
|
|
1127
1130
|
} catch {}
|
|
1128
|
-
const hydrateJson = hydrateTrigger ? ` stx-hydrate="${escapeAttr(hydrateTrigger)}"` : "", slotPresence = Object.fromEntries(Object.entries($slots).map(([name, content]) => [name, Boolean(content)])), slotsJson = Object.keys(slotPresence).length > 0 ? ` data-stx-slots="${escapeAttr(JSON.stringify(slotPresence))}"` : "", scopeAttrs = ` data-stx-scope="${scopeId}"${propsJson}${slotsJson}${hydrateJson}`,
|
|
1131
|
+
const hydrateJson = hydrateTrigger ? ` stx-hydrate="${escapeAttr(hydrateTrigger)}"` : "", slotPresence = Object.fromEntries(Object.entries($slots).map(([name, content]) => [name, Boolean(content)])), slotsJson = Object.keys(slotPresence).length > 0 ? ` data-stx-slots="${escapeAttr(JSON.stringify(slotPresence))}"` : "", scopeAttrs = ` data-stx-scope="${scopeId}"${propsJson}${slotsJson}${hydrateJson}`, rootContent = result.slice(skipLeadingHtmlTrivia(result)), inlineRoot = /^<span(?=[\s/>])/i.test(rootContent), layoutRoot = /^<[^>]+\bdata-stx-layout-root(?:\s|=|>)/i.test(rootContent), fillRoot = /^<[^>]+\bdata-stx-fill-root(?:\s|=|>)/i.test(rootContent), wrapperTag = inlineRoot ? "span" : "div", wrapperStyle = layoutRoot && options._nativeHostAttrs ? ' style="display:flex;flex-direction:column;flex:1;min-height:0;min-width:0"' : fillRoot && options._nativeHostAttrs ? ' style="width:100%;height:100%"' : inlineRoot || layoutRoot ? ' style="display:contents"' : "";
|
|
1129
1132
|
output = scopeOnRootElement(result, scopeAttrs) ?? `<${wrapperTag}${scopeAttrs} data-stx-component-wrapper${wrapperStyle}>${result}</${wrapperTag}>`;
|
|
1130
1133
|
const scopedScripts = await Promise.all(clientScripts.map(async (script) => {
|
|
1131
1134
|
const scriptMatch = script.match(/<script([^>]*)>([\s\S]*)<\/script>/i);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.839",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@stacksjs/ts-css": "^0.3.21",
|
|
130
130
|
"@stacksjs/clapp": "^0.2.16",
|
|
131
|
-
"@stacksjs/desktop": "0.2.
|
|
132
|
-
"@stacksjs/sanitizer": "0.2.
|
|
131
|
+
"@stacksjs/desktop": "0.2.839",
|
|
132
|
+
"@stacksjs/sanitizer": "0.2.839",
|
|
133
133
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
134
|
-
"bun-plugin-stx": "0.2.
|
|
134
|
+
"bun-plugin-stx": "0.2.839",
|
|
135
135
|
"bunfig": "^0.15.21",
|
|
136
|
-
"stx-router": "0.2.
|
|
136
|
+
"stx-router": "0.2.839",
|
|
137
137
|
"ts-broadcasting": "^0.0.11",
|
|
138
138
|
"ts-images": "^0.2.22",
|
|
139
139
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-0a36jnq4.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Mi,Di,Li,Ng,Mg,Dg,Cl,Lg,jg}from"./chunk-dv11h4f0.js";export{Mi as ImageProcessorCache,Cl as applyTransformations,Ng as clearImageCache,Lg as generateResponsiveVariants,jg as generateSrcset,Di as getCachedImageResult,Dg as optimizeImage,Mg as processImage,Li as setCachedImageResult};
|
package/dist/chunk-0c02182b.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ml,hl}from"./chunk-4ntm3dtk.js";import{f,P,ot,d}from"./chunk-txd2js5v.js";import{U,br,Ns,Ms,ai,ci,Ds,vr,fn,Me,fe,J,Sr,ie,Y,N,st,kr,di,Er,ze,r,p,W,xn}from"./chunk-trwe0mfa.js";import{n}from"./chunk-vypnjn9g.js";import{oe}from"./chunk-3bjnrmha.js";import{s}from"./chunk-sfsek961.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Ct}from"crypto";import Q from"fs";import Z from"path";import{decode as on,generateThumbHash as an}from"ts-images";import{createImageDeliveryCatalog as yt}from"ts-images/delivery";import je from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=je.readSync(e,o,0,t,i);return o.subarray(0,a)}function Le(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=je.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(Le(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)je.closeSync(i)}}import Yt from"fs";import ke from"os";import{join as gt}from"path";import{fileURLToPath as pt}from"url";var Pe=Symbol("stx.image-worker.unavailable");function Qt(e=typeof ke.availableParallelism==="function"?ke.availableParallelism():ke.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,ht=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>ht.push(e)),Ae++}function tn(){Ae--,ht.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Yt.existsSync(pt(t)))return pt(t)}catch{}try{let t=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return t&&sn(t)?t:void 0}catch{return}}function sn(e,i=process.env){let t=e.replace(/\\/g,"/");if(t.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![i.BUN_INSTALL_CACHE_DIR,gt(i.BUN_INSTALL||gt(ke.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>t.startsWith(a))}var mt=!1;function ue(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return Pe}function Re(e){return e instanceof Error?e.message:String(e)}async function Fe(e,i){let t;try{t=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Re(a)}`)}if(typeof t!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=rn();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((a,c)=>{let l;try{l=new t(o)}catch(y){a(ue(`could not start ${o}: ${Re(y)}`));return}let m=!1,u=!1,x=(y)=>{if(u)return;u=!0,y(),l.terminate()};l.on("message",(y)=>{if(y.type==="ready"){m=!0,l.postMessage({task:e,args:i});return}if(y.type==="result"){x(()=>a(y.value));return}let h=Error(y.error?.message??"image worker failed");if(y.error?.name)h.name=y.error.name;if(y.error?.stack)h.stack=y.error.stack;x(()=>c(h))}),l.on("error",(y)=>{x(()=>m?c(y instanceof Error?y:Error(Re(y)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Re(y)}`)))}),l.on("exit",(y)=>{x(()=>m?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var cn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),ln=[320,640,960,1280,1920],ye="/_stx/images",un=`stx:${ye}:alpha-1`,dn=`stx:${ye}:opaque-1`,gn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ie;function pn(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function bt(){if(Ie!==void 0)return Ie;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ie=gn.map((i)=>{let t;try{t=e?pn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Ie}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var xt=new Set;function mn(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function hn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Ct("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function wt(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function Rt(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await Rt(e,c));continue}if(!a.isFile()||!cn.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function $t(e,i){return e.map((t)=>({key:mn(t.relativePath),input:t.absolutePath,name:hn(t.relativePath),...yn(t.absolutePath)?{options:{storage:i}}:{}}))}function yn(e){return Ue(e)==="possible"}function bn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function vn(e){let i=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),t=new Set,o=8;for(let a=0;a<i.length;a+=8)await Promise.all(i.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,x)=>u.width-x.width)[0];try{let u=await on(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(bn(u.data))t.add(c)}catch{t.add(c)}}));return t}function wn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!Le(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,t.push(o),!xt.has(o))xt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function $n(e){let i=[],t=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await an(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));i.push(...c.filter((l)=>l!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function Sn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function Cn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function St(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function jo(e){let i=kt(e);return i?be().catalog.get(i):void 0}function Bo(e){let i=kt(e);return i?be().transparent.has(i):!1}function Fo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Nh(e){let i=jo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:Fo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:Bo(e)?void 0:i.placeholder?.dataUrl}}function us(){let e=be();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Mh(e,i,t={}){if(!e||!Q.existsSync(e))return us(),{count:0,fingerprint:""};if(t.offThread){let v=await Fe("delivery",{publicDir:e,outputDir:i});if(v!==Pe)return Rn(v.state),v.result}let o=await Rt(e);if(o.length===0)return us(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((v)=>{let b=a[v.relativePath];if(!b)return!0;let S=St(v.absolutePath);return!S||S.mtimeMs!==b.mtimeMs||S.size!==b.size});if(c.length===0)return us(),{count:0,fingerprint:""};let l=wt(Z.join(i,"_stx","images"),`${un}:${bt()}`),m={outDir:Z.join(i,"_stx","images"),storage:wt(Z.join(i,"_stx","images"),`${dn}:${bt()}`),baseUrl:ye,widths:ln,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,x;try{x=await yt({...m,entries:$t(c,l)})}catch(v){if(u=await $n(c),u.length===c.length)throw v;let b=new Set(u.map((k)=>k.relativePath)),S=!1;for(let k of c){if(b.has(k.relativePath))continue;let A=St(k.absolutePath);if(!A)continue;a[k.relativePath]=A,S=!0}if(S)Cn(i,a);if(u.length===0)return us(),{count:0,fingerprint:""};x=await yt({...m,entries:$t(u,l)})}let y=await vn(x.entries),h=wn(x.entries,y),C=be();C.catalog=new Map(Object.entries(x.entries)),C.transparent=y;let w=y.size===0&&h.length===0?x.fingerprint:Ct("sha256").update(x.fingerprint).update(JSON.stringify({transparent:[...y].sort(),droppedWebp:h.sort()})).digest("hex");return{count:u.length,fingerprint:w}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=ai(e,o);if(a!==void 0)return a;for(let c of ci(e,i,t,o))if(await r(c))return c;return null}}var de=new At;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var kn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||kn.has(i)}function se(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${xn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${xn(c,He(String(a)))}"`)}return t}function An(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=An(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(vr(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let x=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(x)u.push(`data-stx-active-match="${n(x)}"`);let y=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...se(e,y)),u.push(...ae(e,y)),`<a ${u.join(" ")}>${i}</a>`}};var Pn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Pn.get(i)}var In={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function V(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=In[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))t.push(`(max-width: ${m}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function _n(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function En(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function Nn(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=V(e,"src")||"",a=jo(o),c=V(e,"alt")||"",l=V(e,"width")||(a?String(a.source.width):void 0),m=V(e,"height")||(a?String(a.source.height):void 0),u=V(e,"sizes"),x=V(e,"srcset"),y=V(e,"densities"),h=V(e,"format"),C=Bo(o)||Ve(o)?.transparent===!0,w=V(e,"placeholder")||(a&&!C?"thumbhash":void 0),v=V(e,"placeholderColor")||"#e5e7eb",b=V(e,"provider"),S=V(e,"class")||V(e,"className")||"",k=V(e,"style")||"",A=V(e,"objectFit")||V(e,"fit"),R=V(e,"objectPosition")||V(e,"position"),B=V(e,"quality"),G=_e(e,"lazy",!0),M=_e(e,"preload",!1),F=_e(e,"priority",!1),H=V(e,"loading"),E=V(e,"decoding")||"async",D=!!a||_e(e,"picture",!1)||!!h,O=l?Number.parseInt(l):void 0,q=m?Number.parseInt(m):void 0,z=x||"",X="";if(a)z=a.sources[a.fallback.format]||"",X=u?Ge(u):"100vw";else if(!z&&u&&b&&b!=="local"&&b!=="static")z=Ke(o,Ze,b,h),X=Ge(u);else if(!z&&y){let I=y.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));z=_n(o,I,O,b,h)}else if(u)X=Ge(u);let L=[];if(k)L.push(k);if(A)L.push(`object-fit:${A}`);if(R)L.push(`object-position:${R}`);if(O&&q)L.push(`aspect-ratio:${O}/${q}`);let T=[],ce=w==="blur"||w==="color"||w==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:v}:Ve(o);if(I&&w==="color")L.push(`background-color:${I.color}`),T.push("backgroundColor");else if(I)L.push(`background-color:${I.color}`),L.push(`background-image:url(${I.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),T.push("backgroundColor","backgroundImage");else{let _=Nn(O||16,q||9,v);L.push(`background-image:url(${_})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),T.push("backgroundImage")}}else if(!ce&&w&&w!=="empty"&&w!=="none")L.push(`background-image:url(${n(w)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),T.push("backgroundImage");let $e=a?.fallback.url||ve(o,O,q,b,h),K=[];if(K.push(`src="${n(vr($e,"fetched"))}"`),K.push(`alt="${n(c)}"`),l)K.push(`width="${n(l)}"`);if(m)K.push(`height="${n(m)}"`);let le=H||(F||M?"eager":G?"lazy":"");if(le)K.push(`loading="${n(le)}"`);if(F)K.push('fetchpriority="high"');if(K.push(`decoding="${n(E)}"`),S)K.push(`class="${n(S)}"`);if(L.length>0)K.push(`style="${n(L.join(";"))}"`);if(z)K.push(`srcset="${n(vr(z,"fetched"))}"`);if(X)K.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(T.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=En(T)+(I?`;${I}`:"");K.push(`onload="${n(_)}"`),te.add("onload")}K.push(...se(e,te)),K.push(...ae(e,te));let Te=`<img ${K.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${z?` imagesrcset="${n(z)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
|
|
3
|
-
`}if(D){let I=[];if(a)for(let _ of Fo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let _=ve(o,O,q,b,"avif"),ee=z?Ke(o,Ze,b,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let _=ve(o,O,q,b,"webp"),ee=z?Ke(o,Ze,b,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${j}<picture>
|
|
4
|
-
${I.join(`
|
|
5
|
-
`)}
|
|
6
|
-
${Te}
|
|
7
|
-
</picture>`}return`${j}${Te}`}};var Pt="/images/safe-image-default.svg";function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var On=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Pt}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Ye={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,t){let o=ge(e,"src")||"",a=ge(e,"alt")||"",c=ge(e,"fallback")||Pt,l=ge(e,"class")||ge(e,"className")||"",m=ge(e,"fallbackClassName")||"",u=[];if(u.push(`src="${n(o)}"`),u.push(`alt="${n(a)}"`),l)u.push(`class="${n(l)}"`);if(u.push(`data-fallback="${n(c)}"`),m)u.push(`data-fallback-class="${n(m)}"`);u.push('onerror="window.__stxSafeImageHandler(this)"');let x=new Set(["src","alt","fallback","class","className","fallbackClassName"]);u.push(...se(e,x)),u.push(...ae(e,x));let y=`<img ${u.join(" ")} />`,h=t.context;if(!h.__safeImageHandlerEmitted)return h.__safeImageHandlerEmitted=!0,`${On}${y}`;return y}};function Qe(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function xe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Ee(e,i,t){let o=xe(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var et={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,t){let o=Qe(xe(e,"color")||"#6366f1"),a=Qe(xe(e,"initialColor")||xe(e,"initial-color")||""),c=Qe(xe(e,"height")||"3px"),l=Ee(e,"duration",2000),m=Ee(e,"throttle",200),u=Ee(e,"zIndex",999999)||Ee(e,"z-index",999999),x=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
|
|
8
|
-
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${c};background:${x};z-index:${u};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
9
|
-
<div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
|
|
10
|
-
</div>
|
|
11
|
-
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
12
|
-
<script>
|
|
13
|
-
(function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${m})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
|
|
14
|
-
</script>`}};function _t(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Bn(e,i,t){let o=_t(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var It={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},tt={name:"StxToast",aliases:["stx-toast"],render(e,i,t){let o=n(_t(e,"position")||"top-right"),a=Bn(e,"max",5),c=It[o]||It["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${o}" data-stx-toast-max="${a}" style="position:fixed;${c};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
|
|
15
|
-
<style>
|
|
16
|
-
@keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
|
|
17
|
-
@keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
|
|
18
|
-
@keyframes stx-toast-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}
|
|
19
|
-
@keyframes stx-toast-out-left{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(-100%)}}
|
|
20
|
-
@keyframes stx-toast-in-center{from{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}
|
|
21
|
-
@keyframes stx-toast-out-center{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-1rem)}}
|
|
22
|
-
</style>`}};function Ne(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Et={sm:"max-width:24rem",md:"max-width:32rem",lg:"max-width:42rem",xl:"max-width:56rem",full:"max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem)"},nt={name:"StxModal",aliases:["stx-modal"],render(e,i,t){let o=Ne(e,"id");if(!o)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let a=n(o),c=Ne(e,"size")||"md",l=Ne(e,"closeOnBackdrop")!=="false",m=Ne(e,"closeOnEscape")!=="false",u=Et[c]||Et.md;return`<div id="stx-modal-${a}" class="stx-modal-backdrop" data-stx-modal="${a}" data-close-backdrop="${l}" data-close-escape="${m}" style="display:none;position:fixed;inset:0;z-index:99999;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:0;transition:opacity 0.2s ease" aria-modal="true" role="dialog">
|
|
23
|
-
<div class="stx-modal-panel" style="${u};width:100%;margin:1rem;border-radius:0.75rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow:hidden;transform:scale(0.95) translateY(8px);transition:transform 0.2s ease,opacity 0.2s ease;opacity:0;background:var(--stx-modal-bg,#fff);color:var(--stx-modal-text,#1f2937)">
|
|
24
|
-
<div style="padding:1.5rem">${i}</div>
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
<style>
|
|
28
|
-
@media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
|
|
29
|
-
.stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
|
|
30
|
-
.stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
|
|
31
|
-
</style>`}};function pe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Nt={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},rt={name:"StxDrawer",aliases:["stx-drawer"],render(e,i,t){let o=pe(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=pe(e,"side")||"right",l=pe(e,"size")||"md",m=pe(e,"closeOnBackdrop")!=="false",u=pe(e,"closeOnEscape")!=="false",x=pe(e,"overlay")!=="false",y=Nt[l]||Nt.md,h=c==="left",C=h?"left:0":"right:0",w=h?"translateX(-100%)":"translateX(100%)",v=h?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${m}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;${x?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
|
|
32
|
-
<div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${C};width:${y};max-width:100vw;transform:${w};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
|
|
33
|
-
<div style="padding:1.5rem">${i}</div>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
<style>
|
|
37
|
-
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
38
|
-
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
39
|
-
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
40
|
-
</style>`}};import{existsSync as Dn,readFileSync as Tn}from"fs";var Oe=new Map,Ot=new Set;function jn(e){if(Ot.has(e))return;Ot.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Mn(e){let i=process.cwd();for(let t of[`${i}/node_modules/@iconify-json/${e}/icons.json`,`${i}/pantry/@iconify-json/${e}/icons.json`,`${i}/node_modules/@iconify/json/json/${e}.json`,`${i}/pantry/@iconify/json/json/${e}.json`])if(Dn(t))return t;for(let t of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(t)}catch{}return null}function Ln(e){if(Oe.has(e))return Oe.get(e);let i=Mn(e);if(!i)return jn(e),null;try{let t=JSON.parse(Tn(i,"utf8"));return Oe.set(e,t),t}catch{return null}}function zn(e,i,t,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${t/2} ${o/2})`);if(i.hFlip)a.push(`translate(${t} 0) scale(-1 1)`);if(i.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function Un(e,i){let t=i,o=e.icons[t],a={hFlip:!1,vFlip:!1,rotate:0};for(let m=0;!o&&m<8;m++){let u=e.aliases?.[t];if(!u)return null;if(u.hFlip)a.hFlip=!a.hFlip;if(u.vFlip)a.vFlip=!a.vFlip;if(u.rotate)a.rotate=((a.rotate+u.rotate)%4+4)%4;t=u.parent,o=e.icons[t]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:zn(o.body,a,c,l),width:c,height:l}}function me(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);if(e.static[i]!==void 0)return String(e.static[i]);if(e.clientReactive[i]!==void 0)return e.clientReactive[i];return}var it={name:"Icon",aliases:["icon","stx-icon"],render(e,i,t){let o=me(e,"name")??me(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let S=o.split(":");a=S[0],c=S[1]}let l=n(me(e,"size")||"24"),m=n(me(e,"color")||"currentColor"),u=n(me(e,"class")||""),x=n(me(e,"style")||""),y=Oe.get(a)??Ln(a);if(!y)return`<!-- Icon: collection "${a}" not loaded -->`;let h=Un(y,c);if(!h)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${h.width} ${h.height}`,w=h.body;if(m!=="currentColor")w=w.replace(/currentColor/g,m);let v=u?` class="${u}"`:"",b=x?` style="${x}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${v}${b}>${w}</svg>`}};function Bt(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}function Dt(e,i){let t=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(t);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var at={name:"Suspense",aliases:["suspense"],render(e,i,t){let o=Dt(i,"fallback"),a=o.rest,c=Dt(a,"error"),l=c.rest,m=o.region??Bt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Bt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${m}</div><div data-stx-suspense-error hidden>${u}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Be(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}var ct={name:"TransitionGroup",aliases:["transition-group"],render(e,i,t){let o=(Be(e,"name")||"v").replace(/["'<>]/g,""),a=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Be(e,"class"),l=Be(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${i}</${a}>`}};function Tt(e=de){e.registerBuiltin(Xe),e.registerBuiltin(Je),e.registerBuiltin(Ye),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(rt),e.registerBuiltin(it),e.registerBuiltin(at),e.registerBuiltin(ct)}var jt=new Map;function Fn(e){let i=jt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),jt.set(e.source,i);return i}var Mt=new WeakMap;function Lt(e){let i=Mt.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Mt.set(e,i);let t=i;return(o)=>!/[a-z]/.test(o)&&t.has(o.toLowerCase())}function Wn(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function zt(e,i,t){let o=[],a=0,c=typeof t==="function"?t:t?(l)=>t.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Fn(i);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let x=u[1];if(c&&c(x)){let S=l+1+x.length;while(S<e.length&&e[S]!==">")S++;a=S+1;continue}let y=l+1+x.length,h=null,C=y,w=-1,v=!1;while(y<e.length){let S=e[y];if(h){if(S==="\\"&&y+1<e.length){y+=2;continue}if(S===h)h=null;y++;continue}if(S==='"'||S==="'"){h=S,y++;continue}if(S==="/"&&y+1<e.length&&e[y+1]===">"){w=y+2,v=!0;break}if(S===">"){w=y+1;break}y++}if(w===-1){a=l+1;continue}let b=e.slice(C,v?w-2:w-1).trim();if(v)o.push({fullMatch:e.slice(l,w),tagName:x,attributes:b,content:"",startIndex:l,endIndex:w,isSelfClosing:!0}),a=w;else{let S=`<${x}`,k=`</${x}>`,A=1,R=w,B=-1;while(A>0&&R<e.length){let F=e.indexOf(S,R),H=e.indexOf(k,R);if(H===-1)break;if(F!==-1&&F<H){let E=e[F+S.length];if(E===" "||E===">"||E==="/"||E===`
|
|
41
|
-
`||E==="\t"){let D=Wn(e,F+S.length);if(e[D-1]!=="/")A++;R=D+1}else R=F+S.length}else{if(A--,A===0){B=H;break}R=H+k.length}}if(B===-1){a=w;continue}let G=e.slice(w,B),M=B+k.length;o.push({fullMatch:e.slice(l,M),tagName:x,attributes:b,content:G,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function lt(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ut(e,i){try{let t=Buffer.from(e,"base64").toString("utf8");return JSON.parse(t)}catch{}try{let t=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(t)}catch(t){if(i?.debug)console.error("Error decoding __stx_ prop:",t);return e}}function De(e,i){let t=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")t++;else if(c==="}"){if(t--,t===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Ft(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(De(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Wt(e){let i=[],t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o&&e[t]!==l){if(e[t]==="\\"&&t+1<o)t++,c+=e[t];else c+=e[t];t++}if(t<o)t++}else if(e[t]==="{")c=De(e,t),t+=c.length;else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var Hn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),qn=new Set([":for","x-for","v-for","@for"]),Xn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Vn(e){return ut(e).map((i)=>[i.start,i.end])}function ut(e){let i=[],t=new Map;for(let o of fn(e)){let a=o.name.toLowerCase();if(o.closing){let x=t.get(a)?.pop();if(x)x.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Wt(o.attributes).find((x)=>qn.has(x.name)):void 0,m=typeof l?.value==="string"?l.value:null,u=m!==null?{start:o.start,end:o.end,names:Y(m)}:null;if(u)i.push(u);if(!o.selfClosing&&!Xn.has(a)){let x=t.get(a);if(!x)x=[],t.set(a,x);x.push(u)}}return i}function Ht(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Ht(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function lc(e,i){if(!/:[\w-]+=/.test(e))return e;let t=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...Vn(e));let l=new Set([...st(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function m(h){return a.some(([C,w])=>h>=C&&h<w)}let u=[],x=new Map,y=256;for(let h of fn(t)){if(h.closing||m(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let w=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),v=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,b,S=C,k=!1;while((b=v.exec(C))!==null){if(Sr(C,b.index,!0)?.kind==="attribute")continue;let A=b[1],R=b[2];if(ml(A))continue;if(N(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let B=Object.keys(i),G=Object.values(i),M=R.match(/^([a-zA-Z_$][\w$]*)/);if(M&&!B.includes(M[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(M[1]))continue;let F=JSON.stringify([B,R]),H=x.get(F);if(!H){if(H=Function(...B,`return (${R})`),x.size>=y)x.clear();x.set(F,H)}let E=H(...G);if(A==="class"){let D=W(Ht(E));if(D){let O=S.match(/\sclass="([^"]*)"/);if(O)S=S.replace(O[0],()=>` class="${O[1]} ${D}"`);else S=S.replace(b[0],()=>` class="${D}"`)}else S=S.replace(b[0],"");k=!0;continue}if(Hn.has(A)){if(E)S=S.replace(b[0],` ${A}`);else S=S.replace(b[0],"");k=!0;continue}if(E===null||E===void 0||E===!1)S=S.replace(b[0],"");else{let D=w&&typeof E==="object"?JSON.stringify(E):String(E),O=xn(A,D);S=S.replace(b[0],()=>` ${A}="${O}"`)}k=!0}catch(B){if(B instanceof ie)throw B;continue}}if(k){let A=h.selfClosing?" /":"",B=`<${h.name}${S}${A}>`;u.push({start:h.start,end:h.end,replacement:B})}}if(u.length>0){let h=Array(u.length*2+1),C=0;for(let w=0;w<u.length;w++){let{start:v,end:b,replacement:S}=u[w];h[w*2]=t.slice(C,v),h[w*2+1]=S,C=b}h[u.length*2]=t.slice(C),t=h.join("")}return t}import qt from"fs";import Xt from"path";var Vt=!1;function Zn(e,i,t,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),m=(h)=>{if(l.size===0)return!1;let C=s(h),w=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(w&&l.has(w))return!0;for(let v of l){let b=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(C))return!0}return!1},u=new Set(hl),x=(h)=>{if(!h.includes("-")||h.startsWith("@")||h.startsWith(":")||h.startsWith("x-")||h.startsWith("__"))return h;if(h.startsWith("aria-")||h.startsWith("data-"))return h;return h.replace(/-([a-z0-9])/g,(C,w)=>w.toUpperCase())},y=(h,C)=>{let w=x(h);if(c.static[w]=C,w!==h)c.staticNames[w]=h};for(let[h,C]of Object.entries(e)){let w=h.startsWith("x-")&&!u.has(h)&&!h.startsWith("x-bind:")&&!h.startsWith("x-on:")?`:${h.slice(2)}`:h;if(w.startsWith("@")){c.events[w]=C;continue}if(w.startsWith("__stx_")){let v=x(w.slice(6));c.serverDynamic[v]=Ut(C,t);continue}if(w.startsWith(":")){let v=x(w.slice(1)),b=C===re?v:C;if(v==="if"||v==="for"||v==="show"){c.clientReactive[v]=b;continue}if(o){c.clientReactive[v]=b;continue}if(N(b,a)){c.clientReactive[v]=b;continue}if(m(b)){c.clientReactive[v]=b;continue}try{if(!f(b)){if(t.debug)console.error(`Unsafe expression in :${v} binding: ${b}`);c.clientReactive[v]=b;continue}let S=Object.keys(i),k=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),A=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ot(b).some((M)=>!k.has(M)&&!S.includes(M)&&(!(M in globalThis)||A.has(M)))){c.clientReactive[v]=b;continue}let G=d(b,S)(...Object.values(i));if(c.serverDynamic[v]=G,v!==w.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[v]=w.slice(1)}catch{c.clientReactive[v]=b}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let v=Gn(C,a);if(v!==null){c.clientReactive[x(w)]=v;continue}let b=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let S=b[1];if(f(S)){let A=d(S,Object.keys(i))(...Object.values(i));y(w,A!=null?String(A):"")}else{if(t.debug)console.error(`Unsafe expression in ${w}: ${S}`);y(w,C)}}catch(S){if(t.debug)console.error(`Error evaluating expression for ${w}:`,S);y(w,C)}else{let S=C,k=/\{\{\s*([\s\S]+?)\s*\}\}/g,A;while((A=k.exec(C))!==null)try{let R=A[1];if(!f(R)){if(t.debug)console.error(`Unsafe expression in ${w}: ${R}`);continue}let G=d(R,Object.keys(i))(...Object.values(i));S=S.replace(A[0],String(G??""))}catch(R){if(t.debug)console.error(`Error evaluating expression in ${w}:`,R)}y(w,S)}continue}y(w,C===re?"true":lt(C))}return c}function Gn(e,i){if(i.size===0)return null;let t=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(t)];if(!o.some((m)=>N(m[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Kn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Jn(e,i,t){if(!e.includes("@"))return e;if(!Kn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return oe(e,i,t)}catch{return e}}function he(e){let i={},t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o){let m=e[t];if(m==="\\"&&t+1<o){t++,c+=e[t],t++;continue}if(m===l){t++;break}c+=m,t++}}else if(e[t]==="{"){c=De(e,t),t+=c.length;let l=Ft(c);if(l!==null){i[`:${a}`]=l;continue}}else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i[a]=c}else i[a]=re}return i}function Zt(e){return Object.entries(e).map(([i,t])=>t===re?i:`${i}="${Yn(t)}"`).join(" ")}function Yn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Qn(e){let i=new Set,t=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=t.exec(e))!==null){let a=o[1];if(de.isBuiltin(a))i.add(a)}return[...i].sort()}async function Mf(e,i,t,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Xt.dirname(t),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(u)){let[C,w,v]=h,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,S=v,k,A=[];while((k=b.exec(v))!==null){let[R,B,G,M]=k,F=null,H=null;if(M.startsWith(".")||M.startsWith("/")){let O=Xt.resolve(l,M);if(O.endsWith(".stx"))H=O;else{let q=`${O}.stx`;try{if(qt.statSync(q).isFile())H=q}catch{try{if(qt.statSync(O).isDirectory())F=O}catch{}}}}else F=Ns(M,l);if(!F&&!H)continue;let E=!1,D=(O,q)=>{c.set(O,q),c.set(O.toLowerCase(),q);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(z,q),a.add(q)};if(G&&H)D(G,H),E=!0;else if(B){let O=B.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let X=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:z,local:z}}),q=F?br(F):null;for(let{source:z,local:X}of O){let L=null;if(H)L=H;else if(q)L=q.get(z)??q.get(z.toLowerCase())??q.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)D(X,L),E=!0}}if(E)A.push({start:k.index,end:k.index+R.length})}if(A.length===0)continue;for(let R=A.length-1;R>=0;R--)S=S.slice(0,A[R].start)+S.slice(A[R].end);m.push({start:h.index,end:h.index+C.length,value:`<script${w}>${S}</script>`})}if(m.length===0)return e;let x=[],y=0;for(let h of m)x.push(e.slice(y,h.start),h.value),y=h.end;return x.push(e.slice(y)),x.join("")}async function er(e,i,t,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[x,y]=u,h=y.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let w=C.split("/"),b=w[w.length-1].replace(/\.stx$/,""),S=b.includes("-")?b.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),k=null,A=Ms(C,t,o);for(let R of A)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(S,k),l.set(b,k),l.set(b.toLowerCase(),k);let R=S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${S} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(x,""),m.lastIndex=0}return c}async function tr(e,i,t,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=/@component\s*\(/g,x;while((x=u.exec(c))!==null){let y=x.index,h=y+x[0].length-1,C=1,w=h+1;while(w<c.length&&C>0){if(c[w]==="(")C++;else if(c[w]===")"){if(C--,C===0)break}w++}if(C!==0)break;let v=c.substring(h+1,w),b=w+1,S=v.match(/^\s*['"]([^'"]+)['"]/);if(!S){u.lastIndex=b;continue}let k=S[1],A,R=v.slice(S[0].length),B=R.match(/^\s*,\s*/);if(B)A=R.slice(B[0].length).trim();let G={};if(A)try{G=P(A,i)}catch(O){let q=O instanceof Error?O.message:String(O);c=c.replace(c.substring(y,b),`[Error parsing component props: ${q}]`);continue}let M="",F=b,E=c.substring(b).match(/^([\s\S]*?)@endcomponent/);if(E)M=E[1].trim(),F=b+E[0].length;let D=await ze(k,G,M,l,i,t,o,m,a);c=c.substring(0,y)+D+c.substring(F),u.lastIndex=0}return c}async function nr(e,i,t,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=ir(c);if(u.size>0){let b=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...b,...u])]}let x=J(c);c=x.output;let y=st(i);return c=await v(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await v(c,/[A-Z][a-zA-Z0-9]*/,!0,Lt(kr)),c=await v(c,/[a-z][a-z0-9]*/,!1,kr),c=x.restore(c),c;async function v(b,S,k,A){if(!b)return b;let R=b,B=zt(R,S,A),G=ut(R),M=new Map;for(let E=B.length-1;E>=0;E--){let D=B[E],O=k?U(D.tagName):D.tagName,q=he(Jn(D.attributes,i,t)),z=G.filter(({start:I,end:_})=>D.startIndex>=I&&D.startIndex<_),X=z.length>0,L=new Set(y);for(let I of z)for(let _ of I.names)L.add(_);let T=Zn(q,i,o,X,L);if(typeof T.clientReactive.for==="string")for(let I of Y(T.clientReactive.for))L.add(I);let ce=de.getBuiltin(D.tagName),$e=ce?await Er(D.tagName,l,i,t,o):!1,K=D.tagName==="Image"&&Ds([...Object.keys(T.static),...Object.keys(T.serverDynamic),...Object.keys(T.clientReactive)],Object.keys(T.events),{...T.static,...T.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>br(I).has("Image"));if(ce&&!$e&&!K){let I={context:i,filePath:t,options:o,dependencies:a},_=ce.render(T,D.content,I);if(Object.keys(T.events).length>0){let ee=Zt(T.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(T.clientReactive).length>0)_=Gt(_,T.clientReactive);M.set(E,_);continue}if(!k&&D.tagName.includes("-")&&!await Er(O,l,i,t,o))continue;let le={};for(let[I,_]of Object.entries(T.static))le[I]=_;for(let[I,_]of Object.entries(T.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(T.clientReactive),events:Object.keys(T.events)},j=await ze(O,le,x.restore(D.content),l,i,t,o,m,a,[...L],te,D.tagName);if(j=rr(j,T,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(U),_=ft(j,!0);if(I.length&&_){if(!Object.hasOwn(he(j.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))j=j.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+j.slice(_.insertPos);let ne=we(j);j=j.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+j.slice(ne.insertPos)}let ee=ft(j,!0);if(ee){let ne=he(j.slice(ee.insertPos,ee.tagEnd)),Se=we(j),Jt=he(j.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Jt,"data-stx-native-host-owner"))j=j.slice(0,Se.insertPos)+" data-stx-native-host-owner"+j.slice(Se.insertPos)}}if(Object.keys(T.events).length>0){let I=we(j);if(I){let _=Zt(T.events),ee=Object.keys(T.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");j=j.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+j.substring(I.insertPos)}}if(Object.keys(T.clientReactive).length>0)j=Gt(j,T.clientReactive);M.set(E,j)}if(M.size===0)return R;let F="",H=0;for(let E=0;E<B.length;E++){let D=M.get(E);if(D===void 0)continue;F+=R.slice(H,B[E].startIndex),F+=D,H=B[E].endIndex}return F+=R.slice(H),F}}function Gt(e,i){let t=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([y])=>!t.has(y)),c=a.filter(([y])=>!o.has(y)).map(([y])=>U(y)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let y=a.map(([C,w])=>`:${U(C)}="${w.replace(/"/g,""")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${h} ${y}`+l.substring(m.insertPos)}let u=i.if;if(u)l=`<template :if="${u.replace(/"/g,""")}">${l}</template>`;let x=i.for;if(x){let y=i.key,h=y?` :key="${y.replace(/"/g,""")}"`:"";l=`<template :for="${x.replace(/"/g,""")}"${h}>${l}</template>`}return l}function rr(e,i,t=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=i.serverDynamic.class??i.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let v=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=v.test(l)?l.replace(v,(S,k,A,R,B)=>`${k}class="${n(`${lt(A??R??B)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+b+e.slice(c.tagEnd),c.tagEnd+=b.length-l.length,l=b}let u=a||/\bdata-native(?:\s|=)/i.test(l),x=u?o:t,y=new Set(Object.keys(he(l))),h=new Set(["class","className"]);for(let v of Object.keys(i.static)){let b=i.staticNames[v]??v;if(y.has(b)||x.has(v)||!u&&!qe(b))h.add(v)}for(let v of Object.keys(i.serverDynamic)){let b=i.serverDynamicNames?.[v]??v;if(y.has(b)||x.has(v)||!u&&!qe(b))h.add(v)}let C=[];if(u){for(let[v,b]of Object.entries(i.static)){if(h.has(v)||b!==!0&&b!==re)continue;h.add(v),C.push(`${n(i.staticNames?.[v]??v)}="true"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!0)continue;h.add(v),C.push(`${n(i.serverDynamicNames?.[v]??v)}="true"`)}}let w=[...se(i,h),...ae(i,h),...C];if(u){for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!1)continue;let S=i.serverDynamicNames?.[v]??v;w.push(`${n(S)}="false"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b===null||typeof b!=="object")continue;let S=JSON.stringify(b);if(S!==void 0){let k=i.serverDynamicNames?.[v]??v;w.push(`${n(k)}="${n(S)}"`)}}}if(w.length===0)return e;return`${e.slice(0,c.insertPos)} ${w.join(" ")}${e.slice(c.insertPos)}`}function we(e){let i=Kt(e,0);if(i)return i;let t=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(t)return{insertPos:t.index+1+t[1].length,tagEnd:dt(e,t.index+1+t[1].length)};return null}function ft(e,i=!1){let t=we(e);if(!t)return null;let o=e.slice(t.insertPos,t.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Kt(e,t.tagEnd+1):t;return a&&i?sr(e,a)??a:a}function sr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let t=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",i.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let y=e.indexOf("-->",o+4);if(y<0)return null;o=e.indexOf("<",y+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,x=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let y=new RegExp(`</${m}\\s*>`,"gi");if(y.lastIndex=x+1,!y.exec(e))return null;o=e.indexOf("<",y.lastIndex);continue}else{let y=he(e.slice(u,x)),h=a>0&&(Object.hasOwn(y,"data-stx-component-wrapper")||Object.hasOwn(y,"data-stx-native-host-owner"));if(c===void 0&&!h&&Object.hasOwn(y,"data-stx-native-host-root"))return{insertPos:u,tagEnd:x};if(!t.has(m)&&e[x-1]!=="/"){if(a++,c===void 0&&h)c=a}else if(a===0)return null}o=e.indexOf("<",x+1)}return null}function Kt(e,i){let t=i;while(t<e.length){let o=e.slice(t),a=o.match(/^\s+/);if(a){t+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",t+4);if(m===-1)return null;t=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,t+c[0].length);if(u===-1)return null;t=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:t+1+l[1].length,tagEnd:dt(e,t+1+l[1].length)}}return null}function dt(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function ir(e){let i=new Set;for(let t of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=t[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of di(t[2]))i.add(a);for(let a of t[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function ds(e,i,t,o,a){if(!Vt)Tt(de),Vt=!0;let c=await Mf(e,i,t,o,a);c=await er(c,i,t,o,a),c=await tr(c,i,t,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,x=fe(c,Me,(h,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...x.tokens);let y=c;if(c=await nr(x.output,i,t,o,a),c===y)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Qn(c);if(m.length>0)console.warn(`[stx] ${t}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
|
|
42
|
-
export{jo,Bo,Fo,Nh,us,Mh,lc,Mf,ds};
|
package/dist/chunk-0rnfywsx.js
DELETED
package/dist/chunk-1bpx9b0m.js
DELETED
package/dist/chunk-1g6xxftp.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{F,Vf,Yo,a,O,Uh,Wh}from"./chunk-3yggtch5.js";import"./chunk-t2vmk8tf.js";import"./chunk-gh62p9mx.js";import"./chunk-amg6kr1p.js";import"./chunk-ms3v5nat.js";import"./chunk-29f6vmyz.js";import"./chunk-trwe0mfa.js";import"./chunk-cwfavkk0.js";import"./chunk-vfj9wp11.js";import"./chunk-txd2js5v.js";import"./chunk-s6r54dyf.js";import"./chunk-4ntm3dtk.js";export{O as config,F as defaultConfig,Uh as defineStxConfig,Yo as discoverConfig,a as loadStxConfig,Vf as resolveStxDirectories,Wh as validateConfig};
|