@stacksjs/stx 0.2.222 → 0.2.224
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-placeholder.d.ts +78 -0
- package/dist/builtins/image-placeholder.js +136 -0
- package/dist/builtins/stx-image.js +15 -4
- package/dist/chunk-05c6c4sf.js +2 -0
- package/dist/{chunk-nnw1ka45.js → chunk-0h08j951.js} +1 -1
- package/dist/{chunk-yppz6dgg.js → chunk-0n4fvqm8.js} +2 -2
- package/dist/{chunk-ceqzwfcq.js → chunk-0yw0x5qz.js} +1 -1
- package/dist/{chunk-qr90ng3a.js → chunk-21kvpnqq.js} +2 -2
- package/dist/chunk-23sgbe69.js +2 -0
- package/dist/chunk-2kdfa1sw.js +2 -0
- package/dist/chunk-2m9k26n4.js +2 -0
- package/dist/chunk-38dwv9n5.js +2 -0
- package/dist/{chunk-fm03jwb1.js → chunk-43hbdkws.js} +1 -1
- package/dist/{chunk-vg0kzfcy.js → chunk-47v621t0.js} +1 -1
- package/dist/{chunk-vaa8tk98.js → chunk-4jzzgnym.js} +2 -2
- package/dist/chunk-5e887teq.js +2 -0
- package/dist/{chunk-8awfakrk.js → chunk-5m9vyv2m.js} +1 -1
- package/dist/{chunk-gnmft4dz.js → chunk-5rynsy4e.js} +1 -1
- package/dist/{chunk-2bxgan9p.js → chunk-6345zcg6.js} +1 -1
- package/dist/{chunk-ansvb340.js → chunk-6jzf989m.js} +1 -1
- package/dist/{chunk-m86nzprx.js → chunk-6n317mmy.js} +2 -2
- package/dist/{chunk-ad84gwgv.js → chunk-6rjc6687.js} +1 -1
- package/dist/{chunk-4vhxtfkw.js → chunk-6t89bck2.js} +1 -1
- package/dist/{chunk-dykhpgyx.js → chunk-70v7vvry.js} +1 -1
- package/dist/{chunk-4k5f40bb.js → chunk-72ywcwe8.js} +1 -1
- package/dist/{chunk-ewdn7s6r.js → chunk-82qd7jw1.js} +1 -1
- package/dist/{chunk-zhfdf2h5.js → chunk-87q97btf.js} +1 -1
- package/dist/{chunk-02k0pg5s.js → chunk-8hnyynhv.js} +1 -1
- package/dist/{chunk-8rgd1mn9.js → chunk-9aewbe13.js} +1 -1
- package/dist/chunk-9vpqzs8r.js +3 -0
- package/dist/{chunk-135mme4g.js → chunk-a2ppgamd.js} +1 -1
- package/dist/{chunk-8j2v2hnc.js → chunk-a2yanhxh.js} +2 -2
- package/dist/{chunk-kwpvv59c.js → chunk-bqdbf8k2.js} +2 -2
- package/dist/{chunk-kvz7rg2x.js → chunk-by2p4by1.js} +1 -1
- package/dist/{chunk-vgf945mj.js → chunk-c38dqdqt.js} +1 -1
- package/dist/{chunk-szw6at2m.js → chunk-c4aez3fr.js} +2 -2
- package/dist/{chunk-bhz0py78.js → chunk-ctba9211.js} +1 -1
- package/dist/chunk-d1nk0neq.js +2 -0
- package/dist/chunk-d8efym0s.js +2 -0
- package/dist/{chunk-53d24qhh.js → chunk-dgy9fns1.js} +2 -2
- package/dist/{chunk-arnse15r.js → chunk-dmzc008f.js} +1 -1
- package/dist/{chunk-zg5mq1cj.js → chunk-dn4gw490.js} +1 -1
- package/dist/{chunk-j3mw2vpt.js → chunk-ds6jn0m1.js} +1 -1
- package/dist/chunk-dwb1yw05.js +2 -0
- package/dist/{chunk-7ryqex47.js → chunk-ectezqxn.js} +1 -1
- package/dist/chunk-ejm3bypm.js +2 -0
- package/dist/{chunk-m6damb1f.js → chunk-ep2agtrk.js} +1 -1
- package/dist/{chunk-efrv1yp5.js → chunk-exr6hs21.js} +1 -1
- package/dist/{chunk-7cqda8w2.js → chunk-f10yf8p0.js} +1 -1
- package/dist/{chunk-x0bcc9sj.js → chunk-ge69r310.js} +1 -1
- package/dist/chunk-gmj16etx.js +2 -0
- package/dist/chunk-grp2f3mq.js +2 -0
- package/dist/chunk-gw35w0wr.js +2 -0
- package/dist/{chunk-1rka3ffx.js → chunk-hm4gvkhg.js} +1 -1
- package/dist/chunk-hrdps19s.js +2 -0
- package/dist/{chunk-bg595da5.js → chunk-j3jzc0xj.js} +1 -1
- package/dist/{chunk-6vdn3qy0.js → chunk-j4v43wsq.js} +1 -1
- package/dist/chunk-jd68p7x1.js +2 -0
- package/dist/chunk-k2avxp56.js +2 -0
- package/dist/chunk-k7xpch16.js +2 -0
- package/dist/{chunk-pbyxj0zr.js → chunk-kq4z185m.js} +168 -168
- package/dist/{chunk-2v1cj2qp.js → chunk-m0sgdvnk.js} +1 -1
- package/dist/chunk-m0xtfsd4.js +2 -0
- package/dist/chunk-m1sqpnkq.js +2 -0
- package/dist/chunk-m29rat2r.js +2 -0
- package/dist/{chunk-xrnqz76v.js → chunk-mjv4ar2y.js} +1 -1
- package/dist/{chunk-ry86fd41.js → chunk-myh6j9ab.js} +1 -1
- package/dist/{chunk-s6yn1mbm.js → chunk-n3ggrhb3.js} +1 -1
- package/dist/{chunk-mt4cdgz3.js → chunk-n3w7xxx7.js} +1 -1
- package/dist/{chunk-egpmwqas.js → chunk-n43xg568.js} +2 -2
- package/dist/{chunk-td2et1ek.js → chunk-n58aem37.js} +1 -1
- package/dist/{chunk-06f65jz3.js → chunk-nf4tx374.js} +1 -1
- package/dist/{chunk-z794cdmn.js → chunk-njc6sven.js} +1 -1
- package/dist/{chunk-6b0xz02h.js → chunk-nstqd54d.js} +1 -1
- package/dist/{chunk-bx766t25.js → chunk-nx5qkm8k.js} +1 -1
- package/dist/{chunk-rpyck7kn.js → chunk-p3h8z1zx.js} +1 -1
- package/dist/chunk-p799ret6.js +12 -0
- package/dist/chunk-p7rde9hp.js +2 -0
- package/dist/chunk-pm23gcqm.js +2 -0
- package/dist/chunk-pt1bcewc.js +2 -0
- package/dist/{chunk-8rn5e39c.js → chunk-q891e1vj.js} +1 -1
- package/dist/chunk-qbp1yp4a.js +2 -0
- package/dist/{chunk-v7ggp28p.js → chunk-qn2hsdy5.js} +1 -1
- package/dist/{chunk-bz9z4pfr.js → chunk-qrpg15eb.js} +1 -1
- package/dist/{chunk-j51tsstz.js → chunk-r93rb19w.js} +1 -1
- package/dist/{chunk-hcqzbhc1.js → chunk-rhkwswq0.js} +1 -1
- package/dist/chunk-rmwbw8fw.js +2 -0
- package/dist/{chunk-m8kn995q.js → chunk-sm1xqvra.js} +2 -2
- package/dist/{chunk-80qre9zp.js → chunk-t0jzk81v.js} +1 -1
- package/dist/chunk-t0ybs2jy.js +2 -0
- package/dist/chunk-t2c96p0g.js +2 -0
- package/dist/chunk-tbyaz9ff.js +2 -0
- package/dist/{chunk-txre2e2m.js → chunk-tdt7b8kg.js} +1 -1
- package/dist/{chunk-pd8cce9a.js → chunk-tjb64c7k.js} +12 -12
- package/dist/{chunk-dbvvgvwk.js → chunk-v7vwmmts.js} +2 -2
- package/dist/{chunk-8ha8h3s1.js → chunk-vqxmxgaj.js} +1 -1
- package/dist/{chunk-4thj960e.js → chunk-vrpqmd6b.js} +1 -1
- package/dist/{chunk-1gy7fa09.js → chunk-vs7843yp.js} +1 -1
- package/dist/{chunk-hg2ja2gj.js → chunk-vwwn4h5j.js} +1 -1
- package/dist/{chunk-w7ped5p5.js → chunk-w6h9c3f6.js} +1 -1
- package/dist/chunk-wkmd8pfh.js +2 -0
- package/dist/chunk-wyy4ny3x.js +2 -0
- package/dist/{chunk-3s3zyq5q.js → chunk-x8w319bf.js} +1 -1
- package/dist/{chunk-cc6b6cvn.js → chunk-y494rjex.js} +2 -2
- package/dist/{chunk-yf4p02wy.js → chunk-ypjgcb5w.js} +2 -2
- package/dist/{chunk-ydk1n77q.js → chunk-ytr18qnm.js} +2 -2
- package/dist/{chunk-rbnmbeda.js → chunk-z44ra321.js} +1 -1
- package/dist/{chunk-0k12epgy.js → chunk-z4msg4y0.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +7 -0
- package/dist/pwa.js +2 -2
- package/dist/ssg.js +14 -14
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-24271vkv.js +0 -12
- package/dist/chunk-2gwfcgct.js +0 -2
- package/dist/chunk-409jrxj6.js +0 -2
- package/dist/chunk-4a01b3qp.js +0 -2
- package/dist/chunk-67b47fez.js +0 -2
- package/dist/chunk-735atsqq.js +0 -2
- package/dist/chunk-749d2abw.js +0 -2
- package/dist/chunk-7ggk2vmy.js +0 -2
- package/dist/chunk-7jhtvcy5.js +0 -2
- package/dist/chunk-7tzyw85k.js +0 -2
- package/dist/chunk-85yfwhdx.js +0 -2
- package/dist/chunk-98a8ma06.js +0 -2
- package/dist/chunk-epep418h.js +0 -2
- package/dist/chunk-et555kdz.js +0 -2
- package/dist/chunk-etnqfdcj.js +0 -2
- package/dist/chunk-fqrfhf6n.js +0 -2
- package/dist/chunk-ftdysk1n.js +0 -2
- package/dist/chunk-gyf7n2as.js +0 -2
- package/dist/chunk-h7xtn6j0.js +0 -2
- package/dist/chunk-hh2r7hrb.js +0 -2
- package/dist/chunk-hysfnyh4.js +0 -2
- package/dist/chunk-hzj77qay.js +0 -2
- package/dist/chunk-j8dg655g.js +0 -2
- package/dist/chunk-jvxc59g1.js +0 -2
- package/dist/chunk-qpm1px64.js +0 -2
- package/dist/chunk-rmyrzcac.js +0 -2
- package/dist/chunk-s0perkbz.js +0 -2
- package/dist/chunk-s8x2n1p6.js +0 -2
- package/dist/chunk-zztd93sa.js +0 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real placeholders for `<StxImage>`, derived from the image's own pixels.
|
|
3
|
+
*
|
|
4
|
+
* `placeholder="blur"` used to render a flat grey rectangle — the same one for
|
|
5
|
+
* every image on the page, because the component had no way to look at the file
|
|
6
|
+
* it was pointing at. It renders synchronously; reading and decoding a JPEG does
|
|
7
|
+
* not. So the work moves earlier: the build warms a cache from disk, and the
|
|
8
|
+
* component reads it with a synchronous lookup.
|
|
9
|
+
*
|
|
10
|
+
* What lands in the HTML is a thumbhash (evanw/thumbhash) rendered as a blurred
|
|
11
|
+
* SVG mesh, with the image's average colour painted underneath it. Both are
|
|
12
|
+
* inline, so there is no second request and nothing to wait for — and no
|
|
13
|
+
* JavaScript, which is the point. A placeholder that needs a script has already
|
|
14
|
+
* lost to the image it was supposed to cover for.
|
|
15
|
+
*
|
|
16
|
+
* Size was the deciding constraint. thumbhash's own 32×32 PNG is ~4.2KB per
|
|
17
|
+
* image; nine of those roughly doubles a page here. The mesh below carries the
|
|
18
|
+
* same information as twelve colours and gzips against its neighbours, because
|
|
19
|
+
* every one of them is the same markup with different hex — about 480 bytes for
|
|
20
|
+
* nine images, against 3.3KB for the PNGs.
|
|
21
|
+
*
|
|
22
|
+
* @module builtins/image-placeholder
|
|
23
|
+
*/
|
|
24
|
+
/** A placeholder ready to be dropped into markup. */
|
|
25
|
+
export interface ImagePlaceholder {
|
|
26
|
+
/** `data:image/svg+xml;base64,…` — the blurred mesh. */
|
|
27
|
+
dataUrl: string;
|
|
28
|
+
/** `#rrggbb` average, painted under the mesh and used alone as a fallback. */
|
|
29
|
+
color: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The placeholder for `src`, or undefined when there is none.
|
|
33
|
+
*
|
|
34
|
+
* Synchronous by requirement: builtin components render inside a synchronous
|
|
35
|
+
* pass. A miss is normal and never an error — an unwarmed build, an image
|
|
36
|
+
* outside the public directory, or a remote URL all land here, and the caller
|
|
37
|
+
* falls back to what it did before.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getImagePlaceholder(src: string): ImagePlaceholder | undefined;
|
|
40
|
+
/** Whether {@link warmImagePlaceholders} has run in this process. */
|
|
41
|
+
export declare function placeholdersWarmed(): boolean;
|
|
42
|
+
/** Drop everything, for tests and for a watch-mode rebuild. */
|
|
43
|
+
export declare function clearImagePlaceholders(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Register a placeholder directly. Used by the warm below, and by tests that
|
|
46
|
+
* would rather not decode a real JPEG to check the markup.
|
|
47
|
+
*/
|
|
48
|
+
export declare function setImagePlaceholder(urlPath: string, placeholder: ImagePlaceholder): void;
|
|
49
|
+
/**
|
|
50
|
+
* A blurred SVG mesh from decoded thumbhash pixels.
|
|
51
|
+
*
|
|
52
|
+
* Four by three is deliberate. It is enough cells to carry where the light and
|
|
53
|
+
* the subject are — which is all a placeholder has to say — and few enough that
|
|
54
|
+
* the markup stays shorter than the image it stands in for. The Gaussian blur
|
|
55
|
+
* does the rest, so the cell edges never show.
|
|
56
|
+
*/
|
|
57
|
+
export declare function meshSvg(rgba: Uint8Array | Uint8ClampedArray | number[], width: number, height: number, cols?: number, rows?: number): string;
|
|
58
|
+
/** Base64 rather than percent-encoding: the same SVG, roughly 400 bytes shorter. */
|
|
59
|
+
export declare function svgDataUrl(svg: string): string;
|
|
60
|
+
export interface WarmOptions {
|
|
61
|
+
/** Where the on-disk cache lives. Omit to recompute every build. */
|
|
62
|
+
cachePath?: string;
|
|
63
|
+
/** Skip files larger than this. Decoding a 40MB source costs more than it returns. */
|
|
64
|
+
maxBytes?: number;
|
|
65
|
+
/** Stop after this many images, so an enormous asset tree cannot stall a build. */
|
|
66
|
+
limit?: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Derive placeholders for every image under `publicDir` and hold them for
|
|
70
|
+
* {@link getImagePlaceholder}.
|
|
71
|
+
*
|
|
72
|
+
* Called once per build, before any page renders. Failures are per-file and
|
|
73
|
+
* silent by design: a placeholder is decoration, and one unreadable image must
|
|
74
|
+
* not take a build down with it.
|
|
75
|
+
*
|
|
76
|
+
* Returns how many placeholders are available afterwards.
|
|
77
|
+
*/
|
|
78
|
+
export declare function warmImagePlaceholders(publicDir: string, options?: WarmOptions): Promise<number>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png", ".webp", ".avif"]), placeholders = new Map;
|
|
4
|
+
let warmed = !1;
|
|
5
|
+
export function getImagePlaceholder(src) {
|
|
6
|
+
if (!src)
|
|
7
|
+
return;
|
|
8
|
+
const clean = src.split("?")[0].split("#")[0];
|
|
9
|
+
return placeholders.get(clean);
|
|
10
|
+
}
|
|
11
|
+
export function placeholdersWarmed() {
|
|
12
|
+
return warmed;
|
|
13
|
+
}
|
|
14
|
+
export function clearImagePlaceholders() {
|
|
15
|
+
placeholders.clear();
|
|
16
|
+
warmed = !1;
|
|
17
|
+
}
|
|
18
|
+
export function setImagePlaceholder(urlPath, placeholder) {
|
|
19
|
+
placeholders.set(urlPath, placeholder);
|
|
20
|
+
warmed = !0;
|
|
21
|
+
}
|
|
22
|
+
function averageColor(rgba) {
|
|
23
|
+
let r = 0, g = 0, b = 0, n = 0;
|
|
24
|
+
for (let i = 0;i < rgba.length; i += 4) {
|
|
25
|
+
r += rgba[i];
|
|
26
|
+
g += rgba[i + 1];
|
|
27
|
+
b += rgba[i + 2];
|
|
28
|
+
n++;
|
|
29
|
+
}
|
|
30
|
+
if (n === 0)
|
|
31
|
+
return "#e5e7eb";
|
|
32
|
+
const hex = (v) => Math.round(v / n).toString(16).padStart(2, "0");
|
|
33
|
+
return `#${hex(r)}${hex(g)}${hex(b)}`;
|
|
34
|
+
}
|
|
35
|
+
export function meshSvg(rgba, width, height, cols = 4, rows = 3) {
|
|
36
|
+
const cells = [];
|
|
37
|
+
for (let y = 0;y < rows; y++)
|
|
38
|
+
for (let x = 0;x < cols; x++) {
|
|
39
|
+
const x0 = Math.floor(x * width / cols), x1 = Math.max(x0 + 1, Math.floor((x + 1) * width / cols)), y0 = Math.floor(y * height / rows), y1 = Math.max(y0 + 1, Math.floor((y + 1) * height / rows));
|
|
40
|
+
let r = 0, g = 0, b = 0, n = 0;
|
|
41
|
+
for (let yy = y0;yy < y1; yy++)
|
|
42
|
+
for (let xx = x0;xx < x1; xx++) {
|
|
43
|
+
const i = (yy * width + xx) * 4;
|
|
44
|
+
r += rgba[i];
|
|
45
|
+
g += rgba[i + 1];
|
|
46
|
+
b += rgba[i + 2];
|
|
47
|
+
n++;
|
|
48
|
+
}
|
|
49
|
+
const hex = (v) => Math.round(v / n).toString(16).padStart(2, "0");
|
|
50
|
+
cells.push(`<rect x="${x}" y="${y}" width="1" height="1" fill="#${hex(r)}${hex(g)}${hex(b)}"/>`);
|
|
51
|
+
}
|
|
52
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${cols} ${rows}" preserveAspectRatio="none"><filter id="b"><feGaussianBlur stdDeviation=".6"/></filter><g filter="url(#b)">${cells.join("")}</g></svg>`;
|
|
53
|
+
}
|
|
54
|
+
export function svgDataUrl(svg) {
|
|
55
|
+
return `data:image/svg+xml;base64,${Buffer.from(svg, "utf8").toString("base64")}`;
|
|
56
|
+
}
|
|
57
|
+
function readCache(cachePath) {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(fs.readFileSync(cachePath, "utf8"));
|
|
60
|
+
} catch {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function writeCache(cachePath, cache) {
|
|
65
|
+
try {
|
|
66
|
+
fs.mkdirSync(path.dirname(cachePath), { recursive: !0 });
|
|
67
|
+
fs.writeFileSync(cachePath, JSON.stringify(cache));
|
|
68
|
+
} catch {}
|
|
69
|
+
}
|
|
70
|
+
function collectImages(dir, baseUrl, out = []) {
|
|
71
|
+
let entries;
|
|
72
|
+
try {
|
|
73
|
+
entries = fs.readdirSync(dir, { withFileTypes: !0 });
|
|
74
|
+
} catch {
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
for (const entry of entries) {
|
|
78
|
+
const full = path.join(dir, entry.name);
|
|
79
|
+
if (entry.isDirectory()) {
|
|
80
|
+
collectImages(full, `${baseUrl}/${entry.name}`, out);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (!IMAGE_EXTENSIONS.has(path.extname(entry.name).toLowerCase()))
|
|
84
|
+
continue;
|
|
85
|
+
out.push([`${baseUrl}/${entry.name}`, full]);
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
export async function warmImagePlaceholders(publicDir, options = {}) {
|
|
90
|
+
const { cachePath, maxBytes = 33554432, limit = 2000 } = options;
|
|
91
|
+
if (!publicDir || !fs.existsSync(publicDir)) {
|
|
92
|
+
warmed = !0;
|
|
93
|
+
return placeholders.size;
|
|
94
|
+
}
|
|
95
|
+
let tsImages;
|
|
96
|
+
try {
|
|
97
|
+
tsImages = await import("ts-images");
|
|
98
|
+
} catch {
|
|
99
|
+
warmed = !0;
|
|
100
|
+
return placeholders.size;
|
|
101
|
+
}
|
|
102
|
+
const cache = cachePath ? readCache(cachePath) : {};
|
|
103
|
+
let cacheDirty = !1;
|
|
104
|
+
const images = collectImages(publicDir, "").slice(0, limit);
|
|
105
|
+
await Promise.all(images.map(async ([urlPath, filePath]) => {
|
|
106
|
+
let stat;
|
|
107
|
+
try {
|
|
108
|
+
stat = fs.statSync(filePath);
|
|
109
|
+
} catch {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (stat.size > maxBytes)
|
|
113
|
+
return;
|
|
114
|
+
const cached = cache[urlPath];
|
|
115
|
+
if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {
|
|
116
|
+
placeholders.set(urlPath, { dataUrl: cached.dataUrl, color: cached.color });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const { hash } = await tsImages.generateThumbHash(filePath);
|
|
121
|
+
if (!hash)
|
|
122
|
+
return;
|
|
123
|
+
const { rgba, w, h } = tsImages.thumbHashToRGBA(hash), placeholder = {
|
|
124
|
+
dataUrl: svgDataUrl(meshSvg(rgba, w, h)),
|
|
125
|
+
color: averageColor(rgba)
|
|
126
|
+
};
|
|
127
|
+
placeholders.set(urlPath, placeholder);
|
|
128
|
+
cache[urlPath] = { mtimeMs: stat.mtimeMs, size: stat.size, ...placeholder };
|
|
129
|
+
cacheDirty = !0;
|
|
130
|
+
} catch {}
|
|
131
|
+
}));
|
|
132
|
+
if (cachePath && cacheDirty)
|
|
133
|
+
writeCache(cachePath, cache);
|
|
134
|
+
warmed = !0;
|
|
135
|
+
return placeholders.size;
|
|
136
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { forwardResolvedAttrs, forwardStaticAttrs } from "./attrs.js";
|
|
2
|
+
import { getImagePlaceholder } from "./image-placeholder.js";
|
|
2
3
|
const DEFAULT_BREAKPOINTS = {
|
|
3
4
|
sm: 640,
|
|
4
5
|
md: 768,
|
|
@@ -117,10 +118,20 @@ export const StxImageBuiltin = {
|
|
|
117
118
|
if (numWidth && numHeight)
|
|
118
119
|
styles.push(`aspect-ratio:${numWidth}/${numHeight}`);
|
|
119
120
|
if (placeholder === "blur" || placeholder === "color" || placeholder === "thumbhash") {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const derived = getImagePlaceholder(src);
|
|
122
|
+
if (derived && placeholder === "color")
|
|
123
|
+
styles.push(`background-color:${derived.color}`);
|
|
124
|
+
else if (derived) {
|
|
125
|
+
styles.push(`background-color:${derived.color}`);
|
|
126
|
+
styles.push(`background-image:url(${derived.dataUrl})`);
|
|
127
|
+
styles.push("background-size:cover");
|
|
128
|
+
styles.push("background-repeat:no-repeat");
|
|
129
|
+
} else {
|
|
130
|
+
const placeholderUrl = generateBlurPlaceholder(numWidth || 16, numHeight || 9, placeholderColor);
|
|
131
|
+
styles.push(`background-image:url(${placeholderUrl})`);
|
|
132
|
+
styles.push("background-size:cover");
|
|
133
|
+
styles.push("background-repeat:no-repeat");
|
|
134
|
+
}
|
|
124
135
|
} else if (placeholder && placeholder !== "empty" && placeholder !== "none") {
|
|
125
136
|
styles.push(`background-image:url(${escapeAttr(placeholder)})`);
|
|
126
137
|
styles.push("background-size:cover");
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Yi as a,Zi as b}from"./chunk-6jzf989m.js";import"./chunk-efr3ejqt.js";import"./chunk-kq4z185m.js";import"./chunk-by2p4by1.js";import"./chunk-a2ppgamd.js";import"./chunk-dmzc008f.js";import"./chunk-nstqd54d.js";import"./chunk-a2yanhxh.js";import"./chunk-9vpqzs8r.js";import"./chunk-t0jzk81v.js";import"./chunk-njc6sven.js";import"./chunk-70v7vvry.js";import"./chunk-myh6j9ab.js";import"./chunk-bqdbf8k2.js";import"./chunk-ge69r310.js";import"./chunk-q891e1vj.js";export{a as getStoreScript,b as clearStoreCache};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-q891e1vj.js";function F(){return`<script data-stx-scoped data-stx-x-element-runtime data-stx-run="always">
|
|
3
3
|
(function() {
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{g as
|
|
2
|
+
import{zg as T}from"./chunk-21kvpnqq.js";import{Eu as I}from"./chunk-q891e1vj.js";import E from"fs";import X from"path";import U from"crypto";var _=new Set(["webp","avif","jpeg","png"]),F=new Set(["cover","contain","fill","inside","outside"]),A=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"]),S=4096,y=80,D="cover";async function g(k,G){let J=G.routePath??"/_stx/img",B=new URL(k.url);if(B.pathname!==J)return null;let $=q(B,G);if(!$.ok)return new Response($.error,{status:$.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:j,srcUrl:K,width:H,height:v,format:Z,quality:Y,fit:z}=$,C;try{C=E.statSync(j)}catch{return new Response(`Source image not found: ${K}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!C.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let N=G.cacheDir??".stx/cache/img";await E.promises.mkdir(N,{recursive:!0});let V=`${j}:${C.mtimeMs}:${C.size}`,O=`${H}x${v}:${Z}:${Y}:${z}`,b=U.createHash("sha256").update(`${V}|${O}`).digest("hex").slice(0,16),Q=X.join(N,`${b}.${Z}`),W={"Content-Type":T(Z),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${b}"`,"X-Stx-Image-Cache":"HIT"};if(k.headers.get("if-none-match")===`"${b}"`)return new Response(null,{status:304,headers:W});let L=Bun.file(Q);if(await L.exists())return new Response(L,{headers:W});try{let R=Buffer.from(await Bun.file(j).arrayBuffer()),{resizeAndConvert:M}=await P(),w=await M(R,{width:H,height:v,format:Z,quality:Y,fit:z});return await Bun.write(Q,w),W["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(w),{headers:W})}catch(R){let M=R.message;return new Response(`Image processing failed: ${M}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function l(k){return async(G)=>{return await g(G,k)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function q(k,G){let J=k.searchParams.get("src");if(!J)return{ok:!1,error:"Missing required param: src",status:400};if(!J.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(J.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let B=X.extname(J).toLowerCase();if(!A.has(B))return{ok:!1,error:`Unsupported source extension: ${B}`,status:400};let $=X.resolve(G.publicDir),j=X.resolve($,J.slice(1));if(!j.startsWith(`${$}${X.sep}`)&&j!==$)return{ok:!1,error:"src is outside publicDir",status:400};let K=G.maxWidth??S,H=G.maxHeight??S,v=k.searchParams.get("w"),Z=k.searchParams.get("h"),Y=v?Number.parseInt(v,10):0,z=Z?Number.parseInt(Z,10):0;if(v&&(!Number.isFinite(Y)||Y<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(Z&&(!Number.isFinite(z)||z<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!v&&!Z)return{ok:!1,error:"At least one of w or h is required",status:400};let C=Math.min(Y||K,K),N=Math.min(z||H,H),V=k.searchParams.get("f")||"webp";if(!_.has(V))return{ok:!1,error:`Invalid f (must be one of: ${[..._].join(", ")})`,status:400};let O=V,b=k.searchParams.get("q"),Q=b?Number.parseInt(b,10):G.defaultQuality??y;if(!Number.isFinite(Q)||Q<1||Q>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let x=k.searchParams.get("fit")||G.defaultFit||D;if(!F.has(x))return{ok:!1,error:`Invalid fit (must be one of: ${[...F].join(", ")})`,status:400};return{ok:!0,srcFsPath:j,srcUrl:J,width:C,height:N,format:O,quality:Q,fit:x}}async function P(){return await import("./chunk-hm4gvkhg.js")}
|
|
3
|
+
export{g as Cf,l as Df};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$t as
|
|
2
|
+
import{$t as s,Jt as a,Kt as b,Lt as c,Mt as d,Nt as e,Ot as f,Pt as g,Qt as h,Rt as i,St as j,Tt as k,Ut as l,Vt as m,Wt as n,Xt as o,Yt as p,Zt as q,_t as r,au as t,bu as u,cu as v,du as w,eu as x,fu as y,gu as z,hu as A,iu as B,ju as C,ku as D,lu as E,mu as F,nu as G,ou as H,pu as I,qu as J,su as K,uu as L}from"./chunk-bqdbf8k2.js";import"./chunk-q891e1vj.js";L();export{o as setAppUrl,H as runMiddleware,r as route,j as resolveLayoutChain,s as resetRoutes,z as registerMiddleware,g as patternToRegex,t as navigateTo,h as matchRoute,E as loadMiddlewareFromDirectory,c as isNonPageRoutePattern,b as isNonPageRoutePath,B as hasMiddleware,K as getRouterScript,D as getMiddlewareNames,A as getMiddleware,d as generateRouteTypes,e as generateRouteManifest,n as formatRoutes,m as findErrorPage,f as filePathToPattern,J as extractLayoutMetadata,I as deriveLayoutGroup,q as defineRoutes,p as defineRoute,v as defineMiddleware,y as createStorageManager,w as createServerCookieManager,l as createRouter,F as createRouteLocation,G as createMiddlewareContext,x as createClientCookieManager,C as clearMiddleware,i as bracketPathToRegex,u as abortNavigation,k as Router,a as NON_PAGE_DIRS};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{d as
|
|
2
|
+
import{Eu as l}from"./chunk-q891e1vj.js";import U from"fs";import G from"path";import I from"os";import H from"crypto";import{generatePlaceholder as m,processImage as g}from"ts-images";var d=[320,640,768,1024,1280,1536,1920],h=["webp","jpeg"],b=80,u=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},N=null,W=!1;async function Y(){if(W)return N;W=!0;try{let J=await import("sharp");return N=J.default||J,N}catch{return null}}async function e(){return await Y()!==null}async function t(){return!0}async function JJ(J,K={}){let{widths:Z=d,formats:$=h,quality:q=b,fit:C="cover",placeholder:X="none",outputDir:Q=".stx/images",baseUrl:_="/images"}=K,j,x;if(typeof J==="string"){if(x=J,!await Bun.file(J).exists())throw new L(`Image not found: ${J}`,"NOT_FOUND");j=await Bun.file(J).arrayBuffer().then((V)=>Buffer.from(V))}else x="buffer-input",j=J;let w=H.createHash("sha256").update(j).digest("hex").slice(0,12),y=await O(j),{width:B,height:D}=y,A=B/D;await U.promises.mkdir(Q,{recursive:!0});let T=[],v=G.basename(x,G.extname(x)),z=Z.filter((V)=>V<=B);if(!z.includes(B)&&B<=Math.max(...Z))z.push(B);z.sort((V,R)=>V-R);for(let V of z){let R=Math.round(V/A);for(let F of $){let S=`${v}-${V}w-${w}.${F}`,k=G.join(Q,S),c=`${_}/${S}`,E=await n(j,{width:V,height:R,format:F,quality:q,fit:C});await Bun.write(k,E),T.push({path:k,url:c,width:V,height:R,format:F,size:E.length})}}let M;if(X!=="none")M=await o(j,X);return{src:x,variants:T,placeholder:M,width:B,height:D,aspectRatio:A,hash:w}}async function O(J){let K=typeof J==="string"?Buffer.from(await Bun.file(J).arrayBuffer()):J,Z=await Y();if(Z){let q=await Z(K).metadata();return{width:q.width||0,height:q.height||0,format:q.format||"unknown",hasAlpha:q.hasAlpha}}return p(K)}function p(J){if(J[0]===137&&J[1]===80&&J[2]===78&&J[3]===71){let K=J.readUInt32BE(16),Z=J.readUInt32BE(20);return{width:K,height:Z,format:"png",hasAlpha:!0}}if(J[0]===255&&J[1]===216){let K=2;while(K<J.length){if(J[K]!==255)break;let Z=J[K+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let q=J.readUInt16BE(K+5);return{width:J.readUInt16BE(K+7),height:q,format:"jpeg",hasAlpha:!1}}let $=J.readUInt16BE(K+2);K+=2+$}}if(J.toString("utf8",0,4)==="RIFF"&&J.toString("utf8",8,12)==="WEBP"){let K=J.toString("utf8",12,16);if(K==="VP8 "){let Z=J.readUInt16LE(26)&16383,$=J.readUInt16LE(28)&16383;return{width:Z,height:$,format:"webp",hasAlpha:!1}}if(K==="VP8L"){let Z=J.readUInt32LE(21),$=(Z&16383)+1,q=(Z>>14&16383)+1;return{width:$,height:q,format:"webp",hasAlpha:!0}}}if(J.toString("utf8",0,3)==="GIF"){let K=J.readUInt16LE(6),Z=J.readUInt16LE(8);return{width:K,height:Z,format:"gif",hasAlpha:!0}}throw new L("Unable to parse image dimensions","PARSE_ERROR")}async function n(J,K){let Z=await Y();if(Z){let q=Z(J).resize(K.width,K.height,{fit:K.fit});switch(K.format){case"webp":q=q.webp({quality:K.quality});break;case"avif":q=q.avif({quality:K.quality});break;case"jpeg":q=q.jpeg({quality:K.quality});break;case"png":q=q.png({quality:K.quality});break}return q.toBuffer()}let $=G.join(I.tmpdir(),`stx-img-${H.randomBytes(8).toString("hex")}.${K.format}`);try{return await g({input:J,output:$,format:K.format,quality:K.quality,resize:{width:K.width,height:K.height,fit:K.fit}}),Buffer.from(await Bun.file($).arrayBuffer())}finally{await U.promises.unlink($).catch(()=>{})}}async function o(J,K){let Z=await Y();if(K==="blur"&&Z){let X=(await Z(J).resize(20).blur(10).toBuffer()).toString("base64"),Q=await O(J);return`data:${P[Q.format]||"image/jpeg"};base64,${X}`}if(K==="dominant-color"&&Z){let{dominant:C}=await Z(J).resize(1,1).toBuffer().then(async(X)=>{let Q=await Z(X).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${C.r}, ${C.g}, ${C.b})`}let $=await O(J),q=G.join(I.tmpdir(),`stx-ph-${H.randomBytes(8).toString("hex")}.${$.format==="unknown"?"bin":$.format}`);try{await Bun.write(q,J);let C=K==="blur"?"blur":K==="thumbhash"?"thumbhash":"dominant-color",Q=await m(q,{strategy:C,width:C==="thumbhash"?void 0:32});if(K==="dominant-color"&&Q.dominantColor)return Q.dominantColor;if(Q.dataURL)return Q.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await U.promises.unlink(q).catch(()=>{})}}function KJ(J,K){return(K?J.filter(($)=>$.format===K):J).sort(($,q)=>$.width-q.width).map(($)=>`${$.url} ${$.width}w`).join(", ")}function ZJ(J){if(!J||Object.keys(J).length===0)return"100vw";return Object.entries(J).sort((Z,$)=>{let q=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt($[0].replace(/\D/g,""))||0)-q}).map(([Z,$])=>`(max-width: ${Z}) ${$}`).join(", ")+", 100vw"}function $J(J){let K=J.filter(($)=>$.format==="jpeg");if(K.length===0)return J[Math.floor(J.length/2)];let Z=K.sort(($,q)=>$.width-q.width);return Z[Math.floor(Z.length/2)]}function qJ(J){let K=new Map;for(let Z of J){let $=K.get(Z.format)||[];$.push(Z),K.set(Z.format,$)}return K}function CJ(J){let K=G.extname(J).toLowerCase();return u.includes(K)}function QJ(J){return P[J]||"application/octet-stream"}function VJ(J){return J.reduce((K,Z)=>K+Z.size,0)}function XJ(J){if(J<1024)return`${J} B`;if(J<1048576)return`${(J/1024).toFixed(1)} KB`;return`${(J/1048576).toFixed(2)} MB`}class L extends Error{code;constructor(J,K){super(J);this.name="ImageProcessingError",this.code=K}}
|
|
3
|
+
export{d as mg,h as ng,b as og,e as pg,t as qg,JJ as rg,O as sg,n as tg,KJ as ug,ZJ as vg,$J as wg,qJ as xg,CJ as yg,QJ as zg,VJ as Ag,XJ as Bg,L as Cg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$i as b,_i as a,aj as c}from"./chunk-r93rb19w.js";import"./chunk-efr3ejqt.js";import"./chunk-kq4z185m.js";import"./chunk-by2p4by1.js";import"./chunk-a2ppgamd.js";import"./chunk-dmzc008f.js";import"./chunk-nstqd54d.js";import"./chunk-a2yanhxh.js";import"./chunk-9vpqzs8r.js";import"./chunk-t0jzk81v.js";import"./chunk-njc6sven.js";import"./chunk-70v7vvry.js";import"./chunk-myh6j9ab.js";import"./chunk-bqdbf8k2.js";import"./chunk-ge69r310.js";import"./chunk-q891e1vj.js";export{a as listComposableModules,b as getComposableScript,c as clearComposableCache};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{kk as a,lk as b,mk as c,nk as d}from"./chunk-f10yf8p0.js";import"./chunk-n43xg568.js";import"./chunk-kq4z185m.js";import"./chunk-by2p4by1.js";import"./chunk-a2ppgamd.js";import"./chunk-dmzc008f.js";import"./chunk-nstqd54d.js";import"./chunk-a2yanhxh.js";import"./chunk-9vpqzs8r.js";import"./chunk-t0jzk81v.js";import"./chunk-njc6sven.js";import"./chunk-70v7vvry.js";import"./chunk-myh6j9ab.js";import"./chunk-bqdbf8k2.js";import"./chunk-ge69r310.js";import"./chunk-q891e1vj.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ql as c,Rl as d,Sl as e,Tl as f,Ul as g,Vl as h,Wl as i,Xl as j,Yl as k}from"./chunk-kq4z185m.js";import"./chunk-by2p4by1.js";import"./chunk-a2ppgamd.js";import"./chunk-dmzc008f.js";import{Fs as a,Gs as b}from"./chunk-nstqd54d.js";import"./chunk-a2yanhxh.js";import"./chunk-9vpqzs8r.js";import"./chunk-t0jzk81v.js";import"./chunk-njc6sven.js";import"./chunk-70v7vvry.js";import"./chunk-myh6j9ab.js";import"./chunk-bqdbf8k2.js";import"./chunk-ge69r310.js";import"./chunk-q891e1vj.js";export{b as stripCommentsAndLiterals,d as renderVendorStyleTags,k as processClientScript,f as injectBrowserCoreAutoImports,j as generateServerDataBridge,h as generateBrowserAutoImportDestructuring,g as generateAutoImportDestructuring,a as findInterpolationEnd,i as extractBridgeData,c as extractAndStripCssImports,e as STX_AUTO_IMPORTS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ks as a,Ls as b,Ms as c,Ns as d,Os as e,Ps as f,Qs as g,Rs as h,Ss as i,Ts as j,Us as k,Vs as l,Ws as m}from"./chunk-
|
|
2
|
+
import{Ks as a,Ls as b,Ms as c,Ns as d,Os as e,Ps as f,Qs as g,Rs as h,Ss as i,Ts as j,Us as k,Vs as l,Ws as m}from"./chunk-a2yanhxh.js";import"./chunk-t0jzk81v.js";import"./chunk-q891e1vj.js";export{f as resolveUserCrosswindConfig,c as resetCssCache,d as resetCrosswindCache,i as rebuildCrosswindCSS,e as loadCrosswindConfig,b as loadCrosswind,m as injectCrosswindCSS,a as getCrosswindServeAsset,j as getCachedCSS,l as generateCrosswindCSS,g as fingerprintConfig,k as extractClassNames,h as buildCrosswindCSS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fj as a,gj as b}from"./chunk-cq6fsp6j.js";import"./chunk-
|
|
2
|
+
import{fj as a,gj as b}from"./chunk-cq6fsp6j.js";import"./chunk-q891e1vj.js";export{a as processTeleportDirectives,b as ensureTeleportTargets};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ag as o,Bg as a,mg as L,ng as w,og as x,pg as p,qg as F,rg as T,ug as I,vg as f,wg as l,xg as n,yg as i,zg as P}from"./chunk-21kvpnqq.js";import{ys as ZG}from"./chunk-a2ppgamd.js";function HG(X,Z={}){let{src:G,alt:J,width:q,height:$,sizes:K="100vw",loading:Q="lazy",priority:Y=!1,quality:M=x,placeholder:N="none",formats:j=w,widths:C=L,decoding:B="async",fetchpriority:V,objectFit:O,objectPosition:W}=X,H=X.class,z=X.style,{processedImage:R,variants:_,optimize:E=!0,isDev:S=!1}=Z;if(_&&_.length>0)return OG(X,_,R);if(S||!E)return MG(X);return VG(X)}function OG(X,Z,G){let{src:J,alt:q,width:$,height:K,sizes:Q="100vw",loading:Y="lazy",priority:M=!1,decoding:N="async",fetchpriority:j,objectFit:C,objectPosition:B,placeholder:V="none"}=X,O=X.class,W=X.style,H=n(Z),z=l(Z),R=typeof Q==="object"?f(Q):Q,_=G?G.aspectRatio:$&&K?Number($)/Number(K):void 0,E=[];if(_)E.push(`aspect-ratio: ${_}`);if(C)E.push(`object-fit: ${C}`);if(B)E.push(`object-position: ${B}`);if(W)E.push(W);let S=E.length>0?` style="${E.join("; ")}"`:"",b=O?` class="${O}"`:"",u=M?"":` loading="${Y}"`,d=` decoding="${N}"`,h=j?` fetchpriority="${j}"`:M?' fetchpriority="high"':"",r=["avif","webp","jpeg","png"],s=[];for(let U of r){let D=H.get(U);if(D&&D.length>0){let m=I(D),QG=P(U);s.push(` <source type="${QG}" srcset="${m}" sizes="${R}" />`)}}let e="",t="",g;if(V!=="none"&&G?.placeholder){let U=`img-${Math.random().toString(36).slice(2,8)}`;if(e=`<div class="stx-image-wrapper" id="${U}">`,t="</div>",V==="blur")g=`
|
|
3
3
|
#${U} {
|
|
4
4
|
position: relative;
|
|
5
5
|
background-image: url('${G.placeholder}');
|
|
@@ -40,4 +40,4 @@ ${O}
|
|
|
40
40
|
${O}
|
|
41
41
|
</div>`}}if(G.priority&&C){let W=P(C.format);O=`<link rel="preload" as="image" href="${k(C.url)}" type="${W}" />
|
|
42
42
|
`+O}return O}function k(X){return X.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var UG=$G();import v from"fs";import A from"path";function LG(X={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:G="dist/images",baseUrl:J="/images",formats:q=w,widths:$=L,quality:K=x,placeholder:Q="none",concurrency:Y=4,cache:M=!0,cacheDir:N=".stx/image-cache",referencedOnly:j=!1,verbose:C=!1}=X,B={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(V){if(!await F()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(M)await v.promises.mkdir(N,{recursive:!0});if(C){let W=await p();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${W?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${Z.join(", ")}`),console.log(` Output dir: ${G}`),console.log(` Formats: ${q.join(", ")}`),console.log(` Widths: ${$.join(", ")}`)}},async buildStart(){B.imageReferences.clear(),B.processedImages.clear(),B.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(V,O){if(O.endsWith(".html")||O.endsWith(".stx")){let W=wG(V);for(let H of W)B.imageReferences.add(H)}if(V.includes("<Image")||V.includes("@image"))return await kG(V,{formats:q,widths:$,quality:K,placeholder:Q,outputDir:G,baseUrl:J,processedImages:B.processedImages});return V},async buildEnd(V){if(!await F())return;await v.promises.mkdir(G,{recursive:!0});let W=[];for(let R of Z){if(!v.existsSync(R))continue;let _=await KG(R);W.push(..._)}let H=j?W.filter((R)=>xG(R,B.imageReferences)):W;if(B.stats.totalImages=H.length,C)console.log(`[stx-images] Processing ${H.length} images...`);let z=qG(H,Y);for(let R of z)await Promise.all(R.map(async(_)=>{try{let E=await T(_,{formats:q,widths:$,quality:K,placeholder:Q,outputDir:G,baseUrl:J});B.processedImages.set(_,E),B.stats.optimizedImages++,B.stats.variants+=E.variants.length;let S=v.statSync(_).size,b=o(E.variants);if(B.stats.savedBytes+=Math.max(0,S-b/E.variants.length),C)console.log(` \u2713 ${A.basename(_)} \u2192 ${E.variants.length} variants`)}catch(E){console.error(`[stx-images] Error processing ${_}:`,E)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${B.stats.optimizedImages}/${B.stats.totalImages}`),console.log(` Variants: ${B.stats.variants}`),B.stats.savedBytes>0)console.log(` Saved: ~${a(B.stats.savedBytes)}`)}}}function wG(X){let Z=[],G=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,J;while((J=G.exec(X))!==null)Z.push(J[1]);let q=/<Image[^>]+src=["']([^"']+)["']/gi;while((J=q.exec(X))!==null)Z.push(J[1]);let $=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((J=$.exec(X))!==null)Z.push(J[1]);let K=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((J=K.exec(X))!==null)Z.push(J[1]);return Z}function xG(X,Z){let G=A.basename(X);for(let J of Z)if(J.endsWith(G)||J.includes(G))return!0;return!1}async function kG(X,Z){return X}async function KG(X){let Z=[];async function G(J){let q=await v.promises.readdir(J,{withFileTypes:!0});for(let $ of q){let K=A.join(J,$.name);if($.isDirectory())await G(K);else if($.isFile()&&i(K))Z.push(K)}}return await G(X),Z}function qG(X,Z){let G=[];for(let J=0;J<X.length;J+=Z)G.push(X.slice(J,J+Z));return G}async function FG(X,Z,G={}){if(!await F())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return T(X,{...G,outputDir:Z})}async function SG(X,Z,G={}){let{formats:J=w,widths:q=L,quality:$=x,placeholder:K="none",concurrency:Q=4,verbose:Y=!1}=G;if(!await F())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await v.promises.mkdir(Z,{recursive:!0});let N=await KG(X),j=[],C={totalImages:N.length,optimizedImages:0,savedBytes:0,variants:0},B=qG(N,Q);for(let V of B){let O=await Promise.all(V.map(async(W)=>{try{let H=await T(W,{formats:J,widths:q,quality:$,placeholder:K,outputDir:Z,baseUrl:"/"});if(C.optimizedImages++,C.variants+=H.variants.length,Y)console.log(` \u2713 ${A.basename(W)}`);return H}catch(H){return console.error(`Error processing ${W}:`,H),null}}));j.push(...O.filter((W)=>W!==null))}return{processed:j,stats:C}}function YG(X){let Z={};for(let G of X)Z[G.src]={variants:G.variants,placeholder:G.placeholder};return Z}async function PG(X,Z){let G=YG(X);await Bun.write(Z,JSON.stringify(G,null,2))}var cG={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"};
|
|
43
|
-
export{HG as
|
|
43
|
+
export{HG as Xe,JG as Ye,jG as Ze,CG as _e,$G as $e,UG as af,LG as bf,FG as cf,SG as df,YG as ef,PG as ff,cG as gf};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$l as a,Wo as b,Xo as c}from"./chunk-kq4z185m.js";import"./chunk-by2p4by1.js";import"./chunk-a2ppgamd.js";import"./chunk-dmzc008f.js";import"./chunk-nstqd54d.js";import"./chunk-a2yanhxh.js";import"./chunk-9vpqzs8r.js";import"./chunk-t0jzk81v.js";import"./chunk-njc6sven.js";import"./chunk-70v7vvry.js";import"./chunk-myh6j9ab.js";import"./chunk-bqdbf8k2.js";import"./chunk-ge69r310.js";import"./chunk-q891e1vj.js";export{b as processESImports,c as processComponents,a as freeIdentifiers};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ph as a,qh as b,rh as c,sh as d,th as e,uh as f,vh as g,wh as h,xh as i}from"./chunk-
|
|
2
|
+
import{ph as a,qh as b,rh as c,sh as d,th as e,uh as f,vh as g,wh as h,xh as i}from"./chunk-qrpg15eb.js";import"./chunk-jw1besrt.js";import"./chunk-q891e1vj.js";export{c as setCachedImageResult,e as processImage,f as optimizeImage,b as getCachedImageResult,i as generateSrcset,h as generateResponsiveVariants,d as clearImageCache,g as applyTransformations,a as ImageProcessorCache};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function D(j){return j}class F{plugins=new Map;sortedPlugins=[];initialized=!1;async register(j,q){if(this.plugins.has(j.name))throw Error(`Plugin "${j.name}" is already registered`);if(j.dependencies){for(let w of j.dependencies)if(!this.plugins.has(w))throw Error(`Plugin "${j.name}" depends on "${w}" which is not registered`)}if(this.plugins.set(j.name,j),j.onRegister)await j.onRegister(q);this.sortPlugins()}async unregister(j){let q=this.plugins.get(j);if(!q)return!1;for(let[w,z]of this.plugins)if(z.dependencies?.includes(j))throw Error(`Cannot unregister "${j}" because "${w}" depends on it`);if(q.onUnregister)await q.onUnregister();return this.plugins.delete(j),this.sortPlugins(),!0}get(j){return this.plugins.get(j)}has(j){return this.plugins.has(j)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let j=[];for(let q of this.sortedPlugins)if(q.registerDirectives)j.push(...q.registerDirectives());return j}getAllFilters(){let j={};for(let q of this.sortedPlugins)if(q.registerFilters)Object.assign(j,q.registerFilters());return j}async runBeforeProcess(j){return this.runHooks("beforeProcess",j)}async runAfterParse(j){return this.runHooks("afterParse",j)}async runBeforeDirective(j,q){return this.runDirectiveHooks("beforeDirective",j,q)}async runAfterDirective(j,q){return this.runDirectiveHooks("afterDirective",j,q)}async runBeforeRender(j){return this.runHooks("beforeRender",j)}async runAfterRender(j){return this.runHooks("afterRender",j)}async runOnError(j){for(let q of this.sortedPlugins)if(q.onError)try{let w=await q.onError(j);if(w){if(w.template!==void 0)j.template=w.template;if(w.context)j.context={...j.context,...w.context};if(w.metadata)j.metadata={...j.metadata,...w.metadata};if(w.skip)return j}}catch(w){console.error(`Error in plugin "${q.name}" onError hook:`,w)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort((j,q)=>(j.priority??100)-(q.priority??100))}async runHooks(j,q){let w={...q};for(let z of this.sortedPlugins){let B=z[j];if(B)try{let y=await B(w);if(y){if(y.template!==void 0)w.template=y.template;if(y.context)w.context={...w.context,...y.context};if(y.metadata)w.metadata={...w.metadata,...y.metadata};if(y.skip)break}}catch(y){console.error(`Error in plugin "${z.name}" ${j} hook:`,y)}}return w}async runDirectiveHooks(j,q,w){let z={...w};for(let B of this.sortedPlugins){let y=B[j];if(y)try{let A=await y(q,z);if(A){if(A.template!==void 0)z.template=A.template;if(A.context)z.context={...z.context,...A.context};if(A.metadata)z.metadata={...z.metadata,...A.metadata};if(A.skip)break}}catch(A){console.error(`Error in plugin "${B.name}" ${j} hook:`,A)}}return z}}var G=new F;function H(j,q,w={}){return{name:j,...w,registerDirectives:()=>q}}function I(j,q,w={}){return{name:j,...w,registerFilters:()=>q}}var J=D({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess(j){console.log("[stx-debug] beforeProcess:",j.filePath)},afterParse(j){console.log("[stx-debug] afterParse:",j.template.length,"chars")},beforeDirective(j,q){console.log("[stx-debug] beforeDirective:",j)},afterDirective(j,q){console.log("[stx-debug] afterDirective:",j)},beforeRender(j){console.log("[stx-debug] beforeRender")},afterRender(j){console.log("[stx-debug] afterRender:",j.template.length,"chars")},onError(j){console.error("[stx-debug] onError:",j.error.message,"in phase:",j.phase)}}),K=D({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess(j){j.metadata.startTime=performance.now()},afterRender(j){let q=j.metadata.startTime;if(q){let w=performance.now()-q;console.log(`[stx-timing] Processing took ${w.toFixed(2)}ms`)}}});function L(j){return D({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(q){return{context:{...q.context,...j}}}})}
|
|
3
|
-
export{D as
|
|
3
|
+
export{D as eg,F as fg,G as gg,H as hg,I as ig,J as jg,K as kg,L as lg};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ji as a,ki as b,li as c,mi as d,ni as e,oi as f,pi as g}from"./chunk-s88yt309.js";import"./chunk-
|
|
2
|
+
import{ji as a,ki as b,li as c,mi as d,ni as e,oi as f,pi as g}from"./chunk-s88yt309.js";import"./chunk-q891e1vj.js";export{d as useVirtualList,b as processVirtualListDirectives,f as processVirtualGridDirectives,e as processInfiniteListDirectives,c as generateVirtualListCSS,g as default,a as createVirtualList};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bj as j,cj as E,dj as Z}from"./chunk-efr3ejqt.js";import{Jq as L,Ml as R,Nl as U,Ol as X,_r as M}from"./chunk-
|
|
2
|
+
import{bj as j,cj as E,dj as Z}from"./chunk-efr3ejqt.js";import{Jq as L,Ml as R,Nl as U,Ol as X,_r as M}from"./chunk-kq4z185m.js";import{At as P}from"./chunk-myh6j9ab.js";import $ from"path";var V=new Map;function w(Q,z){for(let J of Q.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(J[1])z.add(J[1]);for(let J of Q.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let H of(J[1]??"").split(",")){let Y=((H.includes(":")?H.split(":").pop():H)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(Y))z.add(Y)}for(let J of Q.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let H of(J[1]??"").split(",")){let K=H.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(K))z.add(K)}}async function u(Q){let z;if(Q)z=$.resolve(Q);else{let q=await M();z=$.resolve(q.root||process.cwd(),q.storesDir||"stores")}let J=new Bun.Glob("*.ts"),H=[];try{for await(let q of J.scan({cwd:z,absolute:!0})){let y=$.basename(q,".ts");if(["index","types"].includes(y))continue;if(q.includes(".d.ts"))continue;H.push(q)}}catch{return Z(V,z,"",""),null}let K=j(H),Y=E(V,z,K);if(Y!==void 0)return Y||null;if(H.length===0)return Z(V,z,K,""),null;let x=[];for(let q of H){let y=await Bun.file(q).text();x.push({file:q,hasUseStore:/useStore\s*\(/.test(y)})}x.sort((q,y)=>{if(q.hasUseStore===y.hasUseStore)return 0;return q.hasUseStore?1:-1});let I=x.map((q)=>q.file),A=[],B=new Set,T=L({loader:"ts",target:"browser",define:X()});for(let q of I)try{let y=await Bun.file(q).text(),W=$.basename(q,".ts");w(y,B),y=R(y),y=U(y),y=y.replace(/^export\s+(default\s+)?/gm,""),y=T.transformSync(y),A.push(`// Store: ${W}
|
|
3
3
|
${y.trim()}`)}catch(y){console.warn(`[stx] Failed to load store ${q}:`,y)}if(A.length===0)return Z(V,z,K,""),null;let G=A.join(`
|
|
4
4
|
|
|
5
5
|
`),O=`;(function(){
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ng as p}from"./chunk-ytr18qnm.js";import{ch as a,eh as JF,fh as ZF,gh as qF}from"./chunk-ypjgcb5w.js";import{Bj as C,Cj as D}from"./chunk-6rjc6687.js";import{Ck as QF,Dk as XF,Ek as YF}from"./chunk-c0n802j1.js";import{Bq as c,Km as u,Pp as o,Yr as n,_r as N,bm as l,bq as e,dm as d,iq as t,jq as FF}from"./chunk-kq4z185m.js";import{Ws as r}from"./chunk-a2yanhxh.js";import{su as S,uu as WF}from"./chunk-bqdbf8k2.js";import G from"fs";import Z from"path";import{createHash as $F}from"crypto";WF();function g(J){return $F("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function UF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as GF}from"crypto";function VF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function i(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=GF("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>p($))),{context:E}=VF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...n,...K,...z,buildMode:"compile",strict:!1},w=await c(X,E,Q,_,L),U=a(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,status:u(X),streamTemplates:E.__streamTemplates}}var kF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function s(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(kF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function lF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=FF(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await i(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=t(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=o(F.html,W);if(k.htmlAttrs)F.html=e(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await r(F.html),F.fragment=JF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=s(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=YF(z);if(v){let{copied:Y,bytes:F}=s(v,Z.join(Q,"public",XF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${QF}/`)}let R={runtime:H.filename,router:$.filename},zF=ZF(j,R,Q);qF(zF,Q);let x=Date.now()-q;return console.log(`
|
|
3
3
|
[stx build] Done in ${x}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:R,outputDir:Q,duration:x}}
|
|
4
|
-
export{g as
|
|
4
|
+
export{g as Dg,f as Eg,m as Fg,UF as Gg,i as Hg,lF as Ig};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jj as K,Kj as N,Lj as O,Mj as P,Nj as Q,Oj as T,Sj as U,Tj as V,Uj as W,Vj as Y}from"./chunk-k6b7gpk2.js";import{
|
|
2
|
+
import{Jj as K,Kj as N,Lj as O,Mj as P,Nj as Q,Oj as T,Sj as U,Tj as V,Uj as W,Vj as Y}from"./chunk-k6b7gpk2.js";import{It as J}from"./chunk-myh6j9ab.js";function $(){let w=q(Z());try{let z=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(w);return z=z.replace(/\}(var |let |const |function )/g,"};$1"),z}catch{return w}}function q(w){let E=[],z=0,I="console.log(";while(z<w.length){let F=w.indexOf(I,z);if(F===-1){E.push(w.slice(z));break}E.push(w.slice(z,F));let G=1,x=F+I.length;while(x<w.length&&G>0){let B=w[x];if(B==='"'||B==="'"||B==="`"){let _=B;x++;while(x<w.length&&w[x]!==_){if(w[x]==="\\")x++;x++}x++;continue}if(B==="(")G++;else if(B===")")G--;x++}E.push("0"),z=x}return E.join("")}function Z(){return`
|
|
3
3
|
// STX Signals Runtime (Development Build)
|
|
4
4
|
console.log('[stx] signals runtime loading');
|
|
5
5
|
// Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{hj as a,ij as b,jj as c,kj as d,lj as e,mj as f}from"./chunk-572ttrsj.js";import"./chunk-
|
|
2
|
+
import{hj as a,ij as b,jj as c,kj as d,lj as e,mj as f}from"./chunk-572ttrsj.js";import"./chunk-q891e1vj.js";export{c as processTransitionDirectives,f as processTransitionAttributes,b as performLeave,a as performEnter,e as generateTransitionRuntime,d as generateTransitionCSS};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var E=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),N=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);function X(Q){return Q.replace(/[^\n]/g," ")}function R(Q){let H=Q.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,X).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,X).replace(/<!--[\s\S]*?-->/g,X).replace(/\{\{\{[\s\S]*?\}\}\}/g,X).replace(/\{\{[\s\S]*?\}\}/g,X).replace(/\{!![\s\S]*?!!\}/g,X),F=new Map,J=new Map,Y=/<(\/?)([A-Za-z][\w-]*)\b(?:[^>"']|"[^"]*"|'[^']*')*?(\/?)>/g,z;while((z=Y.exec(H))!==null){let j=z[1]==="/",q=z[2],W=z[3]==="/";if(E.has(q.toLowerCase()))continue;if(W)continue;if(j)J.set(q,(J.get(q)??0)+1);else{let Z=F.get(q);if(Z)Z.count++;else{let B=H.slice(0,z.index).split(`
|
|
3
3
|
`).length;F.set(q,{count:1,firstLine:B})}}}let M=[];for(let j of new Set([...F.keys(),...J.keys()])){if(N.has(j.toLowerCase()))continue;let q=F.get(j)?.count??0,W=J.get(j)??0;if(q!==W)M.push({tag:j,opened:q,closed:W,firstOpenLine:F.get(j)?.firstLine??0})}return M}var $=new Set;function U(Q,H){let F;try{F=R(Q)}catch{return}if(F.length===0)return;let J=`${H}:${Q.length}`;if($.has(J))return;$.add(J);let Y=H?H.split(/[/\\]/).pop()||H:"template";for(let{tag:z,opened:M,closed:j,firstOpenLine:q}of F)if(M>j){let W=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${Y}: <${z}> ${M} opened, ${j} closed \u2014 an unclosed <${z}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${Y}: <${z}> ${M} opened, ${j} closed \u2014 ${j-M} stray </${z}>.`)}
|
|
4
|
-
export{R as
|
|
4
|
+
export{R as yt,U as zt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fi as a,Gi as b,Hi as c,Ii as d,Ji as e,Ki as f,Li as g,Mi as h}from"./chunk-a6nnbnmb.js";import"./chunk-k6b7gpk2.js";import"./chunk-
|
|
2
|
+
import{Fi as a,Gi as b,Hi as c,Ii as d,Ji as e,Ki as f,Li as g,Mi as h}from"./chunk-a6nnbnmb.js";import"./chunk-k6b7gpk2.js";import"./chunk-q891e1vj.js";export{d as v,a as useForm,g as processHasErrorsDirective,h as processFormValidationDirectives,f as processErrorsDirective,e as processErrorDirective,b as defineForm,c as Validator};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Gs as _}from"./chunk-nstqd54d.js";import"./chunk-q891e1vj.js";function W(j,G,H=240){return j.slice(G,G+H)}var v=[{rule:"route-params",pattern:/\blocation\s*\.\s*pathname\s*\.\s*(?:match|split)\s*\(/g,primitive:"useRoute() / useRouteParams() / useRouteParam(name)",why:"parsing the URL by hand re-implements the router and does not update on SPA navigation"},{rule:"alert",pattern:/(?<![.#\w$])(?:(?:window|globalThis)\s*\.\s*)?alert\s*\(/g,primitive:"stxAlert(message)",why:"themed, focus-trapped and non-blocking \u2014 but `await` it if the code after it "+"depended on the native dialog blocking until dismissal",reject:(j)=>/\b(?:async\s+)?function\s+alert\s*\(/.test(j)||/\b(?:const|let|var)\s+alert\s*=/.test(j)},{rule:"search-params",pattern:/new\s+URLSearchParams\s*\(/g,primitive:"useSearchParams()",why:"reactive, and writes back through the router instead of history.replaceState",reject:(j,G)=>{let H=j.indexOf("(",G);if(H===-1)return!0;let Q=j.slice(H+1,j.indexOf(")",H)+1);return!/\b(?:location|search|href|url)\b/i.test(Q)}},{rule:"navigate",pattern:/\blocation\s*\.\s*(?:assign|replace)\s*\(|\blocation\s*\.\s*href\s*=/g,primitive:"navigate(path) / goBack()",why:"a full document load throws away every store and the scroll position; navigate() is an SPA transition",reject:(j,G)=>/^[^\n]*?(?:['"`]\s*)?(?:mailto:|tel:|sms:|https?:\/\/|\/\/)/.test(W(j,G,160))},{rule:"fetch",pattern:/new\s+AbortController\s*\(/g,primitive:"useFetch(url) / useAsyncData(key, fn)",why:"cancellation, loading and error state are already wired; hand-rolling them is where the races live"},{rule:"polling",pattern:/setInterval\s*\(/g,primitive:"useEventSource() / useSSE() / useWebSocket() / useChannel()",why:"polling burns requests and lags; the push primitives are delivered",reject:(j,G)=>!/\bfetch\s*\(|\$fetch\b|useFetch\b|\.get\s*\(|axios\b/.test(W(j,G))},{rule:"debounce",pattern:/\bclearTimeout\s*\(/g,primitive:"useDebounce(fn, ms) / useThrottle(fn, ms)",why:"a hand-held timer handle per call site is the usual source of stale-result bugs",requires:(j)=>/setTimeout\s*\(/.test(j)},{rule:"click-outside",pattern:/document\s*\.\s*addEventListener\s*\(\s*['"](?:click|mousedown|pointerdown)['"]/g,primitive:"useClickOutside(ref, fn)",why:"the document-level listener plus the blur race is exactly what this composable exists to remove"},{rule:"focus",pattern:/\.\s*(?:getElementById|querySelector)\s*\([^)]*\)\s*(?:\?\.)?\s*\.?focus\s*\(/g,primitive:"useFocus(ref) with x-ref",why:"a query by id breaks under nested scopes and SPA navigation; a ref does not"},{rule:"clipboard",pattern:/navigator\s*\.\s*(?:clipboard|share)\b/g,primitive:"useClipboard() / useShare()",why:"permission state, the copied flag and the unsupported-browser fallback are already handled"},{rule:"watch",pattern:/\beffect\s*\(\s*\(\s*\)\s*=>\s*\{[^}]*\bvoid\s+\w+\s*\(\s*\)/g,primitive:"watch(source, cb) / watchMultiple([...], cb)",why:"the `void a(); void b()` dance is a manual dependency list; watch takes one directly"}],U=["confirm","tooltip",...v.map((j)=>j.rule)];function N(j,G){let H=1;for(let Q=0;Q<G;Q++)if(j[Q]===`
|
|
3
3
|
`)H++;return H}function P(j,G){let H=j.lastIndexOf(`
|
|
4
4
|
`,G)+1,Q=j.indexOf(`
|
|
5
5
|
`,G);return j.slice(H,Q===-1?j.length:Q).trim().slice(0,120)}function q(j,G){let H=j.slice(0,G),Q=H.lastIndexOf("function"),X=H.lastIndexOf("=>"),M=Math.max(Q,X);if(M===-1)return!1;let z=j.slice(Math.max(0,M-120),M);return/\basync\b[^;{}]*$/.test(z)}function L(j){return/\b(?:async\s+)?function\s+confirm\s*\(/.test(j)||/\b(?:const|let|var)\s+confirm\s*=/.test(j)||/\bimport\s*\{[^}]*\bconfirm\b[^}]*\}/.test(j)}function O(j,G,H){if(L(j))return j;let Q=/(^|[^\w$.])(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(/g,X=F(j),M="",z=0,Y;while((Y=Q.exec(X))!==null){let Z=Y.index+Y[1].length,$=N(j,Z),J=P(j,Z);if(/stxConfirm\s*\($/.test(j.slice(0,Z+8)))continue;let D=q(j,Z);if(H.push({file:G,line:$,rule:"confirm",applied:D,snippet:J,reason:D?void 0:"stxConfirm() returns a Promise and native confirm() is synchronous, so this needs `await` inside an async function. Rewriting it here would make the condition always true."}),D)M+=j.slice(z,Z)+"await stxConfirm(",z=Z+(Y[0].length-Y[1].length)}return M+j.slice(z)}function w(j,G,H){let Q=/(<[a-z][\w-]*\b[^>]*?)\stitle=(["'])(.*?)\2/gis,X=C(j),M="",z=0,Y;while((Y=Q.exec(X))!==null){let[Z,$,J,D]=Y,K=N(j,Y.index),B=P(j,Y.index),V=$.match(/^<([A-Za-z][\w-]*)/)?.[1]??"";if(/^[A-Z]/.test(V)){H.push({file:G,line:K,rule:"tooltip",applied:!1,snippet:B,reason:`\`title\` on <${V}> is a component prop, not an HTML attribute \u2014 `+"adding x-tooltip here would put a tooltip on a component and may duplicate text it already renders."});continue}if(/\bx-tooltip[=\s]/.test($)||D.trim()===""){H.push({file:G,line:K,rule:"tooltip",applied:!1,snippet:B,reason:/\bx-tooltip[=\s]/.test($)?"already has x-tooltip":"empty title"});continue}H.push({file:G,line:K,rule:"tooltip",applied:!0,snippet:B}),M+=j.slice(z,Y.index)+`${$} x-tooltip=${J}${D}${J} title=${J}${D}${J}`,z=Y.index+Z.length}return M+j.slice(z)}function C(j){return j.replace(/<!--[\s\S]*?-->/g,(G)=>G.replace(/[^\n]/g," ")).replace(/\{\{--[\s\S]*?--\}\}/g,(G)=>G.replace(/[^\n]/g," "))}function E(j){let G=(H)=>H.replace(/[^\n]/g," ");return j.replace(/\/\*[\s\S]*?\*\//g,G).replace(/\/\/[^\n]*/g,G)}function F(j,G=!1){let H=C(j);return(G?E(H):_(H)).replace(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,(X,M)=>/\bclient\b/i.test(M)?X:X.replace(/[^\n]/g," "))}function S(j,G,H,Q){let X=F(j),M=F(j,!0);for(let z of v){if(!H.includes(z.rule))continue;if(z.requires&&!z.requires(j))continue;z.pattern.lastIndex=0;let Y,Z=/['"]/.test(z.pattern.source)?M:X;z.pattern.lastIndex=0;while((Y=z.pattern.exec(Z))!==null){if(z.reject?.(j,Y.index))continue;Q.push({file:G,line:N(j,Y.index),rule:z.rule,applied:!1,snippet:P(j,Y.index),reason:`${z.primitive} \u2014 ${z.why}`})}}}function k(j,G={}){let H=G.rules??U,Q=G.file??"<source>",X=[];S(j,Q,H,X);let M=j;if(H.includes("confirm"))M=O(M,Q,X);if(H.includes("tooltip"))M=w(M,Q,X);X.sort((Z,$)=>Z.line-$.line);let z=new Set,Y=X.filter((Z)=>{let $=`${Z.rule}:${Z.line}`;if(z.has($))return!1;return z.add($),!0});return{code:M,findings:Y}}var I=new Set(["confirm","tooltip"]);function A(j,G){if(j.length===0)return"No hand-rolled equivalents found.";let H=j.filter((z)=>z.applied),Q=j.filter((z)=>!z.applied&&I.has(z.rule)),X=j.filter((z)=>!z.applied&&!I.has(z.rule)),M=[];if(H.length>0){M.push(G?`Rewrote ${H.length} site(s):`:`Would rewrite ${H.length} site(s) (pass --fix):`);for(let z of H)M.push(` ${z.file}:${z.line} [${z.rule}] ${z.snippet}`)}if(Q.length>0){M.push("",`Needs a human \u2014 ${Q.length} site(s):`);for(let z of Q)M.push(` ${z.file}:${z.line} [${z.rule}] ${z.snippet}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{$f as k,Rf as a,Sf as b,Tf as c,Uf as d,Vf as e,Wf as f,Xf as g,Yf as h,Zf as i,_f as j,ag as l,bg as m,cg as n,dg as o}from"./chunk-nx5qkm8k.js";import"./chunk-q891e1vj.js";export{k as writeNetlifyConfig,n as initNetlify,l as hasNetlifyConfig,g as getTotalSize,h as generateNetlifyToml,f as formatSize,e as filterRequiredFiles,i as detectProjectConfig,m as deploy,a as createNetlifyClient,d as createFileManifest,j as createDefaultNetlifyConfig,c as collectDeployFiles,b as calculateSha1,o as DeployError};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-q891e1vj.js";var Y=null,S=[],F=new WeakMap;function I(z){let K=z,B=new Set,G={get value(){if(Y){let H=F.get(G);if(!H)H=new Set,F.set(G,H);H.add(Y)}return K},set value(H){if(!Object.is(K,H)){K=H,B.forEach((J)=>J(H));let L=F.get(G);if(L)L.forEach((J)=>J())}},subscribe(H){return B.add(H),()=>B.delete(H)},peek(){return K}};return G}function W(z){return z!==null&&typeof z==="object"&&"value"in z&&"subscribe"in z&&"peek"in z}function P(z){return W(z)?z.value:z}function j(z){let K={};for(let B in z)if(Object.prototype.hasOwnProperty.call(z,B))K[B]=I(z[B]);return K}function D(z){return I(z)}function U(z){let K=typeof z==="function",B=K?z:z.get,G=K?void 0:z.set,H=K?Object.is:z.equals||Object.is,L,J=!0,Q=new Set,X=new Set,_=()=>{if(J=!0,X.size>0){let N=T.value;X.forEach(($)=>$(N))}};function Z(){Q.clear();let N=Y;Y=_,S.push(_);try{return B()}finally{S.pop(),Y=N}}let T={get value(){if(Y){let N=F.get(T);if(!N)N=new Set,F.set(T,N);N.add(Y)}if(J){let N=Z();if(!H(L,N))L=N;J=!1}return L},set value(N){if(G)G(N);else console.warn("Computed property is readonly")},subscribe(N){return X.add(N),()=>X.delete(N)},peek(){if(J)L=B(),J=!1;return L},invalidate(){J=!0},get dirty(){return J},get deps(){return Q}};return T}function x(z,K,B={}){let{immediate:G=!1,deep:H=!1,flush:L="pre",once:J=!1}=B,Q,X=!0,_=!1,Z=()=>{if(W(z))return H?q(z.value):z.value;return z()},T=()=>{if(!X||_)return;let M=Z();if(Q!==void 0&&Object.is(Q,M)&&!H)return;let A=()=>{if(K(M,Q),Q=H?q(M):M,J)$()};if(L==="sync")A();else if(L==="post")queueMicrotask(A);else Promise.resolve().then(A)},N=null;if(W(z))N=z.subscribe(()=>T());else N=U(z).subscribe(()=>T());if(G)Q=void 0,T();else Q=Z();let $=()=>{if(X=!1,N)N(),N=null};return $.pause=()=>{_=!0},$.resume=()=>{_=!1},$}function E(z,K,B={}){let{immediate:G=!1,once:H=!1}=B,L=z.map((T)=>W(T)?T.value:void 0),J=!0,Q=!1,X=()=>{if(!J||Q)return;let T=z.map((N)=>W(N)?N.value:void 0);if(K(T,L),L=[...T],H)Z()},_=z.map((T)=>{if(W(T))return T.subscribe(()=>X());return()=>{}});if(G)X();let Z=()=>{J=!1,_.forEach((T)=>T())};return Z.pause=()=>{Q=!0},Z.resume=()=>{Q=!1},Z}function y(z,K={}){let{flush:B="pre"}=K,G,H=!0,L=!1,J=()=>{if(!H||L)return;if(G)G();let X=Y;Y=J,S.push(J);try{G=z()}finally{S.pop(),Y=X}};if(B==="sync")J();else if(B==="post")queueMicrotask(J);else Promise.resolve().then(J);let Q=()=>{if(H=!1,G)G()};return Q.pause=()=>{L=!0},Q.resume=()=>{L=!1},Q}function C(z,K={},B){let G=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return z.replace(G,(H,L,J)=>{try{let X=Function(...Object.keys(K),`return ${J}`)(...Object.values(K));return K[L]=X,`<!-- computed: ${L} = ${X} -->`}catch(Q){return`<!-- computed error: ${L} - ${Q} -->`}})}function R(z,K={},B){let G=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return z.replace(G,(H,L,J)=>{return`
|
|
3
3
|
<script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
|
|
4
4
|
(function() {
|
|
5
5
|
// Watch implementation for ${L}
|