@stacksjs/stx 0.2.581 → 0.2.583
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/{chunk-ayy9mmrw.js → chunk-02qaqamv.js} +6 -6
- package/dist/{chunk-6w2yqtrd.js → chunk-07anexcg.js} +1 -1
- package/dist/{chunk-dvgvvy5b.js → chunk-09zwhsf9.js} +1 -1
- package/dist/{chunk-cb2pyg5t.js → chunk-0dfgefjv.js} +2 -2
- package/dist/chunk-0fx3ppnt.js +2 -0
- package/dist/chunk-0sfexf9t.js +2 -0
- package/dist/chunk-2927nax9.js +2 -0
- package/dist/{chunk-eww6sdzz.js → chunk-2943qhdt.js} +1 -1
- package/dist/{chunk-9jh2ake5.js → chunk-2nehykbm.js} +5 -5
- package/dist/chunk-2rj0ttas.js +2 -0
- package/dist/chunk-3ae39ttg.js +2 -0
- package/dist/{chunk-q2a58n2a.js → chunk-440yjsk5.js} +1 -1
- package/dist/{chunk-kp0hg06s.js → chunk-4pkpr5cg.js} +2 -2
- package/dist/{chunk-g4crr86j.js → chunk-4pmgr32a.js} +3 -3
- package/dist/chunk-521pe0hb.js +18 -0
- package/dist/chunk-58z26y07.js +2 -0
- package/dist/chunk-5r9k9s3m.js +2 -0
- package/dist/{chunk-vx75fb0d.js → chunk-6fc8vw2v.js} +2 -2
- package/dist/{chunk-43h8q2cm.js → chunk-6m3me7yj.js} +6 -6
- package/dist/chunk-76vza4ve.js +2 -0
- package/dist/{chunk-c1r7zq0q.js → chunk-8tq83fq7.js} +71 -71
- package/dist/chunk-8y8bbsh5.js +2 -0
- package/dist/{chunk-620szfcp.js → chunk-96mb3brj.js} +2 -2
- package/dist/chunk-9kzycb15.js +2 -0
- package/dist/{chunk-djft0m5h.js → chunk-ac6v3s3k.js} +1 -1
- package/dist/chunk-agfhb2qd.js +2 -0
- package/dist/chunk-ay6dzpt4.js +2 -0
- package/dist/{chunk-dtcc09x1.js → chunk-b9njk81d.js} +1 -1
- package/dist/chunk-bfbcmfww.js +2 -0
- package/dist/chunk-br01jvra.js +2 -0
- package/dist/{chunk-v8p5p2kp.js → chunk-c12y2bet.js} +1 -1
- package/dist/chunk-c2nwchk0.js +2 -0
- package/dist/{chunk-3qrrv6af.js → chunk-cby4mkjf.js} +1 -1
- package/dist/{chunk-qazn64pm.js → chunk-ck1yca7g.js} +1 -1
- package/dist/chunk-cxqrwvc5.js +2 -0
- package/dist/chunk-czea8zr1.js +2 -0
- package/dist/chunk-d99kfx3k.js +2 -0
- package/dist/{chunk-7hkc96de.js → chunk-dhq80e4r.js} +4 -4
- package/dist/{chunk-cdgwkzms.js → chunk-dm1qh2vq.js} +1 -1
- package/dist/{chunk-5pgbsc3a.js → chunk-dskrwa8f.js} +1 -1
- package/dist/{chunk-zk2xk0wd.js → chunk-dvc15djp.js} +2 -2
- package/dist/chunk-e6ycqvdm.js +2 -0
- package/dist/{chunk-8v19753h.js → chunk-e809x7m0.js} +1 -1
- package/dist/{chunk-ta3wn842.js → chunk-en7xxgtb.js} +2 -2
- package/dist/chunk-fvx6pd66.js +2 -0
- package/dist/{chunk-xpnpg967.js → chunk-g9zeybqh.js} +2 -2
- package/dist/{chunk-zz02hwec.js → chunk-h3z9b6bw.js} +22 -22
- package/dist/{chunk-yk3fbzx5.js → chunk-hp9nxva6.js} +3 -3
- package/dist/chunk-hrbjapvr.js +2 -0
- package/dist/{chunk-pmpb34md.js → chunk-hzqyfdpy.js} +5 -5
- package/dist/chunk-jc4mxq56.js +2 -0
- package/dist/chunk-jdpyxt8j.js +2 -0
- package/dist/{chunk-4rkvwm6v.js → chunk-je1as16r.js} +9 -9
- package/dist/chunk-k0zev8wc.js +2 -0
- package/dist/{chunk-nrfh7gaa.js → chunk-kfwmqacd.js} +1 -1
- package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
- package/dist/{chunk-y8q1n7hx.js → chunk-ky1426s1.js} +6 -6
- package/dist/{chunk-rr8a7d4q.js → chunk-m417sp42.js} +3 -3
- package/dist/{chunk-101ekf6y.js → chunk-mjj24qpb.js} +2 -2
- package/dist/{chunk-ev5f79mg.js → chunk-mt9x626h.js} +3 -3
- package/dist/{chunk-faghmmrs.js → chunk-n4e02qdz.js} +85 -85
- package/dist/{chunk-yy3ser06.js → chunk-nh3svtvj.js} +3 -3
- package/dist/{chunk-yfq2v7x5.js → chunk-nhd9m8h5.js} +6 -6
- package/dist/chunk-nx8rf4qd.js +2 -0
- package/dist/{chunk-t8wpzqs4.js → chunk-pbwk8tzz.js} +1 -1
- package/dist/chunk-pe5bk9ns.js +2 -0
- package/dist/chunk-qb2j34sp.js +2 -0
- package/dist/chunk-qknfceta.js +2 -0
- package/dist/{chunk-0vnngvy1.js → chunk-qn8gdw21.js} +4 -4
- package/dist/chunk-sf98zgw2.js +2 -0
- package/dist/chunk-sgsp4dph.js +2 -0
- package/dist/{chunk-jtbzmbzz.js → chunk-sv08pd66.js} +2 -2
- package/dist/{chunk-30rf7k4n.js → chunk-tfxmzat6.js} +24 -24
- package/dist/chunk-tms7amrb.js +2 -0
- package/dist/chunk-v0zgarvv.js +2 -0
- package/dist/chunk-vczw73ga.js +2 -0
- package/dist/{chunk-be2ba3hj.js → chunk-vkc51n9m.js} +2 -2
- package/dist/{chunk-1v1mew46.js → chunk-vke73gts.js} +1 -1
- package/dist/{chunk-c0s3k64c.js → chunk-w6wtxj54.js} +2 -2
- package/dist/chunk-webrqm20.js +2 -0
- package/dist/chunk-wngqr949.js +2 -0
- package/dist/{chunk-71sdgv7e.js → chunk-wyn5rfzk.js} +105 -35
- package/dist/{chunk-yhpyqsbr.js → chunk-x552npae.js} +2 -2
- package/dist/{chunk-3wy8q3aq.js → chunk-xp7fxc6p.js} +5 -5
- package/dist/{chunk-t4g2fptt.js → chunk-xytkfa48.js} +4 -4
- package/dist/chunk-xyzy84x0.js +2 -0
- package/dist/chunk-y1jffvkj.js +2 -0
- package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
- package/dist/chunk-yas134jv.js +2 -0
- package/dist/{chunk-tszkg6sj.js → chunk-ycj0342k.js} +1 -1
- package/dist/{chunk-mxe21m6q.js → chunk-yd55vynh.js} +1 -1
- package/dist/{chunk-hzfhn2vr.js → chunk-ye66wc53.js} +2 -2
- package/dist/{chunk-k9th7hc4.js → chunk-ym1sb5bg.js} +2 -2
- package/dist/chunk-yn2d8x8m.js +3 -0
- package/dist/chunk-ze86h6vp.js +2 -0
- package/dist/cli.js +44 -44
- package/dist/client/signals-authoring-runtime.js +13 -6
- package/dist/client/signals-binding-utils-runtime.js +14 -1
- package/dist/client/signals-component-api-runtime.js +3 -1
- package/dist/client/signals-event-shorthand-runtime.js +1 -1
- package/dist/client/signals-expression-runtime.js +1 -1
- package/dist/client/signals-host-runtime.js +20 -0
- package/dist/client/signals-manifest-hydration-runtime.js +7 -0
- package/dist/client/signals-model-runtime.js +2 -0
- package/dist/client/signals-mount-runtime.js +5 -1
- package/dist/client/signals-process-element-runtime.js +22 -7
- package/dist/component-model.d.ts +1 -1
- package/dist/component-model.js +6 -3
- package/dist/composition-api.js +3 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/compiler/bundle.js +8 -3
- package/dist/native/compiler/html-to-ir.d.ts +3 -1
- package/dist/native/compiler/html-to-ir.js +28 -1
- package/dist/native/runtime/binding-tree.js +12 -0
- package/dist/native/runtime/craft-bridge.js +2 -1
- package/dist/native/runtime/jsc-globals.d.ts +10 -3
- package/dist/native/runtime/jsc-globals.js +23 -4
- package/dist/native/runtime/native-host.d.ts +4 -0
- package/dist/native/runtime/native-host.js +273 -21
- package/dist/native/runtime/shared-screen.js +1 -0
- package/dist/native/testing.js +1 -1
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +7 -7
- package/package.json +5 -5
- package/dist/chunk-0047meje.js +0 -2
- package/dist/chunk-1cat8kdj.js +0 -2
- package/dist/chunk-1dwnp35v.js +0 -2
- package/dist/chunk-2dnr5qfk.js +0 -2
- package/dist/chunk-2v73cjbc.js +0 -2
- package/dist/chunk-3akgppsy.js +0 -2
- package/dist/chunk-4t67wmcg.js +0 -2
- package/dist/chunk-51zn42jy.js +0 -2
- package/dist/chunk-5702x95v.js +0 -2
- package/dist/chunk-60c2bsh9.js +0 -2
- package/dist/chunk-79v4d9qh.js +0 -2
- package/dist/chunk-7pp2vx1g.js +0 -2
- package/dist/chunk-8zm6tkqb.js +0 -2
- package/dist/chunk-a1z36dt5.js +0 -2
- package/dist/chunk-atsf1fe0.js +0 -2
- package/dist/chunk-b8qd6h1q.js +0 -2
- package/dist/chunk-ccxs40xy.js +0 -2
- package/dist/chunk-cg8hg6cs.js +0 -3
- package/dist/chunk-cp442y7a.js +0 -2
- package/dist/chunk-d4en5d3s.js +0 -2
- package/dist/chunk-dh80d57p.js +0 -2
- package/dist/chunk-dyqte1xq.js +0 -2
- package/dist/chunk-e4n4v022.js +0 -2
- package/dist/chunk-g2fw68zm.js +0 -2
- package/dist/chunk-hcgm37dy.js +0 -2
- package/dist/chunk-hd2bn5q7.js +0 -2
- package/dist/chunk-j1nqnmcd.js +0 -18
- package/dist/chunk-k7jqkt93.js +0 -2
- package/dist/chunk-mqy7g74k.js +0 -2
- package/dist/chunk-ne03tfje.js +0 -2
- package/dist/chunk-p2sns0bn.js +0 -2
- package/dist/chunk-s1sycp43.js +0 -2
- package/dist/chunk-sp46w7z9.js +0 -2
- package/dist/chunk-sy1bk1ry.js +0 -2
- package/dist/chunk-tpd5nwa3.js +0 -2
- package/dist/chunk-tpt4bgs5.js +0 -2
- package/dist/chunk-vq0cb1m9.js +0 -2
- package/dist/chunk-y1bppxgw.js +0 -2
- package/dist/chunk-yv5rwthv.js +0 -2
- package/dist/chunk-z1r4tdqy.js +0 -2
- package/dist/chunk-zv288w4e.js +0 -2
|
@@ -22,8 +22,11 @@ export declare interface NativeHost {
|
|
|
22
22
|
setMarkup: (node: NativeNode, value: unknown) => void
|
|
23
23
|
setAttribute: (node: NativeNode, name: string, value: unknown) => void
|
|
24
24
|
removeAttribute: (node: NativeNode, name: string) => void
|
|
25
|
+
observeAttributes: (node: NativeNode, names: string[], callback: () => void) => (() => void)
|
|
25
26
|
setStyle: (node: NativeNode, value: unknown) => void
|
|
26
27
|
listen: (node: NativeNode, event: string, handler: (payload?: unknown) => void, options?: unknown) => void
|
|
28
|
+
emitComponentEvent: (node: NativeNode, event: Event) => boolean
|
|
29
|
+
onFormReset: (node: NativeNode, callback: () => void) => (() => void)
|
|
27
30
|
scopeOf: (node: NativeNode, from?: boolean) => NativeNode | null
|
|
28
31
|
setVisible: (node: NativeNode, visible: boolean) => boolean
|
|
29
32
|
anchor: (label: string) => NativeNode
|
|
@@ -36,5 +39,6 @@ export declare interface NativeHost {
|
|
|
36
39
|
flush: () => void
|
|
37
40
|
dispatch: (handlerId: string, payload?: unknown) => void
|
|
38
41
|
pending: () => number
|
|
42
|
+
dispose: () => void
|
|
39
43
|
snapshot: (root: NativeNode) => STXNode
|
|
40
44
|
}
|
|
@@ -4,24 +4,39 @@ import { affectsGeometry, parseSvgMarkup, parseViewBox, SVG_NODE_TYPES, svgGeome
|
|
|
4
4
|
import { NATIVE_EVENT_NAMES } from "../event-names.js";
|
|
5
5
|
import { nativePropName } from "../prop-names.js";
|
|
6
6
|
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
7
|
+
import { NATIVE_FORM_ENTRIES } from "./jsc-globals.js";
|
|
7
8
|
function irDisplay(value) {
|
|
8
9
|
return value === "none" || value === "grid" || value === "flex" ? value : "flex";
|
|
9
10
|
}
|
|
10
|
-
function eventAt(payload, node) {
|
|
11
|
-
if (payload
|
|
12
|
-
return { target: node, currentTarget: node };
|
|
13
|
-
if (typeof payload !== "object" || Array.isArray(payload))
|
|
11
|
+
function eventAt(payload, node, type = "") {
|
|
12
|
+
if (payload != null && (typeof payload !== "object" || Array.isArray(payload)))
|
|
14
13
|
return payload;
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return {
|
|
15
|
+
...payload,
|
|
16
|
+
type,
|
|
17
|
+
target: node,
|
|
18
|
+
currentTarget: node,
|
|
19
|
+
bubbles: !0,
|
|
20
|
+
cancelBubble: !1,
|
|
21
|
+
defaultPrevented: !1,
|
|
22
|
+
preventDefault() {
|
|
23
|
+
this.defaultPrevented = !0;
|
|
24
|
+
},
|
|
25
|
+
stopPropagation() {
|
|
26
|
+
this.cancelBubble = !0;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
17
29
|
}
|
|
18
30
|
export const HOST_METHODS = [
|
|
19
31
|
"setText",
|
|
20
32
|
"setMarkup",
|
|
21
33
|
"setAttribute",
|
|
22
34
|
"removeAttribute",
|
|
35
|
+
"observeAttributes",
|
|
23
36
|
"setStyle",
|
|
24
37
|
"listen",
|
|
38
|
+
"emitComponentEvent",
|
|
39
|
+
"onFormReset",
|
|
25
40
|
"scopeOf",
|
|
26
41
|
"setVisible",
|
|
27
42
|
"anchor",
|
|
@@ -32,9 +47,14 @@ export const HOST_METHODS = [
|
|
|
32
47
|
"scopesIn"
|
|
33
48
|
];
|
|
34
49
|
export function createNativeHost(options) {
|
|
35
|
-
const records = new Map, handlers = new Map;
|
|
36
|
-
let queue = [], scheduled = !1, counter = 0, colorScheme = options.colorScheme ?? "light";
|
|
50
|
+
const records = new Map, attributeObservers = new WeakMap, handlers = new Map, eventRegistrations = new WeakMap, componentListeners = new WeakMap, formControls = new WeakSet, formResetCallbacks = new WeakMap;
|
|
51
|
+
let queue = [], scheduled = !1, counter = 0, colorScheme = options.colorScheme ?? "light", disposed = !1;
|
|
37
52
|
const schedule = options.schedule ?? ((flush) => queueMicrotask(flush)), nextId = (prefix) => `${prefix}${++counter}`;
|
|
53
|
+
function notifyAttributes(node, name) {
|
|
54
|
+
for (const observer of attributeObservers.get(node) ?? [])
|
|
55
|
+
if (observer.names.includes(name))
|
|
56
|
+
observer.notify();
|
|
57
|
+
}
|
|
38
58
|
function flush() {
|
|
39
59
|
scheduled = !1;
|
|
40
60
|
if (queue.length === 0)
|
|
@@ -44,6 +64,8 @@ export function createNativeHost(options) {
|
|
|
44
64
|
options.send(batch);
|
|
45
65
|
}
|
|
46
66
|
function emit(operation) {
|
|
67
|
+
if (disposed)
|
|
68
|
+
return;
|
|
47
69
|
queue.push(operation);
|
|
48
70
|
if (!scheduled) {
|
|
49
71
|
scheduled = !0;
|
|
@@ -98,27 +120,110 @@ export function createNativeHost(options) {
|
|
|
98
120
|
return record;
|
|
99
121
|
}
|
|
100
122
|
function decorateControl(node, type) {
|
|
101
|
-
|
|
123
|
+
const htmlCheckbox = type === "Checkbox" && descriptorOf(node)?.props.type === "checkbox", hidden = descriptorOf(node)?.props.type === "hidden";
|
|
124
|
+
if (type === "TextInput" || type === "Picker" || htmlCheckbox || hidden) {
|
|
102
125
|
Object.defineProperty(node, "value", {
|
|
103
126
|
configurable: !0,
|
|
104
127
|
enumerable: !0,
|
|
105
|
-
get: () => descriptorOf(node)?.props
|
|
128
|
+
get: () => descriptorOf(node)?.props[type === "Checkbox" ? "formValue" : "value"] ?? "",
|
|
106
129
|
set: (value) => {
|
|
107
|
-
const record = recordOf(node);
|
|
108
|
-
if (Object.is(record.props
|
|
130
|
+
const record = recordOf(node), prop = type === "Checkbox" ? "formValue" : "value";
|
|
131
|
+
if (Object.is(record.props[prop], value))
|
|
109
132
|
return;
|
|
110
|
-
record.props
|
|
133
|
+
record.props[prop] = value;
|
|
111
134
|
if (record.materialized)
|
|
112
|
-
emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
|
|
135
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
|
|
113
136
|
}
|
|
114
137
|
});
|
|
115
138
|
Object.defineProperty(node, "type", { configurable: !0, get: () => descriptorOf(node)?.props.type ?? "text" });
|
|
139
|
+
Object.defineProperty(node, "name", { configurable: !0, get: () => descriptorOf(node)?.props.name ?? "" });
|
|
140
|
+
}
|
|
141
|
+
if (type === "Checkbox")
|
|
142
|
+
Object.defineProperty(node, "checked", {
|
|
143
|
+
configurable: !0,
|
|
144
|
+
get: () => Boolean(descriptorOf(node)?.props.checked ?? descriptorOf(node)?.props.value),
|
|
145
|
+
set: (value) => {
|
|
146
|
+
const record = recordOf(node), checked = Boolean(value);
|
|
147
|
+
if (record.props.checked === checked && record.props.value === checked)
|
|
148
|
+
return;
|
|
149
|
+
record.props.checked = checked;
|
|
150
|
+
record.props.value = checked;
|
|
151
|
+
if (record.materialized)
|
|
152
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { checked, value: checked } } });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
if (descriptorOf(node)?.props["data-stx-form"]) {
|
|
156
|
+
Object.defineProperty(node, NATIVE_FORM_ENTRIES, { configurable: !0, value: () => formEntries(node) });
|
|
157
|
+
Object.defineProperty(node, "reset", { configurable: !0, value: () => resetForm(node) });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function formOwner(node) {
|
|
161
|
+
for (let current = node.__stxOwner;current; current = current.__stxOwner)
|
|
162
|
+
if (descriptorOf(current)?.props["data-stx-form"])
|
|
163
|
+
return current;
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
function disabled(record) {
|
|
167
|
+
return record.props.disabled === !0 || record.props.disabled === "" || record.props.disabled === "true";
|
|
168
|
+
}
|
|
169
|
+
function formEntries(form) {
|
|
170
|
+
const values = [];
|
|
171
|
+
for (const node of collectDescendants(form)) {
|
|
172
|
+
const record = descriptorOf(node);
|
|
173
|
+
if (!record?.materialized)
|
|
174
|
+
continue;
|
|
175
|
+
const name = record.props.name;
|
|
176
|
+
if (!name || disabled(record) || formOwner(node) !== form)
|
|
177
|
+
continue;
|
|
178
|
+
if (!["TextInput", "Picker", "Checkbox"].includes(record.type) && record.props.type !== "hidden")
|
|
179
|
+
continue;
|
|
180
|
+
if (["submit", "reset", "button", "file"].includes(String(record.props.type)))
|
|
181
|
+
continue;
|
|
182
|
+
if (record.type === "Checkbox" && !node.checked)
|
|
183
|
+
continue;
|
|
184
|
+
const value = record.type === "Checkbox" ? record.props.formValue ?? "on" : record.props.value ?? "";
|
|
185
|
+
for (const item of Array.isArray(value) ? value : [value])
|
|
186
|
+
values.push([String(name), item]);
|
|
187
|
+
}
|
|
188
|
+
return values;
|
|
189
|
+
}
|
|
190
|
+
function resetForm(form) {
|
|
191
|
+
if (!host.emitComponentEvent(form, eventAt(null, form, "reset")))
|
|
192
|
+
return;
|
|
193
|
+
for (const node of collectDescendants(form)) {
|
|
194
|
+
const record = descriptorOf(node);
|
|
195
|
+
if (!record?.materialized || !record.controlDefaults || formOwner(node) !== form || !("value" in node) && record.type !== "Checkbox")
|
|
196
|
+
continue;
|
|
197
|
+
const control = node;
|
|
198
|
+
if (record.type === "Checkbox")
|
|
199
|
+
control.checked = record.controlDefaults.checked;
|
|
200
|
+
else
|
|
201
|
+
control.value = record.controlDefaults.value;
|
|
202
|
+
}
|
|
203
|
+
for (const node of collectDescendants(form)) {
|
|
204
|
+
if (formOwner(node) !== form)
|
|
205
|
+
continue;
|
|
206
|
+
for (const callback of formResetCallbacks.get(node) ?? [])
|
|
207
|
+
callback();
|
|
116
208
|
}
|
|
117
209
|
}
|
|
210
|
+
function installFormListeners(node) {
|
|
211
|
+
const record = descriptorOf(node);
|
|
212
|
+
if (!record || formControls.has(node) || !formOwner(node))
|
|
213
|
+
return;
|
|
214
|
+
formControls.add(node);
|
|
215
|
+
if (record.type === "TextInput" || record.type === "Picker" || record.type === "Checkbox") {
|
|
216
|
+
host.listen(node, record.type === "TextInput" ? "input" : "change", () => {});
|
|
217
|
+
host.listen(node, "focusout", () => {});
|
|
218
|
+
}
|
|
219
|
+
if (record.type === "Button")
|
|
220
|
+
host.listen(node, "click", () => {});
|
|
221
|
+
}
|
|
118
222
|
function materialize(node) {
|
|
119
223
|
const record = recordOf(node);
|
|
120
224
|
if (record.materialized || node.__stxAnchor !== void 0)
|
|
121
225
|
return;
|
|
226
|
+
installFormListeners(node);
|
|
122
227
|
record.style = resolveStyle(record);
|
|
123
228
|
record.materialized = !0;
|
|
124
229
|
emit({
|
|
@@ -245,7 +350,8 @@ export function createNativeHost(options) {
|
|
|
245
350
|
text: descriptor?.children?.find((child) => typeof child === "string"),
|
|
246
351
|
children: [],
|
|
247
352
|
visible: !0,
|
|
248
|
-
materialized: !0
|
|
353
|
+
materialized: !0,
|
|
354
|
+
controlDefaults: { value: descriptor?.props.value ?? "", checked: descriptor?.props.checked ?? descriptor?.props.value ?? !1 }
|
|
249
355
|
};
|
|
250
356
|
record.style = resolveStyle(record);
|
|
251
357
|
if (descriptor)
|
|
@@ -259,9 +365,10 @@ export function createNativeHost(options) {
|
|
|
259
365
|
if (!children.some((child) => child.__stxId === node.__stxId))
|
|
260
366
|
children.push(node);
|
|
261
367
|
}
|
|
368
|
+
installFormListeners(node);
|
|
262
369
|
return node;
|
|
263
370
|
}
|
|
264
|
-
|
|
371
|
+
const host = {
|
|
265
372
|
isNative: !0,
|
|
266
373
|
adopt,
|
|
267
374
|
setColorScheme(scheme) {
|
|
@@ -273,6 +380,12 @@ export function createNativeHost(options) {
|
|
|
273
380
|
},
|
|
274
381
|
pending: () => queue.length,
|
|
275
382
|
flush,
|
|
383
|
+
dispose() {
|
|
384
|
+
disposed = !0;
|
|
385
|
+
queue = [];
|
|
386
|
+
handlers.clear();
|
|
387
|
+
records.clear();
|
|
388
|
+
},
|
|
276
389
|
snapshot(root) {
|
|
277
390
|
queue = [];
|
|
278
391
|
const describe = (node) => {
|
|
@@ -320,6 +433,13 @@ export function createNativeHost(options) {
|
|
|
320
433
|
}
|
|
321
434
|
},
|
|
322
435
|
setAttribute(node, name, value) {
|
|
436
|
+
if (isBindingNode(node) && name !== "class" && name !== "className") {
|
|
437
|
+
const serialized = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
438
|
+
if (node.getAttribute(name) !== serialized) {
|
|
439
|
+
node.setAttribute(name, serialized);
|
|
440
|
+
notifyAttributes(node, name);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
323
443
|
if (name === "class" || name === "className") {
|
|
324
444
|
const record = recordOf(node);
|
|
325
445
|
record.classes = String(value ?? "");
|
|
@@ -346,6 +466,10 @@ export function createNativeHost(options) {
|
|
|
346
466
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: patch } });
|
|
347
467
|
},
|
|
348
468
|
removeAttribute(node, name) {
|
|
469
|
+
if (isBindingNode(node) && name !== "class" && name !== "className" && node.hasAttribute(name)) {
|
|
470
|
+
node.removeAttribute(name);
|
|
471
|
+
notifyAttributes(node, name);
|
|
472
|
+
}
|
|
349
473
|
if (name === "class" || name === "className") {
|
|
350
474
|
this.setAttribute(node, name, "");
|
|
351
475
|
return;
|
|
@@ -358,6 +482,26 @@ export function createNativeHost(options) {
|
|
|
358
482
|
if (record.materialized)
|
|
359
483
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: patch } });
|
|
360
484
|
},
|
|
485
|
+
observeAttributes(node, names, callback) {
|
|
486
|
+
const observers = attributeObservers.get(node) ?? new Set;
|
|
487
|
+
attributeObservers.set(node, observers);
|
|
488
|
+
let active = !0, pending = !1;
|
|
489
|
+
const observer = { names, notify() {
|
|
490
|
+
if (pending || !active)
|
|
491
|
+
return;
|
|
492
|
+
pending = !0;
|
|
493
|
+
queueMicrotask(() => {
|
|
494
|
+
pending = !1;
|
|
495
|
+
if (active && !disposed)
|
|
496
|
+
callback();
|
|
497
|
+
});
|
|
498
|
+
} };
|
|
499
|
+
observers.add(observer);
|
|
500
|
+
return () => {
|
|
501
|
+
active = !1;
|
|
502
|
+
observers.delete(observer);
|
|
503
|
+
};
|
|
504
|
+
},
|
|
361
505
|
setStyle(node, value) {
|
|
362
506
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
363
507
|
return;
|
|
@@ -367,20 +511,126 @@ export function createNativeHost(options) {
|
|
|
367
511
|
if (recordOf(node).materialized)
|
|
368
512
|
emit({ op: "updateNode", id: node.__stxId, patch: { style } });
|
|
369
513
|
},
|
|
370
|
-
|
|
371
|
-
|
|
514
|
+
emitComponentEvent(node, event) {
|
|
515
|
+
if (disposed || !descriptorOf(node)?.materialized)
|
|
516
|
+
return !0;
|
|
517
|
+
const ancestors = [];
|
|
518
|
+
for (let current = node;current; current = current.__stxOwner)
|
|
519
|
+
ancestors.push(current);
|
|
520
|
+
Object.defineProperty(event, "target", { configurable: !0, value: node });
|
|
521
|
+
const invoke = (current, capture) => {
|
|
522
|
+
Object.defineProperty(event, "currentTarget", { configurable: !0, value: current });
|
|
523
|
+
const listeners = componentListeners.get(current) ?? [];
|
|
524
|
+
for (const listener of [...listeners]) {
|
|
525
|
+
if (listener.event !== event.type || listener.capture !== capture)
|
|
526
|
+
continue;
|
|
527
|
+
if (listener.once)
|
|
528
|
+
listeners.splice(listeners.indexOf(listener), 1);
|
|
529
|
+
listener.handler(event);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
try {
|
|
533
|
+
for (const current of ancestors.slice(1).reverse()) {
|
|
534
|
+
invoke(current, !0);
|
|
535
|
+
if (event.cancelBubble)
|
|
536
|
+
return !event.defaultPrevented;
|
|
537
|
+
}
|
|
538
|
+
invoke(node, !0);
|
|
539
|
+
invoke(node, !1);
|
|
540
|
+
if (!event.bubbles || event.cancelBubble)
|
|
541
|
+
return !event.defaultPrevented;
|
|
542
|
+
for (const current of ancestors.slice(1)) {
|
|
543
|
+
invoke(current, !1);
|
|
544
|
+
if (event.cancelBubble)
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
return !event.defaultPrevented;
|
|
548
|
+
} finally {
|
|
549
|
+
Object.defineProperty(event, "currentTarget", { configurable: !0, value: null });
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
onFormReset(node, callback) {
|
|
553
|
+
const callbacks = formResetCallbacks.get(node) ?? new Set;
|
|
554
|
+
formResetCallbacks.set(node, callbacks);
|
|
555
|
+
callbacks.add(callback);
|
|
556
|
+
return () => {
|
|
557
|
+
callbacks.delete(callback);
|
|
558
|
+
};
|
|
559
|
+
},
|
|
560
|
+
listen(node, event, handler, options) {
|
|
561
|
+
const listenerOptions = options, listeners = componentListeners.get(node) ?? [], listener = { event, handler, once: !!listenerOptions?.once, capture: !!listenerOptions?.capture };
|
|
562
|
+
listeners.push(listener);
|
|
563
|
+
componentListeners.set(node, listeners);
|
|
564
|
+
const nativeEvent = NATIVE_EVENT_NAMES[event.toLowerCase()] ?? event, record = recordOf(node), registrations = eventRegistrations.get(node) ?? new Map;
|
|
565
|
+
eventRegistrations.set(node, registrations);
|
|
566
|
+
const existing = registrations.get(nativeEvent);
|
|
567
|
+
if (existing && handlers.has(existing))
|
|
568
|
+
return;
|
|
569
|
+
const id = nextId("h");
|
|
570
|
+
registrations.set(nativeEvent, id);
|
|
372
571
|
handlers.set(id, (payload) => {
|
|
572
|
+
if (disabled(record))
|
|
573
|
+
return;
|
|
373
574
|
if (nativeEvent === "onChangeText" || nativeEvent === "onValueChange") {
|
|
374
575
|
const data = payload && typeof payload === "object" ? payload : {}, value = data.text ?? data.value ?? data.nativeEvent?.text ?? data.nativeEvent?.value, record = recordOf(node);
|
|
576
|
+
if (record.type === "Checkbox" && value !== void 0)
|
|
577
|
+
node.checked = Boolean(value);
|
|
375
578
|
if (value !== void 0 && !Object.is(record.props.value, value) && (record.type === "TextInput" || record.type === "Picker")) {
|
|
376
579
|
record.props.value = value;
|
|
377
580
|
if (record.materialized)
|
|
378
581
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
|
|
379
582
|
}
|
|
380
583
|
}
|
|
381
|
-
|
|
584
|
+
const delivered = eventAt(payload, node, event), physical = delivered && typeof delivered === "object" ? delivered : null, ancestors = [node];
|
|
585
|
+
if (physical && ["onPress", "onChangeText", "onValueChange", "onBlur", "onFocus"].includes(nativeEvent))
|
|
586
|
+
for (let owner = node.__stxOwner;owner; owner = owner.__stxOwner)
|
|
587
|
+
ancestors.push(owner);
|
|
588
|
+
const invoke = (target, capture) => {
|
|
589
|
+
if (physical)
|
|
590
|
+
Object.defineProperty(physical, "currentTarget", { configurable: !0, value: target });
|
|
591
|
+
const group = componentListeners.get(target) ?? [];
|
|
592
|
+
for (const current of [...group]) {
|
|
593
|
+
if ((NATIVE_EVENT_NAMES[current.event.toLowerCase()] ?? current.event) !== nativeEvent || current.capture !== capture)
|
|
594
|
+
continue;
|
|
595
|
+
if (target !== node && (current.event === "blur" || current.event === "focus"))
|
|
596
|
+
continue;
|
|
597
|
+
if (!group.includes(current))
|
|
598
|
+
continue;
|
|
599
|
+
if (current.once)
|
|
600
|
+
group.splice(group.indexOf(current), 1);
|
|
601
|
+
current.handler(delivered);
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
let reachedTarget = !0;
|
|
605
|
+
for (const target of ancestors.slice(1).reverse()) {
|
|
606
|
+
invoke(target, !0);
|
|
607
|
+
if (physical?.cancelBubble) {
|
|
608
|
+
reachedTarget = !1;
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (reachedTarget) {
|
|
613
|
+
invoke(node, !0);
|
|
614
|
+
invoke(node, !1);
|
|
615
|
+
}
|
|
616
|
+
if (!physical?.cancelBubble)
|
|
617
|
+
for (const target of ancestors.slice(1)) {
|
|
618
|
+
invoke(target, !1);
|
|
619
|
+
if (physical?.cancelBubble)
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
if (physical)
|
|
623
|
+
Object.defineProperty(physical, "currentTarget", { configurable: !0, value: node });
|
|
624
|
+
if (nativeEvent === "onValueChange" && (record.type === "Picker" || record.type === "Checkbox"))
|
|
625
|
+
host.emitComponentEvent(node, eventAt(payload, node, "input"));
|
|
626
|
+
const form = formOwner(node);
|
|
627
|
+
if (form && nativeEvent === "onPress" && !physical?.defaultPrevented && !disabled(record)) {
|
|
628
|
+
if (record.props.type === "submit")
|
|
629
|
+
host.emitComponentEvent(form, eventAt({ submitter: node }, form, "submit"));
|
|
630
|
+
if (record.props.type === "reset")
|
|
631
|
+
resetForm(form);
|
|
632
|
+
}
|
|
382
633
|
});
|
|
383
|
-
const record = recordOf(node);
|
|
384
634
|
record.events[nativeEvent] = id;
|
|
385
635
|
if (record.materialized)
|
|
386
636
|
emit({ op: "updateNode", id: node.__stxId, patch: { events: { [nativeEvent]: id } } });
|
|
@@ -448,7 +698,8 @@ export function createNativeHost(options) {
|
|
|
448
698
|
text: descriptor.text,
|
|
449
699
|
children: [],
|
|
450
700
|
visible: descriptor.visible,
|
|
451
|
-
materialized: !1
|
|
701
|
+
materialized: !1,
|
|
702
|
+
controlDefaults: descriptor.controlDefaults
|
|
452
703
|
});
|
|
453
704
|
decorateControl(copy, descriptor.type);
|
|
454
705
|
setConnected(copy, !1);
|
|
@@ -520,4 +771,5 @@ export function createNativeHost(options) {
|
|
|
520
771
|
emit({ op: "removeNode", id: node.__stxId });
|
|
521
772
|
}
|
|
522
773
|
};
|
|
774
|
+
return host;
|
|
523
775
|
}
|
package/dist/native/testing.js
CHANGED
|
@@ -247,7 +247,7 @@ export function mountNativeScreen(code, screen, options = {}) {
|
|
|
247
247
|
appURL: options.appURL ?? "https://fixture.invalid/m",
|
|
248
248
|
appVersion: options.appVersion ?? "1.0.0",
|
|
249
249
|
appBuild: options.appBuild ?? "1",
|
|
250
|
-
sessionTokenKey,
|
|
250
|
+
...options.sessionEvents === !1 ? {} : { sessionTokenKey },
|
|
251
251
|
postMessage: (raw) => {
|
|
252
252
|
const message = JSON.parse(raw);
|
|
253
253
|
messages.push(JSON.parse(raw));
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
2
|
+
import{Wn,je,Xo,nc}from"./chunk-hp9nxva6.js";import{Vn,Yr,Qa,ec,tc}from"./chunk-xytkfa48.js";import{qo,Go,Ko,Ya,Za}from"./chunk-c0h2eqe0.js";import{ae,yt,Zr}from"./chunk-jpqkm8tm.js";import{sl,ol,il,al,Sr,Td}from"./chunk-ye66wc53.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-nx8rf4qd.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
|
|
|
233
233
|
}, 5000);
|
|
234
234
|
</script>
|
|
235
235
|
</body>
|
|
236
|
-
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=
|
|
236
|
+
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Wn(n,t);if(a){let s=je(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function se(n,t){return Yr(n,t)}function oe(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Go as auditBuildOutput,qo as auditConfig,re as buildPwaAssets,Ko as calculateAuditResult,Za as formatAuditResult,Zr as formatSize,j as generateManifest,_ as generateManifestJson,ec as generateManifestLink,F as generateOfflinePage,ae as generatePrecacheManifest,yt as generatePrecacheManifestJs,M as generatePwaIcons,Vn as generatePwaTags,Wn as generateServiceWorker,nc as generateServiceWorkerAuto,Qa as generateSwRegistrationScript,tc as generateThemeColorMeta,N as getExpectedIconPaths,je as getServiceWorkerFileName,Yr as injectPwaTags,oe as isPwaEnabled,I as isSharpAvailable,Xo as isWorkboxEnabled,q as mergeManifestConfig,se as processPwaHtml,Sr as pwaDirectives,sl as pwaInstallDirective,il as pwaOfflineDirective,al as pwaPushDirective,ol as pwaUpdateDirective,Td as registerPwaDirectives,Ya as runPwaAudit,D as validateManifest};
|
package/dist/ssg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-ktyctev3.js";import"./chunk-
|
|
3
|
-
`)}class mt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class
|
|
2
|
+
import"./chunk-ktyctev3.js";import"./chunk-dhq80e4r.js";import"./chunk-ah9xyss2.js";import{rt,st,ot,it,at,ct}from"./chunk-x552npae.js";import"./chunk-dvc15djp.js";import"./chunk-vpdx7qr3.js";import{f,He,L,J,n,o}from"./chunk-n4e02qdz.js";import"./chunk-6m3me7yj.js";import{ur}from"./chunk-02qaqamv.js";import"./chunk-vkc51n9m.js";import"./chunk-2943qhdt.js";import"./chunk-qdyp2zqf.js";import"./chunk-sv08pd66.js";import"./chunk-nh3svtvj.js";import{ce,bt,vt}from"./chunk-4pkpr5cg.js";import{Uo,Vo,Wo}from"./chunk-bj29pwm0.js";import{ht,rn,sn}from"./chunk-wg2w7zmt.js";import"./chunk-dm1qh2vq.js";import{a}from"./chunk-00p22wzr.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Et=new Set(["visible","idle"]);function dt(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Et.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function jt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ft(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
|
+
`)}class mt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class wt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function Ft(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
6
6
|
})()
|
|
@@ -8,7 +8,7 @@ import"./chunk-ktyctev3.js";import"./chunk-7hkc96de.js";import"./chunk-ah9xyss2.
|
|
|
8
8
|
return (async function getStaticProps() {
|
|
9
9
|
${e[1]}
|
|
10
10
|
})()
|
|
11
|
-
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function
|
|
11
|
+
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function yt(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Tt(t.filePath),w=await At(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
|
|
12
12
|
resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of ce(b))h.add(B);if(Object.keys(i).length>0){let b=`<script>if(window.stx)window.stx._rp=${JSON.stringify(i)};else window.__stx_rp=${JSON.stringify(i)};</script>`;if(p.includes("</head>"))p=p.replace("</head>",`${b}
|
|
13
13
|
</head>`);else p=`${b}
|
|
14
14
|
${p}`}if(p=await J(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:Mt(p),dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P};return{html:p,dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P}}function Mt(t){let i=[],s=0,r=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=r.exec(t))!==null){let l=t.slice(s,c.index);i.push(l.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],y=c[2],h=c[3];y=y.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),i.push(w+y+h),s=c.index+c[0].length}let e=t.slice(s);return i.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),i.join("").trim()}function Ut(t){let i=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);i=(i<<5)-i+r,i=i&i}return`"${Math.abs(i).toString(36)}"`}function _t(t,i,s,r){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(i))return!0;return r.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Gt(t,i){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -41,10 +41,10 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let i=Date.now();
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();vt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-0fx3ppnt.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-58z26y07.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new mt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-0fx3ppnt.js");await u('<div class="bg-black"></div>')}catch{}rt();let St=s?.routeMiddleware?.dir||"middleware";await ot(process.cwd(),St);let H=st();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let xt=s?.routeMiddleware?.global||[];Wo(s?.layoutsDir,a(process.cwd()));let K=L(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ot(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<G.length;u+=e.concurrency)X.push(G.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...xt,...$t];if(tt.length>0){let C=it(d,M,F||{}),O=at(C,null,void 0,{isServer:!0}),E=await ct(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${et[1]};
|
|
46
46
|
return validate(route);
|
|
47
|
-
`)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,nt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)nt=!0,l.cachedCount++}if(!k){let C=await
|
|
47
|
+
`)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,nt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)nt=!0,l.cachedCount++}if(!k){let C=await yt(v,M,Pt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
48
48
|
${C.includeFailures.join(`
|
|
49
49
|
`)}
|
|
50
50
|
Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&C.serverScriptFailures.length>0)throw Error(`${C.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
|
|
@@ -73,7 +73,7 @@ ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.
|
|
|
73
73
|
<a href="/">Go home</a>
|
|
74
74
|
</div>
|
|
75
75
|
</body>
|
|
76
|
-
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=
|
|
76
|
+
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=ur({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let N=Uo(e.outputDir);if(N.assets>0)console.log(`Externalized ${N.assets} asset(s) from ${N.pages} page(s) (${(N.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=Vo(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await V(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=sn();if(Z)await V(Z,g.join(e.outputDir,rn)),console.log(`Copied assets from ${ht}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
|
|
77
77
|
Island chunks: ${l.islandChunks.count} (${(l.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
78
78
|
Build complete!
|
|
79
79
|
Total: ${l.totalPages} pages
|
|
@@ -81,7 +81,7 @@ Build complete!
|
|
|
81
81
|
Cached: ${l.cachedCount}
|
|
82
82
|
Failed: ${l.failedCount}
|
|
83
83
|
Time: ${l.buildTime}ms${P}
|
|
84
|
-
`),l}async function V(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await V(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new
|
|
84
|
+
`),l}async function V(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await V(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new wt(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=L(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await yt(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Ut(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
|
|
85
85
|
`)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return He(t)}function Vt(t,i){return`<!DOCTYPE html>
|
|
86
86
|
<html>
|
|
87
87
|
<head>
|