@stacksjs/stx 0.2.413 → 0.2.415
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/appearance-bootstrap.js +1 -1
- package/dist/binding-manifest.d.ts +1 -1
- package/dist/builtins/image-delivery.js +19 -11
- package/dist/bundle-analyzer.js +20 -20
- package/dist/chunk-020xyn9q.js +3 -0
- package/dist/chunk-04jhmfbz.js +2 -0
- package/dist/chunk-0pnj3zt2.js +2 -0
- package/dist/{chunk-bwjxk1dw.js → chunk-0zaess6f.js} +29 -29
- package/dist/chunk-1098mas0.js +2 -0
- package/dist/chunk-169n1vpx.js +12 -0
- package/dist/chunk-18vmfkcc.js +2 -0
- package/dist/chunk-1b6t12hd.js +2 -0
- package/dist/chunk-1xdzcy9d.js +14 -0
- package/dist/chunk-1zs30k3y.js +2 -0
- package/dist/chunk-2ce7f416.js +2 -0
- package/dist/chunk-340a824p.js +2 -0
- package/dist/chunk-393341w7.js +2 -0
- package/dist/chunk-39g1134q.js +2 -0
- package/dist/chunk-3efw27as.js +2785 -0
- package/dist/chunk-3kthfs03.js +3 -0
- package/dist/chunk-3qn1wcdg.js +2 -0
- package/dist/chunk-3s2vnqcf.js +2 -0
- package/dist/chunk-42wbs8vq.js +17 -0
- package/dist/chunk-4bjravgk.js +2 -0
- package/dist/chunk-5gsxpaqk.js +2 -0
- package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
- package/dist/chunk-6cfa3g0r.js +2 -0
- package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
- package/dist/chunk-6hc5vz20.js +3 -0
- package/dist/chunk-6q6g76vg.js +499 -0
- package/dist/chunk-74j18qk0.js +930 -0
- package/dist/chunk-752hw7cd.js +4 -0
- package/dist/{chunk-kgd8kchy.js → chunk-765e1s44.js} +11 -76
- package/dist/chunk-7gkv67ky.js +4 -0
- package/dist/chunk-7z2ra0yf.js +2 -0
- package/dist/chunk-8eqrwj1k.js +20 -0
- package/dist/chunk-8nhshfz6.js +5 -0
- package/dist/chunk-92ps1xpk.js +2 -0
- package/dist/chunk-96k8s808.js +3 -0
- package/dist/chunk-9amp82bx.js +7 -0
- package/dist/chunk-9g27ybyr.js +3 -0
- package/dist/chunk-9p9qkbtg.js +3 -0
- package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
- package/dist/{chunk-24zher49.js → chunk-9vrja6vp.js} +4 -4
- package/dist/chunk-9xrbve19.js +2 -0
- package/dist/chunk-a688m6js.js +3 -0
- package/dist/chunk-ak1cgcah.js +5 -0
- package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
- package/dist/chunk-amtr3rmf.js +11 -0
- package/dist/chunk-atws6p5s.js +2 -0
- package/dist/chunk-b84h16er.js +61 -0
- package/dist/chunk-b98be3yp.js +32 -0
- package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
- package/dist/chunk-ce1sejr3.js +3 -0
- package/dist/chunk-cg8hg6cs.js +3 -0
- package/dist/{chunk-4f9zyfdw.js → chunk-czxt605c.js} +4 -5
- package/dist/chunk-dd8cja4h.js +2 -0
- package/dist/chunk-dgdm3hy3.js +2 -0
- package/dist/chunk-e9hs7kk6.js +12 -0
- package/dist/chunk-eed4fwps.js +3 -0
- package/dist/chunk-ej9j6k1q.js +3 -0
- package/dist/chunk-et0rr8c7.js +3 -0
- package/dist/chunk-f1sxycmv.js +2 -0
- package/dist/chunk-f46qsp4m.js +4 -0
- package/dist/chunk-fbcv4fes.js +2 -0
- package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
- package/dist/chunk-fjs0a8h7.js +2 -0
- package/dist/chunk-fpfzm238.js +2 -0
- package/dist/chunk-fr2txj8q.js +829 -0
- package/dist/{chunk-xssw417m.js → chunk-ft4p6d28.js} +14 -14
- package/dist/chunk-fyzajkrx.js +2 -0
- package/dist/chunk-fzapbw9p.js +3 -0
- package/dist/chunk-g03s93qr.js +3 -0
- package/dist/chunk-g186znp9.js +33 -0
- package/dist/chunk-gawrg4gb.js +216 -0
- package/dist/chunk-gc1drn2p.js +2 -0
- package/dist/chunk-gea5hf0v.js +2 -0
- package/dist/chunk-gqv3ta5d.js +2 -0
- package/dist/chunk-h6kp2m9r.js +2 -0
- package/dist/chunk-h6zsqb9r.js +3 -0
- package/dist/{chunk-2snqdnk9.js → chunk-h85hrwkq.js} +13 -13
- package/dist/chunk-hbxz85wy.js +2 -0
- package/dist/chunk-hepd9qgx.js +6 -0
- package/dist/chunk-hhnw2sn3.js +2 -0
- package/dist/chunk-hjg3ndgh.js +2 -0
- package/dist/chunk-hk1mj4tz.js +2 -0
- package/dist/{chunk-smcj3442.js → chunk-hkrmcbwy.js} +79 -79
- package/dist/chunk-hn9pkyv8.js +2 -0
- package/dist/chunk-hpgr4qgp.js +2 -0
- package/dist/chunk-hrbbbtbn.js +2 -0
- package/dist/chunk-j03revz2.js +8 -0
- package/dist/chunk-j9qcrwbg.js +2 -0
- package/dist/chunk-jk4njz0w.js +2 -0
- package/dist/chunk-jmabeqfq.js +2 -0
- package/dist/chunk-jnkrn913.js +4 -0
- package/dist/chunk-jp10q90g.js +2 -0
- package/dist/chunk-jt0n43mk.js +2 -0
- package/dist/chunk-kjbv8a3m.js +2 -0
- package/dist/chunk-m1vdghnx.js +2 -0
- package/dist/chunk-m4sk62wb.js +5 -0
- package/dist/chunk-md8rqn48.js +30 -0
- package/dist/chunk-mp6hy8g4.js +2 -0
- package/dist/chunk-nc8my58s.js +2 -0
- package/dist/chunk-ngc2wke4.js +3 -0
- package/dist/chunk-nn2vstke.js +2 -0
- package/dist/chunk-nppdrf0x.js +2 -0
- package/dist/chunk-p2v2a68k.js +2 -0
- package/dist/chunk-pazfr1a1.js +2 -0
- package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
- package/dist/chunk-pdb5fw3r.js +2 -0
- package/dist/chunk-pdt69hpb.js +2 -0
- package/dist/chunk-pgzvyrv6.js +29 -0
- package/dist/chunk-px7fvbj6.js +3 -0
- package/dist/chunk-q6vrb2pe.js +2 -0
- package/dist/chunk-q7qchkvk.js +2 -0
- package/dist/chunk-q9bdh4s5.js +8 -0
- package/dist/chunk-qghxz7jm.js +194 -0
- package/dist/chunk-r3f9jcf7.js +5 -0
- package/dist/chunk-re8b5r9x.js +3 -0
- package/dist/chunk-s5xezjps.js +3 -0
- package/dist/chunk-sd321bn3.js +2 -0
- package/dist/chunk-shr559s7.js +3 -0
- package/dist/chunk-t4hzprsm.js +3 -0
- package/dist/chunk-t5pvq5mx.js +2 -0
- package/dist/{chunk-pv3d7sfn.js → chunk-t61vdbje.js} +89 -89
- package/dist/chunk-tafqyf2g.js +2033 -0
- package/dist/chunk-tfexmdkt.js +3 -0
- package/dist/chunk-thyt8ed8.js +6 -0
- package/dist/chunk-v91p6ekp.js +24 -0
- package/dist/chunk-vgvtnwxa.js +4 -0
- package/dist/chunk-w72qx0eb.js +2 -0
- package/dist/chunk-wfy1zq53.js +30 -0
- package/dist/chunk-wzx0164n.js +18 -0
- package/dist/chunk-x0q32ees.js +3 -0
- package/dist/chunk-xfp7k0v8.js +64 -0
- package/dist/chunk-xtvf6n6f.js +4 -0
- package/dist/chunk-xwzvfqcb.js +2 -0
- package/dist/chunk-y1cmjvk3.js +43 -0
- package/dist/chunk-y5310237.js +311 -0
- package/dist/chunk-ya0qecph.js +27 -0
- package/dist/chunk-yazk54jr.js +8 -0
- package/dist/chunk-ydjfar14.js +2 -0
- package/dist/chunk-ym95v4nc.js +3 -0
- package/dist/chunk-z0g9jvv0.js +40 -0
- package/dist/chunk-z23kaxq6.js +2 -0
- package/dist/chunk-z8xn5ta3.js +2 -0
- package/dist/{chunk-8sdhs0zk.js → chunk-zhxdpzga.js} +4 -4
- package/dist/cli.js +110 -110
- package/dist/craft-entry.js +7 -7
- package/dist/craft.js +7 -7
- package/dist/database.js +2 -2
- package/dist/image-optimization/component.js +4 -4
- package/dist/media/image/component.js +5 -5
- package/dist/media/protected/component.js +2 -2
- package/dist/media/video/index.js +4 -4
- package/dist/native/bridge/protocol.d.ts +325 -0
- package/dist/native/bridge/protocol.js +219 -0
- package/dist/native/cli.d.ts +24 -0
- package/dist/native/cli.js +52 -0
- package/dist/native/compiler/bundle.d.ts +41 -0
- package/dist/native/compiler/bundle.js +90 -0
- package/dist/native/compiler/client-script.d.ts +8 -0
- package/dist/native/compiler/client-script.js +31 -0
- package/dist/native/compiler/codegen.d.ts +10 -0
- package/dist/native/compiler/codegen.js +145 -0
- package/dist/native/compiler/headwind-to-style.d.ts +395 -0
- package/dist/native/compiler/headwind-to-style.js +1163 -0
- package/dist/native/compiler/html-to-ir.d.ts +41 -0
- package/dist/native/compiler/html-to-ir.js +411 -0
- package/dist/native/compiler/icons.d.ts +220 -0
- package/dist/native/compiler/icons.js +208 -0
- package/dist/native/compiler/ir.d.ts +234 -0
- package/dist/native/compiler/ir.js +15 -0
- package/dist/native/compiler/parser.d.ts +88 -0
- package/dist/native/compiler/parser.js +753 -0
- package/dist/native/compiler/render-screen.d.ts +26 -0
- package/dist/native/compiler/render-screen.js +31 -0
- package/dist/native/components/primitives.d.ts +291 -0
- package/dist/native/components/primitives.js +22 -0
- package/dist/native/hot-reload/client.d.ts +62 -0
- package/dist/native/hot-reload/client.js +324 -0
- package/dist/native/index.d.ts +90 -0
- package/dist/native/index.js +34 -0
- package/dist/native/primitives/ActivityIndicator.stx +5 -0
- package/dist/native/primitives/Button.stx +5 -0
- package/dist/native/primitives/DatePicker.stx +5 -0
- package/dist/native/primitives/FlatList.stx +5 -0
- package/dist/native/primitives/Image.stx +5 -0
- package/dist/native/primitives/ImageBackground.stx +5 -0
- package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
- package/dist/native/primitives/Modal.stx +5 -0
- package/dist/native/primitives/Picker.stx +5 -0
- package/dist/native/primitives/Pressable.stx +5 -0
- package/dist/native/primitives/RefreshControl.stx +5 -0
- package/dist/native/primitives/SafeAreaView.stx +5 -0
- package/dist/native/primitives/ScrollView.stx +5 -0
- package/dist/native/primitives/SectionList.stx +5 -0
- package/dist/native/primitives/Slider.stx +5 -0
- package/dist/native/primitives/StatusBar.stx +5 -0
- package/dist/native/primitives/Switch.stx +5 -0
- package/dist/native/primitives/Text.stx +5 -0
- package/dist/native/primitives/TextInput.stx +5 -0
- package/dist/native/primitives/TouchableHighlight.stx +5 -0
- package/dist/native/primitives/TouchableOpacity.stx +5 -0
- package/dist/native/primitives/View.stx +5 -0
- package/dist/native/runtime/craft.d.ts +75 -0
- package/dist/native/runtime/craft.js +0 -0
- package/dist/native/runtime/entry.d.ts +1 -0
- package/dist/native/runtime/entry.js +3 -0
- package/dist/native/runtime/index.d.ts +45 -0
- package/dist/native/runtime/index.js +165 -0
- package/dist/native/runtime/native-host.d.ts +33 -0
- package/dist/native/runtime/native-host.js +184 -0
- package/dist/native/runtime/screen.d.ts +43 -0
- package/dist/native/runtime/screen.js +808 -0
- package/dist/pwa/service-worker.js +1 -1
- package/dist/pwa/workbox.js +1 -1
- package/dist/pwa.js +8 -8
- package/dist/site-url.d.ts +1 -1
- package/dist/ssg.js +53 -53
- package/dist/visual-testing.js +42 -42
- package/dist/web-components/reactive-generator.js +2 -2
- package/package.json +9 -5
- package/dist/chunk-0btmm4m2.js +0 -147
- package/dist/chunk-0c2h69k2.js +0 -4
- package/dist/chunk-0d0qeqvv.js +0 -2
- package/dist/chunk-0psndabd.js +0 -2
- package/dist/chunk-0qv8yf53.js +0 -2
- package/dist/chunk-0vkxyvsd.js +0 -2
- package/dist/chunk-0we9nw1d.js +0 -3
- package/dist/chunk-0xqdmemy.js +0 -3
- package/dist/chunk-0y46fbkx.js +0 -3
- package/dist/chunk-158wqccn.js +0 -4422
- package/dist/chunk-1cyxbb8y.js +0 -16
- package/dist/chunk-1enwnh2a.js +0 -2
- package/dist/chunk-213pzm0d.js +0 -3
- package/dist/chunk-21hzqyja.js +0 -12
- package/dist/chunk-266t58b8.js +0 -5
- package/dist/chunk-27fgag95.js +0 -4
- package/dist/chunk-2a9n102n.js +0 -2
- package/dist/chunk-2eqzrczk.js +0 -2
- package/dist/chunk-2ke37m54.js +0 -14
- package/dist/chunk-35ds08e7.js +0 -3
- package/dist/chunk-3mtwkjcg.js +0 -2
- package/dist/chunk-4xr8zwkp.js +0 -2
- package/dist/chunk-58v77x2c.js +0 -2
- package/dist/chunk-5mhq8605.js +0 -2
- package/dist/chunk-5se8xt9e.js +0 -64
- package/dist/chunk-5zh0h080.js +0 -2
- package/dist/chunk-62435225.js +0 -2
- package/dist/chunk-6kdrncsx.js +0 -30
- package/dist/chunk-6n2rr3x7.js +0 -2
- package/dist/chunk-6xk87qf2.js +0 -30
- package/dist/chunk-72rwcbp6.js +0 -3
- package/dist/chunk-76w34xne.js +0 -3
- package/dist/chunk-7ekd7zj9.js +0 -2
- package/dist/chunk-7pr3wdd5.js +0 -3
- package/dist/chunk-7rxvafwc.js +0 -24
- package/dist/chunk-7tnwfa7w.js +0 -8
- package/dist/chunk-8c5je0wf.js +0 -2
- package/dist/chunk-8dz6nyvx.js +0 -2
- package/dist/chunk-98zj3fv2.js +0 -7
- package/dist/chunk-9e8t0twa.js +0 -3
- package/dist/chunk-9fqp72ze.js +0 -5
- package/dist/chunk-anydpa34.js +0 -3
- package/dist/chunk-ay6zjq8v.js +0 -3
- package/dist/chunk-az4v4ard.js +0 -3
- package/dist/chunk-ba5erggg.js +0 -2
- package/dist/chunk-bnagrdz6.js +0 -2
- package/dist/chunk-by8wghtf.js +0 -2
- package/dist/chunk-cd7h4q51.js +0 -2
- package/dist/chunk-cjmv8hgp.js +0 -33
- package/dist/chunk-cthf912y.js +0 -2
- package/dist/chunk-cxbpmwq5.js +0 -4
- package/dist/chunk-d3sy16qn.js +0 -2
- package/dist/chunk-dh6s7mrj.js +0 -1199
- package/dist/chunk-dm2nzg7a.js +0 -2
- package/dist/chunk-e2sgcnxc.js +0 -2
- package/dist/chunk-e3b7jj74.js +0 -2
- package/dist/chunk-ec4wq2sv.js +0 -6
- package/dist/chunk-ekzg97dn.js +0 -29
- package/dist/chunk-epjt342x.js +0 -2
- package/dist/chunk-eqe26g14.js +0 -18
- package/dist/chunk-ev0v1yma.js +0 -2
- package/dist/chunk-f53psr2y.js +0 -5
- package/dist/chunk-f8p69dsg.js +0 -3
- package/dist/chunk-f95drhdb.js +0 -194
- package/dist/chunk-ff5a6hvb.js +0 -17
- package/dist/chunk-fs5fy4h8.js +0 -2
- package/dist/chunk-fzsygce3.js +0 -2
- package/dist/chunk-g465x63k.js +0 -2
- package/dist/chunk-g708ekh1.js +0 -2
- package/dist/chunk-gcr9e83g.js +0 -11
- package/dist/chunk-gdmyrsr8.js +0 -4
- package/dist/chunk-gkms2ngq.js +0 -2
- package/dist/chunk-gnfywmgs.js +0 -7
- package/dist/chunk-hpf8kq7e.js +0 -2
- package/dist/chunk-j4x3faf8.js +0 -2
- package/dist/chunk-jkavtw9f.js +0 -2
- package/dist/chunk-kg1rdena.js +0 -3
- package/dist/chunk-km91wx0v.js +0 -2
- package/dist/chunk-kmsyvaex.js +0 -8
- package/dist/chunk-mrahwn5v.js +0 -8
- package/dist/chunk-nk3czvnk.js +0 -2
- package/dist/chunk-nmw4eewb.js +0 -2
- package/dist/chunk-nq5zxrk0.js +0 -4
- package/dist/chunk-ny67c03k.js +0 -3
- package/dist/chunk-p4wdxp2c.js +0 -2
- package/dist/chunk-pcxp4r9n.js +0 -3
- package/dist/chunk-pdyeaxc1.js +0 -2
- package/dist/chunk-pf06ded4.js +0 -2
- package/dist/chunk-pfs0gpzm.js +0 -2
- package/dist/chunk-pshdwq44.js +0 -2
- package/dist/chunk-pwgv84pn.js +0 -32
- package/dist/chunk-pwsnafp3.js +0 -4367
- package/dist/chunk-q9n5swx7.js +0 -3
- package/dist/chunk-qr346wnp.js +0 -2
- package/dist/chunk-r02hke04.js +0 -2
- package/dist/chunk-ranshpyc.js +0 -3
- package/dist/chunk-rn194bhp.js +0 -20
- package/dist/chunk-rn1hgyc8.js +0 -930
- package/dist/chunk-s7z5dp70.js +0 -43
- package/dist/chunk-s8jd13nb.js +0 -3
- package/dist/chunk-sn7exv0n.js +0 -2
- package/dist/chunk-t1tdjjht.js +0 -216
- package/dist/chunk-t6qx04s8.js +0 -499
- package/dist/chunk-t6y6gyps.js +0 -2
- package/dist/chunk-tjfs7cc3.js +0 -2
- package/dist/chunk-tkyrk66a.js +0 -3
- package/dist/chunk-tntv9hvq.js +0 -2
- package/dist/chunk-v3nwkveg.js +0 -12
- package/dist/chunk-vd4cb5xr.js +0 -2
- package/dist/chunk-vkhdce50.js +0 -2
- package/dist/chunk-w183av08.js +0 -2
- package/dist/chunk-w2m02njv.js +0 -2
- package/dist/chunk-wpjrcrs5.js +0 -2
- package/dist/chunk-wqmppf6b.js +0 -3
- package/dist/chunk-wtb9fxdy.js +0 -2
- package/dist/chunk-xmzygmcz.js +0 -3
- package/dist/chunk-xsng1mtq.js +0 -3
- package/dist/chunk-xxzefj4j.js +0 -2
- package/dist/chunk-yq8x8bxq.js +0 -47
- package/dist/chunk-ytma76qe.js +0 -3
- package/dist/chunk-yw1m115e.js +0 -2
- package/dist/chunk-z64a924m.js +0 -2
- package/dist/chunk-zcz9rs6p.js +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { STXDocument } from '../compiler/ir';
|
|
2
|
+
export type { RuntimeConfig };
|
|
3
|
+
/**
|
|
4
|
+
* Get or create the runtime instance
|
|
5
|
+
*/
|
|
6
|
+
export declare function getRuntime(config?: RuntimeConfig): STXRuntime;
|
|
7
|
+
/**
|
|
8
|
+
* Initialize and start the runtime
|
|
9
|
+
*/
|
|
10
|
+
export declare function startRuntime(config?: RuntimeConfig): Promise<STXRuntime>;
|
|
11
|
+
/**
|
|
12
|
+
* Render an STX document
|
|
13
|
+
*/
|
|
14
|
+
export declare function render(document: STXDocument): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Update application state
|
|
17
|
+
*/
|
|
18
|
+
export declare function setState(key: string, value: unknown): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get application state
|
|
21
|
+
*/
|
|
22
|
+
export declare function getState<T>(key: string): T | undefined;
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Runtime Configuration
|
|
25
|
+
// ============================================================================
|
|
26
|
+
declare interface RuntimeConfig {
|
|
27
|
+
devServerUrl?: string
|
|
28
|
+
hotReload?: boolean
|
|
29
|
+
debug?: boolean
|
|
30
|
+
document?: STXDocument
|
|
31
|
+
}
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// STX Runtime
|
|
34
|
+
// ============================================================================
|
|
35
|
+
declare class STXRuntime {
|
|
36
|
+
constructor(config?: RuntimeConfig);
|
|
37
|
+
initialize(): Promise<void>;
|
|
38
|
+
render(document: STXDocument): Promise<void>;
|
|
39
|
+
setState(key: string, value: unknown): void;
|
|
40
|
+
getState<T>(key: string): T | undefined;
|
|
41
|
+
}
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Exports
|
|
44
|
+
// ============================================================================
|
|
45
|
+
export { STXRuntime };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { getBridge, createBridge, registerHandler, callHandler } from "../bridge/protocol.js";
|
|
2
|
+
import { initHotReload, getErrorOverlay } from "../hot-reload/client.js";
|
|
3
|
+
|
|
4
|
+
class STXRuntime {
|
|
5
|
+
config;
|
|
6
|
+
currentDocument = null;
|
|
7
|
+
state = new Map;
|
|
8
|
+
initialized = !1;
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
this.config = {
|
|
11
|
+
devServerUrl: "ws://localhost:8081",
|
|
12
|
+
hotReload: __DEV__,
|
|
13
|
+
debug: __DEV__,
|
|
14
|
+
...config
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async initialize() {
|
|
18
|
+
if (this.initialized) {
|
|
19
|
+
this.log("Runtime already initialized");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this.log("Initializing STX Native Runtime...");
|
|
23
|
+
createBridge();
|
|
24
|
+
const bridge = getBridge();
|
|
25
|
+
this.setupEventHandlers();
|
|
26
|
+
if (this.config.hotReload)
|
|
27
|
+
initHotReload(this.config.devServerUrl).onReload((doc) => {
|
|
28
|
+
this.handleHotReload(doc);
|
|
29
|
+
});
|
|
30
|
+
if (this.config.document)
|
|
31
|
+
await this.render(this.config.document);
|
|
32
|
+
this.initialized = !0;
|
|
33
|
+
this.log("Runtime initialized");
|
|
34
|
+
}
|
|
35
|
+
async render(document) {
|
|
36
|
+
this.currentDocument = document;
|
|
37
|
+
const bridge = getBridge();
|
|
38
|
+
if (document.script.code)
|
|
39
|
+
this.executeScript(document.script.code);
|
|
40
|
+
for (const funcName of document.script.functions) {
|
|
41
|
+
const func = this.getGlobalFunction(funcName);
|
|
42
|
+
if (func)
|
|
43
|
+
registerHandler(funcName, func);
|
|
44
|
+
}
|
|
45
|
+
for (const [key, value] of Object.entries(document.script.exports))
|
|
46
|
+
this.state.set(key, value);
|
|
47
|
+
bridge.render(document.root, { mode: "replace" });
|
|
48
|
+
this.log("Document rendered");
|
|
49
|
+
}
|
|
50
|
+
setState(key, value) {
|
|
51
|
+
const previousValue = this.state.get(key);
|
|
52
|
+
this.state.set(key, value);
|
|
53
|
+
this.setGlobal(key, value);
|
|
54
|
+
getBridge().send("STATE_UPDATE", {
|
|
55
|
+
key,
|
|
56
|
+
value,
|
|
57
|
+
previousValue
|
|
58
|
+
});
|
|
59
|
+
this.log(`State updated: ${key}`, value);
|
|
60
|
+
}
|
|
61
|
+
getState(key) {
|
|
62
|
+
return this.state.get(key);
|
|
63
|
+
}
|
|
64
|
+
setupEventHandlers() {
|
|
65
|
+
const bridge = getBridge();
|
|
66
|
+
bridge.on("EVENT", (message) => {
|
|
67
|
+
const payload = message.payload;
|
|
68
|
+
this.log(`Event: ${payload.eventType} -> ${payload.handlerName}`);
|
|
69
|
+
const result = callHandler(payload.handlerName, payload.nativeEvent);
|
|
70
|
+
});
|
|
71
|
+
bridge.on("APP_STATE", (message) => {
|
|
72
|
+
const payload = message.payload;
|
|
73
|
+
this.log(`App state: ${payload.state}`);
|
|
74
|
+
switch (payload.state) {
|
|
75
|
+
case "active":
|
|
76
|
+
callHandler("onAppForeground");
|
|
77
|
+
break;
|
|
78
|
+
case "background":
|
|
79
|
+
callHandler("onAppBackground");
|
|
80
|
+
break;
|
|
81
|
+
case "inactive":
|
|
82
|
+
callHandler("onAppInactive");
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
bridge.on("HOT_RELOAD", (message) => {
|
|
87
|
+
const payload = message.payload;
|
|
88
|
+
if (payload.document)
|
|
89
|
+
this.handleHotReload(payload.document);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
handleHotReload(document) {
|
|
93
|
+
this.log("Hot reload triggered");
|
|
94
|
+
const savedState = new Map(this.state);
|
|
95
|
+
this.render(document);
|
|
96
|
+
for (const [key, value] of savedState)
|
|
97
|
+
if (this.state.has(key))
|
|
98
|
+
this.setState(key, value);
|
|
99
|
+
this.log("Hot reload complete");
|
|
100
|
+
}
|
|
101
|
+
executeScript(code) {
|
|
102
|
+
try {
|
|
103
|
+
const wrappedCode = `
|
|
104
|
+
(function() {
|
|
105
|
+
${code}
|
|
106
|
+
})();
|
|
107
|
+
`;
|
|
108
|
+
Function(wrappedCode)();
|
|
109
|
+
this.log("Script executed");
|
|
110
|
+
} catch (error) {
|
|
111
|
+
this.logError("Script execution failed:", error);
|
|
112
|
+
if (this.config.hotReload)
|
|
113
|
+
getErrorOverlay().show({
|
|
114
|
+
error,
|
|
115
|
+
source: this.currentDocument?.meta.source
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
getGlobalFunction(name) {
|
|
120
|
+
try {
|
|
121
|
+
const fn = globalThis[name];
|
|
122
|
+
if (typeof fn === "function")
|
|
123
|
+
return fn;
|
|
124
|
+
} catch {}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
setGlobal(key, value) {
|
|
128
|
+
try {
|
|
129
|
+
globalThis[key] = value;
|
|
130
|
+
} catch {}
|
|
131
|
+
}
|
|
132
|
+
log(...args) {
|
|
133
|
+
if (this.config.debug)
|
|
134
|
+
console.log("[STXRuntime]", ...args);
|
|
135
|
+
}
|
|
136
|
+
logError(...args) {
|
|
137
|
+
console.error("[STXRuntime]", ...args);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (typeof globalThis.__DEV__ > "u")
|
|
141
|
+
globalThis.__DEV__ = !0;
|
|
142
|
+
let runtimeInstance = null;
|
|
143
|
+
export function getRuntime(config) {
|
|
144
|
+
if (!runtimeInstance)
|
|
145
|
+
runtimeInstance = new STXRuntime(config);
|
|
146
|
+
return runtimeInstance;
|
|
147
|
+
}
|
|
148
|
+
export async function startRuntime(config) {
|
|
149
|
+
const runtime = getRuntime(config);
|
|
150
|
+
await runtime.initialize();
|
|
151
|
+
return runtime;
|
|
152
|
+
}
|
|
153
|
+
export async function render(document) {
|
|
154
|
+
const runtime = getRuntime();
|
|
155
|
+
await runtime.initialize();
|
|
156
|
+
await runtime.render(document);
|
|
157
|
+
}
|
|
158
|
+
export function setState(key, value) {
|
|
159
|
+
getRuntime().setState(key, value);
|
|
160
|
+
}
|
|
161
|
+
export function getState(key) {
|
|
162
|
+
return getRuntime().getState(key);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export { STXRuntime };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { NativeMutationOperation } from '../bridge/protocol';
|
|
2
|
+
export declare function createNativeHost(options: NativeHostOptions): NativeHost;
|
|
3
|
+
/** Every method the DOM host in `signals.ts` defines. The contract, in one place. */
|
|
4
|
+
export declare const HOST_METHODS: readonly string[];
|
|
5
|
+
/** A handle on a node in the native tree. Not an element; just an identity. */
|
|
6
|
+
export declare interface NativeNode {
|
|
7
|
+
__stxId: string
|
|
8
|
+
__stxScope?: string
|
|
9
|
+
__stxOwner?: NativeNode | null
|
|
10
|
+
__stxAnchor?: string
|
|
11
|
+
}
|
|
12
|
+
export declare interface NativeHostOptions {
|
|
13
|
+
send: (operations: NativeMutationOperation[]) => void
|
|
14
|
+
schedule?: (flush: () => void) => void
|
|
15
|
+
}
|
|
16
|
+
export declare interface NativeHost {
|
|
17
|
+
setText: (node: NativeNode, value: unknown) => void
|
|
18
|
+
setAttribute: (node: NativeNode, name: string, value: unknown) => void
|
|
19
|
+
removeAttribute: (node: NativeNode, name: string) => void
|
|
20
|
+
listen: (node: NativeNode, event: string, handler: (payload?: unknown) => void, options?: unknown) => void
|
|
21
|
+
scopeOf: (node: NativeNode, from?: boolean) => NativeNode | null
|
|
22
|
+
setVisible: (node: NativeNode, visible: boolean) => boolean
|
|
23
|
+
anchor: (label: string) => NativeNode
|
|
24
|
+
clone: (node: NativeNode) => NativeNode
|
|
25
|
+
insert: (parent: NativeNode, node: NativeNode, before?: NativeNode | null) => void
|
|
26
|
+
remove: (node: NativeNode) => void
|
|
27
|
+
descendants: (node: NativeNode) => NativeNode[]
|
|
28
|
+
scopesIn: (node: NativeNode) => string[]
|
|
29
|
+
adopt: (node: NativeNode, type: string, owner?: NativeNode | null) => NativeNode
|
|
30
|
+
flush: () => void
|
|
31
|
+
dispatch: (handlerId: string, payload?: unknown) => void
|
|
32
|
+
pending: () => number
|
|
33
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
export const HOST_METHODS = [
|
|
2
|
+
"setText",
|
|
3
|
+
"setAttribute",
|
|
4
|
+
"removeAttribute",
|
|
5
|
+
"listen",
|
|
6
|
+
"scopeOf",
|
|
7
|
+
"setVisible",
|
|
8
|
+
"anchor",
|
|
9
|
+
"clone",
|
|
10
|
+
"insert",
|
|
11
|
+
"remove",
|
|
12
|
+
"descendants",
|
|
13
|
+
"scopesIn"
|
|
14
|
+
];
|
|
15
|
+
export function createNativeHost(options) {
|
|
16
|
+
const records = new Map, handlers = new Map;
|
|
17
|
+
let queue = [], scheduled = !1, counter = 0;
|
|
18
|
+
const schedule = options.schedule ?? ((flush) => queueMicrotask(flush)), nextId = (prefix) => `${prefix}${++counter}`;
|
|
19
|
+
function flush() {
|
|
20
|
+
scheduled = !1;
|
|
21
|
+
if (queue.length === 0)
|
|
22
|
+
return;
|
|
23
|
+
const batch = queue;
|
|
24
|
+
queue = [];
|
|
25
|
+
options.send(batch);
|
|
26
|
+
}
|
|
27
|
+
function emit(operation) {
|
|
28
|
+
queue.push(operation);
|
|
29
|
+
if (!scheduled) {
|
|
30
|
+
scheduled = !0;
|
|
31
|
+
schedule(flush);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function recordOf(node) {
|
|
35
|
+
let record = records.get(node.__stxId);
|
|
36
|
+
if (!record) {
|
|
37
|
+
record = { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0 };
|
|
38
|
+
records.set(node.__stxId, record);
|
|
39
|
+
}
|
|
40
|
+
return record;
|
|
41
|
+
}
|
|
42
|
+
function collectDescendants(node) {
|
|
43
|
+
const out = [], visit = (current) => {
|
|
44
|
+
const record = records.get(current.__stxId);
|
|
45
|
+
if (!record)
|
|
46
|
+
return;
|
|
47
|
+
for (const child of record.children) {
|
|
48
|
+
out.push(child);
|
|
49
|
+
visit(child);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
if (node)
|
|
53
|
+
visit(node);
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function adopt(node, type, owner) {
|
|
57
|
+
records.set(node.__stxId, {
|
|
58
|
+
type,
|
|
59
|
+
props: {},
|
|
60
|
+
style: {},
|
|
61
|
+
events: {},
|
|
62
|
+
children: [],
|
|
63
|
+
visible: !0
|
|
64
|
+
});
|
|
65
|
+
node.__stxOwner = owner ?? null;
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
adopt,
|
|
70
|
+
pending: () => queue.length,
|
|
71
|
+
flush,
|
|
72
|
+
setText(node, value) {
|
|
73
|
+
const text = value == null ? "" : String(value);
|
|
74
|
+
recordOf(node).text = text;
|
|
75
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
|
|
76
|
+
},
|
|
77
|
+
setAttribute(node, name, value) {
|
|
78
|
+
recordOf(node).props[name] = value;
|
|
79
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [name]: value } } });
|
|
80
|
+
},
|
|
81
|
+
removeAttribute(node, name) {
|
|
82
|
+
delete recordOf(node).props[name];
|
|
83
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [name]: null } } });
|
|
84
|
+
},
|
|
85
|
+
listen(node, event, handler) {
|
|
86
|
+
const id = nextId("h");
|
|
87
|
+
handlers.set(id, handler);
|
|
88
|
+
recordOf(node).events[event] = id;
|
|
89
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { events: { [event]: id } } });
|
|
90
|
+
},
|
|
91
|
+
dispatch(handlerId, payload) {
|
|
92
|
+
handlers.get(handlerId)?.(payload);
|
|
93
|
+
},
|
|
94
|
+
scopeOf(node, from) {
|
|
95
|
+
let current = from ? node?.__stxOwner : node;
|
|
96
|
+
while (current) {
|
|
97
|
+
if (current.__stxScope !== void 0)
|
|
98
|
+
return current;
|
|
99
|
+
current = current.__stxOwner;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
},
|
|
103
|
+
setVisible(node, visible) {
|
|
104
|
+
const record = recordOf(node), was = record.visible;
|
|
105
|
+
record.visible = visible;
|
|
106
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { style: { display: visible ? "flex" : "none" } } });
|
|
107
|
+
return was;
|
|
108
|
+
},
|
|
109
|
+
anchor(label) {
|
|
110
|
+
return { __stxId: nextId("a"), __stxAnchor: label };
|
|
111
|
+
},
|
|
112
|
+
clone(node) {
|
|
113
|
+
const source = records.get(node.__stxId), copy = { __stxId: nextId("n"), __stxOwner: node.__stxOwner };
|
|
114
|
+
if (node.__stxScope !== void 0)
|
|
115
|
+
copy.__stxScope = node.__stxScope;
|
|
116
|
+
const descriptor = source ?? { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0 };
|
|
117
|
+
records.set(copy.__stxId, {
|
|
118
|
+
type: descriptor.type,
|
|
119
|
+
props: { ...descriptor.props },
|
|
120
|
+
style: { ...descriptor.style },
|
|
121
|
+
events: { ...descriptor.events },
|
|
122
|
+
text: descriptor.text,
|
|
123
|
+
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
|
+
}
|
|
135
|
+
});
|
|
136
|
+
for (const child of descriptor.children) {
|
|
137
|
+
const childCopy = this.clone(child);
|
|
138
|
+
this.insert(copy, childCopy);
|
|
139
|
+
}
|
|
140
|
+
return copy;
|
|
141
|
+
},
|
|
142
|
+
insert(parent, node, before) {
|
|
143
|
+
const record = recordOf(parent), existing = record.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
144
|
+
if (existing !== -1)
|
|
145
|
+
record.children.splice(existing, 1);
|
|
146
|
+
const index = before ? Math.max(0, record.children.findIndex((child) => child.__stxId === before.__stxId)) : record.children.length;
|
|
147
|
+
record.children.splice(index, 0, node);
|
|
148
|
+
node.__stxOwner = parent;
|
|
149
|
+
if (node.__stxAnchor !== void 0)
|
|
150
|
+
return;
|
|
151
|
+
emit({
|
|
152
|
+
op: existing === -1 ? "insertChild" : "moveChild",
|
|
153
|
+
parentId: parent.__stxId,
|
|
154
|
+
childId: node.__stxId,
|
|
155
|
+
index
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
descendants: collectDescendants,
|
|
159
|
+
scopesIn(node) {
|
|
160
|
+
const ids = [];
|
|
161
|
+
if (!node)
|
|
162
|
+
return ids;
|
|
163
|
+
if (node.__stxScope !== void 0)
|
|
164
|
+
ids.push(node.__stxScope);
|
|
165
|
+
for (const child of collectDescendants(node))
|
|
166
|
+
if (child.__stxScope !== void 0)
|
|
167
|
+
ids.push(child.__stxScope);
|
|
168
|
+
return ids;
|
|
169
|
+
},
|
|
170
|
+
remove(node) {
|
|
171
|
+
const owner = node.__stxOwner;
|
|
172
|
+
if (owner) {
|
|
173
|
+
const record = recordOf(owner), at = record.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
174
|
+
if (at !== -1)
|
|
175
|
+
record.children.splice(at, 1);
|
|
176
|
+
}
|
|
177
|
+
node.__stxOwner = null;
|
|
178
|
+
records.delete(node.__stxId);
|
|
179
|
+
if (node.__stxAnchor !== void 0)
|
|
180
|
+
return;
|
|
181
|
+
emit({ op: "removeNode", id: node.__stxId });
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** `:class` as Vue and Alpine take it: a string, an array, or `{ name: on }`. */
|
|
2
|
+
export declare function normalizeClass(value: Any): string;
|
|
3
|
+
/** `:style` as an object, or as CSS text (`left: 12px; width: 40%`). */
|
|
4
|
+
export declare function normalizeStyle(value: Any): Record<string, Any>;
|
|
5
|
+
export declare function createRuntime(bridge: Any, options?: RuntimeOptions): { mount: (screen: ScreenDefinition) => void };
|
|
6
|
+
/**
|
|
7
|
+
* The bundle's entry: installs the Craft APIs once, before any screen script
|
|
8
|
+
* runs, and hands each screen a `mount`. Without a bridge (a test importing a
|
|
9
|
+
* screen, a web build) there is nothing to render to, so mount does nothing.
|
|
10
|
+
*/
|
|
11
|
+
export declare function installRuntime(options?: RuntimeOptions): { mount: (screen: ScreenDefinition) => void };
|
|
12
|
+
/** A template node as `codegen.ts` emits it. Numbers are expression indexes. */
|
|
13
|
+
export declare interface TemplateNode {
|
|
14
|
+
type: string
|
|
15
|
+
key?: Any
|
|
16
|
+
props: Record<string, Any>
|
|
17
|
+
style: Record<string, Any>
|
|
18
|
+
darkStyle?: Record<string, Any>
|
|
19
|
+
events: Record<string, number>
|
|
20
|
+
children: Array<TemplateNode | TemplateText>
|
|
21
|
+
directives?: {
|
|
22
|
+
if?: number
|
|
23
|
+
elseIf?: number
|
|
24
|
+
else?: boolean
|
|
25
|
+
for?: { source: number, item: string, index?: string }
|
|
26
|
+
show?: number
|
|
27
|
+
}
|
|
28
|
+
bindings?: { class?: number, style?: number }
|
|
29
|
+
}
|
|
30
|
+
export declare interface ScreenDefinition {
|
|
31
|
+
document: { root: TemplateNode }
|
|
32
|
+
expressions: Expression[]
|
|
33
|
+
functions?: Record<string, ((event?: Any) => Any) | undefined>
|
|
34
|
+
}
|
|
35
|
+
export declare interface RuntimeOptions {
|
|
36
|
+
routeName?: string
|
|
37
|
+
routeNames?: string[]
|
|
38
|
+
}
|
|
39
|
+
declare type Any = any // eslint-disable-line ts/no-explicit-any
|
|
40
|
+
type Scope = Record<string, Any>;
|
|
41
|
+
declare type Expression = (scope: Scope, event?: Any) => Any;
|
|
42
|
+
/** A text child: a literal, or an expression reference. */
|
|
43
|
+
export type TemplateText = string | { $x: number }
|