@stacksjs/stx 0.2.422 → 0.2.424
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-ep5jnqdb.js → chunk-02n071n7.js} +6 -6
- package/dist/chunk-03n23sh6.js +2 -0
- package/dist/chunk-07mxghsz.js +2 -0
- package/dist/{chunk-kjkwycce.js → chunk-0bmc75w6.js} +4 -4
- package/dist/{chunk-hyak4dzg.js → chunk-0hhq9hbq.js} +3 -3
- package/dist/{chunk-66k7yxnr.js → chunk-12pvnn1e.js} +4 -4
- package/dist/chunk-1497wcxc.js +2 -0
- package/dist/chunk-17n9e5wk.js +2 -0
- package/dist/chunk-1p8hc1ve.js +2 -0
- package/dist/chunk-1r3ghgsz.js +2 -0
- package/dist/{chunk-681cxw8j.js → chunk-24e7qjb8.js} +2 -2
- package/dist/chunk-259ecbwa.js +2 -0
- package/dist/chunk-26gfsa9w.js +2 -0
- package/dist/{chunk-zp0mg8b2.js → chunk-2bpjq1qz.js} +2 -2
- package/dist/{chunk-11ra3sbc.js → chunk-2x9jd5w0.js} +3 -3
- package/dist/{chunk-k31fwm2w.js → chunk-3hmy75tw.js} +5 -5
- package/dist/{chunk-12b8akfg.js → chunk-3pxp0r0a.js} +3 -3
- package/dist/{chunk-x5ks23vx.js → chunk-3ry9ca1s.js} +2 -2
- package/dist/{chunk-th9s15es.js → chunk-45rfv3a5.js} +2 -2
- package/dist/chunk-47apfsxp.js +2 -0
- package/dist/{chunk-w72p2ak0.js → chunk-48kgnqpk.js} +4 -4
- package/dist/{chunk-rsxvbnp4.js → chunk-4hd5wb8x.js} +3 -3
- package/dist/chunk-535nrr6j.js +2 -0
- package/dist/chunk-5mfhk69g.js +2 -0
- package/dist/{chunk-aync8qmk.js → chunk-5vwg3h5g.js} +2 -2
- package/dist/{chunk-tspmynvh.js → chunk-62chbqev.js} +1 -1
- package/dist/chunk-6c7294j8.js +2 -0
- package/dist/{chunk-qwgdtrhj.js → chunk-6cbvx87h.js} +5 -5
- package/dist/{chunk-q0cehgy2.js → chunk-6fsbny9m.js} +3 -3
- package/dist/chunk-6gh2rvyz.js +2 -0
- package/dist/chunk-6j6gbp0y.js +2 -0
- package/dist/chunk-6jgjmycb.js +2 -0
- package/dist/{chunk-w83djypm.js → chunk-6t278w29.js} +2 -2
- package/dist/{chunk-5vfyxxrp.js → chunk-6t7mxb0b.js} +2 -2
- package/dist/chunk-6wmxrn6x.js +2 -0
- package/dist/chunk-6wweqfg7.js +2 -0
- package/dist/{chunk-ja7znxnz.js → chunk-7a9h7ycs.js} +5 -5
- package/dist/chunk-7pbv9mg7.js +2 -0
- package/dist/{chunk-09hhrjk9.js → chunk-89b2r1q0.js} +6 -6
- package/dist/{chunk-0varh725.js → chunk-8a0r2j8f.js} +3 -3
- package/dist/{chunk-gp8xzbyt.js → chunk-8nsbf2mz.js} +1074 -1074
- package/dist/{chunk-mg13q1kd.js → chunk-8zf5q1m3.js} +2 -2
- package/dist/chunk-9d53d0t6.js +2 -0
- package/dist/chunk-9j72har9.js +2 -0
- package/dist/chunk-9yqz5ge5.js +2 -0
- package/dist/chunk-a5c9n7an.js +2 -0
- package/dist/chunk-a836zn7c.js +2 -0
- package/dist/{chunk-kzkjc12e.js → chunk-a8g6y9kw.js} +5 -5
- package/dist/{chunk-21a7p956.js → chunk-acwgap78.js} +1 -1
- package/dist/{chunk-qx3js9tk.js → chunk-aen2baze.js} +1 -1
- package/dist/chunk-ahgrkva8.js +2 -0
- package/dist/chunk-akbb6j7s.js +2 -0
- package/dist/chunk-avakcrbs.js +2 -0
- package/dist/{chunk-tafebmtg.js → chunk-axydabse.js} +2 -2
- package/dist/{chunk-4n6c5rp5.js → chunk-b7973zvk.js} +2 -2
- package/dist/{chunk-ebkpdc45.js → chunk-bxwe7wxj.js} +10 -10
- package/dist/{chunk-2ewa2sg5.js → chunk-c1dmr865.js} +3 -3
- package/dist/chunk-cenq2n6e.js +2 -0
- package/dist/{chunk-zvh2nnzr.js → chunk-cf6htz63.js} +1 -1
- package/dist/chunk-cnmz9543.js +2 -0
- package/dist/{chunk-h1585jbm.js → chunk-cx2rdew4.js} +13 -13
- package/dist/{chunk-wg1ttvs5.js → chunk-cznsm2n3.js} +2 -2
- package/dist/chunk-d1qzhawc.js +2 -0
- package/dist/chunk-d6hnvwre.js +2 -0
- package/dist/{chunk-7abgzdsm.js → chunk-dcwjxq8n.js} +2 -2
- package/dist/chunk-dhqwg62x.js +2 -0
- package/dist/{chunk-95e3rz88.js → chunk-dmd6yk2x.js} +5 -5
- package/dist/chunk-e18qfegt.js +2 -0
- package/dist/chunk-eej89wkt.js +2 -0
- package/dist/chunk-ekxffxbd.js +2 -0
- package/dist/{chunk-hy9e3ny6.js → chunk-ex0tq6x2.js} +1 -1
- package/dist/{chunk-nqr77pxk.js → chunk-fg5ve6ey.js} +2 -2
- package/dist/{chunk-dejsjk4h.js → chunk-fnt1q1sp.js} +11 -11
- package/dist/chunk-g67gg66e.js +2 -0
- package/dist/chunk-gq16fxc2.js +2 -0
- package/dist/{chunk-5e9zkd65.js → chunk-h3c7z73m.js} +2 -2
- package/dist/chunk-h4avjh3q.js +2 -0
- package/dist/chunk-h7qte7ye.js +2 -0
- package/dist/{chunk-hmdnn9ja.js → chunk-hb9gxad0.js} +3 -3
- package/dist/{chunk-dmxh7zwq.js → chunk-hg4k3nkr.js} +1 -1
- package/dist/{chunk-dhxbjw6k.js → chunk-hnep9jbj.js} +2 -2
- package/dist/chunk-hwycbxg7.js +2 -0
- package/dist/{chunk-34gy5zjm.js → chunk-j1q65enz.js} +2 -2
- package/dist/chunk-j5myfxe8.js +18 -0
- package/dist/{chunk-8jqy69td.js → chunk-j7zywbq0.js} +2 -2
- package/dist/{chunk-788g87ft.js → chunk-jbrdebzs.js} +7 -7
- package/dist/{chunk-wr6b99pw.js → chunk-jj4pyeyj.js} +1 -1
- package/dist/{chunk-g1fxmp9z.js → chunk-k8sqs7j2.js} +4 -4
- package/dist/chunk-mg7jhx5v.js +2 -0
- package/dist/chunk-n16wa755.js +2 -0
- package/dist/chunk-ngv1c807.js +2 -0
- package/dist/{chunk-krr2vb0s.js → chunk-p2x7tjbt.js} +3 -3
- package/dist/{chunk-62r4fa4q.js → chunk-ptjqacjd.js} +2 -2
- package/dist/{chunk-597rfddk.js → chunk-qm1tt8g1.js} +2334 -2334
- package/dist/chunk-r7r5h2eh.js +2 -0
- package/dist/chunk-rhkx17d9.js +2 -0
- package/dist/{chunk-b1fg9vg7.js → chunk-s28eh0jn.js} +2 -2
- package/dist/{chunk-837nb4zv.js → chunk-s295vp9x.js} +3 -3
- package/dist/chunk-sazpw71r.js +4 -0
- package/dist/{chunk-20tdz0zs.js → chunk-sbdzqqr1.js} +6 -6
- package/dist/{chunk-qby6wxat.js → chunk-spx27cs4.js} +2 -2
- package/dist/{chunk-n7jjp08m.js → chunk-stxmwytg.js} +2 -2
- package/dist/{chunk-2tfe2g58.js → chunk-t3wh1jbk.js} +6 -6
- package/dist/{chunk-802pr252.js → chunk-tfexmdkt.js} +2 -2
- package/dist/{chunk-2cn8krpp.js → chunk-tfz95n7j.js} +5 -5
- package/dist/chunk-thdbqsxq.js +2 -0
- package/dist/chunk-tpnfcb83.js +2 -0
- package/dist/chunk-tqkv4th9.js +2 -0
- package/dist/chunk-tznejj9h.js +2 -0
- package/dist/{chunk-ap6fehea.js → chunk-vfk725vm.js} +5 -5
- package/dist/chunk-vsrm9k7p.js +2 -0
- package/dist/chunk-vwms759h.js +2 -0
- package/dist/{chunk-xvzxrt9a.js → chunk-w2085fwx.js} +5 -5
- package/dist/chunk-w252cgnv.js +30 -0
- package/dist/chunk-whdw6dhb.js +2 -0
- package/dist/chunk-wtms9jhs.js +3 -0
- package/dist/chunk-wtqjfar3.js +2 -0
- package/dist/chunk-wx7kfet5.js +2 -0
- package/dist/chunk-wy873fy8.js +2 -0
- package/dist/{chunk-d2z6828s.js → chunk-xa3wsmt5.js} +11 -11
- package/dist/chunk-xrbqf77j.js +2 -0
- package/dist/{chunk-757ec865.js → chunk-yaebdyfr.js} +2 -2
- package/dist/chunk-ycpq3gxc.js +2 -0
- package/dist/chunk-yd50awqp.js +3 -0
- package/dist/{chunk-csjw5esc.js → chunk-ydz7w2mt.js} +2 -2
- package/dist/chunk-yjgbxf26.js +2 -0
- package/dist/{chunk-jjnfj9nf.js → chunk-yqsza22w.js} +2 -2
- package/dist/{chunk-3xm6dyab.js → chunk-zbr333kf.js} +88 -27
- package/dist/chunk-zcyjdcpx.js +33 -0
- package/dist/{chunk-tqnysw0k.js → chunk-zfzcedw4.js} +4 -4
- package/dist/chunk-zm73n103.js +2 -0
- package/dist/cli.js +20 -20
- package/dist/component-renderer.js +54 -2
- package/dist/composables/use-outbox.d.ts +1 -0
- package/dist/composables/use-outbox.js +23 -10
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/database.js +2 -2
- package/dist/native/bridge/protocol.d.ts +5 -0
- package/dist/native/bridge/protocol.js +3 -0
- package/dist/native/cli.js +12 -2
- package/dist/native/compiler/bundle.d.ts +4 -3
- package/dist/native/compiler/bundle.js +46 -51
- package/dist/native/compiler/component-mapping.d.ts +5 -0
- package/dist/native/compiler/component-mapping.js +90 -0
- package/dist/native/compiler/html-to-ir.js +42 -6
- package/dist/native/compiler/ir.d.ts +2 -0
- package/dist/native/compiler/render-screen.d.ts +4 -0
- package/dist/native/compiler/render-screen.js +10 -2
- package/dist/native/compiler/setup-script.d.ts +6 -0
- package/dist/native/compiler/setup-script.js +10 -0
- package/dist/native/components/primitives.d.ts +10 -0
- package/dist/native/index.d.ts +6 -24
- package/dist/native/index.js +1 -17
- package/dist/native/primitives/Button.stx +2 -1
- package/dist/native/primitives/Text.stx +2 -1
- package/dist/native/primitives/TextInput.stx +3 -1
- package/dist/native/prop-names.d.ts +2 -0
- package/dist/native/prop-names.js +71 -0
- package/dist/native/runtime/binding-tree.d.ts +31 -0
- package/dist/native/runtime/binding-tree.js +100 -0
- package/dist/native/runtime/craft-bridge.d.ts +9 -0
- package/dist/native/runtime/craft-bridge.js +231 -0
- package/dist/native/runtime/craft.d.ts +28 -3
- package/dist/native/runtime/jsc-globals.d.ts +16 -0
- package/dist/native/runtime/jsc-globals.js +64 -0
- package/dist/native/runtime/native-host.d.ts +3 -1
- package/dist/native/runtime/native-host.js +183 -33
- package/dist/native/runtime/shared-screen.d.ts +15 -0
- package/dist/native/runtime/shared-screen.js +41 -0
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.d.ts +3 -1
- package/dist/signal-processing.js +4 -3
- package/dist/signals.js +77 -16
- package/dist/ssg.js +28 -28
- package/package.json +5 -5
- package/dist/chunk-10fh9qhe.js +0 -2
- package/dist/chunk-1569v24d.js +0 -2
- package/dist/chunk-18awnp9d.js +0 -2
- package/dist/chunk-1r0c5920.js +0 -30
- package/dist/chunk-2hswgxpb.js +0 -2
- package/dist/chunk-4363reg4.js +0 -2
- package/dist/chunk-48axv7bm.js +0 -2
- package/dist/chunk-50hgr79y.js +0 -2
- package/dist/chunk-54wczcee.js +0 -2
- package/dist/chunk-74gz26zs.js +0 -2
- package/dist/chunk-7906p8zs.js +0 -2
- package/dist/chunk-7dkfjmjw.js +0 -2
- package/dist/chunk-7vr5w75r.js +0 -4
- package/dist/chunk-7zn0yyqk.js +0 -2
- package/dist/chunk-8d2kamh2.js +0 -2
- package/dist/chunk-8ttvazck.js +0 -2
- package/dist/chunk-8y4bqsxz.js +0 -2
- package/dist/chunk-9bpnz431.js +0 -2
- package/dist/chunk-ac033b93.js +0 -2
- package/dist/chunk-aj43359g.js +0 -2
- package/dist/chunk-aj8yq228.js +0 -2
- package/dist/chunk-as72dvvm.js +0 -2
- package/dist/chunk-bfvaxrq0.js +0 -2
- package/dist/chunk-bkaw7sgz.js +0 -2
- package/dist/chunk-d0q2x8e3.js +0 -2
- package/dist/chunk-d2c5727w.js +0 -2
- package/dist/chunk-d5amzers.js +0 -2
- package/dist/chunk-dfchrqw5.js +0 -2
- package/dist/chunk-epv0ahg1.js +0 -2
- package/dist/chunk-f5489ese.js +0 -2
- package/dist/chunk-fqq1w9m1.js +0 -2
- package/dist/chunk-hcgsgnq8.js +0 -2
- package/dist/chunk-hgqcqg1h.js +0 -2
- package/dist/chunk-hjdwf9gp.js +0 -2
- package/dist/chunk-hp7ewdnp.js +0 -2
- package/dist/chunk-jjtzm6dn.js +0 -3
- package/dist/chunk-js79j12f.js +0 -18
- package/dist/chunk-kfsp322p.js +0 -2
- package/dist/chunk-kt557jaj.js +0 -2
- package/dist/chunk-n8kqvzba.js +0 -2
- package/dist/chunk-na70r4sp.js +0 -2
- package/dist/chunk-p083sckk.js +0 -2
- package/dist/chunk-pc178389.js +0 -2
- package/dist/chunk-psqk7932.js +0 -2
- package/dist/chunk-pv5nr9pd.js +0 -2
- package/dist/chunk-q1v0jwr4.js +0 -2
- package/dist/chunk-qeye0901.js +0 -2
- package/dist/chunk-qy59yp2v.js +0 -2
- package/dist/chunk-r5gjb55x.js +0 -2
- package/dist/chunk-tf44jyrh.js +0 -2
- package/dist/chunk-tfypkw4y.js +0 -3
- package/dist/chunk-vv4kkwhn.js +0 -2
- package/dist/chunk-vwhd3h8x.js +0 -2
- package/dist/chunk-vxj8kd2v.js +0 -2
- package/dist/chunk-vzzpvn21.js +0 -2
- package/dist/chunk-w1a2v264.js +0 -2
- package/dist/chunk-wcs7w8wv.js +0 -2
- package/dist/chunk-x6ndnpvr.js +0 -2
- package/dist/chunk-x8rckpyz.js +0 -2
- package/dist/chunk-ya0qecph.js +0 -27
- package/dist/chunk-ykwmqh8z.js +0 -2
- package/dist/chunk-ys71pmrb.js +0 -2
- package/dist/chunk-z5y4qyhg.js +0 -2
- package/dist/chunk-zpcz2kh6.js +0 -2
- package/dist/native/compiler/codegen.d.ts +0 -10
- package/dist/native/compiler/codegen.js +0 -145
- package/dist/native/compiler/parser.d.ts +0 -88
- package/dist/native/compiler/parser.js +0 -753
- package/dist/native/runtime/entry.d.ts +0 -1
- package/dist/native/runtime/entry.js +0 -3
- package/dist/native/runtime/index.d.ts +0 -45
- package/dist/native/runtime/index.js +0 -165
- package/dist/native/runtime/screen.d.ts +0 -43
- package/dist/native/runtime/screen.js +0 -808
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `craft` object a native screen's script sees, typed.
|
|
3
3
|
*
|
|
4
|
-
* The
|
|
5
|
-
* before the script runs. A screen written in TypeScript can name it:
|
|
4
|
+
* The shared native screen adapter and the Craft host install it on
|
|
5
|
+
* `globalThis` before the script runs. A screen written in TypeScript can name it:
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
8
|
* import type { NativeCraft } from '@stacksjs/stx/native'
|
|
@@ -57,6 +57,7 @@ export declare interface NativeSnapshots {
|
|
|
57
57
|
}
|
|
58
58
|
export declare interface NativeCraft {
|
|
59
59
|
platform: string
|
|
60
|
+
capabilityProtocolVersion: number
|
|
60
61
|
route: { name: string, params: Record<string, unknown> }
|
|
61
62
|
capabilities: Record<string, boolean>
|
|
62
63
|
navigation: NativeNavigation
|
|
@@ -69,8 +70,32 @@ export declare interface NativeCraft {
|
|
|
69
70
|
notification: (type?: 'success' | 'warning' | 'error') => Promise<void>
|
|
70
71
|
selection: () => Promise<void>
|
|
71
72
|
}
|
|
73
|
+
haptic: (style?: string) => Promise<unknown>
|
|
72
74
|
clipboard: { write: (text: string) => Promise<unknown>, read: () => Promise<string> }
|
|
73
75
|
device: { getInfo: () => Promise<Record<string, unknown>> }
|
|
74
|
-
|
|
76
|
+
biometrics: {
|
|
77
|
+
isAvailable: () => Promise<boolean>
|
|
78
|
+
getBiometricType: () => Promise<string | null>
|
|
79
|
+
authenticate: (reason?: string) => Promise<unknown>
|
|
80
|
+
}
|
|
81
|
+
db: {
|
|
82
|
+
execute: (sql: string, params?: unknown[]) => Promise<unknown>
|
|
83
|
+
query: <T = unknown>(sql: string, params?: unknown[]) => Promise<T[]>
|
|
84
|
+
beginTransaction: () => Promise<unknown>
|
|
85
|
+
commit: () => Promise<unknown>
|
|
86
|
+
rollback: () => Promise<unknown>
|
|
87
|
+
}
|
|
88
|
+
notifications: {
|
|
89
|
+
show: (notification: unknown) => Promise<unknown>
|
|
90
|
+
schedule: (notification: unknown) => Promise<unknown>
|
|
91
|
+
cancel: (id: string) => Promise<unknown>
|
|
92
|
+
cancelAll: () => Promise<unknown>
|
|
93
|
+
pending: () => Promise<unknown[]>
|
|
94
|
+
}
|
|
95
|
+
lifecycle: {
|
|
96
|
+
getState: () => 'active' | 'inactive' | 'background'
|
|
97
|
+
onStateChange: (callback: (state: string) => unknown) => () => void
|
|
98
|
+
onChange: (callback: (state: string) => unknown) => () => void
|
|
99
|
+
}
|
|
75
100
|
deepLinks: { getInitialURL: () => Promise<string | null>, onLink: (callback: (link: unknown) => unknown) => () => void }
|
|
76
101
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Install only the browser-shaped globals the shared runtime needs to boot in JSC. */
|
|
2
|
+
export declare function installJSCGlobals(target?: AnyRecord): void;
|
|
3
|
+
declare type AnyRecord = Record<string, any> // eslint-disable-line ts/no-explicit-any;
|
|
4
|
+
declare class NativeEvent {
|
|
5
|
+
type: string;
|
|
6
|
+
detail: unknown;
|
|
7
|
+
target: unknown;
|
|
8
|
+
key: string;
|
|
9
|
+
ctrlKey: boolean;
|
|
10
|
+
altKey: boolean;
|
|
11
|
+
shiftKey: boolean;
|
|
12
|
+
metaKey: boolean;
|
|
13
|
+
constructor(type: string, options?: { detail?: unknown });
|
|
14
|
+
preventDefault(): void;
|
|
15
|
+
stopPropagation(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
class NativeEvent {
|
|
2
|
+
type;
|
|
3
|
+
detail;
|
|
4
|
+
target = null;
|
|
5
|
+
key = "";
|
|
6
|
+
ctrlKey = !1;
|
|
7
|
+
altKey = !1;
|
|
8
|
+
shiftKey = !1;
|
|
9
|
+
metaKey = !1;
|
|
10
|
+
constructor(type, options = {}) {
|
|
11
|
+
this.type = type;
|
|
12
|
+
this.detail = options.detail;
|
|
13
|
+
}
|
|
14
|
+
preventDefault() {}
|
|
15
|
+
stopPropagation() {}
|
|
16
|
+
}
|
|
17
|
+
export function installJSCGlobals(target = globalThis) {
|
|
18
|
+
const listeners = new Map, addEventListener = (name, listener) => {
|
|
19
|
+
const group = listeners.get(name) ?? new Set;
|
|
20
|
+
group.add(listener);
|
|
21
|
+
listeners.set(name, group);
|
|
22
|
+
}, removeEventListener = (name, listener) => {
|
|
23
|
+
listeners.get(name)?.delete(listener);
|
|
24
|
+
}, dispatchEvent = (event) => {
|
|
25
|
+
for (const listener of listeners.get(event.type) ?? [])
|
|
26
|
+
listener(event);
|
|
27
|
+
return !0;
|
|
28
|
+
}, emptyList = [], documentElement = { setAttribute() {}, removeAttribute() {}, getAttribute() {
|
|
29
|
+
return null;
|
|
30
|
+
} }, head = { appendChild() {} };
|
|
31
|
+
target.window = target;
|
|
32
|
+
target.Node ??= { ELEMENT_NODE: 1, TEXT_NODE: 3, COMMENT_NODE: 8 };
|
|
33
|
+
target.Event ??= NativeEvent;
|
|
34
|
+
target.CustomEvent ??= NativeEvent;
|
|
35
|
+
target.addEventListener ??= addEventListener;
|
|
36
|
+
target.removeEventListener ??= removeEventListener;
|
|
37
|
+
target.dispatchEvent ??= dispatchEvent;
|
|
38
|
+
target.performance ??= { now: () => Date.now() };
|
|
39
|
+
target.queueMicrotask ??= (callback) => Promise.resolve().then(callback);
|
|
40
|
+
target.requestAnimationFrame ??= (callback) => target.setTimeout(() => callback(Date.now()), 0);
|
|
41
|
+
target.cancelAnimationFrame ??= (id) => target.clearTimeout(id);
|
|
42
|
+
target.location ??= { href: "", pathname: "/", search: "", hash: "" };
|
|
43
|
+
target.history ??= { back() {}, forward() {}, pushState() {}, replaceState() {} };
|
|
44
|
+
target.navigator ??= { language: "en" };
|
|
45
|
+
target.document ??= {
|
|
46
|
+
body: null,
|
|
47
|
+
head,
|
|
48
|
+
hidden: !1,
|
|
49
|
+
documentElement,
|
|
50
|
+
addEventListener,
|
|
51
|
+
removeEventListener,
|
|
52
|
+
dispatchEvent,
|
|
53
|
+
querySelectorAll: () => emptyList,
|
|
54
|
+
querySelector: () => null,
|
|
55
|
+
getElementById: () => null,
|
|
56
|
+
createElement: () => ({
|
|
57
|
+
setAttribute() {},
|
|
58
|
+
removeAttribute() {},
|
|
59
|
+
appendChild() {},
|
|
60
|
+
style: {},
|
|
61
|
+
textContent: ""
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NativeMutationOperation } from '../bridge/protocol';
|
|
2
|
+
import type { STXNode } from '../compiler/ir';
|
|
2
3
|
export declare function createNativeHost(options: NativeHostOptions): NativeHost;
|
|
3
4
|
/** Every method the DOM host in `signals.ts` defines. The contract, in one place. */
|
|
4
5
|
export declare const HOST_METHODS: readonly string[];
|
|
@@ -17,6 +18,7 @@ export declare interface NativeHost {
|
|
|
17
18
|
setText: (node: NativeNode, value: unknown) => void
|
|
18
19
|
setAttribute: (node: NativeNode, name: string, value: unknown) => void
|
|
19
20
|
removeAttribute: (node: NativeNode, name: string) => void
|
|
21
|
+
setStyle: (node: NativeNode, value: unknown) => void
|
|
20
22
|
listen: (node: NativeNode, event: string, handler: (payload?: unknown) => void, options?: unknown) => void
|
|
21
23
|
scopeOf: (node: NativeNode, from?: boolean) => NativeNode | null
|
|
22
24
|
setVisible: (node: NativeNode, visible: boolean) => boolean
|
|
@@ -26,7 +28,7 @@ export declare interface NativeHost {
|
|
|
26
28
|
remove: (node: NativeNode) => void
|
|
27
29
|
descendants: (node: NativeNode) => NativeNode[]
|
|
28
30
|
scopesIn: (node: NativeNode) => string[]
|
|
29
|
-
adopt: (node: NativeNode, type: string, owner?: NativeNode | null) => NativeNode
|
|
31
|
+
adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'props' | 'style' | 'events' | 'children'>) => NativeNode
|
|
30
32
|
flush: () => void
|
|
31
33
|
dispatch: (handlerId: string, payload?: unknown) => void
|
|
32
34
|
pending: () => number
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { nativePropName } from "../prop-names.js";
|
|
2
|
+
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
1
3
|
export const HOST_METHODS = [
|
|
2
4
|
"setText",
|
|
3
5
|
"setAttribute",
|
|
4
6
|
"removeAttribute",
|
|
7
|
+
"setStyle",
|
|
5
8
|
"listen",
|
|
6
9
|
"scopeOf",
|
|
7
10
|
"setVisible",
|
|
@@ -12,6 +15,21 @@ export const HOST_METHODS = [
|
|
|
12
15
|
"descendants",
|
|
13
16
|
"scopesIn"
|
|
14
17
|
];
|
|
18
|
+
const NATIVE_EVENT_NAMES = {
|
|
19
|
+
click: "onPress",
|
|
20
|
+
press: "onPress",
|
|
21
|
+
longpress: "onLongPress",
|
|
22
|
+
contextmenu: "onLongPress",
|
|
23
|
+
input: "onChangeText",
|
|
24
|
+
change: "onValueChange",
|
|
25
|
+
focus: "onFocus",
|
|
26
|
+
focusin: "onFocus",
|
|
27
|
+
blur: "onBlur",
|
|
28
|
+
focusout: "onBlur",
|
|
29
|
+
submit: "onSubmitEditing",
|
|
30
|
+
scroll: "onScroll",
|
|
31
|
+
close: "onRequestClose"
|
|
32
|
+
};
|
|
15
33
|
export function createNativeHost(options) {
|
|
16
34
|
const records = new Map, handlers = new Map;
|
|
17
35
|
let queue = [], scheduled = !1, counter = 0;
|
|
@@ -34,11 +52,52 @@ export function createNativeHost(options) {
|
|
|
34
52
|
function recordOf(node) {
|
|
35
53
|
let record = records.get(node.__stxId);
|
|
36
54
|
if (!record) {
|
|
37
|
-
record = { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0 };
|
|
55
|
+
record = { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0, materialized: !0 };
|
|
38
56
|
records.set(node.__stxId, record);
|
|
39
57
|
}
|
|
40
58
|
return record;
|
|
41
59
|
}
|
|
60
|
+
function descriptorOf(node) {
|
|
61
|
+
return records.get(node.__stxId) ?? node.__stxDetachedRecord;
|
|
62
|
+
}
|
|
63
|
+
function retainDetachedDescriptors(node) {
|
|
64
|
+
const record = records.get(node.__stxId);
|
|
65
|
+
if (!record)
|
|
66
|
+
return;
|
|
67
|
+
node.__stxDetachedRecord = record;
|
|
68
|
+
record.children.forEach(retainDetachedDescriptors);
|
|
69
|
+
records.delete(node.__stxId);
|
|
70
|
+
}
|
|
71
|
+
function releaseHandlers(node) {
|
|
72
|
+
const record = descriptorOf(node);
|
|
73
|
+
if (!record)
|
|
74
|
+
return;
|
|
75
|
+
Object.values(record.events).forEach((handlerId) => handlers.delete(handlerId));
|
|
76
|
+
record.children.forEach(releaseHandlers);
|
|
77
|
+
}
|
|
78
|
+
function materialize(node) {
|
|
79
|
+
const record = recordOf(node);
|
|
80
|
+
if (record.materialized || node.__stxAnchor !== void 0)
|
|
81
|
+
return;
|
|
82
|
+
record.materialized = !0;
|
|
83
|
+
emit({
|
|
84
|
+
op: "createNode",
|
|
85
|
+
id: node.__stxId,
|
|
86
|
+
node: {
|
|
87
|
+
type: record.type,
|
|
88
|
+
props: { ...record.props },
|
|
89
|
+
style: { ...record.style },
|
|
90
|
+
...record.text === void 0 ? {} : { children: [record.text] }
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
let index = 0;
|
|
94
|
+
for (const child of record.children) {
|
|
95
|
+
if (child.__stxAnchor !== void 0)
|
|
96
|
+
continue;
|
|
97
|
+
materialize(child);
|
|
98
|
+
emit({ op: "insertChild", parentId: node.__stxId, childId: child.__stxId, index: index++ });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
42
101
|
function collectDescendants(node) {
|
|
43
102
|
const out = [], visit = (current) => {
|
|
44
103
|
const record = records.get(current.__stxId);
|
|
@@ -53,16 +112,79 @@ export function createNativeHost(options) {
|
|
|
53
112
|
visit(node);
|
|
54
113
|
return out;
|
|
55
114
|
}
|
|
56
|
-
function
|
|
115
|
+
function isBindingNode(node) {
|
|
116
|
+
return node.nodeType === 1;
|
|
117
|
+
}
|
|
118
|
+
function decoratePosition(node) {
|
|
119
|
+
const target = node;
|
|
120
|
+
if (target.__stxPositionDecorated)
|
|
121
|
+
return;
|
|
122
|
+
Object.defineProperties(target, {
|
|
123
|
+
nextSibling: {
|
|
124
|
+
configurable: !0,
|
|
125
|
+
get() {
|
|
126
|
+
const owner = target.__stxOwner;
|
|
127
|
+
if (!owner)
|
|
128
|
+
return null;
|
|
129
|
+
const siblings = recordOf(owner).children, index = siblings.findIndex((candidate) => candidate.__stxId === target.__stxId);
|
|
130
|
+
return index === -1 ? null : siblings[index + 1] ?? null;
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
nextElementSibling: {
|
|
134
|
+
configurable: !0,
|
|
135
|
+
get() {
|
|
136
|
+
let sibling = target.nextSibling;
|
|
137
|
+
while (sibling && !isBindingNode(sibling))
|
|
138
|
+
sibling = sibling.nextSibling;
|
|
139
|
+
return sibling;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
target.__stxPositionDecorated = !0;
|
|
144
|
+
}
|
|
145
|
+
function setConnected(node, connected) {
|
|
146
|
+
if ("isConnected" in node)
|
|
147
|
+
node.isConnected = connected;
|
|
148
|
+
records.get(node.__stxId)?.children.forEach((child) => setConnected(child, connected));
|
|
149
|
+
}
|
|
150
|
+
function removeFromBindingParent(node) {
|
|
151
|
+
const owner = node.__stxOwner;
|
|
152
|
+
if (!owner || !isBindingNode(owner))
|
|
153
|
+
return;
|
|
154
|
+
owner.childNodes = owner.childNodes.filter((child) => child.__stxId !== node.__stxId);
|
|
155
|
+
owner.children = owner.children.filter((child) => child.__stxId !== node.__stxId);
|
|
156
|
+
}
|
|
157
|
+
function insertIntoBindingParent(parent, node, index) {
|
|
158
|
+
if (!isBindingNode(parent))
|
|
159
|
+
return;
|
|
160
|
+
parent.childNodes.splice(index, 0, node);
|
|
161
|
+
parent.children.splice(index, 0, node);
|
|
162
|
+
if (isBindingNode(node)) {
|
|
163
|
+
node.parentNode = parent;
|
|
164
|
+
node.parentElement = parent;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function adopt(node, type, owner, descriptor) {
|
|
168
|
+
const suffix = /(?:^|\D)(\d+)$/.exec(node.__stxId)?.[1];
|
|
169
|
+
if (suffix)
|
|
170
|
+
counter = Math.max(counter, Number(suffix));
|
|
57
171
|
records.set(node.__stxId, {
|
|
58
172
|
type,
|
|
59
|
-
props: {},
|
|
60
|
-
style: {},
|
|
61
|
-
events: {},
|
|
173
|
+
props: { ...descriptor?.props ?? {} },
|
|
174
|
+
style: { ...descriptor?.style ?? {} },
|
|
175
|
+
events: { ...descriptor?.events ?? {} },
|
|
176
|
+
text: descriptor?.children?.find((child) => typeof child === "string"),
|
|
62
177
|
children: [],
|
|
63
|
-
visible: !0
|
|
178
|
+
visible: !0,
|
|
179
|
+
materialized: !0
|
|
64
180
|
});
|
|
181
|
+
decoratePosition(node);
|
|
65
182
|
node.__stxOwner = owner ?? null;
|
|
183
|
+
if (owner) {
|
|
184
|
+
const children = recordOf(owner).children;
|
|
185
|
+
if (!children.some((child) => child.__stxId === node.__stxId))
|
|
186
|
+
children.push(node);
|
|
187
|
+
}
|
|
66
188
|
return node;
|
|
67
189
|
}
|
|
68
190
|
return {
|
|
@@ -75,18 +197,27 @@ export function createNativeHost(options) {
|
|
|
75
197
|
emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
|
|
76
198
|
},
|
|
77
199
|
setAttribute(node, name, value) {
|
|
78
|
-
|
|
79
|
-
|
|
200
|
+
const prop = nativePropName(name);
|
|
201
|
+
recordOf(node).props[prop] = value;
|
|
202
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
|
|
80
203
|
},
|
|
81
204
|
removeAttribute(node, name) {
|
|
82
|
-
|
|
83
|
-
|
|
205
|
+
const prop = nativePropName(name);
|
|
206
|
+
delete recordOf(node).props[prop];
|
|
207
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: null } } });
|
|
208
|
+
},
|
|
209
|
+
setStyle(node, value) {
|
|
210
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
211
|
+
return;
|
|
212
|
+
const style = value;
|
|
213
|
+
Object.assign(recordOf(node).style, style);
|
|
214
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { style } });
|
|
84
215
|
},
|
|
85
216
|
listen(node, event, handler) {
|
|
86
|
-
const id = nextId("h");
|
|
217
|
+
const id = nextId("h"), nativeEvent = NATIVE_EVENT_NAMES[event.toLowerCase()] ?? event;
|
|
87
218
|
handlers.set(id, handler);
|
|
88
|
-
recordOf(node).events[
|
|
89
|
-
emit({ op: "updateNode", id: node.__stxId, patch: { events: { [
|
|
219
|
+
recordOf(node).events[nativeEvent] = id;
|
|
220
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { events: { [nativeEvent]: id } } });
|
|
90
221
|
},
|
|
91
222
|
dispatch(handlerId, payload) {
|
|
92
223
|
handlers.get(handlerId)?.(payload);
|
|
@@ -107,32 +238,35 @@ export function createNativeHost(options) {
|
|
|
107
238
|
return was;
|
|
108
239
|
},
|
|
109
240
|
anchor(label) {
|
|
110
|
-
|
|
241
|
+
const anchor = { __stxId: nextId("a"), __stxAnchor: label };
|
|
242
|
+
decoratePosition(anchor);
|
|
243
|
+
return anchor;
|
|
111
244
|
},
|
|
112
245
|
clone(node) {
|
|
113
|
-
const source =
|
|
246
|
+
const source = descriptorOf(node), id = nextId("n"), copy = isBindingNode(node) ? cloneNativeBindingNode(node, id) : { __stxId: id, __stxOwner: node.__stxOwner };
|
|
247
|
+
decoratePosition(copy);
|
|
114
248
|
if (node.__stxScope !== void 0)
|
|
115
249
|
copy.__stxScope = node.__stxScope;
|
|
116
|
-
const descriptor = source ?? {
|
|
250
|
+
const descriptor = source ?? {
|
|
251
|
+
type: "View",
|
|
252
|
+
props: {},
|
|
253
|
+
style: {},
|
|
254
|
+
events: {},
|
|
255
|
+
children: [],
|
|
256
|
+
visible: !0,
|
|
257
|
+
materialized: !0
|
|
258
|
+
};
|
|
117
259
|
records.set(copy.__stxId, {
|
|
118
260
|
type: descriptor.type,
|
|
119
|
-
props: { ...descriptor.props },
|
|
261
|
+
props: { ...descriptor.props, __stxId: copy.__stxId },
|
|
120
262
|
style: { ...descriptor.style },
|
|
121
263
|
events: { ...descriptor.events },
|
|
122
264
|
text: descriptor.text,
|
|
123
265
|
children: [],
|
|
124
|
-
visible: descriptor.visible
|
|
125
|
-
|
|
126
|
-
emit({
|
|
127
|
-
op: "createNode",
|
|
128
|
-
id: copy.__stxId,
|
|
129
|
-
node: {
|
|
130
|
-
type: descriptor.type,
|
|
131
|
-
props: { ...descriptor.props },
|
|
132
|
-
style: { ...descriptor.style },
|
|
133
|
-
...descriptor.text === void 0 ? {} : { children: [descriptor.text] }
|
|
134
|
-
}
|
|
266
|
+
visible: descriptor.visible,
|
|
267
|
+
materialized: !1
|
|
135
268
|
});
|
|
269
|
+
setConnected(copy, !1);
|
|
136
270
|
for (const child of descriptor.children) {
|
|
137
271
|
const childCopy = this.clone(child);
|
|
138
272
|
this.insert(copy, childCopy);
|
|
@@ -140,14 +274,23 @@ export function createNativeHost(options) {
|
|
|
140
274
|
return copy;
|
|
141
275
|
},
|
|
142
276
|
insert(parent, node, before) {
|
|
143
|
-
const record = recordOf(parent), existing = record.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
277
|
+
const record = recordOf(parent), oldOwner = node.__stxOwner, existing = record.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
144
278
|
if (existing !== -1)
|
|
145
279
|
record.children.splice(existing, 1);
|
|
280
|
+
else if (oldOwner) {
|
|
281
|
+
const oldRecord = recordOf(oldOwner), oldIndex = oldRecord.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
282
|
+
if (oldIndex !== -1)
|
|
283
|
+
oldRecord.children.splice(oldIndex, 1);
|
|
284
|
+
}
|
|
285
|
+
removeFromBindingParent(node);
|
|
146
286
|
const index = before ? Math.max(0, record.children.findIndex((child) => child.__stxId === before.__stxId)) : record.children.length;
|
|
147
287
|
record.children.splice(index, 0, node);
|
|
148
288
|
node.__stxOwner = parent;
|
|
149
|
-
|
|
289
|
+
insertIntoBindingParent(parent, node, index);
|
|
290
|
+
setConnected(node, record.materialized);
|
|
291
|
+
if (node.__stxAnchor !== void 0 || !record.materialized)
|
|
150
292
|
return;
|
|
293
|
+
materialize(node);
|
|
151
294
|
emit({
|
|
152
295
|
op: existing === -1 ? "insertChild" : "moveChild",
|
|
153
296
|
parentId: parent.__stxId,
|
|
@@ -168,15 +311,22 @@ export function createNativeHost(options) {
|
|
|
168
311
|
return ids;
|
|
169
312
|
},
|
|
170
313
|
remove(node) {
|
|
171
|
-
const owner = node.__stxOwner;
|
|
314
|
+
const wasMaterialized = descriptorOf(node)?.materialized === !0, owner = node.__stxOwner;
|
|
172
315
|
if (owner) {
|
|
173
316
|
const record = recordOf(owner), at = record.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
174
317
|
if (at !== -1)
|
|
175
318
|
record.children.splice(at, 1);
|
|
176
319
|
}
|
|
320
|
+
removeFromBindingParent(node);
|
|
177
321
|
node.__stxOwner = null;
|
|
178
|
-
|
|
179
|
-
|
|
322
|
+
if (isBindingNode(node)) {
|
|
323
|
+
node.parentNode = null;
|
|
324
|
+
node.parentElement = null;
|
|
325
|
+
}
|
|
326
|
+
setConnected(node, !1);
|
|
327
|
+
releaseHandlers(node);
|
|
328
|
+
retainDetachedDescriptors(node);
|
|
329
|
+
if (node.__stxAnchor !== void 0 || !wasMaterialized)
|
|
180
330
|
return;
|
|
181
331
|
emit({ op: "removeNode", id: node.__stxId });
|
|
182
332
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CraftBridgeOptions } from './craft-bridge';
|
|
2
|
+
import { type NativeHost } from './native-host';
|
|
3
|
+
import type { BindingManifest } from '../../binding-manifest';
|
|
4
|
+
import type { NativeBridgeInterface } from '../bridge/protocol';
|
|
5
|
+
import type { STXDocument } from '../compiler/ir';
|
|
6
|
+
/** Connect translated IR to the ordinary stx signals runtime and native bridge. */
|
|
7
|
+
export declare function prepareSharedNativeScreen(document: STXDocument, manifest: BindingManifest, bridge: NativeBridgeInterface, options?: CraftBridgeOptions): SharedNativeScreen;
|
|
8
|
+
declare interface SharedSignalsRuntime {
|
|
9
|
+
hydrateHost: (root: unknown, setup: (() => Record<string, unknown>) | Record<string, unknown> | null, manifest: BindingManifest, nodes: Map<number, unknown>) => (() => void)
|
|
10
|
+
}
|
|
11
|
+
export declare interface SharedNativeScreen {
|
|
12
|
+
host: NativeHost
|
|
13
|
+
mount: (runtime: SharedSignalsRuntime, setup: (() => Record<string, unknown>) | null) => void
|
|
14
|
+
unmount: () => void
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { STXBridge } from "../bridge/protocol.js";
|
|
2
|
+
import { materializeNativeBindingTree } from "./binding-tree.js";
|
|
3
|
+
import { installCraftBridge } from "./craft-bridge.js";
|
|
4
|
+
import { createNativeHost } from "./native-host.js";
|
|
5
|
+
export function prepareSharedNativeScreen(document, manifest, bridge, options = {}) {
|
|
6
|
+
let revision = 0;
|
|
7
|
+
const protocol = new STXBridge;
|
|
8
|
+
protocol.initialize(bridge);
|
|
9
|
+
installCraftBridge(protocol, bridge, globalThis, options);
|
|
10
|
+
const host = createNativeHost({
|
|
11
|
+
send(operations) {
|
|
12
|
+
const baseRevision = revision;
|
|
13
|
+
revision++;
|
|
14
|
+
protocol.mutate({
|
|
15
|
+
version: 1,
|
|
16
|
+
batchId: `mutation_${revision}`,
|
|
17
|
+
baseRevision,
|
|
18
|
+
revision,
|
|
19
|
+
operations
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}), tree = materializeNativeBindingTree(document, manifest, host);
|
|
23
|
+
let dispose = null;
|
|
24
|
+
protocol.on("EVENT", (message) => {
|
|
25
|
+
const handlerId = message.payload?.handlerId ?? message.payload?.handlerName;
|
|
26
|
+
if (typeof handlerId === "string")
|
|
27
|
+
host.dispatch(handlerId, message.payload?.nativeEvent);
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
host,
|
|
31
|
+
mount(runtime, setup) {
|
|
32
|
+
dispose?.();
|
|
33
|
+
protocol.render(document.root);
|
|
34
|
+
dispose = runtime.hydrateHost(tree.root, setup, manifest, tree.nodes);
|
|
35
|
+
},
|
|
36
|
+
unmount() {
|
|
37
|
+
dispose?.();
|
|
38
|
+
dispose = null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{An,
|
|
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,Ai,Da}from"./chunk-0bmc75w6.js";import{Rn,jr,Aa,Pa,Ia}from"./chunk-sbdzqqr1.js";import{Ti,_i,Ri,_a,Ra}from"./chunk-cznsm2n3.js";import{ie,pt,Br}from"./chunk-p2x7tjbt.js";import{Mc,Nc,Lc,jc,cr,nd}from"./chunk-hnep9jbj.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-d1qzhawc.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=
|
|
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 jr(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,_i as auditBuildOutput,Ti as auditConfig,re as buildPwaAssets,Ri as calculateAuditResult,Ra as formatAuditResult,Br as formatSize,j as generateManifest,_ as generateManifestJson,Pa as generateManifestLink,F as generateOfflinePage,ie as generatePrecacheManifest,pt as generatePrecacheManifestJs,M as generatePwaIcons,Rn as generatePwaTags,An as generateServiceWorker,Da as generateServiceWorkerAuto,Aa as generateSwRegistrationScript,Ia as generateThemeColorMeta,N as getExpectedIconPaths,Ie as getServiceWorkerFileName,jr as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Ai as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,cr as pwaDirectives,Mc as pwaInstallDirective,Lc as pwaOfflineDirective,jc as pwaPushDirective,Nc as pwaUpdateDirective,nd as registerPwaDirectives,_a as runPwaAudit,D as validateManifest};
|
|
@@ -176,7 +176,9 @@ export declare function preEvalLiteralReactiveIfs(template: string): string;
|
|
|
176
176
|
*/
|
|
177
177
|
export declare function convertServerLoopAttributesToDirectives(template: string, context?: Record<string, any>): string;
|
|
178
178
|
export declare function convertSignalLoopsToAttributes(template: string, context?: Record<string, any>): string;
|
|
179
|
-
export declare function processScriptSetup(template: string, filePath?: string, serverData?: Record<string, unknown
|
|
179
|
+
export declare function processScriptSetup(template: string, filePath?: string, serverData?: Record<string, unknown>, options?: {
|
|
180
|
+
forceClientSetup?: boolean;
|
|
181
|
+
}): Promise<{
|
|
180
182
|
output: string;
|
|
181
183
|
setupCode: string | null;
|
|
182
184
|
}>;
|
|
@@ -806,7 +806,7 @@ function rebuildSetupOwner(template, ranges, markerAt, setupFnName) {
|
|
|
806
806
|
appendThrough(template.length);
|
|
807
807
|
return chunks.join("");
|
|
808
808
|
}
|
|
809
|
-
export async function processScriptSetup(template, filePath, serverData) {
|
|
809
|
+
export async function processScriptSetup(template, filePath, serverData, options = {}) {
|
|
810
810
|
const scripts = scanScriptTags(template, {
|
|
811
811
|
skipAttrs: /\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/
|
|
812
812
|
}), SIGNAL_API_RE = /\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/, signalScripts = [], { hasUserImports, bundleClientScript } = await importOnce("stx/client-script-bundler", () => import("./client-script-bundler.js"));
|
|
@@ -814,7 +814,7 @@ export async function processScriptSetup(template, filePath, serverData) {
|
|
|
814
814
|
let content = s.body;
|
|
815
815
|
if (shouldTranspileTypeScript(s.attrs))
|
|
816
816
|
content = transpileTypeScript(content);
|
|
817
|
-
if (SIGNAL_API_RE.test(content)) {
|
|
817
|
+
if (options.forceClientSetup || SIGNAL_API_RE.test(content)) {
|
|
818
818
|
signalScripts.push({ content, start: s.start, end: s.end });
|
|
819
819
|
continue;
|
|
820
820
|
}
|
|
@@ -836,7 +836,8 @@ export async function processScriptSetup(template, filePath, serverData) {
|
|
|
836
836
|
let scriptContent = signalScripts[i].bundled ?? injectBrowserCoreAutoImports(signalScripts[i].content).code;
|
|
837
837
|
if (!signalScripts[i].bundled && hasUserImports(scriptContent))
|
|
838
838
|
scriptContent = await bundleClientScript(scriptContent, filePath || "", {
|
|
839
|
-
projectRoot: process.cwd()
|
|
839
|
+
projectRoot: process.cwd(),
|
|
840
|
+
externalizeUserModules: options.forceClientSetup ? !1 : void 0
|
|
840
841
|
});
|
|
841
842
|
scriptContent = stripStxRuntimeImports(scriptContent);
|
|
842
843
|
const resolved = transformStoreImports(scriptContent);
|