@stacksjs/stx 0.2.644 → 0.2.647
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/attrs.js +6 -6
- package/dist/builtins/escape.d.ts +0 -11
- package/dist/builtins/escape.js +2 -1
- package/dist/builtins/safe-image.js +1 -3
- package/dist/builtins/stx-image.js +1 -3
- package/dist/builtins/stx-link.d.ts +3 -0
- package/dist/builtins/stx-link.js +1 -3
- package/dist/{chunk-1m5cjrpw.js → chunk-04kg16qs.js} +4 -4
- package/dist/chunk-0jq3w712.js +65 -0
- package/dist/chunk-0ky1j84b.js +2 -0
- package/dist/chunk-0m08316b.js +2 -0
- package/dist/{chunk-qf210sfx.js → chunk-0z5cc7qn.js} +8 -8
- package/dist/{chunk-0ergsswn.js → chunk-120ze5ms.js} +3 -3
- package/dist/chunk-1c5p7ede.js +2 -0
- package/dist/chunk-1q6yvbdx.js +2 -0
- package/dist/chunk-1x4qn6fy.js +2 -0
- package/dist/chunk-20f1veqy.js +3 -0
- package/dist/chunk-2a4szpje.js +3 -0
- package/dist/chunk-2c3w367n.js +2 -0
- package/dist/chunk-2cxav9xe.js +2 -0
- package/dist/chunk-2f17h17f.js +2 -0
- package/dist/{chunk-ktvr45qg.js → chunk-2qbvsvwc.js} +2 -2
- package/dist/chunk-2v4s7xtx.js +2 -0
- package/dist/chunk-31714f76.js +2 -0
- package/dist/chunk-354jmw2k.js +3 -0
- package/dist/chunk-3e7haxwt.js +2 -0
- package/dist/{chunk-afsf6sp0.js → chunk-3ghbxena.js} +14 -14
- package/dist/chunk-40y6mb8t.js +2 -0
- package/dist/chunk-42rghbqe.js +12 -0
- package/dist/chunk-4fz2eq7g.js +2 -0
- package/dist/{chunk-1t0m4pwg.js → chunk-4yf1w261.js} +2 -2
- package/dist/chunk-4yt8tg4j.js +2 -0
- package/dist/chunk-52gp2xxk.js +2 -0
- package/dist/chunk-55x799st.js +49 -0
- package/dist/chunk-5e20mvke.js +2 -0
- package/dist/chunk-5fzh8n52.js +2 -0
- package/dist/chunk-5gtpswnm.js +2 -0
- package/dist/{chunk-a0ygyftk.js → chunk-5t4qtxgr.js} +2 -2
- package/dist/chunk-5yg3tkth.js +2 -0
- package/dist/chunk-67kj14at.js +2 -0
- package/dist/{chunk-gqz26wza.js → chunk-6ajahb2x.js} +3 -3
- package/dist/chunk-6vzktvyw.js +2 -0
- package/dist/chunk-70pmthc3.js +2 -0
- package/dist/chunk-74pej67a.js +18 -0
- package/dist/{chunk-g1ae3haw.js → chunk-7rta163c.js} +2 -2
- package/dist/chunk-7s32fe6k.js +3 -0
- package/dist/chunk-84djpte6.js +3 -0
- package/dist/chunk-864qtx7y.js +2 -0
- package/dist/chunk-8ttg2d3m.js +2 -0
- package/dist/{chunk-9yk5rasj.js → chunk-9am6dsb1.js} +3 -3
- package/dist/{chunk-5e063mgs.js → chunk-9p6efb17.js} +1 -1
- package/dist/chunk-9qeg5trh.js +2 -0
- package/dist/chunk-9szxxgv5.js +2 -0
- package/dist/{chunk-bsts9pr5.js → chunk-9y2ncrnq.js} +2 -2
- package/dist/chunk-9z9jtwct.js +33 -0
- package/dist/{chunk-y255yybn.js → chunk-a3d0g4mr.js} +2 -2
- package/dist/{chunk-9939fjh4.js → chunk-a8j91pqz.js} +11 -11
- package/dist/{chunk-hshcbe3p.js → chunk-aah6csjm.js} +11 -11
- package/dist/{chunk-cw8mx4qf.js → chunk-ajv5xmjx.js} +169 -169
- package/dist/chunk-apgb7r22.js +2 -0
- package/dist/{chunk-c858mepd.js → chunk-aprhqxky.js} +5 -5
- package/dist/{chunk-29sq7kqw.js → chunk-ar22s1e1.js} +2 -2
- package/dist/chunk-asqnaddf.js +3 -0
- package/dist/chunk-aze7k3a5.js +2 -0
- package/dist/chunk-b07djygp.js +18 -0
- package/dist/chunk-b0vhe6d4.js +4 -0
- package/dist/chunk-b4fd2dtk.js +2 -0
- package/dist/chunk-bk96wjaz.js +61 -0
- package/dist/chunk-c7fs96n6.js +4 -0
- package/dist/chunk-c9k40352.js +2 -0
- package/dist/{chunk-ahyq08mp.js → chunk-ce6zddpf.js} +3 -3
- package/dist/{chunk-cpxtmmvv.js → chunk-cj2xj1v6.js} +39 -40
- package/dist/chunk-cs0dd5w8.js +2 -0
- package/dist/chunk-cwd65649.js +2 -0
- package/dist/{chunk-2s3sxt48.js → chunk-da7x7y7j.js} +1 -1
- package/dist/{chunk-wjq1wqn6.js → chunk-dgb4z4kw.js} +2 -2
- package/dist/chunk-dpjnjs09.js +888 -0
- package/dist/chunk-e7sg0fa0.js +2 -0
- package/dist/chunk-edz1h5f9.js +2 -0
- package/dist/chunk-egg54kd0.js +12 -0
- package/dist/chunk-ek2adv0n.js +2 -0
- package/dist/chunk-emaexvgz.js +2 -0
- package/dist/{chunk-pp6ycfay.js → chunk-ewcrsyr7.js} +2 -2
- package/dist/chunk-fcn71bq1.js +2 -0
- package/dist/{chunk-dcwhp21g.js → chunk-fg3jw17w.js} +48 -48
- package/dist/chunk-fygp3cs9.js +2 -0
- package/dist/chunk-g2jmwh7p.js +2 -0
- package/dist/chunk-g8r0km7g.js +106 -0
- package/dist/{chunk-gmxrckgj.js → chunk-gc9ftf7r.js} +3 -3
- package/dist/chunk-ggwm8w5m.js +2 -0
- package/dist/chunk-h5zr710w.js +2 -0
- package/dist/chunk-hgy4c6mm.js +11 -0
- package/dist/chunk-hvtzw1jh.js +2 -0
- package/dist/{chunk-4n24jbfs.js → chunk-hvzzhkhr.js} +2 -2
- package/dist/chunk-j0v970k3.js +2 -0
- package/dist/chunk-jk41jwsc.js +2 -0
- package/dist/{chunk-6mnwvn9v.js → chunk-jkvr7e91.js} +2 -2
- package/dist/{chunk-639ngkgb.js → chunk-jsb4pvj1.js} +2 -2
- package/dist/{chunk-pf5s5gjp.js → chunk-jx3wpgv0.js} +2 -2
- package/dist/{chunk-fztvkacg.js → chunk-jxda11cg.js} +2 -2
- package/dist/chunk-jyth1zjy.js +127 -0
- package/dist/chunk-k2pa44rf.js +2 -0
- package/dist/{chunk-kad2cp0z.js → chunk-k79x96ra.js} +37 -37
- package/dist/{chunk-qy11cp1v.js → chunk-kgfgb971.js} +4 -4
- package/dist/chunk-ma7d95f0.js +31 -0
- package/dist/chunk-mmm6mm16.js +3 -0
- package/dist/{chunk-88p10v0w.js → chunk-mmwedr93.js} +5 -5
- package/dist/{chunk-dyg6sadv.js → chunk-mrrrngzd.js} +1 -1
- package/dist/{chunk-w41kp60h.js → chunk-msr25dhc.js} +4 -4
- package/dist/chunk-myq3hrww.js +6 -0
- package/dist/{chunk-fwdptew6.js → chunk-n38yb274.js} +6 -6
- package/dist/chunk-n4cvg2sw.js +2 -0
- package/dist/chunk-nph4d1ff.js +42 -0
- package/dist/{chunk-aztp8r80.js → chunk-nrvwejdw.js} +5 -5
- package/dist/{chunk-17x6e5mm.js → chunk-p08x0z86.js} +7 -7
- package/dist/chunk-p22w6mwr.js +2 -0
- package/dist/{chunk-xsmvcnmx.js → chunk-pdc9s7bg.js} +2 -2
- package/dist/chunk-pfk9ffbz.js +3 -0
- package/dist/{chunk-pvfx0dgz.js → chunk-prf164ct.js} +2 -2
- package/dist/chunk-pw9bhdaz.js +4 -0
- package/dist/chunk-qn63btbf.js +2 -0
- package/dist/{chunk-eyy6zmdk.js → chunk-qv6axke4.js} +2 -2
- package/dist/{chunk-60azcvwr.js → chunk-r3e6x87d.js} +3 -3
- package/dist/chunk-rb5xdcen.js +25 -0
- package/dist/{chunk-45xhjrha.js → chunk-rcadtv3x.js} +1 -1
- package/dist/{chunk-j00v4m56.js → chunk-rjh2jwxx.js} +9 -9
- package/dist/chunk-rwrbdpdk.js +2 -0
- package/dist/chunk-sf0wsq74.js +2 -0
- package/dist/chunk-shkysa02.js +20 -0
- package/dist/chunk-shpc1ttk.js +2 -0
- package/dist/{chunk-48yja477.js → chunk-t2pzy3x1.js} +3 -3
- package/dist/chunk-t6yjxhn8.js +2 -0
- package/dist/chunk-tkkvvt26.js +2 -0
- package/dist/{chunk-b4j5bpec.js → chunk-tre98h62.js} +2 -2
- package/dist/chunk-vac56rgd.js +12 -0
- package/dist/chunk-vdxjy7j2.js +4 -0
- package/dist/{chunk-gsp3627d.js → chunk-vgt9f7ac.js} +4 -4
- package/dist/{chunk-vq4sh8aq.js → chunk-vmwdt8fr.js} +5 -5
- package/dist/chunk-vn3yx05b.js +2 -0
- package/dist/{chunk-fqg0espy.js → chunk-vqc4h16r.js} +2 -2
- package/dist/chunk-w1v1d7rq.js +406 -0
- package/dist/chunk-w2q32x72.js +2 -0
- package/dist/chunk-weqc0ssb.js +2 -0
- package/dist/{chunk-kjspmegt.js → chunk-wpmrz872.js} +2 -2
- package/dist/chunk-wq712sw1.js +2 -0
- package/dist/chunk-wzgn9fv7.js +20 -0
- package/dist/{chunk-s775b8ra.js → chunk-x8k64g1e.js} +2 -2
- package/dist/chunk-xaa36b0x.js +3 -0
- package/dist/chunk-xnjf1zbn.js +21 -0
- package/dist/chunk-xyjn0rvj.js +3 -0
- package/dist/chunk-y3vget29.js +2 -0
- package/dist/chunk-y9x4pyp2.js +2 -0
- package/dist/chunk-yfrvbnc6.js +1312 -0
- package/dist/{chunk-drrczm0b.js → chunk-ym41ybz2.js} +6 -6
- package/dist/chunk-z8p6tk5z.js +2 -0
- package/dist/{chunk-gbxzqvez.js → chunk-zevx9866.js} +2 -2
- package/dist/chunk-zhf01af3.js +3 -0
- package/dist/{chunk-6avpd901.js → chunk-zqtbtqbq.js} +2 -2
- package/dist/chunk-ztbzktzg.js +2 -0
- package/dist/cli.js +62 -62
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/expressions.d.ts +6 -21
- package/dist/expressions.js +12 -41
- package/dist/forms-validation.d.ts +0 -16
- package/dist/forms-validation.js +4 -2
- package/dist/forms.js +8 -6
- package/dist/i18n.js +6 -4
- package/dist/interpolation-context.js +69 -28
- package/dist/loops.js +70 -90
- package/dist/mustache-span.d.ts +21 -0
- package/dist/mustache-span.js +35 -0
- package/dist/native-build.d.ts +5 -0
- package/dist/native-build.js +11 -27
- package/dist/process.js +4 -3
- package/dist/pwa.js +3 -3
- package/dist/server-bindings.js +12 -6
- package/dist/ssg.js +28 -28
- package/dist/utils.js +1 -2
- package/package.json +5 -5
- package/dist/chunk-12677ap2.js +0 -31
- package/dist/chunk-162gprh9.js +0 -2
- package/dist/chunk-1p6yd17s.js +0 -2
- package/dist/chunk-29gd2kkk.js +0 -20
- package/dist/chunk-3hkp5hym.js +0 -2
- package/dist/chunk-3jrssj8g.js +0 -2
- package/dist/chunk-444pz8yk.js +0 -2
- package/dist/chunk-47shfmkf.js +0 -3
- package/dist/chunk-4b5f28te.js +0 -2
- package/dist/chunk-4dpq1bnh.js +0 -2
- package/dist/chunk-4mm9ttc7.js +0 -2
- package/dist/chunk-5c511mj0.js +0 -2
- package/dist/chunk-5kbkx0np.js +0 -3
- package/dist/chunk-5wyp57g3.js +0 -4
- package/dist/chunk-6bdr0x43.js +0 -18
- package/dist/chunk-6vmvra0f.js +0 -65
- package/dist/chunk-70et0fbw.js +0 -12
- package/dist/chunk-7mkw98cr.js +0 -3
- package/dist/chunk-7qgsgfnt.js +0 -2
- package/dist/chunk-87kza2ez.js +0 -2
- package/dist/chunk-8bk1ghb7.js +0 -127
- package/dist/chunk-8cqx63aw.js +0 -3
- package/dist/chunk-8k5eac6p.js +0 -2
- package/dist/chunk-9nvrkpee.js +0 -2
- package/dist/chunk-9ny6xzw0.js +0 -2
- package/dist/chunk-9r538d93.js +0 -2
- package/dist/chunk-9xaztqhw.js +0 -2
- package/dist/chunk-b2teprjf.js +0 -2
- package/dist/chunk-bnfjwgtm.js +0 -20
- package/dist/chunk-br7xk2hb.js +0 -2
- package/dist/chunk-c8p5jwdq.js +0 -2
- package/dist/chunk-cd76dwdn.js +0 -2
- package/dist/chunk-degxqdbb.js +0 -2
- package/dist/chunk-dr4325et.js +0 -2
- package/dist/chunk-e7bd4vxb.js +0 -2
- package/dist/chunk-eh7qq39j.js +0 -2
- package/dist/chunk-ek5vrw4r.js +0 -2
- package/dist/chunk-erweevv2.js +0 -2
- package/dist/chunk-fdxyj3pk.js +0 -2
- package/dist/chunk-ft3r2rzs.js +0 -2
- package/dist/chunk-fywp8fcr.js +0 -2
- package/dist/chunk-g14mwhqz.js +0 -2
- package/dist/chunk-g6s0xdgb.js +0 -4
- package/dist/chunk-grg366m9.js +0 -2852
- package/dist/chunk-h3brvxbf.js +0 -3
- package/dist/chunk-hbk20w21.js +0 -2
- package/dist/chunk-hrdnz5q9.js +0 -2
- package/dist/chunk-hvk5zkpm.js +0 -4
- package/dist/chunk-j0jz4mfm.js +0 -2
- package/dist/chunk-j37720vw.js +0 -2
- package/dist/chunk-j6fxzkn5.js +0 -2
- package/dist/chunk-ja3m0h9h.js +0 -12
- package/dist/chunk-jmdrhpy7.js +0 -2
- package/dist/chunk-jshv1ye7.js +0 -2
- package/dist/chunk-jtk2p5p0.js +0 -2
- package/dist/chunk-k46gqnmk.js +0 -2
- package/dist/chunk-ktjvqwp4.js +0 -2
- package/dist/chunk-kv5mn1qr.js +0 -6
- package/dist/chunk-kxbw0e2f.js +0 -3
- package/dist/chunk-ky043mkv.js +0 -2
- package/dist/chunk-m2bnyrft.js +0 -2
- package/dist/chunk-m92q2jyt.js +0 -40
- package/dist/chunk-mbqqc20a.js +0 -2
- package/dist/chunk-mqmxhggf.js +0 -2
- package/dist/chunk-myq0m4h4.js +0 -2
- package/dist/chunk-nkgzwyad.js +0 -2
- package/dist/chunk-ns4pc13z.js +0 -2
- package/dist/chunk-nv9syzs0.js +0 -2
- package/dist/chunk-pn719qwa.js +0 -2
- package/dist/chunk-qmh6f1bt.js +0 -24
- package/dist/chunk-r00nn2qs.js +0 -4
- package/dist/chunk-re2mry1d.js +0 -2
- package/dist/chunk-s0tbc9t1.js +0 -33
- package/dist/chunk-s7e9ztgq.js +0 -2
- package/dist/chunk-t6awky15.js +0 -11
- package/dist/chunk-tcq0me7c.js +0 -2
- package/dist/chunk-vse0hhn9.js +0 -2
- package/dist/chunk-vvgs62za.js +0 -2
- package/dist/chunk-wj4rf7sb.js +0 -2
- package/dist/chunk-x901zq4q.js +0 -2
- package/dist/chunk-xe8qmf1d.js +0 -2
- package/dist/chunk-xqtzk9wr.js +0 -2
- package/dist/chunk-y51ndrdb.js +0 -2
- package/dist/chunk-yn2d8x8m.js +0 -3
- package/dist/chunk-zrngcg6r.js +0 -2
package/dist/builtins/attrs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { escapeAttributeValue, escapeHtml } from "../expressions.js";
|
|
2
2
|
import { BOOLEAN_ATTRIBUTE_SENTINEL, stripControlChars } from "../prop-sentinels.js";
|
|
3
3
|
const FALLTHROUGH_ATTRIBUTES = new Set([
|
|
4
4
|
"accesskey",
|
|
@@ -110,14 +110,14 @@ export function forwardStaticAttrs(props, consumed) {
|
|
|
110
110
|
const name = props.staticNames?.[key] ?? key;
|
|
111
111
|
if (typeof value === "boolean") {
|
|
112
112
|
if (value)
|
|
113
|
-
attrs.push(
|
|
113
|
+
attrs.push(escapeHtml(name));
|
|
114
114
|
continue;
|
|
115
115
|
}
|
|
116
116
|
if (value === BOOLEAN_ATTRIBUTE_SENTINEL) {
|
|
117
|
-
attrs.push(
|
|
117
|
+
attrs.push(escapeHtml(name));
|
|
118
118
|
continue;
|
|
119
119
|
}
|
|
120
|
-
attrs.push(`${
|
|
120
|
+
attrs.push(`${escapeHtml(name)}="${escapeAttributeValue(name, stripControlChars(String(value)))}"`);
|
|
121
121
|
}
|
|
122
122
|
return attrs;
|
|
123
123
|
}
|
|
@@ -130,12 +130,12 @@ export function forwardResolvedAttrs(props, consumed) {
|
|
|
130
130
|
continue;
|
|
131
131
|
const name = props.serverDynamicNames?.[key] ?? key;
|
|
132
132
|
if (value === !0) {
|
|
133
|
-
attrs.push(
|
|
133
|
+
attrs.push(escapeHtml(name));
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
136
|
if (typeof value === "object")
|
|
137
137
|
continue;
|
|
138
|
-
attrs.push(`${
|
|
138
|
+
attrs.push(`${escapeHtml(name)}="${escapeAttributeValue(name, stripControlChars(String(value)))}"`);
|
|
139
139
|
}
|
|
140
140
|
return attrs;
|
|
141
141
|
}
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared HTML-attribute escaping for builtin components.
|
|
3
|
-
*
|
|
4
|
-
* Builtins interpolate prop values directly into their rendered markup. Any value
|
|
5
|
-
* that can come from untrusted data (a `:prop="userData.x"` lands in
|
|
6
|
-
* `serverDynamic`) must be escaped before it goes into an attribute, or a value
|
|
7
|
-
* like `x" onload="alert(1)` breaks out of the attribute — an XSS sink.
|
|
8
|
-
*
|
|
9
|
-
* Escapes the five attribute-significant characters. Safe for both double- and
|
|
10
|
-
* single-quoted attribute contexts.
|
|
11
|
-
*/
|
|
12
1
|
export declare function escapeAttr(value: string): string;
|
package/dist/builtins/escape.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { escapeAttr } from "./escape.js";
|
|
1
2
|
import { forwardResolvedAttrs, forwardStaticAttrs } from "./attrs.js";
|
|
2
3
|
const DEFAULT_FALLBACK = "/images/safe-image-default.svg";
|
|
3
|
-
function escapeAttr(value) {
|
|
4
|
-
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5
|
-
}
|
|
6
4
|
function resolveProp(props, key) {
|
|
7
5
|
if (props.serverDynamic[key] !== void 0)
|
|
8
6
|
return String(props.serverDynamic[key]);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { escapeAttr } from "./escape.js";
|
|
1
2
|
import { forwardResolvedAttrs, forwardStaticAttrs } from "./attrs.js";
|
|
2
3
|
import { efficientDeliverySources, getImageDelivery, isTransparentImage } from "./image-delivery.js";
|
|
3
4
|
import { getImagePlaceholder } from "./image-placeholder.js";
|
|
@@ -9,9 +10,6 @@ const DEFAULT_BREAKPOINTS = {
|
|
|
9
10
|
xl: 1280,
|
|
10
11
|
"2xl": 1536
|
|
11
12
|
}, DEFAULT_SRCSET_WIDTHS = [320, 640, 768, 1024, 1280, 1536, 1920];
|
|
12
|
-
function escapeAttr(value) {
|
|
13
|
-
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
14
|
-
}
|
|
15
13
|
function resolveProp(props, key) {
|
|
16
14
|
if (props.serverDynamic[key] !== void 0)
|
|
17
15
|
return String(props.serverDynamic[key]);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { BuiltinComponentDef } from '../component-registry';
|
|
2
|
+
/**
|
|
3
|
+
* Escape a string for safe use inside an HTML attribute value.
|
|
4
|
+
*/
|
|
2
5
|
/**
|
|
3
6
|
* Resolve the `to` prop from any binding category.
|
|
4
7
|
* Returns an object indicating whether the value is a static string
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { escapeAttr } from "./escape.js";
|
|
1
2
|
import { forwardResolvedAttrs, forwardStaticAttrs } from "./attrs.js";
|
|
2
3
|
import { sanitizeUrlValue } from "../url-safety.js";
|
|
3
|
-
function escapeAttr(value) {
|
|
4
|
-
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5
|
-
}
|
|
6
4
|
function resolveTo(props) {
|
|
7
5
|
if (props.clientReactive.to)
|
|
8
6
|
return { value: props.clientReactive.to, reactive: !0 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function
|
|
3
|
-
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
2
|
+
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function ba(e){try{return w.has(c.realpathSync(e))}catch{return w.has(i.resolve(e))}}var _=new Set(["extends","root",...j.map((e)=>`${e}Dir`),"publicDir","stateDir","cachePath"]),x=(e)=>e!==null&&typeof e==="object"&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);function b(e,n,r=""){if(Array.isArray(n))return["middleware","plugins"].includes(r)?[...Array.isArray(e)?e:[],...n]:[...n];if(!x(n))return n;let o={...x(e)?e:{}};for(let[s,a]of Object.entries(n)){if(["__proto__","constructor","prototype"].includes(s))throw Error(`Invalid layer config key: ${s}`);o[s]=b(o[s],a,s)}return o}function v(e){for(let n of["stx.config.ts","stx.config.js","stx.config.mjs",".config/stx.config.ts",".config/stx.ts","ui.config.ts"]){let r=i.join(e,n);if(c.existsSync(r))return c.realpathSync(r)}throw Error(`Application layer has no stx.config.ts: ${e}`)}function E(e,n,r){if(typeof e!=="string"||!e||/^(?:https?:|git[+:])/.test(e))throw Error(`Invalid application layer ${JSON.stringify(e)} in ${n}; use a local path or installed package`);if(e.startsWith(".")||i.isAbsolute(e)){let s=i.resolve(n,e);return c.statSync(s).isDirectory()?v(s):c.realpathSync(s)}let o=n;while(!0){let s=i.join(o,"node_modules",e),a=i.join(s,"package.json");if(c.existsSync(a)){r.add(c.realpathSync(a));let g=JSON.parse(c.readFileSync(a,"utf8"));return g.stx?.layer?c.realpathSync(i.resolve(s,g.stx.layer)):v(s)}let p=i.dirname(o);if(p===o)break;o=p}throw Error(`Cannot resolve application layer ${JSON.stringify(e)} from ${n}`)}async function C(e,n){let r=await Bun.build({entrypoints:[e],target:"bun",format:"esm",splitting:!1,plugins:[{name:"stx-layer-config",setup(a){a.onResolve({filter:/^[^./]/},(p)=>{if(p.path.startsWith("node:"))return{path:p.path,external:!0};return{path:Bun.resolveSync(p.path,p.resolveDir),external:!0}}),a.onLoad({filter:/./},(p)=>{let g=c.realpathSync(p.path);n.add(g),w.add(g);return})}}]});if(!r.success)throw Error(`Cannot load layer ${e}: ${r.logs.join(`
|
|
3
|
+
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function va(e,n){let r=new Set,o=[],s=[],a=new Set,p=[];async function g(t,l){if(t=c.realpathSync(t),p.includes(t))throw Error(`Application layer cycle: ${[...p,t].join(" -> ")}`);if(a.has(t))return;a.add(t),p.push(t);let d=await C(t,r);l??=i.basename(i.dirname(t))===".config"?i.dirname(i.dirname(t)):i.dirname(t),l=c.realpathSync(l);let D=i.resolve(l,d.root??"."),L=Object.fromEntries(j.map((y)=>[y,i.resolve(D,d[`${y}Dir`]??(y==="composables"?"functions":y))]));o.push({root:l,configFile:t,resources:L});let u={...d};if(u.plugins)u.plugins=u.plugins.map((y)=>{let h=typeof y==="string"?y:y[0],S=h.startsWith(".")?i.resolve(l,h):i.isAbsolute(h)?h:Bun.resolveSync(h,l);return r.add(c.realpathSync(S)),typeof y==="string"?S:[S,y[1]]});if(typeof u.css==="string")u.css=i.resolve(l,u.css);if(u.serverApi)u.serverApi={...typeof u.serverApi==="object"?u.serverApi:{},dir:i.resolve(l,typeof u.serverApi==="object"?u.serverApi.dir??"server/api":"server/api")};if(s.push(u),d.extends!==void 0&&!Array.isArray(d.extends))throw Error(`extends in ${t} must be an array`);for(let y of d.extends??[])await g(E(y,l,r));p.pop()}await g(v(e),e);for(let t of["package.json","bun.lock","package-lock.json","pnpm-lock.yaml"]){let l=i.join(e,t);if(c.existsSync(l))r.add(c.realpathSync(l))}let f=b({},n);for(let t=s.length-1;t>=0;t--){let l=t===0?s[t]:Object.fromEntries(Object.entries(s[t]).filter(([d])=>!_.has(d)));f=b(f,l)}let m={layers:o,configDependencies:[...r].sort()};return f._layerGraph=m,f._layerPageDirs=o.map((t)=>t.resources.pages),f._layerComponentDirs=o.map((t)=>t.resources.components),f._layerLayoutDirs=o.map((t)=>t.resources.layouts),f._layerPartialDirs=o.map((t)=>t.resources.partials),f._layerComposableDirs=o.map((t)=>t.resources.composables),await go(m,e),{config:f,graph:m}}async function go(e,n){let r=new Map,o=[];for(let s of e.layers)for(let[a,p]of Object.entries(s.resources)){if(!c.existsSync(p))continue;let g=new Bun.Glob(a==="composables"?"**/*.ts":"**/*.stx");for(let f of[...g.scanSync({cwd:p})].sort()){let m=`${a}/${f}`,t=i.join(p,f),l=r.get(m);if(l)o.push({resource:m,winner:l,shadowed:t});else r.set(m,t)}}Object.assign(e,{overrides:o}),await Bun.write(i.join(n,".stx/layers.json"),JSON.stringify(e,null,2))}function A(e){let n=new Set(e.configDependencies);function r(o){if(!c.existsSync(o))return;n.add(o);for(let s of c.readdirSync(o,{withFileTypes:!0}).sort((a,p)=>a.name.localeCompare(p.name))){if(s.name.startsWith(".")||s.name==="node_modules")continue;let a=i.join(o,s.name);if(s.isDirectory())r(a);else if(s.isFile())n.add(a)}}for(let o of e.layers)for(let s of Object.values(o.resources))r(s);return[...n].sort()}function Gr(e){return O(A(e))}function Kr(e){return O(e.configDependencies)}function O(e){return e.map((n)=>{try{let r=c.statSync(n);return`${n}:${r.mtimeMs}:${r.size}`}catch{return`${n}:missing`}}).join(`
|
|
4
|
+
`)}function wa(e){return e.layers.map((n)=>({config:i.relative(n.root,n.configFile),files:A({layers:[n],configDependencies:e.configDependencies.filter((r)=>r.startsWith(`${n.root}${i.sep}`))}).filter((r)=>c.statSync(r).isFile()).map((r)=>({path:i.relative(n.root,r).replaceAll(i.sep,"/"),sha256:k("sha256").update(c.readFileSync(r)).digest("hex")}))}))}
|
|
5
|
+
export{ba,va,go,Gr,Kr,wa};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,a,Dt,Mt,Lt,Le,tt,P,xs,mr,je}from"./chunk-bk96wjaz.js";var O=/(?<![\w$@])@meta\s*\(/g,I=/(?<![\w$@])@metaTag\s*\(/g,C=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function _(e,r){return(n)=>P(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function N(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function mo(e,r,n,g){if(!e.includes("@meta"))return e;let i=Dt(e,O,(s,c)=>{let o=mr(Mt(s),r);if(o.kind==="tag")return N(o.tag);if(o.kind==="empty")return"";return P("Meta",c,o.message,n,o.code)},_("Meta",n));return i=Dt(i,I,(s,c)=>{let o=Lt(s,r);if(!o.ok)return P("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!tt(o.value))return P("MetaTag",c,`expected an object such as { name, content }, got ${Le(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return P("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let p="<meta";if(u.name)p+=` name="${l(u.name)}"`;if(u.property)p+=` property="${l(u.property)}"`;if(u.httpEquiv)p+=` http-equiv="${l(u.httpEquiv)}"`;return p+=` content="${l(u.content)}">`,p},_("MetaTag",n)),i}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(tt(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(tt))return e.map(r);return null}function E(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function ho(e,r,n){if(!e.includes("@structuredData"))return e;return Dt(e,C,(g,i)=>{let s=Lt(g,r);if(!s.ok)return P("StructuredData",i,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=b(s.value);if(!c)return P("StructuredData",i,`expected an object or an array of objects, got ${Le(s.value)}`,n,t.TYPE_ERROR);try{return E(c)}catch(o){let u=o instanceof Error?o.message:String(o);return P("StructuredData",i,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},_("StructuredData",n))}var j=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function yo(e,r,n,g){if(!e.includes("@seo"))return e;return Dt(e,k,(i,s)=>{if(!i.trim())return P("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Lt(i,r);if(!c.ok)return P("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!tt(c.value))return P("SEO",s,`expected an object such as { title, description }, got ${Le(c.value)}`,n,t.TYPE_ERROR);try{return L(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return P("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},_("SEO",n))}function R(e,r,n,g){let i=e[r];if(i===void 0||i===null||i===!1)return;if(tt(i))return i;xs(n,`${r} must be an object, got ${Le(i)}; its tags were left out`,g);return}function L(e,r,n){let g=Object.keys(e).filter((o)=>!j.has(o));if(g.length>0){let o=g.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");xs(r,`@seo does not read ${o}; ${g.length===1?"it was":"they were"} ignored`,n)}let i="";if(e.title)i+=`<title>${l(e.title)}</title>
|
|
3
|
+
`,i+=`<meta name="title" content="${l(e.title)}">
|
|
4
|
+
`;if(e.description)i+=`<meta name="description" content="${l(e.description)}">
|
|
5
|
+
`;if(e.keywords){let o=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;i+=`<meta name="keywords" content="${l(o)}">
|
|
6
|
+
`}if(e.robots)i+=`<meta name="robots" content="${l(e.robots)}">
|
|
7
|
+
`;if(e.canonical)i+=`<link rel="canonical" href="${l(e.canonical)}">
|
|
8
|
+
`;let s=R(e,"openGraph",r,n);if(s){if(i+=`<meta property="og:type" content="${l(s.type||"website")}">
|
|
9
|
+
`,s.title||e.title){let o=s.title||e.title||"";i+=`<meta property="og:title" content="${l(o)}">
|
|
10
|
+
`}if(s.description||e.description){let o=s.description||e.description||"";i+=`<meta property="og:description" content="${l(o)}">
|
|
11
|
+
`}if(s.url||e.canonical){let o=s.url||e.canonical||"";i+=`<meta property="og:url" content="${l(o)}">
|
|
12
|
+
`}if(s.image){if(i+=`<meta property="og:image" content="${l(s.image)}">
|
|
13
|
+
`,s.imageAlt)i+=`<meta property="og:image:alt" content="${l(s.imageAlt)}">
|
|
14
|
+
`;if(s.imageWidth)i+=`<meta property="og:image:width" content="${l(String(s.imageWidth))}">
|
|
15
|
+
`;if(s.imageHeight)i+=`<meta property="og:image:height" content="${l(String(s.imageHeight))}">
|
|
16
|
+
`;if(s.imageType)i+=`<meta property="og:image:type" content="${l(s.imageType)}">
|
|
17
|
+
`}if(s.siteName)i+=`<meta property="og:site_name" content="${l(s.siteName)}">
|
|
18
|
+
`;if(s.locale)i+=`<meta property="og:locale" content="${l(s.locale)}">
|
|
19
|
+
`;if(s.profile){let o=[["first_name",s.profile.firstName],["last_name",s.profile.lastName],["username",s.profile.username],["gender",s.profile.gender]];for(let[u,p]of o)if(p)i+=`<meta property="profile:${u}" content="${l(p)}">
|
|
20
|
+
`}}let c=R(e,"twitter",r,n);if(c){if(i+=`<meta name="twitter:card" content="${l(c.card||"summary_large_image")}">
|
|
21
|
+
`,c.title||e.title){let o=c.title||e.title||"";i+=`<meta name="twitter:title" content="${l(o)}">
|
|
22
|
+
`}if(c.description||e.description){let o=c.description||e.description||"";i+=`<meta name="twitter:description" content="${l(o)}">
|
|
23
|
+
`}if(c.image||s&&s.image){let o=c.image||(s?s.image:"")||"";i+=`<meta name="twitter:image" content="${l(o)}">
|
|
24
|
+
`;let u=c.imageAlt||(!c.image&&s?s.imageAlt:void 0);if(u)i+=`<meta name="twitter:image:alt" content="${l(u)}">
|
|
25
|
+
`}if(c.site)i+=`<meta name="twitter:site" content="${l(c.site)}">
|
|
26
|
+
`;if(c.creator)i+=`<meta name="twitter:creator" content="${l(c.creator)}">
|
|
27
|
+
`}if(e.structuredData!==void 0&&e.structuredData!==null){let o=b(e.structuredData);if(o)i+=`${E(o)}
|
|
28
|
+
`;else xs(r,`structuredData must be an object or an array of objects, got ${Le(e.structuredData)}; it was left out`,n)}return i.trim()}function bo(e,r,n){if(n.seo?.enabled===!1)return e;if(e.includes("<!-- stx SEO Tags -->")||r.__stx_seo_staged===!0||n.skipDefaultSeoTags===!0)return e;let g=r.__stx_runtime_head;if(!!(g?.title||g?.meta?.some((S)=>S.property==="og:title"||S.name==="og:title"||S.name==="twitter:title"||S.name==="description")))return e;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test(e))return e;if(!e.includes("<head>")&&!e.includes("<head "))return e;let s=e.includes("<title>")||e.includes("</title>"),c=q(e),o=M(c),u=G(c),p="";if(r.title)p=r.title;else if(r.meta&&r.meta.title)p=r.meta.title;else if(o)p=o;else if(n.seo?.defaultConfig?.title)p=n.seo.defaultConfig.title;else p=n.defaultTitle||"stx Project";let m="";if(r.description)m=r.description;else if(r.meta&&r.meta.description)m=r.meta.description;else if(u)m=u;else if(n.seo?.defaultConfig?.description)m=n.seo.defaultConfig.description;else m=n.defaultDescription||"A website built with stx templating engine";let d="";if(r.image)d=r.image;else if(r.meta&&r.meta.image)d=r.meta.image;else if(r.openGraph&&r.openGraph.image)d=r.openGraph.image;else if(n.seo?.defaultImage)d=n.seo.defaultImage;else if(n.defaultImage)d=n.defaultImage;let f=s?"":`
|
|
29
|
+
<meta name="title" content="${l(p)}">`,D=V(c)?"":`
|
|
30
|
+
<meta name="description" content="${l(m)}">`,y=`
|
|
31
|
+
<!-- stx SEO Tags -->${f}${D}
|
|
32
|
+
<meta property="og:title" content="${l(p)}">
|
|
33
|
+
<meta property="og:description" content="${l(m)}">
|
|
34
|
+
<meta property="og:type" content="website">
|
|
35
|
+
<meta name="twitter:card" content="summary_large_image">
|
|
36
|
+
<meta name="twitter:title" content="${l(p)}">
|
|
37
|
+
<meta name="twitter:description" content="${l(m)}">
|
|
38
|
+
`;if(d)y+=`
|
|
39
|
+
<meta property="og:image" content="${l(d)}">
|
|
40
|
+
<meta name="twitter:image" content="${l(d)}">
|
|
41
|
+
`;let h=e;if(!s)h=h.replace(/<head[^>]*>/,`$&
|
|
42
|
+
<title>${l(p)}</title>`);let w=r.__stx_head_injections;if(w)return r.__stx_seo_staged=!0,w.afterOpen.push(`
|
|
43
|
+
${y}
|
|
44
|
+
`),h;return h.replace(/<head[^>]*>/,`$&
|
|
45
|
+
${y}
|
|
46
|
+
`)}function q(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�*39;|'/g,"'").replace(/&/g,"&")}function M(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function V(e){return x(e).length>0}function G(e){for(let r of x(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(n?.[1]??n?.[2]??"").trim();if(g)return v(g)}return""}function l(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var Xr={name:"meta",rawParams:!0,handler:(e,r,n,g)=>{let i=mr(r,n??{});if(i.kind==="error")return P("Meta",`@meta(${r.join(", ")})`,i.message,g,i.code);if(i.kind==="empty")return"";if(n)n.__stx_runtime_head=je(n.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},Jr={name:"structuredData",handler:(e,r,n,g)=>{if(e.trim()==="")return a("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return a("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return E(i)}catch(i){let s=i instanceof Error?i.message:String(i);return a("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function kp(){return[Xr,Jr]}function _p(e,r){let{baseUrl:n,defaultChangefreq:g="weekly",defaultPriority:i=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,""),o=(m)=>m.startsWith("http")?m:`${c}${m.startsWith("/")?"":"/"}${m}`,u=e.map((m)=>{let d=o(m.loc),f=m.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??i,h=` <url>
|
|
47
|
+
<loc>${T(d)}</loc>`;for(let w of m.alternates??[])h+=`
|
|
48
|
+
<xhtml:link rel="alternate" hreflang="${T(w.hreflang)}" href="${T(o(w.href))}"/>`;if(f)h+=`
|
|
49
|
+
<lastmod>${f}</lastmod>`;return h+=`
|
|
50
|
+
<changefreq>${D}</changefreq>`,h+=`
|
|
51
|
+
<priority>${y.toFixed(1)}</priority>`,h+=`
|
|
52
|
+
</url>`,h});return`<?xml version="1.0" encoding="UTF-8"?>
|
|
53
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${e.some((m)=>m.alternates?.length)?' xmlns:xhtml="http://www.w3.org/1999/xhtml"':""}>
|
|
54
|
+
${u.join(`
|
|
55
|
+
`)}
|
|
56
|
+
</urlset>`}function Cp(e,r){let n=r.replace(/\/$/,""),g=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
|
|
57
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
58
|
+
${e.map((s)=>{let c=s.startsWith("http")?s:`${n}${s.startsWith("/")?"":"/"}${s}`;return` <sitemap>
|
|
59
|
+
<loc>${T(c)}</loc>
|
|
60
|
+
<lastmod>${g}</lastmod>
|
|
61
|
+
</sitemap>`}).join(`
|
|
62
|
+
`)}
|
|
63
|
+
</sitemapindex>`}async function Ep(e,r){let{extensions:n=[".stx",".html",".htm"],ignore:g=["_*",".*","node_modules","components","partials","layouts"]}=r,i=[],s=n.length===1?`*${n[0]}`:`*{${n.join(",")}}`,c=new Bun.Glob(`**/${s}`);for await(let o of c.scan(e)){if(g.some((f)=>{if(f.startsWith("*"))return o.includes(f.slice(1));return o.startsWith(f)||o.includes(`/${f}`)}))continue;let p=o.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!p.startsWith("/"))p=`/${p}`;if(p!=="/"&&p.endsWith("/"))p=p.slice(0,-1);let m=`${e}/${o}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}i.push({loc:p||"/",lastmod:d,priority:p==="/"?1:0.5})}return i.sort((o,u)=>o.loc.localeCompare(u.loc)),i}function Yr(e){let r=[];for(let n of e.rules){if(r.push(`User-agent: ${n.userAgent}`),n.allow)for(let g of n.allow)r.push(`Allow: ${g}`);if(n.disallow)for(let g of n.disallow)r.push(`Disallow: ${g}`);if(n.crawlDelay!==void 0)r.push(`Crawl-delay: ${n.crawlDelay}`);r.push("")}if(e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let g of n)r.push(`Sitemap: ${g}`)}if(e.host)r.push(`Host: ${e.host}`);return r.join(`
|
|
64
|
+
`).trim()}function Tp(e){return Yr({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
|
|
65
|
+
export{mo,ho,yo,bo,Xr,Jr,kp,_p,Cp,Ep,Yr,Tp};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$u}from"./chunk-pfk9ffbz.js";import"./chunk-ma7d95f0.js";import"./chunk-myq3hrww.js";import"./chunk-vac56rgd.js";import"./chunk-yfrvbnc6.js";import"./chunk-pw9bhdaz.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-0jq3w712.js";import"./chunk-vgt9f7ac.js";import"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{$u as startProductionServer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{mo,ho,yo,bo,Xr,Jr,kp,_p,Cp,Ep,Yr,Tp}from"./chunk-0jq3w712.js";import"./chunk-bk96wjaz.js";export{Tp as generateDefaultRobotsTxt,Yr as generateRobotsTxt,_p as generateSitemap,Cp as generateSitemapIndex,bo as injectSeoTags,Xr as metaDirective,mo as processMetaDirectives,yo as processSeoDirective,ho as processStructuredData,kp as registerSeoDirectives,Ep as scanForSitemapEntries,Jr as structuredDataDirective};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ot,it,at}from"./chunk-jkvr7e91.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{f}from"./chunk-w1v1d7rq.js";import"./chunk-bk96wjaz.js";import"./chunk-5t4qtxgr.js";import"./chunk-pdc9s7bg.js";import{Bt,$s,Ft,ai,st,ci,Rs,zt,ui,Ht}from"./chunk-4yf1w261.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{ci("Config file changed, restarting...");try{await e.onChange()}catch(p){st(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var ct=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,ct),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -223,7 +223,7 @@ else {
|
|
|
223
223
|
}
|
|
224
224
|
})();
|
|
225
225
|
</script>
|
|
226
|
-
`}var L=[{key:"k",modifiers:["meta"],description:"Open search",category:"Navigation",action:"openSearch"},{key:"ArrowUp",description:"Previous story",category:"Navigation",action:"prevStory"},{key:"ArrowDown",description:"Next story",category:"Navigation",action:"nextStory"},{key:"ArrowLeft",description:"Previous variant",category:"Navigation",action:"prevVariant"},{key:"ArrowRight",description:"Next variant",category:"Navigation",action:"nextVariant"},{key:"Enter",description:"Select story",category:"Navigation",action:"selectStory"},{key:"Escape",description:"Close panel/modal",category:"Navigation",action:"closePanel"},{key:"d",description:"Toggle dark mode",category:"View",action:"toggleDarkMode"},{key:"f",description:"Toggle fullscreen",category:"View",action:"toggleFullscreen"},{key:"s",description:"Toggle sidebar",category:"View",action:"toggleSidebar"},{key:"a",description:"Toggle addons panel",category:"View",action:"toggleAddons"},{key:"z",description:"Zoom in",category:"View",action:"zoomIn"},{key:"x",description:"Zoom out",category:"View",action:"zoomOut"},{key:"0",description:"Reset zoom",category:"View",action:"resetZoom"},{key:"r",description:"Reload story",category:"Actions",action:"reloadStory"},{key:"c",description:"Copy story code",category:"Actions",action:"copyCode"},{key:"p",description:"Open props panel",category:"Actions",action:"openProps"},{key:"b",description:"Toggle bookmark",category:"Actions",action:"toggleBookmark"},{key:"t",description:"Run tests",category:"Actions",action:"runTests"},{key:"?",description:"Show shortcuts",category:"Help",action:"showShortcuts"}];function
|
|
226
|
+
`}var L=[{key:"k",modifiers:["meta"],description:"Open search",category:"Navigation",action:"openSearch"},{key:"ArrowUp",description:"Previous story",category:"Navigation",action:"prevStory"},{key:"ArrowDown",description:"Next story",category:"Navigation",action:"nextStory"},{key:"ArrowLeft",description:"Previous variant",category:"Navigation",action:"prevVariant"},{key:"ArrowRight",description:"Next variant",category:"Navigation",action:"nextVariant"},{key:"Enter",description:"Select story",category:"Navigation",action:"selectStory"},{key:"Escape",description:"Close panel/modal",category:"Navigation",action:"closePanel"},{key:"d",description:"Toggle dark mode",category:"View",action:"toggleDarkMode"},{key:"f",description:"Toggle fullscreen",category:"View",action:"toggleFullscreen"},{key:"s",description:"Toggle sidebar",category:"View",action:"toggleSidebar"},{key:"a",description:"Toggle addons panel",category:"View",action:"toggleAddons"},{key:"z",description:"Zoom in",category:"View",action:"zoomIn"},{key:"x",description:"Zoom out",category:"View",action:"zoomOut"},{key:"0",description:"Reset zoom",category:"View",action:"resetZoom"},{key:"r",description:"Reload story",category:"Actions",action:"reloadStory"},{key:"c",description:"Copy story code",category:"Actions",action:"copyCode"},{key:"p",description:"Open props panel",category:"Actions",action:"openProps"},{key:"b",description:"Toggle bookmark",category:"Actions",action:"toggleBookmark"},{key:"t",description:"Run tests",category:"Actions",action:"runTests"},{key:"?",description:"Show shortcuts",category:"Help",action:"showShortcuts"}];function gt(t){let e=[];if(t.modifiers)for(let s of t.modifiers)switch(s){case"meta":e.push("\u2318");break;case"ctrl":e.push("Ctrl");break;case"alt":e.push("Alt");break;case"shift":e.push("\u21E7");break}let r=t.key;switch(r){case"ArrowUp":r="\u2191";break;case"ArrowDown":r="\u2193";break;case"ArrowLeft":r="\u2190";break;case"ArrowRight":r="\u2192";break;case"Enter":r="\u21B5";break;case"Escape":r="Esc";break;default:r=r.toUpperCase()}return e.push(r),e.join(" + ")}function D(t=L){let e=new Map;for(let s of t){let o=e.get(s.category)||[];o.push(s),e.set(s.category,o)}return`
|
|
227
227
|
<div class="shortcuts-modal" id="shortcuts-modal" style="display: none;">
|
|
228
228
|
<div class="shortcuts-backdrop" onclick="closeShortcutsModal()"></div>
|
|
229
229
|
<div class="shortcuts-content">
|
|
@@ -239,7 +239,7 @@ else {
|
|
|
239
239
|
${o.map((a)=>`
|
|
240
240
|
<div class="shortcut-item">
|
|
241
241
|
<span class="shortcut-desc">${a.description}</span>
|
|
242
|
-
<kbd class="shortcut-key">${
|
|
242
|
+
<kbd class="shortcut-key">${gt(a)}</kbd>
|
|
243
243
|
</div>
|
|
244
244
|
`).join("")}
|
|
245
245
|
</div>
|
|
@@ -487,7 +487,7 @@ else {
|
|
|
487
487
|
window.__stxShortcuts.init();
|
|
488
488
|
}
|
|
489
489
|
</script>
|
|
490
|
-
`}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var
|
|
490
|
+
`}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var Xt=new J;function G(){return`
|
|
491
491
|
<script>
|
|
492
492
|
window.__stxPerformance = {
|
|
493
493
|
metrics: new Map(),
|
|
@@ -556,9 +556,9 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-cs0dd5w8.js"),p={},u=h(n);if(u)try{await f(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await f(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-cs0dd5w8.js"),c={...r},n=h(e);if(n)try{await f(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
|
-
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await
|
|
561
|
+
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await zt(t);it(t,r);let s=Ht(t.config,r);at(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let g=new URL(i.url).pathname;if(g==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(g.startsWith("/api/"))return xt(t,g,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,g,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=ui(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await zt(t);it(t,m);let g=Ht(t.config,m);if(at(t,g),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
563
563
|
<head>
|
|
564
564
|
<meta charset="UTF-8">
|
|
@@ -1276,5 +1276,5 @@ else {
|
|
|
1276
1276
|
<style>${W()}</style>
|
|
1277
1277
|
${D()}
|
|
1278
1278
|
</body>
|
|
1279
|
-
</html>`}import
|
|
1280
|
-
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":
|
|
1279
|
+
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function nt(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Bt();let e=await ot({mode:"dev"});if(!e.config.enabled){st("Story feature is disabled in config.");return}await nt(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),Ft(e.storyFiles.length),$s(s.url),Rs()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await ot({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
|
|
1280
|
+
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":Rs();break;case"o":try{let{exec:p}=await import("child_process"),u=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${u} ${s.url}`)}catch{ai("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Bt(),Ft(e.storyFiles.length),$s(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we as devCommand};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var us=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);async function ei(e,t={}){let r=performance.now(),n={target:t.target||"universal",format:t.format||"zig",optimize:t.optimize??!0,treeShake:t.treeShake??!0,hotReload:t.hotReload??!1,debug:t.debug??!1,sourceMaps:t.sourceMaps??!1,bundle:t.bundle??!0,minify:t.minify??!1,components:t.components||us},i=typeof e==="string"?w(e):e,o=I(i.tree,n),s=L(o),a=n.treeShake?O(o,s):o,l=new Map;if(n.target==="universal"){let c=["macos","windows","linux","ios","android"];for(let g of c){let q=u(a,{...n,target:g});l.set(g,q)}}else{let c=u(a,n);l.set(n.target,c)}let p=H(a,n,l),S=_(i,a,n),k={compilationTime:performance.now()-r,totalComponents:f(i.tree),nativeComponents:d(a),webComponents:f(i.tree)-d(a),bundleSize:p.length,treeShakenSize:n.treeShake?W(o,a):p.length,warnings:[],errors:[]},m;if(n.sourceMaps)m=B(i,a);return{code:p,platformCode:l,dependencies:s,manifest:S,sourceMaps:m,stats:k}}function w(e){let t={type:"fragment",children:[]},r=e.match(/<body[^>]*>([\s\S]*?)<\/body>/i),n=r?r[1]:e;return b(n,t),{id:T(),hash:x(e),tree:t,scripts:U(e),styles:Z(e),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:e.includes("{{"),hasEventHandlers:e.includes("onclick")||e.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:e.length}}}function b(e,t){let r=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,n;while((n=r.exec(e))!==null){let[,i,o,s]=n,a=i.startsWith("@craft-"),l={type:a?"component":"element",tag:a?i.slice(1):i,props:z(o),children:[],componentName:a?i.slice(1):void 0};if(s){let p=s.replace(/<[^>]+>/g,"").trim();if(p)l.children=l.children??[],l.children.push({type:"text",text:p});b(s,l)}t.children=t.children??[],t.children.push(l)}}function z(e){let t={},r=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,n;while((n=r.exec(e))!==null){let[,i,o]=n;t[i]=o??!0}return t}function I(e,t){return h(e,t)}function h(e,t){let r=e.componentName?t.components?.get(e.componentName):void 0,n="craft.View";if(r)n=r.zigType;else if(e.type==="text")n="craft.Text";else if(e.tag)n=R(e.tag);let i={};if(e.props)for(let[l,p]of Object.entries(e.props))i[l]=M(p);let o=[];if(e.children)for(let l of e.children)o.push(h(l,t));let s=new Map;if(e.props){for(let[l,p]of Object.entries(e.props))if(l.startsWith("on")&&typeof p==="string")s.set(l.slice(2).toLowerCase(),p)}let a=V(e);return{type:A(e,r),zigType:n,props:i,children:o,events:s,styles:a,id:e.hydrationKey,key:e.props?.key}}function R(e){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[e.toLowerCase()]||"craft.View"}function M(e){if(typeof e==="string"){if(e.startsWith("{{")&&e.endsWith("}}"))return{type:"binding",path:e.slice(2,-2).trim()};if(e.includes("(")&&e.includes(")"))return{type:"callback",handler:e};return{type:"literal",value:e}}if(typeof e==="number"||typeof e==="boolean")return{type:"literal",value:e};return{type:"literal",value:String(e)}}function A(e,t){if(t){let n=t.name.toLowerCase();if(n.includes("button"))return"button";if(n.includes("input")||n.includes("text"))return"input";if(n.includes("image")||n.includes("avatar"))return"image";if(n.includes("list")||n.includes("table"))return"list";if(n.includes("scroll"))return"scroll";return"custom"}if(e.type==="text")return"text";let r=e.tag?.toLowerCase();if(r==="button")return"button";if(r==="input"||r==="textarea")return"input";if(r==="img")return"image";if(r==="ul"||r==="ol")return"list";return"view"}function V(e){let t=e.props?.style,r={},n={};if(t){let i=t.split(";").filter(Boolean);for(let o of i){let[s,a]=o.split(":").map((l)=>l.trim());if(!s||!a)continue;switch(s){case"display":r.display=a;break;case"flex-direction":r.flexDirection=a;break;case"justify-content":r.justifyContent=j(a);break;case"align-items":r.alignItems=D(a);break;case"gap":r.gap=Number.parseInt(a,10);break;case"padding":r.padding=Number.parseInt(a,10);break;case"margin":r.margin=Number.parseInt(a,10);break;case"width":r.width=a==="auto"?"auto":Number.parseInt(a,10);break;case"height":r.height=a==="auto"?"auto":Number.parseInt(a,10);break;case"background-color":case"background":n.backgroundColor=a;break;case"border-color":n.borderColor=a;break;case"border-width":n.borderWidth=Number.parseInt(a,10);break;case"border-radius":n.borderRadius=Number.parseInt(a,10);break;case"opacity":n.opacity=Number.parseFloat(a);break}}}return{layout:r,appearance:n}}function j(e){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[e]||"start"}function D(e){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[e]||"start"}function L(e){let t=[],r=new Set;function n(i,o){let s=i.id||T();if(r.has(s))return;r.add(s);let a={id:s,type:"component",path:i.zigType,dependencies:o?[o]:[],size:C(i),isStatic:P(i)};t.push(a);for(let l of i.children)n(l,s)}return n(e),t}function C(e){let t=100;return t+=Object.keys(e.props).length*20,t+=e.events.size*50,t}function P(e){for(let t of Object.values(e.props))if(t.type!=="literal")return!1;return e.events.size===0}function O(e,t){return e}function W(e,t){let r=0;function n(i){r+=C(i);for(let o of i.children)n(o)}return n(t),r}function u(e,t){switch(t.format){case"zig":return y(e,t);case"typescript":return E(e,t);case"json":return JSON.stringify(e,null,t.minify?0:2);default:return y(e,t)}}function y(e,t){let r=[];return r.push("// Auto-generated by stx compiler"),r.push("// Target: "+t.target),r.push(""),r.push('const std = @import("std");'),r.push('const craft = @import("craft");'),r.push(""),r.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),r.push(" return try build(allocator);"),r.push("}"),r.push(""),N(e,r,0),r.join(`
|
|
2
|
+
var Ws=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);async function qi(e,t={}){let r=performance.now(),n={target:t.target||"universal",format:t.format||"zig",optimize:t.optimize??!0,treeShake:t.treeShake??!0,hotReload:t.hotReload??!1,debug:t.debug??!1,sourceMaps:t.sourceMaps??!1,bundle:t.bundle??!0,minify:t.minify??!1,components:t.components||Ws},i=typeof e==="string"?w(e):e,o=I(i.tree,n),s=L(o),a=n.treeShake?O(o,s):o,l=new Map;if(n.target==="universal"){let c=["macos","windows","linux","ios","android"];for(let g of c){let q=u(a,{...n,target:g});l.set(g,q)}}else{let c=u(a,n);l.set(n.target,c)}let p=H(a,n,l),S=_(i,a,n),k={compilationTime:performance.now()-r,totalComponents:f(i.tree),nativeComponents:d(a),webComponents:f(i.tree)-d(a),bundleSize:p.length,treeShakenSize:n.treeShake?W(o,a):p.length,warnings:[],errors:[]},m;if(n.sourceMaps)m=B(i,a);return{code:p,platformCode:l,dependencies:s,manifest:S,sourceMaps:m,stats:k}}function w(e){let t={type:"fragment",children:[]},r=e.match(/<body[^>]*>([\s\S]*?)<\/body>/i),n=r?r[1]:e;return b(n,t),{id:T(),hash:x(e),tree:t,scripts:U(e),styles:Z(e),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:e.includes("{{"),hasEventHandlers:e.includes("onclick")||e.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:e.length}}}function b(e,t){let r=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,n;while((n=r.exec(e))!==null){let[,i,o,s]=n,a=i.startsWith("@craft-"),l={type:a?"component":"element",tag:a?i.slice(1):i,props:z(o),children:[],componentName:a?i.slice(1):void 0};if(s){let p=s.replace(/<[^>]+>/g,"").trim();if(p)l.children=l.children??[],l.children.push({type:"text",text:p});b(s,l)}t.children=t.children??[],t.children.push(l)}}function z(e){let t={},r=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,n;while((n=r.exec(e))!==null){let[,i,o]=n;t[i]=o??!0}return t}function I(e,t){return h(e,t)}function h(e,t){let r=e.componentName?t.components?.get(e.componentName):void 0,n="craft.View";if(r)n=r.zigType;else if(e.type==="text")n="craft.Text";else if(e.tag)n=R(e.tag);let i={};if(e.props)for(let[l,p]of Object.entries(e.props))i[l]=M(p);let o=[];if(e.children)for(let l of e.children)o.push(h(l,t));let s=new Map;if(e.props){for(let[l,p]of Object.entries(e.props))if(l.startsWith("on")&&typeof p==="string")s.set(l.slice(2).toLowerCase(),p)}let a=V(e);return{type:A(e,r),zigType:n,props:i,children:o,events:s,styles:a,id:e.hydrationKey,key:e.props?.key}}function R(e){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[e.toLowerCase()]||"craft.View"}function M(e){if(typeof e==="string"){if(e.startsWith("{{")&&e.endsWith("}}"))return{type:"binding",path:e.slice(2,-2).trim()};if(e.includes("(")&&e.includes(")"))return{type:"callback",handler:e};return{type:"literal",value:e}}if(typeof e==="number"||typeof e==="boolean")return{type:"literal",value:e};return{type:"literal",value:String(e)}}function A(e,t){if(t){let n=t.name.toLowerCase();if(n.includes("button"))return"button";if(n.includes("input")||n.includes("text"))return"input";if(n.includes("image")||n.includes("avatar"))return"image";if(n.includes("list")||n.includes("table"))return"list";if(n.includes("scroll"))return"scroll";return"custom"}if(e.type==="text")return"text";let r=e.tag?.toLowerCase();if(r==="button")return"button";if(r==="input"||r==="textarea")return"input";if(r==="img")return"image";if(r==="ul"||r==="ol")return"list";return"view"}function V(e){let t=e.props?.style,r={},n={};if(t){let i=t.split(";").filter(Boolean);for(let o of i){let[s,a]=o.split(":").map((l)=>l.trim());if(!s||!a)continue;switch(s){case"display":r.display=a;break;case"flex-direction":r.flexDirection=a;break;case"justify-content":r.justifyContent=j(a);break;case"align-items":r.alignItems=D(a);break;case"gap":r.gap=Number.parseInt(a,10);break;case"padding":r.padding=Number.parseInt(a,10);break;case"margin":r.margin=Number.parseInt(a,10);break;case"width":r.width=a==="auto"?"auto":Number.parseInt(a,10);break;case"height":r.height=a==="auto"?"auto":Number.parseInt(a,10);break;case"background-color":case"background":n.backgroundColor=a;break;case"border-color":n.borderColor=a;break;case"border-width":n.borderWidth=Number.parseInt(a,10);break;case"border-radius":n.borderRadius=Number.parseInt(a,10);break;case"opacity":n.opacity=Number.parseFloat(a);break}}}return{layout:r,appearance:n}}function j(e){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[e]||"start"}function D(e){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[e]||"start"}function L(e){let t=[],r=new Set;function n(i,o){let s=i.id||T();if(r.has(s))return;r.add(s);let a={id:s,type:"component",path:i.zigType,dependencies:o?[o]:[],size:C(i),isStatic:P(i)};t.push(a);for(let l of i.children)n(l,s)}return n(e),t}function C(e){let t=100;return t+=Object.keys(e.props).length*20,t+=e.events.size*50,t}function P(e){for(let t of Object.values(e.props))if(t.type!=="literal")return!1;return e.events.size===0}function O(e,t){return e}function W(e,t){let r=0;function n(i){r+=C(i);for(let o of i.children)n(o)}return n(t),r}function u(e,t){switch(t.format){case"zig":return y(e,t);case"typescript":return E(e,t);case"json":return JSON.stringify(e,null,t.minify?0:2);default:return y(e,t)}}function y(e,t){let r=[];return r.push("// Auto-generated by stx compiler"),r.push("// Target: "+t.target),r.push(""),r.push('const std = @import("std");'),r.push('const craft = @import("craft");'),r.push(""),r.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),r.push(" return try build(allocator);"),r.push("}"),r.push(""),N(e,r,0),r.join(`
|
|
3
3
|
`)}function N(e,t,r){let n=" ".repeat(r);if(r===0)t.push("fn build(allocator: std.mem.Allocator) !craft.Element {");let i=`node_${r}`;t.push(`${n} var ${i} = try ${e.zigType}.init(allocator);`);for(let[o,s]of Object.entries(e.props))if(s.type==="literal"){let a=typeof s.value==="string"?`"${s.value}"`:String(s.value);t.push(`${n} ${i}.set${J(o)}(${a});`)}for(let o=0;o<e.children.length;o++){let s=e.children[o];if(s.type==="text"){let a=s.props.text?.type==="literal"?String(s.props.text.value):"";t.push(`${n} try ${i}.addChild(try craft.Text.init(allocator, "${a}"));`)}else N(s,t,r+1),t.push(`${n} try ${i}.addChild(node_${r+1});`)}if(r===0)t.push(` return ${i}.element();`),t.push("}")}function E(e,t){let r=[];return r.push("// Auto-generated by stx compiler"),r.push("// Target: "+t.target),r.push(""),r.push('import { Craft } from "@stacksjs/craft";'),r.push(""),r.push("export function render(): Craft.Element {"),r.push(" return "+v(e,1)+";"),r.push("}"),r.join(`
|
|
4
4
|
`)}function v(e,t){let r=" ".repeat(t),n=[];for(let[a,l]of Object.entries(e.props))if(l.type==="literal"){let p=typeof l.value==="string"?`"${l.value}"`:String(l.value);n.push(`${a}: ${p}`)}let i=n.length>0?`{ ${n.join(", ")} }`:"{}",o=e.children.map((a)=>a.type==="text"?`"${a.props.text?.type==="literal"?a.props.text.value:""}"`:v(a,t+1)),s=o.length>0?`,
|
|
5
5
|
${r} [${o.join(`,
|
|
6
6
|
${r} `)}]`:"";return`Craft.create("${e.zigType}", ${i}${s})`}function H(e,t,r){if(t.target==="universal"){let n=[];n.push("// Universal entry point"),n.push("");for(let[i,o]of r)n.push(`// --- ${i.toUpperCase()} ---`),n.push(`#if ${i.toUpperCase()}`),n.push(o),n.push("#endif"),n.push("");return n.join(`
|
|
7
|
-
`)}return r.get(t.target)||u(e,t)}function _(e,t,r){let n=[];function i(o){n.push({name:o.zigType,hash:x(JSON.stringify(o.props)),props:Object.keys(o.props),events:Array.from(o.events.keys()),slots:[],isNative:o.zigType.startsWith("craft.")});for(let s of o.children)i(s)}return i(t),{version:"1.0.0",components:n,entry:e.id,assets:[],styles:e.styles}}function B(e,t){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}var F=0;function T(){return`id_${++F}`}function x(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return Math.abs(t).toString(36)}function J(e){return e.charAt(0).toUpperCase()+e.slice(1)}function U(e){let t=[],r=/<script[^>]*>([\s\S]*?)<\/script>/gi,n;while((n=r.exec(e))!==null)t.push(n[1]);return t}function Z(e){let t=[],r=/<style[^>]*>([\s\S]*?)<\/style>/gi,n;while((n=r.exec(e))!==null)t.push(n[1]);return t}function f(e){let t=e.type==="component"?1:0;if(e.children)for(let r of e.children)t+=f(r);return t}function d(e){let t=e.zigType.startsWith("craft.")?1:0;for(let r of e.children)t+=d(r);return t}function
|
|
8
|
-
export{
|
|
7
|
+
`)}return r.get(t.target)||u(e,t)}function _(e,t,r){let n=[];function i(o){n.push({name:o.zigType,hash:x(JSON.stringify(o.props)),props:Object.keys(o.props),events:Array.from(o.events.keys()),slots:[],isNative:o.zigType.startsWith("craft.")});for(let s of o.children)i(s)}return i(t),{version:"1.0.0",components:n,entry:e.id,assets:[],styles:e.styles}}function B(e,t){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}var F=0;function T(){return`id_${++F}`}function x(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return Math.abs(t).toString(36)}function J(e){return e.charAt(0).toUpperCase()+e.slice(1)}function U(e){let t=[],r=/<script[^>]*>([\s\S]*?)<\/script>/gi,n;while((n=r.exec(e))!==null)t.push(n[1]);return t}function Z(e){let t=[],r=/<style[^>]*>([\s\S]*?)<\/style>/gi,n;while((n=r.exec(e))!==null)t.push(n[1]);return t}function f(e){let t=e.type==="component"?1:0;if(e.children)for(let r of e.children)t+=f(r);return t}function d(e){let t=e.zigType.startsWith("craft.")?1:0;for(let r of e.children)t+=d(r);return t}function Gi(e){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(t)=>{console.log(`[craft-compiler] File changed: ${t}`)}}}var K={compileToNative:qi,createHotReloadServer:Gi,NATIVE_COMPONENTS:Ws},np=K;
|
|
8
|
+
export{Ws,qi,Gi,np};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ll,ul,ke,dl,Qi,Gt,Kt,rp,ea,Xt,Fn,pl,fl,gl,qs,Jt,ml,Yt,hl}from"./chunk-wzgn9fv7.js";import"./chunk-myq3hrww.js";import"./chunk-9y2ncrnq.js";import"./chunk-yfrvbnc6.js";import"./chunk-pw9bhdaz.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-0jq3w712.js";import"./chunk-vgt9f7ac.js";import"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Fn as MODULE_SPECIFIER_PREFIX,ll as bundleCacheDir,ul as bundleCacheEntryLimit,Yt as bundleClientScript,Kt as clearBundleFailures,ke as clientBundleDependencies,Gt as getBundleFailures,Xt as hasUserImports,Jt as moduleSubstitutionKey,fl as normalizeRegistrySpecifiers,ml as queueClientBundleBuild,Qi as recordBundleFailure,pl as registryIdForPath,ea as resolveBundlerFallback,gl as rewriteRegistryImports,rp as setBundlerFallbackMode,dl as shouldLogBundlerDiagnostics,hl as tempBuildName,qs as withModuleSubstitutes};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{xc,Sc}from"./chunk-ajv5xmjx.js";import"./chunk-3ghbxena.js";import"./chunk-pfk9ffbz.js";import"./chunk-rjh2jwxx.js";import"./chunk-a8j91pqz.js";import"./chunk-shkysa02.js";import"./chunk-zqtbtqbq.js";import"./chunk-c7fs96n6.js";import{_i}from"./chunk-ma7d95f0.js";import"./chunk-jxda11cg.js";import"./chunk-jsb4pvj1.js";import"./chunk-zevx9866.js";import"./chunk-rcadtv3x.js";import"./chunk-ar22s1e1.js";import"./chunk-x8k64g1e.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-b0vhe6d4.js";import"./chunk-tre98h62.js";import"./chunk-aah6csjm.js";import"./chunk-dgb4z4kw.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-aprhqxky.js";import"./chunk-kgfgb971.js";import"./chunk-nrvwejdw.js";import"./chunk-hgy4c6mm.js";import"./chunk-9z9jtwct.js";import"./chunk-fg3jw17w.js";import"./chunk-b07djygp.js";import"./chunk-gc9ftf7r.js";import"./chunk-6ajahb2x.js";import"./chunk-wzgn9fv7.js";import"./chunk-myq3hrww.js";import"./chunk-9y2ncrnq.js";import{Ce,s}from"./chunk-dpjnjs09.js";import"./chunk-74pej67a.js";import"./chunk-prf164ct.js";import"./chunk-rb5xdcen.js";import"./chunk-55x799st.js";import"./chunk-nph4d1ff.js";import"./chunk-asqnaddf.js";import"./chunk-xnjf1zbn.js";import{me}from"./chunk-vac56rgd.js";import"./chunk-3e7haxwt.js";import{Xn,Jn}from"./chunk-xyjn0rvj.js";import{qr,N,i}from"./chunk-yfrvbnc6.js";import"./chunk-pw9bhdaz.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-0jq3w712.js";import"./chunk-vgt9f7ac.js";import{f,Ie}from"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";export{qr as buildWebComponents,Jn as cacheTemplate,Xn as checkCache,_i as classifyAllScripts,xc as createMiddleware,Sc as createRoute,N as defaultConfig,f as extractVariables,me as injectRouterScript,i as loadStxConfig,Ie as processClientScript,s as processDirectives,Ce as readMarkdownFile};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ku}from"./chunk-zevx9866.js";import"./chunk-yfrvbnc6.js";import"./chunk-pw9bhdaz.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-0jq3w712.js";import"./chunk-vgt9f7ac.js";import"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Ku as buildApp};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import n from"fs";import a from"path";import{fileURLToPath as s}from"url";var i;function Je(){if(i)return i;let t="unknown";try{t=String(JSON.parse(n.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let o=a.dirname(s(import.meta.url)),e=0;for(let r of n.readdirSync(o,{recursive:!0,withFileTypes:!0}))if(r.isFile()&&r.name.endsWith(".ts"))e=Math.max(e,n.statSync(a.join(r.parentPath,r.name)).mtimeMs);t+=`+src.${Math.trunc(e)}`}catch{}return i=t,t}
|
|
3
|
+
export{Je};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{zs,zd,Hd}from"./chunk-9z9jtwct.js";import"./chunk-wzgn9fv7.js";import"./chunk-myq3hrww.js";import"./chunk-9y2ncrnq.js";import"./chunk-xnjf1zbn.js";import"./chunk-vac56rgd.js";import"./chunk-3e7haxwt.js";import"./chunk-yfrvbnc6.js";import"./chunk-pw9bhdaz.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-0jq3w712.js";import"./chunk-vgt9f7ac.js";import"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Hd as clearComposableCache,zd as getComposableScript,zs as listComposableModules};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hi,Vi,Ui,Wi,tp}from"./chunk-cj2xj1v6.js";import"./chunk-b07djygp.js";import"./chunk-gc9ftf7r.js";import"./chunk-dpjnjs09.js";import"./chunk-74pej67a.js";import"./chunk-prf164ct.js";import"./chunk-rb5xdcen.js";import"./chunk-55x799st.js";import"./chunk-nph4d1ff.js";import"./chunk-asqnaddf.js";import"./chunk-xnjf1zbn.js";import"./chunk-vac56rgd.js";import"./chunk-3e7haxwt.js";import"./chunk-xyjn0rvj.js";import"./chunk-yfrvbnc6.js";import"./chunk-pw9bhdaz.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-0jq3w712.js";import"./chunk-vgt9f7ac.js";import"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Hi as buildNative,tp as default,Vi as findCraftBinary,Wi as getAvailableFormats,Ui as getAvailableTargets};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{p}from"./chunk-2a4szpje.js";import{mkdir as w,writeFile as h}from"fs/promises";import{join as l}from"path";var f="https://api.iconify.design";async function D(){let e=await fetch(`${f}/collections`);if(!e.ok)throw Error(`Failed to fetch collections: ${e.statusText}`);return await e.json()}async function P(e,t){try{let c=p.resolve("@iconify/json"),r=`${`${c.substring(0,c.lastIndexOf("/node_modules/@iconify/json/"))}/node_modules/@iconify/json`}/json/${e}.json`,s=Bun.file(r);if(await s.exists()){let a=await s.json();if(t&&t.length>0){let d={};for(let y of t)if(a.icons[y])d[y]=a.icons[y];return{...a,icons:d}}return a}}catch{}let n=t&&t.length>0?`${f}/${e}.json?icons=${t.join(",")}`:`${f}/${e}.json`,i=await fetch(n);if(!i.ok)throw Error(`Failed to fetch icons for ${e}: ${i.statusText}`);return await i.json()}function F(e,t=24,n=24){return{body:e.body,width:e.width||t,height:e.height||n,viewBox:`0 0 ${e.width||t} ${e.height||n}`}}function T(e,t){let n=u(e);return`import type { IconData } from '@stacksjs/iconify-core'
|
|
3
3
|
|
|
4
4
|
export const ${n}: IconData = ${JSON.stringify(t,null,2)}
|
|
5
5
|
|
|
@@ -502,4 +502,4 @@ ${t.license?.url?`See [license details](${t.license.url}) for more information.`
|
|
|
502
502
|
- [Iconify documentation](https://iconify.design/docs/)
|
|
503
503
|
- [stx iconify integration guide](../../docs/iconify.md)
|
|
504
504
|
`}async function G(e,t,n,i){console.log(`
|
|
505
|
-
\uD83D\uDCE6 Generating package for ${e}...`);let o=(await D())[e];if(!o)throw Error(`Collection ${e} not found`);console.log(` Collection: ${o.name}`),console.log(` Total icons: ${o.total}`);let r=await P(e,n),s=Object.keys(r.icons);console.log(` Generating ${s.length} icons...`);let a=l(t,`iconify-${e}`),
|
|
505
|
+
\uD83D\uDCE6 Generating package for ${e}...`);let o=(await D())[e];if(!o)throw Error(`Collection ${e} not found`);console.log(` Collection: ${o.name}`),console.log(` Total icons: ${o.total}`);let r=await P(e,n),s=Object.keys(r.icons);console.log(` Generating ${s.length} icons...`);let a=l(t,`iconify-${e}`),d=l(a,"src");await w(d,{recursive:!0});let y=r.width||24,b=r.height||24;for(let m of s){let g=r.icons[m],I=F(g,y,b),z=T(m,I);await h(l(d,`${m}.ts`),z);let k=A(m,I);await h(l(d,`${m}-icon.stx`),k)}let v=_(s);await h(l(d,"index.ts"),v);let C=E(e);await h(l(d,"types.ts"),C);let S=N(e,o,s.length);await h(l(a,"package.json"),S);let x=U(e);await h(l(a,"build.ts"),x);let j=R(e,o,s.length);if(await h(l(a,"README.md"),j),i){let m=l(i,`iconify-${e}.md`),g=M(e,o,s);await w(i,{recursive:!0}),await h(m,g),console.log(` \u2713 Generated documentation in ${m}`)}console.log(` \u2713 Generated ${s.length} icons in ${a}`)}var B=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","let","static","yield","implements","interface","package","private","protected","public","await","eval","arguments"]);function u(e){let t=e.replace(/-([a-z0-9])/g,(n)=>n[1].toUpperCase());if(t=t.replace(/[^a-zA-Z0-9_$]/g,"_"),/^[0-9]/.test(t))t=`_${t}`;if(B.has(t))t=`${t}_`;return t}function W(e){let t=u(e);return t.charAt(0).toUpperCase()+t.slice(1)}export{D as fetchCollections,G as generatePackage};
|