@stacksjs/stx 0.2.440 → 0.2.442
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-06qhvtsv.js +2 -0
- package/dist/{chunk-4gmdfym5.js → chunk-0ahjxtkx.js} +22 -22
- package/dist/chunk-0e6da0m4.js +2 -0
- package/dist/{chunk-zfzcedw4.js → chunk-0vbpcef6.js} +4 -4
- package/dist/{chunk-nvht5259.js → chunk-0xntpjmp.js} +3 -3
- package/dist/{chunk-fg5ve6ey.js → chunk-149r1q6c.js} +2 -2
- package/dist/{chunk-a9necy79.js → chunk-1ghj9pgz.js} +154 -154
- package/dist/chunk-1gsr2z6s.js +2 -0
- package/dist/chunk-1k55q9ff.js +2 -0
- package/dist/{chunk-489z8wry.js → chunk-1qnyn82e.js} +2 -2
- package/dist/{chunk-dc89a93n.js → chunk-1rn1g4ac.js} +11 -11
- package/dist/chunk-1s04q9hz.js +2 -0
- package/dist/chunk-224x6rsx.js +2 -0
- package/dist/chunk-2rs6n7c0.js +2 -0
- package/dist/{chunk-1yj3p63h.js → chunk-2xnwsavq.js} +2 -2
- package/dist/{chunk-xfv7evmd.js → chunk-3n8qh43z.js} +3 -3
- package/dist/chunk-3wezvz6m.js +2 -0
- package/dist/chunk-41fbr3m6.js +2 -0
- package/dist/chunk-4ct5vj9n.js +2 -0
- package/dist/chunk-4ta6131h.js +2 -0
- package/dist/chunk-5402rpwg.js +2 -0
- package/dist/{chunk-b9wpgn7b.js → chunk-56hvemdx.js} +5 -5
- package/dist/chunk-5tx1wqns.js +2 -0
- package/dist/chunk-5vgyr78g.js +2 -0
- package/dist/{chunk-t7x753ga.js → chunk-5zpt78j4.js} +4 -4
- package/dist/{chunk-7a0ffmer.js → chunk-6a1jr9pp.js} +4 -4
- package/dist/chunk-6nxzh304.js +2 -0
- package/dist/{chunk-8x47zcfa.js → chunk-73h7qjgq.js} +2 -2
- package/dist/chunk-7416mm6g.js +2 -0
- package/dist/{chunk-8wkja2z2.js → chunk-7676qzab.js} +3 -3
- package/dist/chunk-7cdrpkzz.js +2 -0
- package/dist/{chunk-yhxazetv.js → chunk-7cvc6hdw.js} +6 -6
- package/dist/{chunk-s28eh0jn.js → chunk-7mbx7dzg.js} +2 -2
- package/dist/{chunk-36kkc60p.js → chunk-7x8nd4fw.js} +3 -3
- package/dist/{chunk-74j5jbs6.js → chunk-81zfdd95.js} +3 -3
- package/dist/{chunk-5vwg3h5g.js → chunk-8nsmx2w4.js} +2 -2
- package/dist/{chunk-nq7z26y6.js → chunk-8sbm4bza.js} +5 -5
- package/dist/{chunk-acwgap78.js → chunk-9ad04ksh.js} +1 -1
- package/dist/{chunk-3rbz496d.js → chunk-9f0srtmg.js} +1 -1
- package/dist/{chunk-w040f2er.js → chunk-a3smkhem.js} +2 -2
- package/dist/chunk-a8hjvjb8.js +2 -0
- package/dist/{chunk-my3jkpv7.js → chunk-aa7w63xc.js} +7 -7
- package/dist/{chunk-tywmtk33.js → chunk-ak7eyyka.js} +2 -2
- package/dist/{chunk-pxqs3psa.js → chunk-b5emjcf1.js} +4 -4
- package/dist/{chunk-p2x7tjbt.js → chunk-bbnyq3gm.js} +2 -2
- package/dist/chunk-bcgth8qf.js +2 -0
- package/dist/{chunk-b8dbq51z.js → chunk-bh432b7n.js} +2 -2
- package/dist/chunk-by1s70jp.js +2 -0
- package/dist/{chunk-wtms9jhs.js → chunk-cm875f73.js} +2 -2
- package/dist/chunk-cpfnd8ta.js +2 -0
- package/dist/{chunk-721yq8qx.js → chunk-cs15xqf0.js} +4 -4
- package/dist/chunk-d59cjrpm.js +2 -0
- package/dist/chunk-d6npyn3x.js +2 -0
- package/dist/chunk-dftp2bp0.js +2 -0
- package/dist/{chunk-24e7qjb8.js → chunk-dn9thd0h.js} +2 -2
- package/dist/{chunk-114zdbnd.js → chunk-dqr5n49p.js} +2 -2
- package/dist/chunk-drsy8gek.js +2 -0
- package/dist/chunk-dvja1k84.js +2 -0
- package/dist/{chunk-4xemkkm8.js → chunk-dwp3knc4.js} +3 -3
- package/dist/chunk-e1n2t5tk.js +2 -0
- package/dist/{chunk-ydz7w2mt.js → chunk-f85dyf2f.js} +1 -1
- package/dist/chunk-fgedcdc1.js +2 -0
- package/dist/chunk-fm3k5v8s.js +2 -0
- package/dist/{chunk-thx147nq.js → chunk-fmj4xvqm.js} +5 -5
- package/dist/{chunk-5zahqrb4.js → chunk-fx994kkj.js} +6 -6
- package/dist/chunk-gsgkaa1g.js +2 -0
- package/dist/{chunk-6wmxrn6x.js → chunk-gvefw19e.js} +1 -1
- package/dist/{chunk-m607bd3m.js → chunk-h7ny0py8.js} +5 -5
- package/dist/{chunk-hc9242wm.js → chunk-hkx8pggg.js} +1 -1
- package/dist/{chunk-bjnvymb7.js → chunk-hqywyyez.js} +5 -5
- package/dist/{chunk-tprtjzzc.js → chunk-htwgkg91.js} +5 -5
- package/dist/{chunk-44zjqsh9.js → chunk-hwaxjfr0.js} +2 -2
- package/dist/{chunk-vzek2z1v.js → chunk-j0nyamyf.js} +1 -1
- package/dist/chunk-j3gcjbnm.js +2 -0
- package/dist/{chunk-ptjqacjd.js → chunk-jwpcck1b.js} +2 -2
- package/dist/chunk-k2k6engs.js +2 -0
- package/dist/chunk-kagy1rcd.js +2 -0
- package/dist/{chunk-5ty8h14h.js → chunk-kpz3tpx7.js} +4 -4
- package/dist/chunk-kr2phxhf.js +2 -0
- package/dist/{chunk-771hf74z.js → chunk-m0nw8he9.js} +5 -5
- package/dist/chunk-m3f50p6c.js +2 -0
- package/dist/{chunk-dtvwes4f.js → chunk-m4q2e418.js} +3 -3
- package/dist/chunk-m90a5dpn.js +2 -0
- package/dist/{chunk-9w5nse46.js → chunk-mcgpeyy8.js} +4 -4
- package/dist/{chunk-w2085fwx.js → chunk-mnz6bdp3.js} +5 -5
- package/dist/{chunk-93e1nf1y.js → chunk-mx9wp3va.js} +1 -1
- package/dist/{chunk-j1q65enz.js → chunk-n9jn3qzw.js} +2 -2
- package/dist/chunk-nqcg2bf0.js +2 -0
- package/dist/{chunk-3hmy75tw.js → chunk-nw8p8eg9.js} +5 -5
- package/dist/chunk-pe9hxhrb.js +2 -0
- package/dist/{chunk-3akpy7er.js → chunk-phafsgd9.js} +10 -10
- package/dist/{chunk-p4wvc7wx.js → chunk-qa7j3j71.js} +6 -6
- package/dist/chunk-qg5e32gx.js +2 -0
- package/dist/chunk-qqq7jr16.js +2 -0
- package/dist/chunk-qy8wb31b.js +2 -0
- package/dist/{chunk-ccq35xp7.js → chunk-r3f9jcf7.js} +3 -3
- package/dist/chunk-ra2wyhrd.js +2 -0
- package/dist/{chunk-8zf5q1m3.js → chunk-rdq113p4.js} +2 -2
- package/dist/chunk-rk3nsd1x.js +2 -0
- package/dist/chunk-rmnhy5az.js +2 -0
- package/dist/{chunk-spx27cs4.js → chunk-rvbcnahe.js} +2 -2
- package/dist/chunk-rwdkh7c0.js +2 -0
- package/dist/{chunk-4wf68rht.js → chunk-s5drjm2j.js} +6 -6
- package/dist/{chunk-zpnz1k3b.js → chunk-t5wfq4r9.js} +2 -2
- package/dist/{chunk-hnep9jbj.js → chunk-tn85vr56.js} +2 -2
- package/dist/chunk-tr1q484n.js +2 -0
- package/dist/chunk-tz32ndmq.js +2 -0
- package/dist/chunk-v404gvm0.js +2 -0
- package/dist/chunk-v4mrkvzc.js +33 -0
- package/dist/{chunk-r9vrqxma.js → chunk-v93znq7a.js} +1 -1
- package/dist/chunk-vhywbdej.js +2 -0
- package/dist/{chunk-3pxp0r0a.js → chunk-vxgtq00t.js} +3 -3
- package/dist/{chunk-r7pmpd2x.js → chunk-wbdk7bcw.js} +1 -1
- package/dist/{chunk-5ahb6arz.js → chunk-wf2gq6hc.js} +2 -2
- package/dist/chunk-wn1p05ac.js +2 -0
- package/dist/chunk-xf873x70.js +2 -0
- package/dist/{chunk-mtb5000n.js → chunk-xh420ckt.js} +2 -2
- package/dist/{chunk-7x8qwshk.js → chunk-xq4jdzje.js} +4 -4
- package/dist/chunk-y3695sgc.js +2 -0
- package/dist/chunk-ye27ept1.js +2 -0
- package/dist/chunk-ymvdbs80.js +2 -0
- package/dist/chunk-yqnkzkd3.js +2 -0
- package/dist/{chunk-tnbgy59s.js → chunk-yva29j3q.js} +3 -3
- package/dist/chunk-zntspqxt.js +2 -0
- package/dist/cli.js +19 -19
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/bridge/protocol.d.ts +1 -0
- package/dist/native/compiler/headwind-to-style.js +14 -6
- package/dist/native/compiler/html-to-ir.js +13 -5
- package/dist/native/compiler/icons.d.ts +1 -0
- package/dist/native/compiler/icons.js +1 -0
- package/dist/native/compiler/ir.d.ts +2 -0
- package/dist/native/components/primitives.d.ts +7 -3
- package/dist/native/components/primitives.js +1 -0
- package/dist/native/primitives/Icon.stx +7 -0
- package/dist/native/runtime/binding-tree.d.ts +3 -1
- package/dist/native/runtime/binding-tree.js +26 -5
- package/dist/native/runtime/craft-bridge.js +6 -1
- package/dist/native/runtime/craft.d.ts +4 -0
- package/dist/native/runtime/native-host.d.ts +3 -1
- package/dist/native/runtime/native-host.js +60 -5
- package/dist/native/runtime/shared-screen.js +10 -1
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-053t5wrs.js +0 -2
- package/dist/chunk-0jgvwa50.js +0 -2
- package/dist/chunk-0n28xm1q.js +0 -2
- package/dist/chunk-1cq9w2qz.js +0 -2
- package/dist/chunk-1n7d9ag2.js +0 -2
- package/dist/chunk-259ecbwa.js +0 -2
- package/dist/chunk-386zrhbf.js +0 -2
- package/dist/chunk-397fy72k.js +0 -2
- package/dist/chunk-48w0qzmk.js +0 -2
- package/dist/chunk-4bpc0tsf.js +0 -2
- package/dist/chunk-535nrr6j.js +0 -2
- package/dist/chunk-60j147cj.js +0 -2
- package/dist/chunk-67r98kff.js +0 -2
- package/dist/chunk-6c7294j8.js +0 -2
- package/dist/chunk-6faqgn2f.js +0 -2
- package/dist/chunk-7pbv9mg7.js +0 -2
- package/dist/chunk-7tkwt0a9.js +0 -2
- package/dist/chunk-87c76jq3.js +0 -2
- package/dist/chunk-88ey0pdm.js +0 -2
- package/dist/chunk-8h0nbb7t.js +0 -2
- package/dist/chunk-9yy4fyq6.js +0 -2
- package/dist/chunk-a88mq2k6.js +0 -2
- package/dist/chunk-awqft00q.js +0 -2
- package/dist/chunk-cczrcjfs.js +0 -2
- package/dist/chunk-cnmz9543.js +0 -2
- package/dist/chunk-cv56m171.js +0 -2
- package/dist/chunk-ed7p2a5q.js +0 -2
- package/dist/chunk-fg8kmyz8.js +0 -2
- package/dist/chunk-gq16fxc2.js +0 -2
- package/dist/chunk-h4avjh3q.js +0 -2
- package/dist/chunk-k5tcanyq.js +0 -2
- package/dist/chunk-k6kvgdd0.js +0 -2
- package/dist/chunk-kcwz3kvn.js +0 -2
- package/dist/chunk-ksyb5bgt.js +0 -2
- package/dist/chunk-mh4qh1dk.js +0 -2
- package/dist/chunk-p3462q2p.js +0 -2
- package/dist/chunk-pey0cpyh.js +0 -2
- package/dist/chunk-q5433grh.js +0 -2
- package/dist/chunk-qke87dwv.js +0 -2
- package/dist/chunk-r089d1s4.js +0 -2
- package/dist/chunk-rnjkfhh0.js +0 -2
- package/dist/chunk-rnth7r2v.js +0 -33
- package/dist/chunk-s4ypqjhp.js +0 -2
- package/dist/chunk-st6exqqv.js +0 -2
- package/dist/chunk-tv7hxprx.js +0 -2
- package/dist/chunk-veqzjwty.js +0 -2
- package/dist/chunk-vw8a7yfw.js +0 -2
- package/dist/chunk-vwms759h.js +0 -2
- package/dist/chunk-vzey1tm1.js +0 -2
- package/dist/chunk-w7zh2avv.js +0 -2
- package/dist/chunk-w88efb66.js +0 -2
- package/dist/chunk-xeb3vyhx.js +0 -2
- package/dist/chunk-xq5hzqg5.js +0 -2
- package/dist/chunk-xx5gx241.js +0 -2
- package/dist/chunk-ynrnx1tp.js +0 -2
- package/dist/chunk-z9154ddm.js +0 -2
- package/dist/chunk-zdkspb3m.js +0 -2
|
@@ -15,6 +15,7 @@ export declare interface STXNode {
|
|
|
15
15
|
directives?: STXDirectives
|
|
16
16
|
darkStyle?: STXStyle
|
|
17
17
|
children: (STXNode | string)[]
|
|
18
|
+
_inlineStyle?: STXStyle
|
|
18
19
|
_classes?: string
|
|
19
20
|
_source?: {
|
|
20
21
|
file: string
|
|
@@ -190,6 +191,7 @@ export type STXComponentType = | 'View'
|
|
|
190
191
|
| 'TouchableHighlight'
|
|
191
192
|
| 'Pressable'
|
|
192
193
|
// Media
|
|
194
|
+
| 'Icon'
|
|
193
195
|
| 'Image'
|
|
194
196
|
| 'ImageBackground'
|
|
195
197
|
// Lists
|
|
@@ -13,6 +13,7 @@ export declare const ComponentRegistry: {
|
|
|
13
13
|
Pressable: 'Pressable';
|
|
14
14
|
Switch: 'Switch';
|
|
15
15
|
Slider: 'Slider';
|
|
16
|
+
Icon: 'Icon';
|
|
16
17
|
Image: 'Image';
|
|
17
18
|
ImageBackground: 'ImageBackground';
|
|
18
19
|
FlatList: 'FlatList';
|
|
@@ -158,9 +159,12 @@ export declare interface PickerProps extends BaseProps {
|
|
|
158
159
|
onValueChange?: (value: string | number, index: number) => void
|
|
159
160
|
disabled?: boolean
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
/** Iconify or SF Symbol rendered by the platform's native icon view. */
|
|
163
|
+
export declare interface IconProps extends BaseProps {
|
|
164
|
+
name?: string
|
|
165
|
+
symbol?: string
|
|
166
|
+
color?: string
|
|
167
|
+
}
|
|
164
168
|
export declare interface ImageProps extends BaseProps {
|
|
165
169
|
source: ImageSource
|
|
166
170
|
resizeMode?: 'cover' | 'contain' | 'stretch' | 'center' | 'repeat'
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{{-- Iconify icons rendered as native symbols, without browser SVG markup. --}}
|
|
2
|
+
<script server>
|
|
3
|
+
const classes = $props.class ?? $props.className ?? ''
|
|
4
|
+
const name = $props.name ?? ''
|
|
5
|
+
const symbol = $props.symbol ?? ''
|
|
6
|
+
</script>
|
|
7
|
+
<span data-native="Icon" class="{{ classes }}" name="{{ name }}" symbol="{{ symbol }}"></span>
|
|
@@ -2,11 +2,13 @@ import type { BindingManifest } from '../../binding-manifest';
|
|
|
2
2
|
import type { NativeHost, NativeNode } from './native-host';
|
|
3
3
|
import type { STXDocument } from '../compiler/ir';
|
|
4
4
|
/** Clone the DOM-shaped metadata while the host clones the native descriptor. */
|
|
5
|
-
export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string): NativeBindingNode;
|
|
5
|
+
export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string, onClassChange?: (value: string) => void): NativeBindingNode;
|
|
6
6
|
/** Build host handles and a manifest-id lookup from already translated IR. */
|
|
7
7
|
export declare function materializeNativeBindingTree(document: STXDocument, manifest: BindingManifest, host: NativeHost): NativeBindingTree;
|
|
8
8
|
export declare interface NativeBindingNode extends NativeNode {
|
|
9
9
|
nodeType: 1
|
|
10
|
+
className: string
|
|
11
|
+
classList: { add: (...tokens: string[]) => void, remove: (...tokens: string[]) => void }
|
|
10
12
|
tagName: string
|
|
11
13
|
attributes: Array<{ name: string, value: string }>
|
|
12
14
|
parentNode: NativeBindingNode | null
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
function decodeBindingValue(value) {
|
|
2
2
|
return value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;/g, "'").replace(/'/gi, "'").replace(/&/g, "&");
|
|
3
3
|
}
|
|
4
|
-
function createBindingNode(id, type, bindings, connected = !0) {
|
|
4
|
+
function createBindingNode(id, type, bindings, connected = !0, classes = "", onClassChange) {
|
|
5
5
|
const attributes = bindings.map((binding) => ({
|
|
6
6
|
name: binding.name,
|
|
7
7
|
value: decodeBindingValue(binding.value)
|
|
8
|
-
}))
|
|
8
|
+
}));
|
|
9
|
+
if (classes && !attributes.some((attribute) => attribute.name === "class"))
|
|
10
|
+
attributes.push({ name: "class", value: classes });
|
|
11
|
+
const node = {
|
|
9
12
|
__stxId: id,
|
|
10
13
|
nodeType: 1,
|
|
14
|
+
get className() {
|
|
15
|
+
return node.getAttribute("class") ?? "";
|
|
16
|
+
},
|
|
17
|
+
set className(value) {
|
|
18
|
+
node.setAttribute("class", value);
|
|
19
|
+
},
|
|
20
|
+
classList: {
|
|
21
|
+
add(...tokens) {
|
|
22
|
+
node.className = [...new Set([...node.className.split(/\s+/).filter(Boolean), ...tokens])].join(" ");
|
|
23
|
+
},
|
|
24
|
+
remove(...tokens) {
|
|
25
|
+
node.className = node.className.split(/\s+/).filter((token) => token && !tokens.includes(token)).join(" ");
|
|
26
|
+
}
|
|
27
|
+
},
|
|
11
28
|
tagName: type.toUpperCase(),
|
|
12
29
|
attributes,
|
|
13
30
|
parentNode: null,
|
|
@@ -30,11 +47,15 @@ function createBindingNode(id, type, bindings, connected = !0) {
|
|
|
30
47
|
existing.value = String(value);
|
|
31
48
|
else
|
|
32
49
|
attributes.push({ name, value: String(value) });
|
|
50
|
+
if (name === "class")
|
|
51
|
+
onClassChange?.(String(value));
|
|
33
52
|
},
|
|
34
53
|
removeAttribute(name) {
|
|
35
54
|
const index = attributes.findIndex((attribute) => attribute.name === name);
|
|
36
55
|
if (index !== -1)
|
|
37
56
|
attributes.splice(index, 1);
|
|
57
|
+
if (name === "class")
|
|
58
|
+
onClassChange?.("");
|
|
38
59
|
},
|
|
39
60
|
contains(candidate) {
|
|
40
61
|
for (let current = candidate;current; current = current.parentNode)
|
|
@@ -61,13 +82,13 @@ function createBindingNode(id, type, bindings, connected = !0) {
|
|
|
61
82
|
node.isConnected = connected;
|
|
62
83
|
return node;
|
|
63
84
|
}
|
|
64
|
-
export function cloneNativeBindingNode(source, id) {
|
|
85
|
+
export function cloneNativeBindingNode(source, id, onClassChange) {
|
|
65
86
|
const bindings = source.attributes.map((attribute) => ({
|
|
66
87
|
name: attribute.name,
|
|
67
88
|
value: attribute.value,
|
|
68
89
|
kind: "attr"
|
|
69
90
|
}));
|
|
70
|
-
return createBindingNode(id, source.tagName, bindings, !1);
|
|
91
|
+
return createBindingNode(id, source.tagName, bindings, !1, source.className, onClassChange);
|
|
71
92
|
}
|
|
72
93
|
export function materializeNativeBindingTree(document, manifest, host) {
|
|
73
94
|
const entries = new Map(manifest.entries.map((entry) => [entry.id, entry])), nodes = new Map;
|
|
@@ -77,7 +98,7 @@ export function materializeNativeBindingTree(document, manifest, host) {
|
|
|
77
98
|
for (const [name, value] of Object.entries(source.bindings ?? {}))
|
|
78
99
|
if (!runtimeBindings.some((binding) => binding.name.replace(/^[:@]/, "") === name))
|
|
79
100
|
runtimeBindings.push({ name: `:${name}`, value, kind: "attr" });
|
|
80
|
-
const node = createBindingNode(id, source.type, runtimeBindings);
|
|
101
|
+
const node = createBindingNode(id, source.type, runtimeBindings, !0, source._classes, (value) => host.setAttribute(node, "class", value));
|
|
81
102
|
source.id = id;
|
|
82
103
|
source.props.__stxId = id;
|
|
83
104
|
node.parentNode = parent;
|
|
@@ -70,7 +70,12 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
70
70
|
delete: (key) => request("SecureStorage", "remove", [key]),
|
|
71
71
|
clear: () => request("SecureStorage", "clear", [])
|
|
72
72
|
});
|
|
73
|
-
craft.snapshots = Object.assign({ get: () => null, set: () => Promise.resolve(!1) }, craft.snapshots || {}
|
|
73
|
+
craft.snapshots = Object.assign({ get: () => null, set: () => Promise.resolve(!1) }, craft.snapshots || {}, {
|
|
74
|
+
onChange: (callback) => protocol.on("SNAPSHOT_CHANGED", (message) => {
|
|
75
|
+
if (typeof message.payload?.name === "string")
|
|
76
|
+
callback(message.payload.name);
|
|
77
|
+
})
|
|
78
|
+
});
|
|
74
79
|
craft.biometrics = {
|
|
75
80
|
isAvailable: () => request("Biometrics", "isAvailable", []),
|
|
76
81
|
getBiometricType: () => request("Biometrics", "getBiometricType", []),
|
|
@@ -17,6 +17,9 @@ export declare interface NativeNavigationButton {
|
|
|
17
17
|
image?: string
|
|
18
18
|
color?: string
|
|
19
19
|
accessibilityLabel?: string
|
|
20
|
+
variant?: 'accent' | 'account'
|
|
21
|
+
badge?: number
|
|
22
|
+
badgeStyle?: 'count' | 'dot'
|
|
20
23
|
onPress?: (event: { id: string }) => unknown
|
|
21
24
|
}
|
|
22
25
|
export declare interface NativeNavigationOptions {
|
|
@@ -52,6 +55,7 @@ export declare interface NativeSecureStorage {
|
|
|
52
55
|
getSync: (key: string) => string | null
|
|
53
56
|
}
|
|
54
57
|
export declare interface NativeSnapshots {
|
|
58
|
+
onChange: (callback: (name: string) => void) => () => void
|
|
55
59
|
get: <T = unknown>(name: string) => T | null
|
|
56
60
|
set: (name: string, value: unknown) => Promise<unknown>
|
|
57
61
|
}
|
|
@@ -11,10 +11,12 @@ export declare interface NativeNode {
|
|
|
11
11
|
__stxAnchor?: string
|
|
12
12
|
}
|
|
13
13
|
export declare interface NativeHostOptions {
|
|
14
|
+
colorScheme?: 'light' | 'dark'
|
|
14
15
|
send: (operations: NativeMutationOperation[]) => void
|
|
15
16
|
schedule?: (flush: () => void) => void
|
|
16
17
|
}
|
|
17
18
|
export declare interface NativeHost {
|
|
19
|
+
setColorScheme: (scheme: 'light' | 'dark') => void
|
|
18
20
|
setText: (node: NativeNode, value: unknown) => void
|
|
19
21
|
setAttribute: (node: NativeNode, name: string, value: unknown) => void
|
|
20
22
|
removeAttribute: (node: NativeNode, name: string) => void
|
|
@@ -28,7 +30,7 @@ export declare interface NativeHost {
|
|
|
28
30
|
remove: (node: NativeNode) => void
|
|
29
31
|
descendants: (node: NativeNode) => NativeNode[]
|
|
30
32
|
scopesIn: (node: NativeNode) => string[]
|
|
31
|
-
adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'props' | 'style' | 'events' | 'children'>) => NativeNode
|
|
33
|
+
adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'props' | 'style' | 'events' | 'children' | '_classes' | '_inlineStyle'>) => NativeNode
|
|
32
34
|
flush: () => void
|
|
33
35
|
dispatch: (handlerId: string, payload?: unknown) => void
|
|
34
36
|
pending: () => number
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { compileClassStyles } from "../compiler/headwind-to-style.js";
|
|
2
|
+
import { resolveIconName } from "../compiler/icons.js";
|
|
1
3
|
import { nativePropName } from "../prop-names.js";
|
|
2
4
|
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
3
5
|
export const HOST_METHODS = [
|
|
@@ -33,7 +35,7 @@ const NATIVE_EVENT_NAMES = {
|
|
|
33
35
|
};
|
|
34
36
|
export function createNativeHost(options) {
|
|
35
37
|
const records = new Map, handlers = new Map;
|
|
36
|
-
let queue = [], scheduled = !1, counter = 0;
|
|
38
|
+
let queue = [], scheduled = !1, counter = 0, colorScheme = options.colorScheme ?? "light";
|
|
37
39
|
const schedule = options.schedule ?? ((flush) => queueMicrotask(flush)), nextId = (prefix) => `${prefix}${++counter}`;
|
|
38
40
|
function flush() {
|
|
39
41
|
scheduled = !1;
|
|
@@ -53,7 +55,7 @@ export function createNativeHost(options) {
|
|
|
53
55
|
function recordOf(node) {
|
|
54
56
|
let record = records.get(node.__stxId);
|
|
55
57
|
if (!record) {
|
|
56
|
-
record = { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0, materialized: !0 };
|
|
58
|
+
record = { type: "View", props: {}, style: {}, baseStyle: {}, classes: "", events: {}, children: [], visible: !0, materialized: !0 };
|
|
57
59
|
records.set(node.__stxId, record);
|
|
58
60
|
}
|
|
59
61
|
return record;
|
|
@@ -80,6 +82,7 @@ export function createNativeHost(options) {
|
|
|
80
82
|
const record = recordOf(node);
|
|
81
83
|
if (record.materialized || node.__stxAnchor !== void 0)
|
|
82
84
|
return;
|
|
85
|
+
record.style = resolveStyle(record);
|
|
83
86
|
record.materialized = !0;
|
|
84
87
|
emit({
|
|
85
88
|
op: "createNode",
|
|
@@ -99,6 +102,27 @@ export function createNativeHost(options) {
|
|
|
99
102
|
emit({ op: "insertChild", parentId: node.__stxId, childId: child.__stxId, index: index++ });
|
|
100
103
|
}
|
|
101
104
|
}
|
|
105
|
+
function resolveStyle(record) {
|
|
106
|
+
const classes = compileClassStyles(record.classes);
|
|
107
|
+
return { ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...record.baseStyle };
|
|
108
|
+
}
|
|
109
|
+
function applyClasses(id, record) {
|
|
110
|
+
const style = resolveStyle(record), patch = Object.fromEntries(Object.keys(record.style).filter((key) => !(key in style)).map((key) => [key, null]));
|
|
111
|
+
record.style = style;
|
|
112
|
+
if (record.materialized)
|
|
113
|
+
emit({ op: "updateNode", id, patch: { style: { ...patch, ...style } } });
|
|
114
|
+
const classes = compileClassStyles(record.classes);
|
|
115
|
+
if (record.type === "Icon" && classes.icon) {
|
|
116
|
+
record.props.symbol = resolveIconName(classes.icon).symbol;
|
|
117
|
+
if (record.materialized)
|
|
118
|
+
emit({ op: "updateNode", id, patch: { props: { symbol: record.props.symbol } } });
|
|
119
|
+
}
|
|
120
|
+
if (classes.numberOfLines !== void 0) {
|
|
121
|
+
record.props.numberOfLines = classes.numberOfLines;
|
|
122
|
+
if (record.materialized)
|
|
123
|
+
emit({ op: "updateNode", id, patch: { props: { numberOfLines: classes.numberOfLines } } });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
102
126
|
function collectDescendants(node) {
|
|
103
127
|
const out = [], visit = (current) => {
|
|
104
128
|
const record = records.get(current.__stxId);
|
|
@@ -169,16 +193,22 @@ export function createNativeHost(options) {
|
|
|
169
193
|
const suffix = /(?:^|\D)(\d+)$/.exec(node.__stxId)?.[1];
|
|
170
194
|
if (suffix)
|
|
171
195
|
counter = Math.max(counter, Number(suffix));
|
|
172
|
-
|
|
196
|
+
const classes = descriptor?._classes ?? "", classStyle = compileClassStyles(classes).style, baseStyle = descriptor?._inlineStyle ? { ...descriptor._inlineStyle } : Object.fromEntries(Object.entries(descriptor?.style ?? {}).filter(([key, value]) => classStyle[key] !== value)), record = {
|
|
173
197
|
type,
|
|
174
198
|
props: { ...descriptor?.props ?? {} },
|
|
175
199
|
style: { ...descriptor?.style ?? {} },
|
|
200
|
+
baseStyle,
|
|
201
|
+
classes,
|
|
176
202
|
events: { ...descriptor?.events ?? {} },
|
|
177
203
|
text: descriptor?.children?.find((child) => typeof child === "string"),
|
|
178
204
|
children: [],
|
|
179
205
|
visible: !0,
|
|
180
206
|
materialized: !0
|
|
181
|
-
}
|
|
207
|
+
};
|
|
208
|
+
record.style = resolveStyle(record);
|
|
209
|
+
if (descriptor)
|
|
210
|
+
descriptor.style = { ...record.style };
|
|
211
|
+
records.set(node.__stxId, record);
|
|
182
212
|
decoratePosition(node);
|
|
183
213
|
node.__stxOwner = owner ?? null;
|
|
184
214
|
if (owner) {
|
|
@@ -190,6 +220,13 @@ export function createNativeHost(options) {
|
|
|
190
220
|
}
|
|
191
221
|
return {
|
|
192
222
|
adopt,
|
|
223
|
+
setColorScheme(scheme) {
|
|
224
|
+
if (scheme === colorScheme)
|
|
225
|
+
return;
|
|
226
|
+
colorScheme = scheme;
|
|
227
|
+
for (const [id, record] of records)
|
|
228
|
+
applyClasses(id, record);
|
|
229
|
+
},
|
|
193
230
|
pending: () => queue.length,
|
|
194
231
|
flush,
|
|
195
232
|
setText(node, value) {
|
|
@@ -198,11 +235,23 @@ export function createNativeHost(options) {
|
|
|
198
235
|
emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
|
|
199
236
|
},
|
|
200
237
|
setAttribute(node, name, value) {
|
|
238
|
+
if (name === "class" || name === "className") {
|
|
239
|
+
const record = recordOf(node);
|
|
240
|
+
record.classes = String(value ?? "");
|
|
241
|
+
applyClasses(node.__stxId, record);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
201
244
|
const prop = nativePropName(name);
|
|
202
245
|
recordOf(node).props[prop] = value;
|
|
246
|
+
if (recordOf(node).type === "Icon" && prop === "name")
|
|
247
|
+
this.setAttribute(node, "symbol", resolveIconName(String(value ?? "")).symbol);
|
|
203
248
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
|
|
204
249
|
},
|
|
205
250
|
removeAttribute(node, name) {
|
|
251
|
+
if (name === "class" || name === "className") {
|
|
252
|
+
this.setAttribute(node, name, "");
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
206
255
|
const prop = nativePropName(name);
|
|
207
256
|
delete recordOf(node).props[prop];
|
|
208
257
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: null } } });
|
|
@@ -211,6 +260,7 @@ export function createNativeHost(options) {
|
|
|
211
260
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
212
261
|
return;
|
|
213
262
|
const style = value;
|
|
263
|
+
Object.assign(recordOf(node).baseStyle, style);
|
|
214
264
|
Object.assign(recordOf(node).style, style);
|
|
215
265
|
emit({ op: "updateNode", id: node.__stxId, patch: { style } });
|
|
216
266
|
},
|
|
@@ -235,6 +285,7 @@ export function createNativeHost(options) {
|
|
|
235
285
|
setVisible(node, visible) {
|
|
236
286
|
const record = recordOf(node), was = record.visible;
|
|
237
287
|
record.visible = visible;
|
|
288
|
+
record.baseStyle.display = visible ? "flex" : "none";
|
|
238
289
|
emit({ op: "updateNode", id: node.__stxId, patch: { style: { display: visible ? "flex" : "none" } } });
|
|
239
290
|
return was;
|
|
240
291
|
},
|
|
@@ -244,7 +295,7 @@ export function createNativeHost(options) {
|
|
|
244
295
|
return anchor;
|
|
245
296
|
},
|
|
246
297
|
clone(node) {
|
|
247
|
-
const source = descriptorOf(node), id = nextId("n"), copy = isBindingNode(node) ? cloneNativeBindingNode(node, id) : { __stxId: id, __stxOwner: node.__stxOwner };
|
|
298
|
+
const source = descriptorOf(node), id = nextId("n"), copy = isBindingNode(node) ? cloneNativeBindingNode(node, id, (value) => this.setAttribute(copy, "class", value)) : { __stxId: id, __stxOwner: node.__stxOwner };
|
|
248
299
|
decoratePosition(copy);
|
|
249
300
|
if (node.__stxScope !== void 0)
|
|
250
301
|
copy.__stxScope = node.__stxScope;
|
|
@@ -252,6 +303,8 @@ export function createNativeHost(options) {
|
|
|
252
303
|
type: "View",
|
|
253
304
|
props: {},
|
|
254
305
|
style: {},
|
|
306
|
+
baseStyle: {},
|
|
307
|
+
classes: "",
|
|
255
308
|
events: {},
|
|
256
309
|
children: [],
|
|
257
310
|
visible: !0,
|
|
@@ -261,6 +314,8 @@ export function createNativeHost(options) {
|
|
|
261
314
|
type: descriptor.type,
|
|
262
315
|
props: { ...descriptor.props, __stxId: copy.__stxId },
|
|
263
316
|
style: { ...descriptor.style },
|
|
317
|
+
baseStyle: { ...descriptor.baseStyle },
|
|
318
|
+
classes: descriptor.classes,
|
|
264
319
|
events: { ...descriptor.events },
|
|
265
320
|
text: descriptor.text,
|
|
266
321
|
children: [],
|
|
@@ -8,6 +8,7 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
|
|
|
8
8
|
protocol.initialize(bridge);
|
|
9
9
|
installCraftBridge(protocol, bridge, globalThis, options);
|
|
10
10
|
const host = createNativeHost({
|
|
11
|
+
colorScheme: bridge.colorScheme === "dark" ? "dark" : "light",
|
|
11
12
|
send(operations) {
|
|
12
13
|
const baseRevision = revision;
|
|
13
14
|
revision++;
|
|
@@ -19,7 +20,15 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
|
|
|
19
20
|
operations
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
})
|
|
23
|
+
});
|
|
24
|
+
protocol.on("APPEARANCE", (message) => {
|
|
25
|
+
const scheme = message.payload?.colorScheme;
|
|
26
|
+
if (scheme === "light" || scheme === "dark") {
|
|
27
|
+
bridge.colorScheme = scheme;
|
|
28
|
+
host.setColorScheme(scheme);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const tree = materializeNativeBindingTree(document, manifest, host);
|
|
23
32
|
let dispose = null;
|
|
24
33
|
protocol.on("EVENT", (message) => {
|
|
25
34
|
const handlerId = message.payload?.handlerId ?? message.payload?.handlerName;
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{An,Ie,
|
|
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{An,Ie,Ii,Oa}from"./chunk-xq4jdzje.js";import{Rn,Br,Pa,Ia,Da}from"./chunk-h7ny0py8.js";import{Ri,Ai,Pi,Ra,Aa}from"./chunk-1qnyn82e.js";import{ie,pt,Fr}from"./chunk-bbnyq3gm.js";import{Nc,Lc,jc,Bc,lr,rd}from"./chunk-tn85vr56.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-tr1q484n.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=ie(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=An(n,t);if(a){let s=Ie(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return
|
|
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=ie(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=An(n,t);if(a){let s=Ie(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return Br(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Ai as auditBuildOutput,Ri as auditConfig,re as buildPwaAssets,Pi as calculateAuditResult,Aa as formatAuditResult,Fr as formatSize,j as generateManifest,_ as generateManifestJson,Ia as generateManifestLink,F as generateOfflinePage,ie as generatePrecacheManifest,pt as generatePrecacheManifestJs,M as generatePwaIcons,Rn as generatePwaTags,An as generateServiceWorker,Oa as generateServiceWorkerAuto,Pa as generateSwRegistrationScript,Da as generateThemeColorMeta,N as getExpectedIconPaths,Ie as getServiceWorkerFileName,Br as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Ii as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,lr as pwaDirectives,Nc as pwaInstallDirective,jc as pwaOfflineDirective,Bc as pwaPushDirective,Lc as pwaUpdateDirective,rd as registerPwaDirectives,Ra as runPwaAudit,D as validateManifest};
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-56hvemdx.js";import"./chunk-73h7qjgq.js";import{Qe,et,tt,nt,rt,st}from"./chunk-b5emjcf1.js";import"./chunk-2xnwsavq.js";import"./chunk-axydabse.js";import{f,je,M,q,n,i}from"./chunk-1ghj9pgz.js";import"./chunk-cs15xqf0.js";import{Zn}from"./chunk-aa7w63xc.js";import"./chunk-jwpcck1b.js";import"./chunk-wf2gq6hc.js";import"./chunk-dqr5n49p.js";import"./chunk-5zpt78j4.js";import"./chunk-htwgkg91.js";import{oe,ft,gt}from"./chunk-m0nw8he9.js";import{Ei,Ti,_i}from"./chunk-r3f9jcf7.js";import{dt,Xt,Gt}from"./chunk-yd50awqp.js";import"./chunk-7676qzab.js";import{a}from"./chunk-cm875f73.js";import x from"fs";import g from"path";import{createHash as $t}from"crypto";function Dt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Rt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function kt(t){return Bun.hash(t).toString(16)}function lt(t,s={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let o=new Map,r=t.replace(Rt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(s.minify)h=Dt(h);let S=kt(h);if(!o.has(S))o.set(S,h);let P=s.integrity?` data-stx-integrity="sha384-${$t("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(o,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Ct=new Set(["visible","idle"]);function ut(t){if(!t.includes("data-stx-src="))return t;let s=new Map,o=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=o.exec(t))!==null)s.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(Ct.has(s.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 Et=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function J(t){let s=t.trim();if(!s)return null;let o=/^https?:\/\//i.test(s)?s:`https://${s}`;try{return new URL(o).origin+new URL(o).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let s of Et){let o=t[s];if(!o)continue;let r=J(o);if(r)return{url:r,source:"env",via:s}}return null}function pt(t){if(!t||typeof t!=="object")return null;let s=t,o=s.site?.url??s.url??s.app?.url;return typeof o==="string"?J(o):null}async function Bt(t){let{existsSync:s}=await import("fs"),o=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=o.resolve(t,r);if(!s(c))continue;try{let e=await import(c),l=pt(e.default??e);if(l)return l}catch{}}return null}async function ht(t={}){let s=t.cwd??process.cwd(),o=t.env??process.env;if(t.explicit){let l=J(t.explicit);if(l)return{url:l,source:"option"}}let r=pt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(s);if(c)return{url:c,source:"site.config",via:"url"};let e=It(o);if(e)return e;return{url:"http://localhost",source:"fallback"}}function mt(){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
3
|
`)}class wt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,s=""){this.cacheDir=t,this.salt=s}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let s=JSON.parse(await Bun.file(t).text());for(let[o,r]of Object.entries(s))this.cache.set(o,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),s={};for(let[o,r]of this.cache)s[o]=r;await Bun.write(t,JSON.stringify(s))}getHash(t,s){let o=x.statSync(t),r=`${this.salt}|${t}:${o.mtimeMs}`;for(let e of s)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,s){let o=this.cache.get(t);if(!o)return null;let r=this.getHash(s,o.dependencies??[]);if(o.hash!==r)return this.cache.delete(t),null;return o.html}set(t,s,o,r){let c=this.getHash(s,o);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:o})}}class yt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let s=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",s)}async get(t){let s=this.getFilePath(t);if(!await Bun.file(s).exists())return null;try{return JSON.parse(await Bun.file(s).text())}catch{return null}}async set(t,s){let o=this.getFilePath(t);await x.promises.mkdir(g.dirname(o),{recursive:!0}),await Bun.write(o,JSON.stringify(s))}async invalidate(t){let s=this.getFilePath(t);if(await Bun.file(s).exists())await x.promises.unlink(s)}async invalidatePattern(t){let s=g.join(this.cacheDir,"isr");if(!x.existsSync(s))return;let o=await x.promises.readdir(s);for(let r of o){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(s,r))}}async needsRevalidation(t){let s=await this.get(t);if(!s)return!0;return Date.now()>s.revalidateAfter}}async function jt(t){try{let o=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let r=o[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]}
|
|
@@ -41,7 +41,7 @@ ${t.map((r)=>{let c=new URL(r.loc,s).href,e=` <url>
|
|
|
41
41
|
${o.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let s=Date.now();gt();let o=await i(process.cwd()),r=o.build||{},c=await ht({explicit:t.domain||r.domain,stxConfig:o});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(mt());let e={router:t.router??o?.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||o?.partialsDir||"",componentsDir:t.componentsDir||o?.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-
|
|
44
|
+
</rss>`}async function zt(t={}){let s=Date.now();gt();let o=await i(process.cwd()),r=o.build||{},c=await ht({explicit:t.domain||r.domain,stxConfig:o});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(mt());let e={router:t.router??o?.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||o?.partialsDir||"",componentsDir:t.componentsDir||o?.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-kagy1rcd.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-fgedcdc1.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 wt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-kagy1rcd.js");await u('<div class="bg-black"></div>')}catch{}Qe();let xt=o?.routeMiddleware?.dir||"middleware";await tt(process.cwd(),xt);let H=et();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let vt=o?.routeMiddleware?.global||[];_i(o?.layoutsDir,a(process.cwd()));let K=M(".",{pagesDir:e.pagesDir,pagesDirs:o?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ft(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:L,props:bt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),Pt=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],it=[...vt,...Pt];if(it.length>0){let C=nt(d,L,F||{}),O=rt(C,null,void 0,{isServer:!0}),E=await st(it,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 at=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(at)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${at[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,ot=!1;if(e.cache){if(k=B.get(d,v.filePath),k)ot=!0,l.cachedCount++}if(!k){let C=await St(v,L,bt,e,o);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:
|
|
@@ -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={...o,debug:!1,cache:!1},L=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),L)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...o,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=_t(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={...o,debug:!1,cache:!1},L=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),L)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...o,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=_t(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=Zn({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=Ei(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=Ti(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=Gt();if(Z)await V(Z,g.join(e.outputDir,Xt)),console.log(`Copied assets from ${dt}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-s,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
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.442",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -122,12 +122,12 @@
|
|
|
122
122
|
"dependencies": {
|
|
123
123
|
"@stacksjs/ts-css": "^0.3.2",
|
|
124
124
|
"@stacksjs/clapp": "^0.2.16",
|
|
125
|
-
"@stacksjs/desktop": "0.2.
|
|
126
|
-
"@stacksjs/sanitizer": "0.2.
|
|
125
|
+
"@stacksjs/desktop": "0.2.442",
|
|
126
|
+
"@stacksjs/sanitizer": "0.2.442",
|
|
127
127
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
128
|
-
"bun-plugin-stx": "0.2.
|
|
128
|
+
"bun-plugin-stx": "0.2.442",
|
|
129
129
|
"bunfig": "^0.15.19",
|
|
130
|
-
"stx-router": "0.2.
|
|
130
|
+
"stx-router": "0.2.442",
|
|
131
131
|
"ts-broadcasting": "^0.0.11",
|
|
132
132
|
"ts-images": "^0.2.22",
|
|
133
133
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-053t5wrs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{In,za,yu,Ha,bu,Va,Dn,h,wt,he,Ua,Gr,Wa,wu,W,qa,vu,b,xu}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{qa as applyFilters,bu as clearCustomFilters,Ua as clientLoopScopes,In as defaultFilters,h as escapeHtml,wt as escapeHtmlValue,b as evaluateExpression,Va as findMustacheEnd,Ha as getAllFilters,Wa as interpolateScriptAttributes,Gr as interpolateScriptExpressions,wu as interpolateScriptsInTemplate,W as processExpressions,za as registerFilter,yu as registerFilters,Dn as replaceInterpolations,vu as resetRejectedExpressionWarnings,xu as unescapeHtml,he as usesSignalsInScript};
|
package/dist/chunk-0jgvwa50.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ou,nc,es,ts,Vi,Ui,ns,rs,Ln,rc,Wi,qi,sc,ze}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Ou as clearScriptScanCache,ns as convertServerLoopAttributesToDirectives,Vi as convertSignalDirectivesToAttributes,rs as convertSignalLoopsToAttributes,rc as extractExports,qi as findMarkupIndexOutsideScripts,ts as hasSignalsSyntax,es as parseLoopExpression,Ui as preEvalLiteralReactiveIfs,Ln as processScriptSetup,Wi as processSignals,sc as rewriteStxImportSpecifiers,nc as scanScriptTags,ze as stripStxRuntimeImports};
|
package/dist/chunk-0n28xm1q.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Is,Ds,Ze,X,gn,sr,mn,ir,or,Ec,Tc,_c,hn,Rc,Ac,Pc,Ic,_o,Ro,Ao,Os,Po,Dc,Qe,et,tt,nt,rt,st,Se,Oc}from"./chunk-pxqs3psa.js";export{mn as Router,Pc as abortNavigation,sr as bracketPathToRegex,Qe as clearMiddleware,Ro as createClientCookieManager,rt as createMiddlewareContext,nt as createRouteLocation,_o as createServerCookieManager,Ao as createStorageManager,Ic as defineMiddleware,Tc as defineRoute,_c as defineRoutes,ir as findErrorPage,or as formatRoutes,Ds as generateRouteManifest,Is as generateRouteTypes,Po as getMiddleware,et as getMiddlewareNames,Se as getRouterScript,Oc as getRouterScriptDev,Dc as hasMiddleware,Ze as isFileRequestPath,tt as loadMiddlewareFromDirectory,gn as matchRoute,Ac as navigateTo,X as patternToRegex,Os as registerMiddleware,Rc as resetRoutes,hn as route,st as runMiddleware,Ec as setAppUrl};
|
package/dist/chunk-1cq9w2qz.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{oe,Oa,Ii,ft,gt,gu,Di,mt,Jt,Ma,Na,La,ja,ht,Ba}from"./chunk-771hf74z.js";import"./chunk-tprtjzzc.js";import"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Jt as MODULE_SPECIFIER_PREFIX,ht as bundleClientScript,gt as clearBundleFailures,oe as clientBundleDependencies,ft as getBundleFailures,mt as hasUserImports,Na as normalizeRegistrySpecifiers,ja as queueClientBundleBuild,Ii as recordBundleFailure,Ma as registryIdForPath,Di as resolveBundlerFallback,La as rewriteRegistryImports,gu as setBundlerFallbackMode,Oa as shouldLogBundlerDiagnostics,Ba as tempBuildName};
|
package/dist/chunk-1n7d9ag2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Me,Ka,Su,ku,Cu,$u,Xa,Ga,Eu,Tu,Bi,_u,Zt,Qt,On}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{$u as __setSignalsGeneratorsForTest,Me as cacheEngineFingerprint,Qt as cacheTemplate,Zt as checkCache,_u as clearDevCaches,Ga as getCachedRouterScript,Xa as getCachedSignalsRuntime,Eu as getServeClientAsset,Bi as getServeModuleBundle,On as hashFilePath,ku as invalidateFileCache,Cu as invalidateFileCacheByDir,Su as readFileCached,Tu as registerServeModuleBundle,Ka as templateCache};
|
package/dist/chunk-259ecbwa.js
DELETED
package/dist/chunk-386zrhbf.js
DELETED
package/dist/chunk-397fy72k.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ho,Zs,Hc,Vo,Uo,Vc,Uc}from"./chunk-3akpy7er.js";import"./chunk-xfv7evmd.js";import"./chunk-771hf74z.js";import"./chunk-tprtjzzc.js";import{He,fc}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Ho as buildVirtualSource,He as extractScriptBlocks,fc as extractTemplateExpressions,Vo as findRuntimeTypeDeclarations,Uo as findStxModuleDeclarations,Uc as formatTypecheckDiagnostics,Hc as sourcePathFor,Vc as typecheckStxFiles,Zs as virtualPathFor};
|
package/dist/chunk-48w0qzmk.js
DELETED
package/dist/chunk-4bpc0tsf.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{qc}from"./chunk-36kkc60p.js";import"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{qc as startInteractive};
|
package/dist/chunk-535nrr6j.js
DELETED
package/dist/chunk-60j147cj.js
DELETED
package/dist/chunk-67r98kff.js
DELETED