@stacksjs/stx 0.2.421 → 0.2.423
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-r8wze9ym.js → chunk-24e7qjb8.js} +2 -2
- package/dist/chunk-259ecbwa.js +2 -0
- package/dist/chunk-26gfsa9w.js +2 -0
- package/dist/{chunk-3ynkg5dz.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-ax58cds3.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-z0ck9t6j.js → chunk-6cbvx87h.js} +5 -5
- package/dist/{chunk-kea18wnc.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-hjp990p8.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-h1h6xe1k.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-pzngjk81.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-8vq0qjq9.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-debz86rr.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-bh4x090w.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-014gmm8w.js → chunk-dcwjxq8n.js} +2 -2
- package/dist/chunk-dhqwg62x.js +2 -0
- package/dist/{chunk-z521cyfv.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-8drvzsk1.js → chunk-fg5ve6ey.js} +2 -2
- package/dist/{chunk-3kmhv1kf.js → chunk-fnt1q1sp.js} +11 -11
- package/dist/chunk-g67gg66e.js +2 -0
- package/dist/chunk-gq16fxc2.js +2 -0
- package/dist/{chunk-4e101kjp.js → chunk-h3c7z73m.js} +2 -2
- package/dist/chunk-h4avjh3q.js +2 -0
- package/dist/chunk-h7qte7ye.js +2 -0
- package/dist/{chunk-4mew0ae3.js → chunk-hb9gxad0.js} +3 -3
- package/dist/{chunk-0y7x0hvr.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-32y3767j.js → chunk-jbrdebzs.js} +7 -7
- package/dist/{chunk-1336h4sv.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-rj3hyqff.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-10967rws.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-m16h8ea0.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-6aqcgrhw.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-a4r19yxm.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-8j8k27xb.js → chunk-zbr333kf.js} +115 -31
- 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 +21 -21
- package/dist/component-renderer.js +54 -2
- package/dist/composables/use-outbox.d.ts +1 -0
- package/dist/composables/use-outbox.js +14 -4
- 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 +104 -20
- package/dist/ssg.js +28 -28
- package/dist/variable-extractor.js +4 -1
- package/package.json +5 -5
- package/dist/chunk-0n76c3g8.js +0 -2
- package/dist/chunk-10fh9qhe.js +0 -2
- package/dist/chunk-18awnp9d.js +0 -2
- package/dist/chunk-2hswgxpb.js +0 -2
- package/dist/chunk-3zye6eh1.js +0 -2
- package/dist/chunk-4488r5j1.js +0 -2
- package/dist/chunk-4amznxaq.js +0 -2
- package/dist/chunk-5akd7qsb.js +0 -2
- package/dist/chunk-5eqd40k0.js +0 -2
- package/dist/chunk-6r9y4p81.js +0 -2
- package/dist/chunk-75zcwcrt.js +0 -2
- package/dist/chunk-89e1d0rz.js +0 -4
- package/dist/chunk-8nsqac4z.js +0 -2
- package/dist/chunk-8ttvazck.js +0 -2
- package/dist/chunk-8y4bqsxz.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-awtrcb5m.js +0 -18
- package/dist/chunk-b01jqb5f.js +0 -2
- package/dist/chunk-b7z2yegr.js +0 -2
- package/dist/chunk-bfvaxrq0.js +0 -2
- package/dist/chunk-bkaw7sgz.js +0 -2
- package/dist/chunk-bmk0s261.js +0 -2
- package/dist/chunk-bvbank3z.js +0 -2
- package/dist/chunk-cvzkbsds.js +0 -2
- package/dist/chunk-cw6j75ck.js +0 -30
- package/dist/chunk-d2c5727w.js +0 -2
- package/dist/chunk-d5amzers.js +0 -2
- package/dist/chunk-dfchrqw5.js +0 -2
- package/dist/chunk-dscsvkfa.js +0 -2
- package/dist/chunk-eav0pt6d.js +0 -2
- package/dist/chunk-hahzjyxc.js +0 -2
- package/dist/chunk-hgqcqg1h.js +0 -2
- package/dist/chunk-hjdwf9gp.js +0 -2
- package/dist/chunk-jjm0ekw8.js +0 -2
- package/dist/chunk-jjtzm6dn.js +0 -3
- package/dist/chunk-k1am0dyg.js +0 -2
- package/dist/chunk-m2jphkdv.js +0 -2
- package/dist/chunk-mk7b3qdz.js +0 -2
- package/dist/chunk-ncvfjcr2.js +0 -2
- package/dist/chunk-p083sckk.js +0 -2
- package/dist/chunk-p7b17yr0.js +0 -2
- package/dist/chunk-pc178389.js +0 -2
- package/dist/chunk-q1v0jwr4.js +0 -2
- package/dist/chunk-r5gjb55x.js +0 -2
- package/dist/chunk-rj8rdd8n.js +0 -2
- package/dist/chunk-s0pmn48x.js +0 -2
- package/dist/chunk-s58yz9q0.js +0 -2
- package/dist/chunk-srdzwtsq.js +0 -2
- package/dist/chunk-tf44jyrh.js +0 -2
- package/dist/chunk-tfypkw4y.js +0 -3
- package/dist/chunk-vwxasbtx.js +0 -2
- package/dist/chunk-wynvh7dc.js +0 -2
- package/dist/chunk-x8rckpyz.js +0 -2
- package/dist/chunk-y4xs4m7p.js +0 -2
- package/dist/chunk-y8rpk1b9.js +0 -2
- package/dist/chunk-y9m93qkk.js +0 -2
- package/dist/chunk-ya0qecph.js +0 -27
- package/dist/chunk-ya9c8nec.js +0 -2
- package/dist/chunk-yvq1f313.js +0 -2
- package/dist/chunk-yy3dgwfm.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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const COMPONENT_MAPPING = {
|
|
2
|
+
view: "View",
|
|
3
|
+
text: "Text",
|
|
4
|
+
button: "Button",
|
|
5
|
+
image: "Image",
|
|
6
|
+
img: "Image",
|
|
7
|
+
input: "TextInput",
|
|
8
|
+
textarea: "TextInput",
|
|
9
|
+
scroll: "ScrollView",
|
|
10
|
+
scrollview: "ScrollView",
|
|
11
|
+
list: "FlatList",
|
|
12
|
+
flatlist: "FlatList",
|
|
13
|
+
modal: "Modal",
|
|
14
|
+
switch: "Switch",
|
|
15
|
+
slider: "Slider",
|
|
16
|
+
picker: "Picker",
|
|
17
|
+
select: "Picker",
|
|
18
|
+
loading: "ActivityIndicator",
|
|
19
|
+
spinner: "ActivityIndicator",
|
|
20
|
+
div: "View",
|
|
21
|
+
span: "Text",
|
|
22
|
+
p: "Text",
|
|
23
|
+
h1: "Text",
|
|
24
|
+
h2: "Text",
|
|
25
|
+
h3: "Text",
|
|
26
|
+
h4: "Text",
|
|
27
|
+
h5: "Text",
|
|
28
|
+
h6: "Text",
|
|
29
|
+
a: "TouchableOpacity",
|
|
30
|
+
section: "View",
|
|
31
|
+
article: "View",
|
|
32
|
+
header: "SafeAreaView",
|
|
33
|
+
footer: "View",
|
|
34
|
+
main: "View",
|
|
35
|
+
nav: "View",
|
|
36
|
+
aside: "View",
|
|
37
|
+
form: "View",
|
|
38
|
+
label: "Text",
|
|
39
|
+
fieldset: "View",
|
|
40
|
+
legend: "Text",
|
|
41
|
+
option: "Text",
|
|
42
|
+
dialog: "Modal",
|
|
43
|
+
figure: "View",
|
|
44
|
+
figcaption: "Text",
|
|
45
|
+
picture: "View",
|
|
46
|
+
hr: "View",
|
|
47
|
+
ul: "View",
|
|
48
|
+
ol: "View",
|
|
49
|
+
li: "View",
|
|
50
|
+
dl: "View",
|
|
51
|
+
dt: "Text",
|
|
52
|
+
dd: "Text",
|
|
53
|
+
table: "View",
|
|
54
|
+
thead: "View",
|
|
55
|
+
tbody: "View",
|
|
56
|
+
tfoot: "View",
|
|
57
|
+
tr: "View",
|
|
58
|
+
th: "Text",
|
|
59
|
+
td: "Text",
|
|
60
|
+
caption: "Text",
|
|
61
|
+
strong: "Text",
|
|
62
|
+
b: "Text",
|
|
63
|
+
em: "Text",
|
|
64
|
+
i: "Text",
|
|
65
|
+
u: "Text",
|
|
66
|
+
s: "Text",
|
|
67
|
+
small: "Text",
|
|
68
|
+
mark: "Text",
|
|
69
|
+
abbr: "Text",
|
|
70
|
+
time: "Text",
|
|
71
|
+
code: "Text",
|
|
72
|
+
kbd: "Text",
|
|
73
|
+
samp: "Text",
|
|
74
|
+
pre: "Text",
|
|
75
|
+
blockquote: "Text",
|
|
76
|
+
cite: "Text",
|
|
77
|
+
q: "Text",
|
|
78
|
+
sub: "Text",
|
|
79
|
+
sup: "Text"
|
|
80
|
+
};
|
|
81
|
+
export function mapToNativeComponent(tag) {
|
|
82
|
+
return COMPONENT_MAPPING[tag.toLowerCase()] || tag;
|
|
83
|
+
}
|
|
84
|
+
export function transformToNativeComponents(node) {
|
|
85
|
+
return {
|
|
86
|
+
...node,
|
|
87
|
+
type: mapToNativeComponent(node.type),
|
|
88
|
+
children: node.children.map((child) => typeof child === "string" ? child : transformToNativeComponents(child))
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { nativePropName } from "../prop-names.js";
|
|
2
|
+
import { mapToNativeComponent } from "./component-mapping.js";
|
|
1
3
|
import { compileHeadwindToStyle } from "./headwind-to-style.js";
|
|
2
4
|
import { createDocument, createNode } from "./ir.js";
|
|
3
|
-
import { mapToNativeComponent } from "./parser.js";
|
|
4
5
|
const DROP_SUBTREE = new Set(["script", "style", "head", "meta", "link", "title", "base", "noscript", "svg"]), UNWRAP = new Set(["template", "body", "html", "main", "fragment"]), BOX_ONLY = new Set(["svg"]), EVENT_NAMES = {
|
|
5
6
|
click: "onPress",
|
|
6
7
|
press: "onPress",
|
|
@@ -252,10 +253,11 @@ function readAttributes(tag, attributes, diagnostics) {
|
|
|
252
253
|
props.key = value;
|
|
253
254
|
continue;
|
|
254
255
|
}
|
|
256
|
+
const decoded = decodeEntities(value);
|
|
255
257
|
try {
|
|
256
|
-
props[rawName] = JSON.parse(
|
|
258
|
+
props[nativePropName(rawName)] = JSON.parse(decoded);
|
|
257
259
|
} catch {
|
|
258
|
-
props[rawName] =
|
|
260
|
+
props[nativePropName(rawName)] = decoded;
|
|
259
261
|
}
|
|
260
262
|
}
|
|
261
263
|
const style = { ...classes ? compileHeadwindToStyle(classes) : {}, ...inline };
|
|
@@ -269,8 +271,31 @@ function holdsString(property, value) {
|
|
|
269
271
|
return !0;
|
|
270
272
|
}
|
|
271
273
|
function inlineStyle(tag, css, diagnostics) {
|
|
272
|
-
const style = {};
|
|
273
|
-
|
|
274
|
+
const style = {}, decoded = decodeEntities(css);
|
|
275
|
+
try {
|
|
276
|
+
const object = JSON.parse(decoded);
|
|
277
|
+
if (object && typeof object === "object" && !Array.isArray(object)) {
|
|
278
|
+
for (const [rawProperty, rawValue] of Object.entries(object)) {
|
|
279
|
+
const property = STYLE_KEYS.has(rawProperty) ? rawProperty : camelCase(rawProperty.trim().toLowerCase());
|
|
280
|
+
if (!STYLE_KEYS.has(property)) {
|
|
281
|
+
diagnostics.push({ kind: "unknown-style", tag, name: property });
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (rawValue === null || rawValue === void 0)
|
|
285
|
+
continue;
|
|
286
|
+
const translated = typeof rawValue === "string" ? styleValue(rawValue) : rawValue;
|
|
287
|
+
if (typeof translated !== "string" && typeof translated !== "number")
|
|
288
|
+
continue;
|
|
289
|
+
if (typeof translated === "string" && !holdsString(property, translated)) {
|
|
290
|
+
diagnostics.push({ kind: "non-numeric-style", tag, name: property });
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
style[property] = translated;
|
|
294
|
+
}
|
|
295
|
+
return style;
|
|
296
|
+
}
|
|
297
|
+
} catch {}
|
|
298
|
+
for (const declaration of decoded.split(";")) {
|
|
274
299
|
const colon = declaration.indexOf(":");
|
|
275
300
|
if (colon === -1)
|
|
276
301
|
continue;
|
|
@@ -320,6 +345,14 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
320
345
|
parent.node.children.push(node);
|
|
321
346
|
}
|
|
322
347
|
function hoist(frame) {
|
|
348
|
+
if (frame.node.bindings && Object.keys(frame.node.bindings).length > 0) {
|
|
349
|
+
const children = frame.node.children, elements = children.filter((child) => typeof child !== "string"), target = elements.length === 1 && elements.length === children.length ? elements[0] : createNode("View", {}, {}, {}, children);
|
|
350
|
+
target.bindings = { ...frame.node.bindings, ...target.bindings };
|
|
351
|
+
if (target.bindingId === void 0 && frame.node.bindingId !== void 0)
|
|
352
|
+
target.bindingId = frame.node.bindingId;
|
|
353
|
+
attach(target);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
323
356
|
const parent = stack[stack.length - 1];
|
|
324
357
|
for (const child of frame.node.children) {
|
|
325
358
|
if (typeof child === "string") {
|
|
@@ -349,7 +382,10 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
349
382
|
seenUnmapped.add(`drop:${tag}`);
|
|
350
383
|
diagnostics.push({ kind: "dropped-subtree", tag });
|
|
351
384
|
}
|
|
352
|
-
const node = createNode(type, props, style, events);
|
|
385
|
+
const node = createNode(type, props, style, events), bindingId = props["data-stx-b"];
|
|
386
|
+
if (typeof bindingId === "number" && Number.isInteger(bindingId))
|
|
387
|
+
node.bindingId = bindingId;
|
|
388
|
+
delete props["data-stx-b"];
|
|
353
389
|
if (classes)
|
|
354
390
|
node._classes = classes;
|
|
355
391
|
if (Object.keys(bindings).length > 0)
|
|
@@ -5,6 +5,8 @@ export declare function createNode(type: STXComponentType | string, props?: Reco
|
|
|
5
5
|
export declare function createDocument(root: STXNode, script: STXDocument['script'], meta?: Partial<STXDocument['meta']>): STXDocument;
|
|
6
6
|
export declare interface STXNode {
|
|
7
7
|
type: STXComponentType | string
|
|
8
|
+
id?: string
|
|
9
|
+
bindingId?: number
|
|
8
10
|
key?: string
|
|
9
11
|
props: Record<string, unknown>
|
|
10
12
|
style: STXStyle
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type BindingManifest } from '../../binding-manifest';
|
|
2
|
+
import { type GeneratedSetupScript } from './setup-script';
|
|
1
3
|
import type { STXDocument } from './ir';
|
|
2
4
|
import type { TranslationDiagnostic } from './html-to-ir';
|
|
3
5
|
/**
|
|
@@ -21,6 +23,8 @@ export declare interface CompileScreenOptions {
|
|
|
21
23
|
}
|
|
22
24
|
export declare interface CompiledScreen {
|
|
23
25
|
document: STXDocument
|
|
26
|
+
manifest: BindingManifest
|
|
27
|
+
setup: GeneratedSetupScript | null
|
|
24
28
|
diagnostics: TranslationDiagnostic[]
|
|
25
29
|
html: string
|
|
26
30
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { extractBindingManifest } from "../../binding-manifest.js";
|
|
3
4
|
import { processDirectives } from "../../process.js";
|
|
5
|
+
import { processScriptSetup } from "../../signal-processing.js";
|
|
4
6
|
import { translateHtmlToDocument } from "./html-to-ir.js";
|
|
5
7
|
import { extractClientScript } from "./client-script.js";
|
|
8
|
+
import { extractGeneratedSetupScript } from "./setup-script.js";
|
|
6
9
|
export function nativePrimitivesDir() {
|
|
7
10
|
const candidates = [
|
|
8
11
|
path.join(import.meta.dir, "..", "primitives"),
|
|
@@ -20,11 +23,16 @@ export async function compileScreenSource(source, filePath, options = {}) {
|
|
|
20
23
|
buildMode: "serve",
|
|
21
24
|
cache: !1,
|
|
22
25
|
_pluginComponentDirs: [nativePrimitivesDir()]
|
|
23
|
-
},
|
|
26
|
+
}, context = { ...options.context ?? {}, __stx_inject_css: !1 }, renderedHtml = await processDirectives(source, context, filePath, config, new Set), { html, manifest } = extractBindingManifest(renderedHtml), { document, diagnostics } = await translateHtmlToDocument(html, {
|
|
24
27
|
source: filePath,
|
|
25
28
|
script: extractClientScript(source)
|
|
26
29
|
});
|
|
27
|
-
|
|
30
|
+
let setup = extractGeneratedSetupScript(html);
|
|
31
|
+
if (extractClientScript(source).code.trim()) {
|
|
32
|
+
const forced = await processScriptSetup(source, filePath, options.context, { forceClientSetup: !0 });
|
|
33
|
+
setup = extractGeneratedSetupScript(forced.setupCode ?? "") ?? setup;
|
|
34
|
+
}
|
|
35
|
+
return { document, manifest, setup, diagnostics, html };
|
|
28
36
|
}
|
|
29
37
|
export async function compileScreenFile(filePath, options = {}) {
|
|
30
38
|
return compileScreenSource(await Bun.file(filePath).text(), filePath, options);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const SCOPED_SCRIPT = /<script\b[^>]*\bdata-stx-scoped\b[^>]*>([\s\S]*?)<\/script>/gi, SETUP_NAME = /function\s+(__stx_setup_[\w$]+)\s*\(/;
|
|
2
|
+
export function extractGeneratedSetupScript(html) {
|
|
3
|
+
SCOPED_SCRIPT.lastIndex = 0;
|
|
4
|
+
for (const match of html.matchAll(SCOPED_SCRIPT)) {
|
|
5
|
+
const code = match[1].trim(), name = SETUP_NAME.exec(code)?.[1];
|
|
6
|
+
if (name)
|
|
7
|
+
return { name, code };
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
@@ -148,6 +148,16 @@ export declare interface SliderProps extends BaseProps {
|
|
|
148
148
|
maximumTrackTintColor?: string
|
|
149
149
|
thumbTintColor?: string
|
|
150
150
|
}
|
|
151
|
+
export declare interface PickerOption {
|
|
152
|
+
label: string
|
|
153
|
+
value: string | number
|
|
154
|
+
}
|
|
155
|
+
export declare interface PickerProps extends BaseProps {
|
|
156
|
+
items: PickerOption[]
|
|
157
|
+
selectedValue?: string | number
|
|
158
|
+
onValueChange?: (value: string | number, index: number) => void
|
|
159
|
+
disabled?: boolean
|
|
160
|
+
}
|
|
151
161
|
// ============================================================================
|
|
152
162
|
// Media Components
|
|
153
163
|
// ============================================================================
|
package/dist/native/index.d.ts
CHANGED
|
@@ -18,21 +18,21 @@ export type {
|
|
|
18
18
|
ModalProps,
|
|
19
19
|
SwitchProps,
|
|
20
20
|
SliderProps,
|
|
21
|
+
PickerOption,
|
|
22
|
+
PickerProps,
|
|
21
23
|
} from './components/primitives';
|
|
22
|
-
export type { Token, TokenType } from './compiler/parser';
|
|
23
24
|
export type {
|
|
24
25
|
HotReloadMessage,
|
|
25
26
|
HotReloadState,
|
|
26
27
|
HotReloadCallback,
|
|
27
28
|
ErrorOverlayOptions,
|
|
28
29
|
} from './hot-reload/client';
|
|
29
|
-
export type { RuntimeConfig } from './runtime/index';
|
|
30
30
|
/**
|
|
31
31
|
* `@stacksjs/stx/native`: stx templates as native iOS/Android screens.
|
|
32
32
|
*
|
|
33
|
-
* A `.stx` screen compiles to a
|
|
34
|
-
* UIKit (and Android views)
|
|
35
|
-
*
|
|
33
|
+
* A `.stx` screen compiles to rendered IR plus a binding manifest that Craft
|
|
34
|
+
* draws with UIKit (and Android views). The ordinary stx signals runtime owns
|
|
35
|
+
* client state and sends targeted native-tree mutations without a WebView.
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* ```ts
|
|
@@ -51,26 +51,17 @@ export type { RuntimeConfig } from './runtime/index';
|
|
|
51
51
|
// Compiler exports
|
|
52
52
|
export * from './compiler/ir';
|
|
53
53
|
export * from './compiler/headwind-to-style';
|
|
54
|
-
export * from './compiler/parser';
|
|
55
54
|
export * from './compiler/html-to-ir';
|
|
56
55
|
export * from './compiler/client-script';
|
|
57
56
|
export * from './compiler/render-screen';
|
|
58
57
|
export * from './compiler/bundle';
|
|
59
58
|
export * from './compiler/icons';
|
|
60
59
|
export * from './cli';
|
|
60
|
+
export * from './runtime/shared-screen';
|
|
61
61
|
// Bridge exports
|
|
62
62
|
export * from './bridge/protocol';
|
|
63
63
|
// Component exports
|
|
64
64
|
export * from './components/primitives';
|
|
65
|
-
// Parser exports
|
|
66
|
-
export {
|
|
67
|
-
parseSTX,
|
|
68
|
-
parseSTXToNode,
|
|
69
|
-
compileSTX,
|
|
70
|
-
compileSTXFiles,
|
|
71
|
-
mapToNativeComponent,
|
|
72
|
-
transformToNativeComponents,
|
|
73
|
-
} from './compiler/parser';
|
|
74
65
|
// Hot Reload exports
|
|
75
66
|
export {
|
|
76
67
|
getHotReloadClient,
|
|
@@ -79,12 +70,3 @@ export {
|
|
|
79
70
|
HotReloadClient,
|
|
80
71
|
ErrorOverlay,
|
|
81
72
|
} from './hot-reload/client';
|
|
82
|
-
// Runtime exports
|
|
83
|
-
export {
|
|
84
|
-
getRuntime,
|
|
85
|
-
startRuntime,
|
|
86
|
-
render,
|
|
87
|
-
setState,
|
|
88
|
-
getState,
|
|
89
|
-
STXRuntime,
|
|
90
|
-
} from './runtime/index';
|
package/dist/native/index.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
export * from "./compiler/ir.js";
|
|
2
2
|
export * from "./compiler/headwind-to-style.js";
|
|
3
|
-
export * from "./compiler/parser.js";
|
|
4
3
|
export * from "./compiler/html-to-ir.js";
|
|
5
4
|
export * from "./compiler/client-script.js";
|
|
6
5
|
export * from "./compiler/render-screen.js";
|
|
7
6
|
export * from "./compiler/bundle.js";
|
|
8
7
|
export * from "./compiler/icons.js";
|
|
9
8
|
export * from "./cli.js";
|
|
9
|
+
export * from "./runtime/shared-screen.js";
|
|
10
10
|
export * from "./bridge/protocol.js";
|
|
11
11
|
export * from "./components/primitives.js";
|
|
12
|
-
export {
|
|
13
|
-
parseSTX,
|
|
14
|
-
parseSTXToNode,
|
|
15
|
-
compileSTX,
|
|
16
|
-
compileSTXFiles,
|
|
17
|
-
mapToNativeComponent,
|
|
18
|
-
transformToNativeComponents
|
|
19
|
-
} from "./compiler/parser.js";
|
|
20
12
|
export {
|
|
21
13
|
getHotReloadClient,
|
|
22
14
|
getErrorOverlay,
|
|
@@ -24,11 +16,3 @@ export {
|
|
|
24
16
|
HotReloadClient,
|
|
25
17
|
ErrorOverlay
|
|
26
18
|
} from "./hot-reload/client.js";
|
|
27
|
-
export {
|
|
28
|
-
getRuntime,
|
|
29
|
-
startRuntime,
|
|
30
|
-
render,
|
|
31
|
-
setState,
|
|
32
|
-
getState,
|
|
33
|
-
STXRuntime
|
|
34
|
-
} from "./runtime/index.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{-- Button: the native type, written as an ordinary stx component. --}}
|
|
2
2
|
<script server>
|
|
3
3
|
const classes = $props.class ?? $props.className ?? ''
|
|
4
|
+
const testID = $props.testID
|
|
4
5
|
</script>
|
|
5
|
-
<button data-native="Button" class="{{ classes }}" type="button"><slot /></button>
|
|
6
|
+
<button data-native="Button" class="{{ classes }}" type="button" @if(testID) testID="{{ testID }}" @endif><slot /></button>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{-- Text: the native type, written as an ordinary stx component. --}}
|
|
2
2
|
<script server>
|
|
3
3
|
const classes = $props.class ?? $props.className ?? ''
|
|
4
|
+
const testID = $props.testID
|
|
4
5
|
</script>
|
|
5
|
-
<span data-native="Text" class="{{ classes }}"><slot /></span>
|
|
6
|
+
<span data-native="Text" class="{{ classes }}" @if(testID) testID="{{ testID }}" @endif><slot /></span>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
{{-- TextInput: the native type, written as an ordinary stx component. --}}
|
|
2
2
|
<script server>
|
|
3
3
|
const classes = $props.class ?? $props.className ?? ''
|
|
4
|
+
const testID = $props.testID
|
|
5
|
+
const placeholder = $props.placeholder
|
|
4
6
|
</script>
|
|
5
|
-
<input data-native="TextInput" class="{{ classes }}" />
|
|
7
|
+
<input data-native="TextInput" class="{{ classes }}" @if(testID) testID="{{ testID }}" @endif @if(placeholder) placeholder="{{ placeholder }}" @endif />
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const NATIVE_PROP_NAMES = [
|
|
2
|
+
"accessibilityHint",
|
|
3
|
+
"accessibilityLabel",
|
|
4
|
+
"accessibilityRole",
|
|
5
|
+
"accessibilityState",
|
|
6
|
+
"accessibilityValue",
|
|
7
|
+
"activeOpacity",
|
|
8
|
+
"alwaysBounceHorizontal",
|
|
9
|
+
"alwaysBounceVertical",
|
|
10
|
+
"animationType",
|
|
11
|
+
"autoCapitalize",
|
|
12
|
+
"autoCorrect",
|
|
13
|
+
"autoFocus",
|
|
14
|
+
"blurRadius",
|
|
15
|
+
"contentContainerStyle",
|
|
16
|
+
"defaultSource",
|
|
17
|
+
"defaultValue",
|
|
18
|
+
"ellipsizeMode",
|
|
19
|
+
"fadeDuration",
|
|
20
|
+
"hidesWhenStopped",
|
|
21
|
+
"hitSlop",
|
|
22
|
+
"imageStyle",
|
|
23
|
+
"initialNumToRender",
|
|
24
|
+
"iosBackgroundColor",
|
|
25
|
+
"keyboardDismissMode",
|
|
26
|
+
"keyboardShouldPersistTaps",
|
|
27
|
+
"keyboardType",
|
|
28
|
+
"keyboardVerticalOffset",
|
|
29
|
+
"keyExtractor",
|
|
30
|
+
"maxLength",
|
|
31
|
+
"maximumTrackTintColor",
|
|
32
|
+
"maximumValue",
|
|
33
|
+
"maxToRenderPerBatch",
|
|
34
|
+
"minimumTrackTintColor",
|
|
35
|
+
"minimumValue",
|
|
36
|
+
"numberOfLines",
|
|
37
|
+
"numColumns",
|
|
38
|
+
"onEndReachedThreshold",
|
|
39
|
+
"pagingEnabled",
|
|
40
|
+
"placeholderTextColor",
|
|
41
|
+
"pointerEvents",
|
|
42
|
+
"presentationStyle",
|
|
43
|
+
"pressRetentionOffset",
|
|
44
|
+
"progressBackgroundColor",
|
|
45
|
+
"progressViewOffset",
|
|
46
|
+
"refreshControl",
|
|
47
|
+
"resizeMode",
|
|
48
|
+
"returnKeyType",
|
|
49
|
+
"scrollEnabled",
|
|
50
|
+
"scrollTarget",
|
|
51
|
+
"secureTextEntry",
|
|
52
|
+
"selectedValue",
|
|
53
|
+
"selectionColor",
|
|
54
|
+
"showsHorizontalScrollIndicator",
|
|
55
|
+
"showsVerticalScrollIndicator",
|
|
56
|
+
"statusBarTranslucent",
|
|
57
|
+
"stickyHeaderIndices",
|
|
58
|
+
"testID",
|
|
59
|
+
"thumbColor",
|
|
60
|
+
"thumbTintColor",
|
|
61
|
+
"titleColor",
|
|
62
|
+
"trackColor",
|
|
63
|
+
"underlayColor",
|
|
64
|
+
"windowSize"
|
|
65
|
+
], nativePropNames = new Map(NATIVE_PROP_NAMES.map((name) => [normaliseKey(name), name]));
|
|
66
|
+
function normaliseKey(name) {
|
|
67
|
+
return name.replace(/[-_]/g, "").toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
export function nativePropName(name) {
|
|
70
|
+
return nativePropNames.get(normaliseKey(name)) ?? name;
|
|
71
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BindingManifest } from '../../binding-manifest';
|
|
2
|
+
import type { NativeHost, NativeNode } from './native-host';
|
|
3
|
+
import type { STXDocument } from '../compiler/ir';
|
|
4
|
+
/** Clone the DOM-shaped metadata while the host clones the native descriptor. */
|
|
5
|
+
export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string): NativeBindingNode;
|
|
6
|
+
/** Build host handles and a manifest-id lookup from already translated IR. */
|
|
7
|
+
export declare function materializeNativeBindingTree(document: STXDocument, manifest: BindingManifest, host: NativeHost): NativeBindingTree;
|
|
8
|
+
export declare interface NativeBindingNode extends NativeNode {
|
|
9
|
+
nodeType: 1
|
|
10
|
+
tagName: string
|
|
11
|
+
attributes: Array<{ name: string, value: string }>
|
|
12
|
+
parentNode: NativeBindingNode | null
|
|
13
|
+
parentElement: NativeBindingNode | null
|
|
14
|
+
childNodes: NativeNode[]
|
|
15
|
+
children: NativeNode[]
|
|
16
|
+
readonly nextSibling: NativeNode | null
|
|
17
|
+
readonly nextElementSibling: NativeBindingNode | null
|
|
18
|
+
namespaceURI: string
|
|
19
|
+
isConnected: boolean
|
|
20
|
+
hasAttribute: (name: string) => boolean
|
|
21
|
+
getAttribute: (name: string) => string | null
|
|
22
|
+
setAttribute: (name: string, value: unknown) => void
|
|
23
|
+
removeAttribute: (name: string) => void
|
|
24
|
+
contains: (node: NativeBindingNode) => boolean
|
|
25
|
+
querySelector: (selector: string) => NativeBindingNode | null
|
|
26
|
+
querySelectorAll: (selector: string) => NativeBindingNode[]
|
|
27
|
+
}
|
|
28
|
+
export declare interface NativeBindingTree {
|
|
29
|
+
root: NativeBindingNode
|
|
30
|
+
nodes: Map<number, NativeBindingNode>
|
|
31
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
function decodeBindingValue(value) {
|
|
2
|
+
return value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;/g, "'").replace(/'/gi, "'").replace(/&/g, "&");
|
|
3
|
+
}
|
|
4
|
+
function createBindingNode(id, type, bindings, connected = !0) {
|
|
5
|
+
const attributes = bindings.map((binding) => ({
|
|
6
|
+
name: binding.name,
|
|
7
|
+
value: decodeBindingValue(binding.value)
|
|
8
|
+
})), node = {
|
|
9
|
+
__stxId: id,
|
|
10
|
+
nodeType: 1,
|
|
11
|
+
tagName: type.toUpperCase(),
|
|
12
|
+
attributes,
|
|
13
|
+
parentNode: null,
|
|
14
|
+
parentElement: null,
|
|
15
|
+
childNodes: [],
|
|
16
|
+
children: [],
|
|
17
|
+
nextSibling: null,
|
|
18
|
+
nextElementSibling: null,
|
|
19
|
+
namespaceURI: "",
|
|
20
|
+
isConnected: !0,
|
|
21
|
+
hasAttribute(name) {
|
|
22
|
+
return attributes.some((attribute) => attribute.name === name);
|
|
23
|
+
},
|
|
24
|
+
getAttribute(name) {
|
|
25
|
+
return attributes.find((attribute) => attribute.name === name)?.value ?? null;
|
|
26
|
+
},
|
|
27
|
+
setAttribute(name, value) {
|
|
28
|
+
const existing = attributes.find((attribute) => attribute.name === name);
|
|
29
|
+
if (existing)
|
|
30
|
+
existing.value = String(value);
|
|
31
|
+
else
|
|
32
|
+
attributes.push({ name, value: String(value) });
|
|
33
|
+
},
|
|
34
|
+
removeAttribute(name) {
|
|
35
|
+
const index = attributes.findIndex((attribute) => attribute.name === name);
|
|
36
|
+
if (index !== -1)
|
|
37
|
+
attributes.splice(index, 1);
|
|
38
|
+
},
|
|
39
|
+
contains(candidate) {
|
|
40
|
+
for (let current = candidate;current; current = current.parentNode)
|
|
41
|
+
if (current === node)
|
|
42
|
+
return !0;
|
|
43
|
+
return !1;
|
|
44
|
+
},
|
|
45
|
+
querySelector(selector) {
|
|
46
|
+
return node.querySelectorAll(selector)[0] ?? null;
|
|
47
|
+
},
|
|
48
|
+
querySelectorAll(selector) {
|
|
49
|
+
const found = [], attribute = /^\[([^\]]+)\]$/.exec(selector)?.[1], visit = (candidate) => {
|
|
50
|
+
const element = candidate;
|
|
51
|
+
if (element.nodeType === 1) {
|
|
52
|
+
if (selector === "*" || attribute && element.hasAttribute(attribute))
|
|
53
|
+
found.push(element);
|
|
54
|
+
element.childNodes.forEach(visit);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
node.childNodes.forEach(visit);
|
|
58
|
+
return found;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
node.isConnected = connected;
|
|
62
|
+
return node;
|
|
63
|
+
}
|
|
64
|
+
export function cloneNativeBindingNode(source, id) {
|
|
65
|
+
const bindings = source.attributes.map((attribute) => ({
|
|
66
|
+
name: attribute.name,
|
|
67
|
+
value: attribute.value,
|
|
68
|
+
kind: "attr"
|
|
69
|
+
}));
|
|
70
|
+
return createBindingNode(id, source.tagName, bindings, !1);
|
|
71
|
+
}
|
|
72
|
+
export function materializeNativeBindingTree(document, manifest, host) {
|
|
73
|
+
const entries = new Map(manifest.entries.map((entry) => [entry.id, entry])), nodes = new Map;
|
|
74
|
+
let sequence = 0;
|
|
75
|
+
function visit(source, parent) {
|
|
76
|
+
const id = `n${sequence++}`, runtimeBindings = [...(source.bindingId === void 0 ? void 0 : entries.get(source.bindingId))?.bindings ?? []];
|
|
77
|
+
for (const [name, value] of Object.entries(source.bindings ?? {}))
|
|
78
|
+
if (!runtimeBindings.some((binding) => binding.name.replace(/^[:@]/, "") === name))
|
|
79
|
+
runtimeBindings.push({ name: `:${name}`, value, kind: "attr" });
|
|
80
|
+
const node = createBindingNode(id, source.type, runtimeBindings);
|
|
81
|
+
source.id = id;
|
|
82
|
+
source.props.__stxId = id;
|
|
83
|
+
node.parentNode = parent;
|
|
84
|
+
node.parentElement = parent;
|
|
85
|
+
host.adopt(node, source.type, parent, source);
|
|
86
|
+
if (source.bindingId !== void 0) {
|
|
87
|
+
node.setAttribute("data-stx-b", source.bindingId);
|
|
88
|
+
nodes.set(source.bindingId, node);
|
|
89
|
+
}
|
|
90
|
+
for (const child of source.children) {
|
|
91
|
+
if (typeof child === "string")
|
|
92
|
+
continue;
|
|
93
|
+
const childNode = visit(child, node);
|
|
94
|
+
node.childNodes.push(childNode);
|
|
95
|
+
node.children.push(childNode);
|
|
96
|
+
}
|
|
97
|
+
return node;
|
|
98
|
+
}
|
|
99
|
+
return { root: visit(document.root, null), nodes };
|
|
100
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { STXBridge } from '../bridge/protocol';
|
|
2
|
+
import type { NativeBridgeInterface } from '../bridge/protocol';
|
|
3
|
+
/** Install the Craft capability surface on top of the shared typed bridge. */
|
|
4
|
+
export declare function installCraftBridge(protocol: STXBridge, nativeBridge: NativeBridgeInterface, target?: AnyRecord, options?: CraftBridgeOptions): AnyRecord;
|
|
5
|
+
export declare interface CraftBridgeOptions {
|
|
6
|
+
routeName?: string
|
|
7
|
+
routeNames?: string[]
|
|
8
|
+
}
|
|
9
|
+
declare type AnyRecord = Record<string, any>;
|