@stacksjs/stx 0.2.605 → 0.2.607
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-38mt83wa.js → chunk-06wv8qwy.js} +6 -6
- package/dist/{chunk-sqq6kpve.js → chunk-0cb00ys2.js} +6 -6
- package/dist/chunk-0d6b3eeb.js +2 -0
- package/dist/chunk-0mgth7cm.js +2 -0
- package/dist/{chunk-9cgga2aw.js → chunk-0v89nfz1.js} +2 -2
- package/dist/{chunk-813wwkap.js → chunk-1dd4qefr.js} +2 -2
- package/dist/chunk-1fdrhfc0.js +2 -0
- package/dist/{chunk-htcptqtn.js → chunk-1jxdkp8x.js} +6 -6
- package/dist/{chunk-6eg9a3mt.js → chunk-20k77e2a.js} +4 -4
- package/dist/chunk-2n59ahd9.js +2 -0
- package/dist/chunk-2pwjnydp.js +2 -0
- package/dist/chunk-2r4an7bh.js +2 -0
- package/dist/chunk-304vaxnk.js +2 -0
- package/dist/chunk-32hr3qq7.js +2 -0
- package/dist/chunk-36n8yz6t.js +2 -0
- package/dist/chunk-39pgf5z3.js +2 -0
- package/dist/chunk-3xwzd9wp.js +2845 -0
- package/dist/chunk-3yttgk0s.js +2 -0
- package/dist/chunk-4ck2xc8m.js +2 -0
- package/dist/chunk-4jasfhh6.js +2 -0
- package/dist/chunk-4szajb1z.js +2 -0
- package/dist/{chunk-axz1x4r9.js → chunk-4tj0ap61.js} +5 -5
- package/dist/{chunk-9nt3q23a.js → chunk-53y4z4p2.js} +3 -3
- package/dist/{chunk-j1dmkt29.js → chunk-5e182xqt.js} +1 -1
- package/dist/{chunk-afnj003j.js → chunk-5j29466h.js} +2 -2
- package/dist/{chunk-67m2prah.js → chunk-5s47qfp6.js} +2 -2
- package/dist/{chunk-h5cgm4hy.js → chunk-60wedefh.js} +2 -2
- package/dist/chunk-61ztfana.js +127 -0
- package/dist/{chunk-1944jgb2.js → chunk-67tpacz0.js} +1 -1
- package/dist/{chunk-9h1ytsgm.js → chunk-6by8dtan.js} +2 -2
- package/dist/{chunk-k71e38fk.js → chunk-6xsm53pz.js} +4 -4
- package/dist/{chunk-tc3ne706.js → chunk-7095f0hb.js} +9 -9
- package/dist/{chunk-jg8w43n0.js → chunk-77kpsnf6.js} +39 -39
- package/dist/{chunk-f49nnf8v.js → chunk-79edpvb2.js} +6 -6
- package/dist/chunk-7f63z4xx.js +2 -0
- package/dist/chunk-7renf4zp.js +2 -0
- package/dist/{chunk-9wtb959p.js → chunk-81qmj3sd.js} +7 -7
- package/dist/chunk-8bzx0r0x.js +2 -0
- package/dist/{chunk-dnnc0m92.js → chunk-8fq6bvnw.js} +13 -13
- package/dist/chunk-974dxazw.js +2 -0
- package/dist/chunk-9fpnnfr3.js +2 -0
- package/dist/chunk-9sgt7v77.js +2 -0
- package/dist/chunk-9zzhpp2a.js +2 -0
- package/dist/chunk-aan7601v.js +2 -0
- package/dist/{chunk-h8a8y1wh.js → chunk-aestp72s.js} +2 -2
- package/dist/{chunk-tt1p6zt8.js → chunk-azpkje69.js} +4 -4
- package/dist/chunk-b4tbqz8r.js +2 -0
- package/dist/chunk-bakxqwnz.js +2 -0
- package/dist/chunk-be2kmw0p.js +2 -0
- package/dist/{chunk-48s1nprc.js → chunk-bhf9yt2w.js} +2 -2
- package/dist/chunk-bnpb6ez9.js +2 -0
- package/dist/{chunk-btbdp4fg.js → chunk-bspryr4a.js} +5 -5
- package/dist/{chunk-jtq8e3b0.js → chunk-bsy8v1xj.js} +2 -2
- package/dist/{chunk-fkh9zshs.js → chunk-c48mh4d6.js} +5 -5
- package/dist/{chunk-x7epxhsz.js → chunk-c65q0svd.js} +5 -5
- package/dist/{chunk-zrw1zf54.js → chunk-cfpenvc7.js} +3 -3
- package/dist/{chunk-rc7wmbnz.js → chunk-cp901m61.js} +1 -1
- package/dist/{chunk-4st1qw62.js → chunk-dmdhbwmn.js} +3 -3
- package/dist/{chunk-t19th11m.js → chunk-dnqq1ze0.js} +3 -3
- package/dist/{chunk-279b1228.js → chunk-dxqwm8tr.js} +3 -3
- package/dist/chunk-dzbkgsv8.js +4 -0
- package/dist/{chunk-bfbmdjh4.js → chunk-efy3038a.js} +2 -2
- package/dist/{chunk-gbe53zv3.js → chunk-ev6w9c69.js} +1 -1
- package/dist/chunk-ewkza45r.js +2 -0
- package/dist/chunk-exd1h9sd.js +2 -0
- package/dist/chunk-fcgf8d5k.js +2 -0
- package/dist/{chunk-kty4k2jq.js → chunk-g04y5wyn.js} +3 -3
- package/dist/chunk-g63ye3fe.js +3 -0
- package/dist/{chunk-9x4r15mv.js → chunk-ghdyqt98.js} +2 -2
- package/dist/chunk-gw2dvp35.js +2 -0
- package/dist/chunk-h9drxwva.js +2 -0
- package/dist/chunk-hrr7k1qc.js +2 -0
- package/dist/chunk-j04brkj0.js +2 -0
- package/dist/chunk-jbvwg4gs.js +2 -0
- package/dist/{chunk-wkxzzdzs.js → chunk-jpxekhdh.js} +3 -3
- package/dist/chunk-jshj69dy.js +2 -0
- package/dist/{chunk-y09g63k0.js → chunk-jsktg3ab.js} +5 -5
- package/dist/{chunk-zvs13kgh.js → chunk-k3f4044e.js} +2 -2
- package/dist/chunk-k4wkfhvz.js +2 -0
- package/dist/chunk-km9a5gp4.js +2 -0
- package/dist/{chunk-4h58as2c.js → chunk-kxjd6e2h.js} +2 -2
- package/dist/{chunk-nb0ytx70.js → chunk-m95zjk91.js} +2 -2
- package/dist/{chunk-h7atbtds.js → chunk-m9h7pmkh.js} +5 -5
- package/dist/chunk-mgj0ngyq.js +2 -0
- package/dist/{chunk-8s7zbhdd.js → chunk-mvwcf4xy.js} +4 -4
- package/dist/chunk-myqhdz1w.js +2 -0
- package/dist/chunk-n35yc890.js +3 -0
- package/dist/chunk-n39ezmxz.js +2 -0
- package/dist/chunk-n8eavnxf.js +2 -0
- package/dist/chunk-p8sv5fqs.js +2 -0
- package/dist/chunk-pghtgep5.js +2 -0
- package/dist/chunk-pt7e0be5.js +2 -0
- package/dist/chunk-q40ahbjs.js +2 -0
- package/dist/{chunk-gzpxvca7.js → chunk-qh07a85k.js} +3 -3
- package/dist/chunk-qjxxhdv7.js +2 -0
- package/dist/{chunk-18ws9heh.js → chunk-r4h8fg1x.js} +1 -1
- package/dist/{chunk-tnafnb23.js → chunk-r69jfs59.js} +1 -1
- package/dist/{chunk-82bttwqm.js → chunk-rmv35cx0.js} +2 -2
- package/dist/chunk-rp93n4z7.js +3 -0
- package/dist/chunk-rrw2jg26.js +2 -0
- package/dist/chunk-rxja040z.js +2 -0
- package/dist/{chunk-tds3d65g.js → chunk-s4pjf2pc.js} +2 -2
- package/dist/{chunk-b3c1gggs.js → chunk-sswjv8p9.js} +2 -2
- package/dist/chunk-sx0qbekt.js +2 -0
- package/dist/chunk-t83acmv2.js +2 -0
- package/dist/{chunk-bsy10tz6.js → chunk-t9t66sz4.js} +6 -6
- package/dist/{chunk-pb7vste8.js → chunk-tbsjg23k.js} +4 -4
- package/dist/chunk-tc176d93.js +2 -0
- package/dist/{chunk-q6h6yjg4.js → chunk-tcd2zez3.js} +2 -2
- package/dist/{chunk-f17rcvdb.js → chunk-td30jg06.js} +2 -2
- package/dist/{chunk-qf39z0hg.js → chunk-td5100fz.js} +7 -7
- package/dist/{chunk-navkh35g.js → chunk-tfjcs55e.js} +3 -3
- package/dist/{chunk-a8n6mt7s.js → chunk-tydv84gj.js} +2 -2
- package/dist/{chunk-hsy9rhct.js → chunk-vehtypx0.js} +2 -2
- package/dist/{chunk-y3wdf7v7.js → chunk-vntpfbwy.js} +1 -1
- package/dist/{chunk-25zpd110.js → chunk-vp3fzjsc.js} +2 -2
- package/dist/{chunk-q1cvef6b.js → chunk-vw62fjpv.js} +3 -3
- package/dist/{chunk-shnsvsg4.js → chunk-w8g2ppnr.js} +2 -2
- package/dist/chunk-wjhhb6dn.js +2 -0
- package/dist/chunk-wm8w2721.js +2 -0
- package/dist/{chunk-v3dnfv5g.js → chunk-wqmm1qsz.js} +5 -5
- package/dist/chunk-wtax276j.js +2 -0
- package/dist/{chunk-g6ew2drc.js → chunk-wy53pys4.js} +5 -5
- package/dist/{chunk-v8ze2q95.js → chunk-wzjf33es.js} +2 -2
- package/dist/chunk-x49qdt4c.js +2 -0
- package/dist/{chunk-gh181dnr.js → chunk-x8q5przn.js} +10 -10
- package/dist/{chunk-vn6h03nq.js → chunk-xjxc4q3w.js} +27 -27
- package/dist/chunk-y0zyzbjf.js +2 -0
- package/dist/{chunk-kx52xt96.js → chunk-y54fz9rk.js} +2 -2
- package/dist/{chunk-y0qjpcc8.js → chunk-yzj55rfs.js} +3 -3
- package/dist/{chunk-hrv206vt.js → chunk-z2xrwmjr.js} +10 -10
- package/dist/{chunk-hz11wmx9.js → chunk-z8fhtym2.js} +2 -2
- package/dist/chunk-z8mdsjzw.js +2 -0
- package/dist/chunk-zg87pybq.js +2 -0
- package/dist/chunk-zq345s76.js +2 -0
- package/dist/chunk-zs3ezqy3.js +2 -0
- package/dist/cli.js +20 -20
- package/dist/component-renderer.js +62 -9
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/expressions.js +7 -1
- package/dist/native/accessibility.d.ts +12 -0
- package/dist/native/accessibility.js +19 -0
- package/dist/native/compiler/headwind-to-style.js +23 -29
- package/dist/native/compiler/html-to-ir.js +18 -7
- package/dist/native/compiler/inline-style.d.ts +7 -0
- package/dist/native/compiler/inline-style.js +8 -1
- package/dist/native/compiler/ir.d.ts +4 -2
- package/dist/native/compiler/render-screen.js +1 -1
- package/dist/native/components/primitives.d.ts +49 -25
- package/dist/native/components/primitives.js +1 -0
- package/dist/native/event-names.js +1 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/primitives/Link.stx +5 -0
- package/dist/native/prop-names.js +9 -1
- package/dist/native/runtime/binding-tree.js +2 -1
- package/dist/native/runtime/browser-renderer.js +63 -4
- package/dist/native/runtime/craft-bridge.js +8 -2
- package/dist/native/runtime/craft.d.ts +4 -0
- package/dist/native/runtime/native-host.js +20 -14
- package/dist/native/runtime/overlay-presenter.d.ts +2 -0
- package/dist/native/runtime/overlay-presenter.js +10 -5
- package/dist/native/runtime/view-operations.d.ts +1 -1
- package/dist/native/runtime/view-operations.js +5 -1
- package/dist/pwa.js +3 -3
- package/dist/server-bindings.js +5 -2
- package/dist/slot-scopes.d.ts +7 -0
- package/dist/slot-scopes.js +19 -0
- package/dist/slots.js +23 -7
- package/dist/ssg.js +12 -12
- package/dist/stx-virtual-ts.js +6 -5
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-04gt67sv.js +0 -2
- package/dist/chunk-0hpw65yr.js +0 -2
- package/dist/chunk-0jsg0z9j.js +0 -127
- package/dist/chunk-122y2fkw.js +0 -3
- package/dist/chunk-138zjhwa.js +0 -2
- package/dist/chunk-1548a62z.js +0 -2
- package/dist/chunk-214w9gst.js +0 -2
- package/dist/chunk-2c7ysn9s.js +0 -2
- package/dist/chunk-2h99p36p.js +0 -2
- package/dist/chunk-2qt63502.js +0 -2
- package/dist/chunk-2rzcy4yg.js +0 -2
- package/dist/chunk-2wb1w0p6.js +0 -2
- package/dist/chunk-3q312svf.js +0 -2
- package/dist/chunk-5ajbkx0a.js +0 -2
- package/dist/chunk-6djvj6hg.js +0 -2
- package/dist/chunk-6kmqb08x.js +0 -2
- package/dist/chunk-7dkwf9h5.js +0 -2
- package/dist/chunk-8992smwz.js +0 -2
- package/dist/chunk-9j6hk72q.js +0 -2
- package/dist/chunk-9nct3gsy.js +0 -2
- package/dist/chunk-a2pd13yw.js +0 -2
- package/dist/chunk-acm2tym9.js +0 -2
- package/dist/chunk-atqnvmea.js +0 -2845
- package/dist/chunk-ax5t83f4.js +0 -2
- package/dist/chunk-bc8rzjnh.js +0 -2
- package/dist/chunk-bvczk7xr.js +0 -2
- package/dist/chunk-c88e6w5r.js +0 -2
- package/dist/chunk-ce2d0hz9.js +0 -2
- package/dist/chunk-cg3vfr6b.js +0 -2
- package/dist/chunk-d81h4mxd.js +0 -2
- package/dist/chunk-dgtxj56t.js +0 -3
- package/dist/chunk-ej1erz2c.js +0 -2
- package/dist/chunk-eqa0wdv9.js +0 -4
- package/dist/chunk-erb1bc49.js +0 -2
- package/dist/chunk-esj49jvz.js +0 -2
- package/dist/chunk-ffykng6w.js +0 -2
- package/dist/chunk-fwt5fh5w.js +0 -2
- package/dist/chunk-gqm3w433.js +0 -2
- package/dist/chunk-hhwnd24n.js +0 -2
- package/dist/chunk-hjh1a3ga.js +0 -2
- package/dist/chunk-hq4mtcp0.js +0 -2
- package/dist/chunk-jhswy523.js +0 -2
- package/dist/chunk-jyqanvwp.js +0 -2
- package/dist/chunk-k229zdjh.js +0 -2
- package/dist/chunk-khdvzjzd.js +0 -2
- package/dist/chunk-knngjd2r.js +0 -2
- package/dist/chunk-makn68zy.js +0 -2
- package/dist/chunk-mnwf9yde.js +0 -2
- package/dist/chunk-n06xznty.js +0 -2
- package/dist/chunk-n633zv27.js +0 -3
- package/dist/chunk-nzpthbe1.js +0 -2
- package/dist/chunk-p973efbe.js +0 -2
- package/dist/chunk-pyj4ashw.js +0 -2
- package/dist/chunk-qhxf7pxh.js +0 -2
- package/dist/chunk-qjmqp5z7.js +0 -2
- package/dist/chunk-qq59xzwc.js +0 -2
- package/dist/chunk-r0e743c3.js +0 -2
- package/dist/chunk-shzesarq.js +0 -2
- package/dist/chunk-tcddr6dx.js +0 -2
- package/dist/chunk-v4gepwh9.js +0 -2
- package/dist/chunk-wn2gzwmv.js +0 -2
- package/dist/chunk-wr6gw263.js +0 -2
- package/dist/chunk-xfe2nzxd.js +0 -2
- package/dist/chunk-xjwgzp6s.js +0 -2
- package/dist/chunk-y6909jm7.js +0 -2
- package/dist/chunk-zfrpjaxw.js +0 -2
package/dist/native/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ const NATIVE_PROP_NAMES = [
|
|
|
16
16
|
"autoFocus",
|
|
17
17
|
"blurRadius",
|
|
18
18
|
"contentContainerStyle",
|
|
19
|
+
"currentTime",
|
|
19
20
|
"defaultSource",
|
|
20
21
|
"defaultValue",
|
|
21
22
|
"ellipsizeMode",
|
|
@@ -24,12 +25,13 @@ const NATIVE_PROP_NAMES = [
|
|
|
24
25
|
"hitSlop",
|
|
25
26
|
"imageStyle",
|
|
26
27
|
"initialNumToRender",
|
|
27
|
-
"
|
|
28
|
+
"ios_backgroundColor",
|
|
28
29
|
"keyboardDismissMode",
|
|
29
30
|
"keyboardShouldPersistTaps",
|
|
30
31
|
"keyboardType",
|
|
31
32
|
"keyboardVerticalOffset",
|
|
32
33
|
"keyExtractor",
|
|
34
|
+
"listRole",
|
|
33
35
|
"maxLength",
|
|
34
36
|
"maximumDate",
|
|
35
37
|
"maximumTrackTintColor",
|
|
@@ -47,6 +49,8 @@ const NATIVE_PROP_NAMES = [
|
|
|
47
49
|
"placeholderTextColor",
|
|
48
50
|
"pointerEvents",
|
|
49
51
|
"presentationStyle",
|
|
52
|
+
"nonModal",
|
|
53
|
+
"dismissOnOutsideTap",
|
|
50
54
|
"pressRetentionOffset",
|
|
51
55
|
"progressBackgroundColor",
|
|
52
56
|
"progressViewOffset",
|
|
@@ -91,6 +95,8 @@ const NATIVE_PROP_NAMES = [
|
|
|
91
95
|
"transitionID"
|
|
92
96
|
];
|
|
93
97
|
export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
98
|
+
"alwaysBounceHorizontal",
|
|
99
|
+
"alwaysBounceVertical",
|
|
94
100
|
"animating",
|
|
95
101
|
"autoCorrect",
|
|
96
102
|
"autoFocus",
|
|
@@ -115,6 +121,8 @@ export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
|
115
121
|
"showsVerticalScrollIndicator",
|
|
116
122
|
"transparent",
|
|
117
123
|
"visible",
|
|
124
|
+
"nonModal",
|
|
125
|
+
"dismissOnOutsideTap",
|
|
118
126
|
"fitToBounds",
|
|
119
127
|
"showsUserLocation",
|
|
120
128
|
"zoomEnabled",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { authoredAccessibilityProps } from "../accessibility.js";
|
|
1
2
|
function decodeBindingValue(value) {
|
|
2
3
|
return value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;/g, "'").replace(/'/gi, "'").replace(/&/g, "&");
|
|
3
4
|
}
|
|
@@ -106,7 +107,7 @@ export function materializeNativeBindingTree(document, manifest, host) {
|
|
|
106
107
|
const node = createBindingNode(id, source.type, runtimeBindings, !0, source._classes, (value) => host.setAttribute(node, "class", value));
|
|
107
108
|
if (source.type === "Checkbox" && source.props.type === "checkbox")
|
|
108
109
|
node.tagName = "INPUT";
|
|
109
|
-
for (const [name, value] of Object.entries(source.props)) {
|
|
110
|
+
for (const [name, value] of Object.entries(authoredAccessibilityProps(source.props, source._accessibilitySource))) {
|
|
110
111
|
if (value === void 0 || value === null || name === "__stxId")
|
|
111
112
|
continue;
|
|
112
113
|
node.setAttribute(name, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LUCIDE_TO_SF } from "../compiler/icons.js";
|
|
2
|
-
const SYMBOL_TO_ICON = Object.fromEntries(Object.entries(LUCIDE_TO_SF).map(([name, symbol]) => [symbol, name])), SVG_NS = "http://www.w3.org/2000/svg", SVG = { Svg: "svg", G: "g", Path: "path", Line: "line", Rect: "rect", Circle: "circle", Ellipse: "ellipse", Polyline: "polyline", Polygon: "polygon", SvgText: "text" }, TAGS = { View: "div", SafeAreaView: "div", ScrollView: "div", KeyboardAvoidingView: "div", Text: "span", TextInput: "input", Button: "button", TouchableOpacity: "button", TouchableHighlight: "button", Pressable: "button", Icon: "span", Image: "img", ImageBackground: "div", Video: "video", FlatList: "div", SectionList: "div", Switch: "input", Checkbox: "input", Slider: "input", Picker: "select", DatePicker: "input", Modal: "dialog", ActivityIndicator: "progress", StatusBar: "div", RefreshControl: "progress", Sidebar: "aside", SplitView: "div" }, CONTAINERS = new Set(["View", "SafeAreaView", "ScrollView", "KeyboardAvoidingView", "FlatList", "SectionList", "Sidebar", "SplitView", "ImageBackground"]), UNITLESS = new Set(["opacity", "flex", "flexGrow", "flexShrink", "fontWeight", "zIndex", "aspectRatio", "order"]), SVG_PROPS = { viewBox: "viewBox", fillRule: "fill-rule", clipRule: "clip-rule", strokeWidth: "stroke-width", strokeLinecap: "stroke-linecap", strokeLinejoin: "stroke-linejoin", strokeDasharray: "stroke-dasharray", strokeDashoffset: "stroke-dashoffset", fillOpacity: "fill-opacity", strokeOpacity: "stroke-opacity", textAnchor: "text-anchor" };
|
|
2
|
+
const SYMBOL_TO_ICON = Object.fromEntries(Object.entries(LUCIDE_TO_SF).map(([name, symbol]) => [symbol, name])), SVG_NS = "http://www.w3.org/2000/svg", SVG = { Svg: "svg", G: "g", Path: "path", Line: "line", Rect: "rect", Circle: "circle", Ellipse: "ellipse", Polyline: "polyline", Polygon: "polygon", SvgText: "text" }, TAGS = { View: "div", SafeAreaView: "div", ScrollView: "div", KeyboardAvoidingView: "div", Text: "span", TextInput: "input", Button: "button", Link: "a", TouchableOpacity: "button", TouchableHighlight: "button", Pressable: "button", Icon: "span", Image: "img", ImageBackground: "div", Video: "video", FlatList: "div", SectionList: "div", Switch: "input", Checkbox: "input", Slider: "input", Picker: "select", DatePicker: "input", Modal: "dialog", ActivityIndicator: "progress", StatusBar: "div", RefreshControl: "progress", Sidebar: "aside", SplitView: "div" }, CONTAINERS = new Set(["View", "SafeAreaView", "ScrollView", "KeyboardAvoidingView", "FlatList", "SectionList", "Sidebar", "SplitView", "ImageBackground"]), UNITLESS = new Set(["opacity", "flex", "flexGrow", "flexShrink", "fontWeight", "zIndex", "aspectRatio", "order"]), SVG_PROPS = { viewBox: "viewBox", fillRule: "fill-rule", clipRule: "clip-rule", strokeWidth: "stroke-width", strokeLinecap: "stroke-linecap", strokeLinejoin: "stroke-linejoin", strokeDasharray: "stroke-dasharray", strokeDashoffset: "stroke-dashoffset", fillOpacity: "fill-opacity", strokeOpacity: "stroke-opacity", textAnchor: "text-anchor" };
|
|
3
3
|
|
|
4
4
|
export class BrowserScreenRenderer {
|
|
5
5
|
container;
|
|
@@ -30,6 +30,7 @@ export class BrowserScreenRenderer {
|
|
|
30
30
|
throw Error("A portable screen node needs an id");
|
|
31
31
|
const record = this.create(node.id, node.type, node.props, { ...node.style }, node.events);
|
|
32
32
|
record.parent = parent;
|
|
33
|
+
this.syncLayoutObserver(record);
|
|
33
34
|
for (const child of node.children)
|
|
34
35
|
if (typeof child === "string") {
|
|
35
36
|
record.text = (record.text ?? "") + child;
|
|
@@ -77,6 +78,7 @@ export class BrowserScreenRenderer {
|
|
|
77
78
|
}
|
|
78
79
|
parent.children.splice(operation.index, 0, operation.childId);
|
|
79
80
|
child.parent = operation.parentId;
|
|
81
|
+
this.syncLayoutObserver(child);
|
|
80
82
|
const before = parent.children[operation.index + 1];
|
|
81
83
|
parent.element.insertBefore(child.element, before ? this.nodes.get(before).element : null);
|
|
82
84
|
}
|
|
@@ -170,8 +172,11 @@ export class BrowserScreenRenderer {
|
|
|
170
172
|
record.dispose.push(() => element.removeEventListener(name, listener));
|
|
171
173
|
};
|
|
172
174
|
listen("click", (event) => {
|
|
173
|
-
if (this.disabled(record) || record.props.editable === !1)
|
|
175
|
+
if (this.disabled(record) || record.props.editable === !1) {
|
|
176
|
+
if (this.disabled(record) && element.tagName.toLowerCase() === "a")
|
|
177
|
+
event.preventDefault();
|
|
174
178
|
return;
|
|
179
|
+
}
|
|
175
180
|
if (event.target?.closest("[data-stx-pressable]") !== element && element.hasAttribute("data-stx-pressable"))
|
|
176
181
|
return;
|
|
177
182
|
this.fire(record, "onPress");
|
|
@@ -266,7 +271,7 @@ export class BrowserScreenRenderer {
|
|
|
266
271
|
css.minWidth = "0";
|
|
267
272
|
css.overflowWrap = "anywhere";
|
|
268
273
|
}
|
|
269
|
-
if (["Button", "TouchableOpacity", "TouchableHighlight", "Pressable"].includes(type)) {
|
|
274
|
+
if (["Button", "Link", "TouchableOpacity", "TouchableHighlight", "Pressable"].includes(type)) {
|
|
270
275
|
css.display = "flex";
|
|
271
276
|
css.flexDirection = "column";
|
|
272
277
|
css.alignItems = "stretch";
|
|
@@ -315,6 +320,10 @@ export class BrowserScreenRenderer {
|
|
|
315
320
|
this.style(css, style);
|
|
316
321
|
if (props.contentContainerStyle && typeof props.contentContainerStyle === "object")
|
|
317
322
|
this.style(css, props.contentContainerStyle);
|
|
323
|
+
if (type === "SafeAreaView") {
|
|
324
|
+
const authored = { ...style, ...props.contentContainerStyle && typeof props.contentContainerStyle === "object" ? props.contentContainerStyle : {} };
|
|
325
|
+
this.applySafeAreaPadding(css, props.edges, authored);
|
|
326
|
+
}
|
|
318
327
|
if (props.testID != null)
|
|
319
328
|
element.setAttribute("data-testid", String(props.testID));
|
|
320
329
|
if (props.accessibilityLabel != null || type === "TextInput" && props.placeholder)
|
|
@@ -325,6 +334,13 @@ export class BrowserScreenRenderer {
|
|
|
325
334
|
element.setAttribute("aria-description", String(props.accessibilityHint));
|
|
326
335
|
else
|
|
327
336
|
element.removeAttribute("aria-description");
|
|
337
|
+
if (type === "Link") {
|
|
338
|
+
const destination = ["href", "to"].map((name) => props[name]).find((value) => typeof value === "string" && value.trim() !== "");
|
|
339
|
+
if (destination)
|
|
340
|
+
element.setAttribute("href", String(destination));
|
|
341
|
+
else
|
|
342
|
+
element.removeAttribute("href");
|
|
343
|
+
}
|
|
328
344
|
const accessibilityState = props.accessibilityState;
|
|
329
345
|
for (const key of ["selected", "checked", "disabled", "busy", "expanded"]) {
|
|
330
346
|
const value = key === "disabled" && (props.disabled != null || accessibilityState?.disabled != null) ? this.disabled(record) : accessibilityState?.[key];
|
|
@@ -338,7 +354,7 @@ export class BrowserScreenRenderer {
|
|
|
338
354
|
element.setAttribute("role", String(role === "header" ? "heading" : role));
|
|
339
355
|
else
|
|
340
356
|
element.removeAttribute("role");
|
|
341
|
-
if (record.events.onPress || ["Button", "TouchableOpacity", "TouchableHighlight", "Pressable"].includes(type)) {
|
|
357
|
+
if (record.events.onPress || ["Button", "Link", "TouchableOpacity", "TouchableHighlight", "Pressable"].includes(type)) {
|
|
342
358
|
element.setAttribute("data-stx-pressable", "");
|
|
343
359
|
if (!["input", "button", "select", "textarea", "a"].includes(element.tagName.toLowerCase())) {
|
|
344
360
|
element.setAttribute("role", String(role || "button"));
|
|
@@ -505,6 +521,49 @@ export class BrowserScreenRenderer {
|
|
|
505
521
|
});
|
|
506
522
|
}
|
|
507
523
|
}
|
|
524
|
+
this.syncLayoutObserver(record);
|
|
525
|
+
}
|
|
526
|
+
syncLayoutObserver(record) {
|
|
527
|
+
if (!Boolean(record.events.onLayout)) {
|
|
528
|
+
record.layoutObserver?.disconnect();
|
|
529
|
+
record.layoutObserver = void 0;
|
|
530
|
+
record.layoutObservedParent = void 0;
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const parent = record.parent ? this.nodes.get(record.parent)?.element : this.container;
|
|
534
|
+
if (record.layoutObserver && record.layoutObservedParent === parent)
|
|
535
|
+
return;
|
|
536
|
+
record.layoutObserver?.disconnect();
|
|
537
|
+
record.layoutObserver = void 0;
|
|
538
|
+
record.layoutObservedParent = void 0;
|
|
539
|
+
const ResizeObserverConstructor = record.element.ownerDocument.defaultView?.ResizeObserver;
|
|
540
|
+
if (!ResizeObserverConstructor)
|
|
541
|
+
return;
|
|
542
|
+
const observer = new ResizeObserverConstructor(() => {
|
|
543
|
+
if (!this.nodes.has(record.element.getAttribute("data-stx-node") ?? "") || !record.events.onLayout)
|
|
544
|
+
return;
|
|
545
|
+
const rect = record.element.getBoundingClientRect(), parentRect = (record.parent ? this.nodes.get(record.parent)?.element : this.container)?.getBoundingClientRect();
|
|
546
|
+
this.fire(record, "onLayout", {
|
|
547
|
+
layout: {
|
|
548
|
+
x: rect.left - (parentRect?.left ?? 0),
|
|
549
|
+
y: rect.top - (parentRect?.top ?? 0),
|
|
550
|
+
width: rect.width,
|
|
551
|
+
height: rect.height
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
observer.observe(record.element);
|
|
556
|
+
if (parent && parent !== record.element)
|
|
557
|
+
observer.observe(parent);
|
|
558
|
+
record.layoutObserver = observer;
|
|
559
|
+
record.layoutObservedParent = parent;
|
|
560
|
+
}
|
|
561
|
+
applySafeAreaPadding(css, rawEdges, authored) {
|
|
562
|
+
const valid = new Set(["top", "right", "bottom", "left"]), edges = Array.isArray(rawEdges) ? new Set(rawEdges.filter((edge) => typeof edge === "string" && valid.has(edge))) : valid, length = (value) => value == null ? void 0 : typeof value === "number" ? `${value}px` : String(value), shorthand = length(authored.padding)?.trim().split(/\s+/).filter(Boolean) ?? [], shorthandValues = shorthand.length === 1 ? [shorthand[0], shorthand[0], shorthand[0], shorthand[0]] : shorthand.length === 2 ? [shorthand[0], shorthand[1], shorthand[0], shorthand[1]] : shorthand.length === 3 ? [shorthand[0], shorthand[1], shorthand[2], shorthand[1]] : shorthand.length >= 4 ? shorthand.slice(0, 4) : [], shorthandByEdge = { top: shorthandValues[0], right: shorthandValues[1], bottom: shorthandValues[2], left: shorthandValues[3] };
|
|
563
|
+
for (const edge of valid) {
|
|
564
|
+
const property = `padding${edge[0].toUpperCase()}${edge.slice(1)}`, axis = edge === "top" || edge === "bottom" ? authored.paddingVertical : authored.paddingHorizontal, authoredValue = length(authored[property]) ?? length(axis) ?? shorthandByEdge[edge] ?? (css[property] || "0px");
|
|
565
|
+
css[property] = edges.has(edge) ? `calc(env(safe-area-inset-${edge}, 0px) + ${authoredValue})` : authoredValue;
|
|
566
|
+
}
|
|
508
567
|
}
|
|
509
568
|
icon(props) {
|
|
510
569
|
const name = String(props.iconify ?? props.name ?? props.symbol ?? ""), find = (key) => this.options.icons?.[SYMBOL_TO_ICON[key]] ?? this.options.icons?.[key] ?? this.options.icons?.[key.replace(/^i-lucide-/, "")], icon = find(name) ?? this.options.icons?.[String(props.symbol)] ?? (name.endsWith(".fill") ? find(name.slice(0, -5)) : void 0);
|
|
@@ -47,7 +47,7 @@ function capabilityFlags(capabilities) {
|
|
|
47
47
|
network: !1,
|
|
48
48
|
deviceInfo: capabilities.has("device"),
|
|
49
49
|
fetch: capabilities.has("fetch"),
|
|
50
|
-
badge:
|
|
50
|
+
badge: capabilities.has("badge"),
|
|
51
51
|
appReview: !1,
|
|
52
52
|
health: capabilities.has("health"),
|
|
53
53
|
dialogs: capabilities.has("dialog"),
|
|
@@ -57,7 +57,8 @@ function capabilityFlags(capabilities) {
|
|
|
57
57
|
crashReporter: capabilities.has("crashReporter"),
|
|
58
58
|
animation: capabilities.has("animation"),
|
|
59
59
|
viewFocus: capabilities.has("viewFocus"),
|
|
60
|
-
viewMeasure: capabilities.has("viewMeasure")
|
|
60
|
+
viewMeasure: capabilities.has("viewMeasure"),
|
|
61
|
+
viewNonModalPresentation: capabilities.has("viewNonModalPresentation")
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
function platformUserAgent(platform) {
|
|
@@ -228,6 +229,11 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
228
229
|
cancelAll: () => request("Notifications", "cancelAll", []),
|
|
229
230
|
pending: () => request("Notifications", "pending", [])
|
|
230
231
|
};
|
|
232
|
+
if (capabilities.has("badge"))
|
|
233
|
+
craft.badge = {
|
|
234
|
+
set: (count) => request("Badge", "set", [count]),
|
|
235
|
+
clear: () => request("Badge", "clear", [])
|
|
236
|
+
};
|
|
231
237
|
if (capabilities.has("dialog"))
|
|
232
238
|
craft.dialog = {
|
|
233
239
|
alert: (options = {}) => ask("Dialog", "alert", [options]).then(() => {
|
|
@@ -257,6 +257,10 @@ export declare interface NativeCraft {
|
|
|
257
257
|
cancelAll: () => Promise<unknown>
|
|
258
258
|
pending: () => Promise<unknown[]>
|
|
259
259
|
}
|
|
260
|
+
badge?: {
|
|
261
|
+
set: (count: number) => Promise<unknown>
|
|
262
|
+
clear: () => Promise<unknown>
|
|
263
|
+
}
|
|
260
264
|
lifecycle: {
|
|
261
265
|
getState: () => 'active' | 'inactive' | 'background'
|
|
262
266
|
onStateChange: (callback: (state: string) => unknown) => () => void
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { accessibilityChanges, authoredAccessibilityProps, projectAccessibility } from "../accessibility.js";
|
|
1
2
|
import { compileClassStyles } from "../compiler/headwind-to-style.js";
|
|
2
3
|
import { resolveIconName } from "../compiler/icons.js";
|
|
3
|
-
import { parseNativeStyleLayers } from "../compiler/inline-style.js";
|
|
4
|
+
import { applyNativeLayoutDefaults, parseNativeStyleLayers } from "../compiler/inline-style.js";
|
|
4
5
|
import { createStyleVariables } from "../compiler/style-variables.js";
|
|
5
6
|
import { affectsGeometry, parseSvgMarkup, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
|
|
6
7
|
import { NATIVE_EVENT_NAMES } from "../event-names.js";
|
|
7
|
-
import { accessibilityPatch, isAccessibilityAttribute } from "../accessibility.js";
|
|
8
8
|
import { nativePropName } from "../prop-names.js";
|
|
9
9
|
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
10
10
|
import { NATIVE_FORM_ENTRIES } from "./jsc-globals.js";
|
|
11
11
|
import { createNativeOverlayPresenter } from "./overlay-presenter.js";
|
|
12
12
|
import { nativeViewError } from "./view-operations.js";
|
|
13
|
+
function isHiddenInput(record) {
|
|
14
|
+
return record.type === "View" && record.props.type === "hidden";
|
|
15
|
+
}
|
|
13
16
|
function irDisplay(value) {
|
|
14
17
|
return value === "none" || value === "grid" || value === "flex" ? value : "flex";
|
|
15
18
|
}
|
|
@@ -256,7 +259,7 @@ export function createNativeHost(options) {
|
|
|
256
259
|
node: {
|
|
257
260
|
type: record.type,
|
|
258
261
|
...record.key === void 0 ? {} : { key: record.key },
|
|
259
|
-
props: { ...record.props },
|
|
262
|
+
props: { ...record.props, ...projectAccessibility(record.props) },
|
|
260
263
|
style: { ...record.style },
|
|
261
264
|
...Object.keys(record.events).length ? { events: { ...record.events } } : {},
|
|
262
265
|
...record.text === void 0 ? {} : { children: [record.text] }
|
|
@@ -280,7 +283,7 @@ export function createNativeHost(options) {
|
|
|
280
283
|
const resolved = parseNativeStyleLayers([record.styleSource, record.boundStyle, record.forwardedStyle], inherited, report);
|
|
281
284
|
record.variables = resolved.variables;
|
|
282
285
|
const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables);
|
|
283
|
-
return { ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...resolved.styles[0], ...record.baseStyle, ...resolved.styles[1], ...resolved.styles[2], ...record.visible ? {} : { display: "none" } };
|
|
286
|
+
return { ...applyNativeLayoutDefaults({ ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...resolved.styles[0], ...record.baseStyle, ...resolved.styles[1], ...resolved.styles[2] }), ...record.visible && !isHiddenInput(record) ? {} : { display: "none" } };
|
|
284
287
|
}
|
|
285
288
|
function refreshStyleTree(node, inherited = node.__stxOwner ? descriptorOf(node.__stxOwner)?.variables : stylesheetVariables, appearanceChanged = !1) {
|
|
286
289
|
if (node.__stxAnchor !== void 0)
|
|
@@ -298,6 +301,8 @@ export function createNativeHost(options) {
|
|
|
298
301
|
if (!isBindingNode(node) || !(node.getAttribute("data-stx-native-forward") ?? "").split(/\s+/).includes(name))
|
|
299
302
|
return;
|
|
300
303
|
const find = (candidate) => {
|
|
304
|
+
if (candidate !== node && isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-owner"))
|
|
305
|
+
return;
|
|
301
306
|
if (isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-root"))
|
|
302
307
|
return candidate;
|
|
303
308
|
for (const child of recordOf(candidate).children) {
|
|
@@ -452,7 +457,7 @@ export function createNativeHost(options) {
|
|
|
452
457
|
const classes = descriptor?._classes ?? "", classStyle = compileClassStyles(classes).style, baseStyle = descriptor?._styleSource !== void 0 ? {} : descriptor?._inlineStyle ? { ...descriptor._inlineStyle } : Object.fromEntries(Object.entries(descriptor?.style ?? {}).filter(([key, value]) => classStyle[key] !== value)), record = {
|
|
453
458
|
type,
|
|
454
459
|
key: descriptor?.key,
|
|
455
|
-
props:
|
|
460
|
+
props: authoredAccessibilityProps(descriptor?.props ?? {}, descriptor?._accessibilitySource),
|
|
456
461
|
style: { ...descriptor?.style ?? {} },
|
|
457
462
|
baseStyle,
|
|
458
463
|
styleSource: descriptor?._styleSource,
|
|
@@ -483,6 +488,7 @@ export function createNativeHost(options) {
|
|
|
483
488
|
}
|
|
484
489
|
const overlayPresenter = createNativeOverlayPresenter({
|
|
485
490
|
canFocus: options.views?.capabilities.focus === !0,
|
|
491
|
+
canPresentNonModal: options.views?.capabilities.nonModalPresentation === !0,
|
|
486
492
|
focus: (node, focusOptions) => host.focus(node, focusOptions),
|
|
487
493
|
descendants: collectDescendants,
|
|
488
494
|
hasAutofocus: (node) => {
|
|
@@ -570,7 +576,7 @@ export function createNativeHost(options) {
|
|
|
570
576
|
return {
|
|
571
577
|
id: node.__stxId,
|
|
572
578
|
type: record.type,
|
|
573
|
-
props: { ...record.props },
|
|
579
|
+
props: { ...record.props, ...projectAccessibility(record.props) },
|
|
574
580
|
style: { ...record.style },
|
|
575
581
|
events: { ...record.events },
|
|
576
582
|
children: record.text === void 0 ? children : [record.text]
|
|
@@ -620,7 +626,7 @@ export function createNativeHost(options) {
|
|
|
620
626
|
applyClasses(node.__stxId, record);
|
|
621
627
|
return;
|
|
622
628
|
}
|
|
623
|
-
const prop = nativePropName(name), record = recordOf(node);
|
|
629
|
+
const prop = nativePropName(name), record = recordOf(node), accessibilityBefore = prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") ? projectAccessibility(record.props) : void 0;
|
|
624
630
|
record.props[prop] = value;
|
|
625
631
|
if (record.type === "Icon" && prop === "name") {
|
|
626
632
|
const icon = resolveIconName(String(value ?? ""));
|
|
@@ -628,8 +634,8 @@ export function createNativeHost(options) {
|
|
|
628
634
|
this.setAttribute(node, "symbol", icon.symbol);
|
|
629
635
|
}
|
|
630
636
|
const patch = { [prop]: value };
|
|
631
|
-
if (
|
|
632
|
-
Object.assign(patch,
|
|
637
|
+
if (accessibilityBefore)
|
|
638
|
+
Object.assign(patch, accessibilityChanges(record.props, accessibilityBefore, prop));
|
|
633
639
|
if (SVG_NODE_TYPES.has(record.type)) {
|
|
634
640
|
if (prop === "strokeDasharray" && value != null && !Array.isArray(value))
|
|
635
641
|
patch[prop] = record.props[prop] = String(value).split(/[\s,]+/).map(Number).filter(Number.isFinite);
|
|
@@ -654,11 +660,11 @@ export function createNativeHost(options) {
|
|
|
654
660
|
this.setAttribute(node, name, "");
|
|
655
661
|
return;
|
|
656
662
|
}
|
|
657
|
-
const prop = nativePropName(name), record = recordOf(node);
|
|
663
|
+
const prop = nativePropName(name), record = recordOf(node), accessibilityBefore = prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") ? projectAccessibility(record.props) : void 0;
|
|
658
664
|
delete record.props[prop];
|
|
659
665
|
const patch = { [prop]: null };
|
|
660
|
-
if (
|
|
661
|
-
Object.assign(patch,
|
|
666
|
+
if (accessibilityBefore)
|
|
667
|
+
Object.assign(patch, accessibilityChanges(record.props, accessibilityBefore, prop));
|
|
662
668
|
if (affectsGeometry(record.type, prop))
|
|
663
669
|
patch.geometry = record.props.geometry = svgGeometry(record.type, record.props);
|
|
664
670
|
if (record.materialized)
|
|
@@ -693,7 +699,7 @@ export function createNativeHost(options) {
|
|
|
693
699
|
}
|
|
694
700
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
695
701
|
return;
|
|
696
|
-
const style = value;
|
|
702
|
+
const style = { ...value, ...isHiddenInput(record) ? { display: "none" } : {} };
|
|
697
703
|
Object.assign(record.baseStyle, style);
|
|
698
704
|
Object.assign(record.style, style);
|
|
699
705
|
if (record.materialized)
|
|
@@ -763,7 +769,7 @@ export function createNativeHost(options) {
|
|
|
763
769
|
const data = payload && typeof payload === "object" ? payload : {}, value = data.text ?? data.value ?? data.nativeEvent?.text ?? data.nativeEvent?.value, record = recordOf(node);
|
|
764
770
|
if (record.type === "Checkbox" && value !== void 0)
|
|
765
771
|
node.checked = Boolean(value);
|
|
766
|
-
if (value !== void 0 && !Object.is(record.props.value, value) && (record.type === "TextInput" || record.type === "Picker")) {
|
|
772
|
+
if (value !== void 0 && !Object.is(record.props.value, value) && (record.type === "TextInput" || record.type === "Picker" || record.type === "Switch")) {
|
|
767
773
|
record.props.value = value;
|
|
768
774
|
if (record.materialized)
|
|
769
775
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
|
|
@@ -9,10 +9,12 @@ export declare interface NativeOverlayEntry {
|
|
|
9
9
|
zIndex?: number | null
|
|
10
10
|
panel?: FocusTarget
|
|
11
11
|
initialFocus?: FocusTarget
|
|
12
|
+
onBackdrop?: (() => void) | null
|
|
12
13
|
onRequestClose?: ((event?: unknown) => void) | null
|
|
13
14
|
}
|
|
14
15
|
declare interface OverlayHost {
|
|
15
16
|
canFocus: boolean
|
|
17
|
+
canPresentNonModal: boolean
|
|
16
18
|
focus: (node: NativeNode, options: NativeFocusOptions) => Promise<true>
|
|
17
19
|
descendants: (node: NativeNode) => NativeNode[]
|
|
18
20
|
hasAutofocus: (node: NativeNode) => boolean
|
|
@@ -27,9 +27,12 @@ export function createNativeOverlayPresenter(host) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function sync(entries) {
|
|
30
|
-
for (const entry of entries)
|
|
31
|
-
if (!entry.
|
|
32
|
-
throw Error(`[stx:overlays] Native
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
if (!entry.modal && !host.canPresentNonModal)
|
|
32
|
+
throw Error(`[stx:overlays] Native popup "${entry.id}" requires the viewNonModalPresentation host positioning capability.`);
|
|
33
|
+
if (!entry.root || host.type(entry.root) !== "Modal")
|
|
34
|
+
throw Error(`[stx:overlays] Native overlay "${entry.id}" requires a Modal root (data-native="Modal") for host-owned presentation.`);
|
|
35
|
+
}
|
|
33
36
|
const previous = current;
|
|
34
37
|
current = entries.slice();
|
|
35
38
|
for (const entry of previous)
|
|
@@ -50,14 +53,16 @@ export function createNativeOverlayPresenter(host) {
|
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
55
|
}
|
|
56
|
+
host.setAttribute(root, "nonModal", !entry.modal);
|
|
57
|
+
host.setAttribute(root, "dismissOnOutsideTap", !entry.modal && !!entry.onBackdrop);
|
|
53
58
|
host.setAttribute(root, "visible", !0);
|
|
54
59
|
host.setStyle(root, { zIndex: (entry.zIndex ?? 1000) + index });
|
|
55
60
|
}
|
|
56
61
|
const top = current.at(-1);
|
|
57
|
-
if (top?.root !== previous.at(-1)?.root) {
|
|
62
|
+
if (top?.root !== previous.at(-1)?.root || top?.modal !== previous.at(-1)?.modal) {
|
|
58
63
|
focusing?.abort();
|
|
59
64
|
focusing = null;
|
|
60
|
-
if (top && !previous.some((entry) => entry.root === top.root))
|
|
65
|
+
if (top?.modal && !previous.some((entry) => entry.root === top.root && entry.modal))
|
|
61
66
|
focusInitial(top);
|
|
62
67
|
}
|
|
63
68
|
}
|
|
@@ -14,7 +14,7 @@ export declare interface NativeViewBounds {
|
|
|
14
14
|
coordinateSpace: 'screenViewport'
|
|
15
15
|
}
|
|
16
16
|
export declare interface NativeViewOperations {
|
|
17
|
-
readonly capabilities: { focus: boolean, measure: boolean }
|
|
17
|
+
readonly capabilities: { focus: boolean, measure: boolean, nonModalPresentation: boolean }
|
|
18
18
|
focus: (nodeId: string, options?: NativeFocusOptions) => Promise<true>
|
|
19
19
|
measure: (nodeId: string) => Promise<NativeViewBounds>
|
|
20
20
|
}
|
|
@@ -9,7 +9,11 @@ export function createNativeViewOperations(protocol, capabilities, beforeRequest
|
|
|
9
9
|
beforeRequest();
|
|
10
10
|
}
|
|
11
11
|
return {
|
|
12
|
-
capabilities: {
|
|
12
|
+
capabilities: {
|
|
13
|
+
focus: supported.has("viewFocus"),
|
|
14
|
+
measure: supported.has("viewMeasure"),
|
|
15
|
+
nonModalPresentation: supported.has("viewNonModalPresentation")
|
|
16
|
+
},
|
|
13
17
|
async focus(nodeId, options = {}) {
|
|
14
18
|
if (options.signal?.aborted)
|
|
15
19
|
throw nativeViewError("CANCELLED", "Native focus was cancelled");
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
2
|
+
import{er,Ve,ri,uc}from"./chunk-tbsjg23k.js";import{Qn,os,ac,cc,lc}from"./chunk-81qmj3sd.js";import{ei,ti,ni,oc,ic}from"./chunk-tydv84gj.js";import{le,kt,is}from"./chunk-dmdhbwmn.js";import{pl,fl,gl,ml,Ar,Nd}from"./chunk-5s47qfp6.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-pghtgep5.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=
|
|
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=le(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=er(n,t);if(a){let s=Ve(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 os(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,ti as auditBuildOutput,ei as auditConfig,re as buildPwaAssets,ni as calculateAuditResult,ic as formatAuditResult,is as formatSize,j as generateManifest,_ as generateManifestJson,cc as generateManifestLink,F as generateOfflinePage,le as generatePrecacheManifest,kt as generatePrecacheManifestJs,M as generatePwaIcons,Qn as generatePwaTags,er as generateServiceWorker,uc as generateServiceWorkerAuto,ac as generateSwRegistrationScript,lc as generateThemeColorMeta,N as getExpectedIconPaths,Ve as getServiceWorkerFileName,os as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ri as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ar as pwaDirectives,pl as pwaInstallDirective,gl as pwaOfflineDirective,ml as pwaPushDirective,fl as pwaUpdateDirective,Nd as registerPwaDirectives,oc as runPwaAudit,D as validateManifest};
|
package/dist/server-bindings.js
CHANGED
|
@@ -87,7 +87,10 @@ export function processServerBindings(template, context) {
|
|
|
87
87
|
while ((match = scriptStyleRegex.exec(template)) !== null)
|
|
88
88
|
protectedRanges.push([match.index, match.index + match[0].length]);
|
|
89
89
|
protectedRanges.push(...reactiveLoopRanges(template));
|
|
90
|
-
const
|
|
90
|
+
const clientOwnedNames = new Set([
|
|
91
|
+
...inheritedClientLoopNames(context),
|
|
92
|
+
...Array.isArray(context.__stx_client_declared_names) ? context.__stx_client_declared_names : []
|
|
93
|
+
]);
|
|
91
94
|
function isProtected(pos) {
|
|
92
95
|
return protectedRanges.some(([start, end]) => pos >= start && pos < end);
|
|
93
96
|
}
|
|
@@ -104,7 +107,7 @@ export function processServerBindings(template, context) {
|
|
|
104
107
|
const attrName = attrMatch[1], expression = attrMatch[2];
|
|
105
108
|
if (isRuntimeOwnedColonAttr(attrName))
|
|
106
109
|
continue;
|
|
107
|
-
if (readsAnyName(expression,
|
|
110
|
+
if (readsAnyName(expression, clientOwnedNames))
|
|
108
111
|
continue;
|
|
109
112
|
if (expression.includes("()") && !expression.includes(".get(") || expression.includes("$store") || expression.includes("$ref"))
|
|
110
113
|
continue;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function collectSlotScopes(source) {
|
|
2
|
+
if (!source.includes("#") && !source.includes("v-slot:"))
|
|
3
|
+
return [];
|
|
4
|
+
const scopes = [], stack = [], tags = /<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;
|
|
5
|
+
for (const match of source.matchAll(tags)) {
|
|
6
|
+
const tag = match[0];
|
|
7
|
+
if (/^<\/template\s*>$/i.test(tag)) {
|
|
8
|
+
const scope = stack.pop();
|
|
9
|
+
if (scope)
|
|
10
|
+
scope.end = match.index;
|
|
11
|
+
} else if (/^<template\b/i.test(tag) && !/\/\s*>$/.test(tag)) {
|
|
12
|
+
const binding = [...tag.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((attr) => /^(?:#[\w-]+|v-slot:[\w-]+)$/i.test(attr[1])), value = (binding?.[2] ?? binding?.[3])?.trim(), scope = value ? { start: match.index + tag.length, end: source.length, binding: value } : void 0;
|
|
13
|
+
stack.push(scope);
|
|
14
|
+
if (scope)
|
|
15
|
+
scopes.push(scope);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return scopes;
|
|
19
|
+
}
|
package/dist/slots.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { escapeHtml } from "./expressions.js";
|
|
2
2
|
import { isExpressionSafe, createSafeFunction } from "./safe-evaluator.js";
|
|
3
|
+
import { readsAnyName } from "./loop-binding.js";
|
|
3
4
|
function findMatchingTemplateClose(content, startIndex) {
|
|
4
5
|
let depth = 1, i = startIndex;
|
|
5
6
|
const openTag = "<template", closeTag = "</template";
|
|
@@ -251,24 +252,39 @@ export async function renderSlot(slotDef, slotProps, defaultContent, context) {
|
|
|
251
252
|
return defaultContent;
|
|
252
253
|
let content = slotDef.content;
|
|
253
254
|
if (slotDef.propsBinding && Object.keys(slotProps).length > 0) {
|
|
254
|
-
const binding = slotDef.propsBinding.trim(), slotContext = { ...context };
|
|
255
|
+
const binding = slotDef.propsBinding.trim(), slotContext = { ...context }, unresolved = new Set, resolved = new Set;
|
|
255
256
|
if (binding.startsWith("{") && binding.endsWith("}")) {
|
|
256
257
|
const propNames = binding.slice(1, -1).split(",").map((p) => p.trim()).filter(Boolean);
|
|
257
258
|
for (const propName of propNames) {
|
|
258
259
|
const [key, alias] = propName.split(":").map((s) => s.trim()), actualKey = alias || key;
|
|
260
|
+
slotContext[actualKey] = slotProps[key];
|
|
259
261
|
if (slotProps[key] !== void 0)
|
|
260
|
-
|
|
262
|
+
resolved.add(actualKey);
|
|
263
|
+
else
|
|
264
|
+
unresolved.add(actualKey);
|
|
261
265
|
}
|
|
262
|
-
} else
|
|
266
|
+
} else {
|
|
263
267
|
slotContext[binding] = slotProps;
|
|
264
|
-
|
|
268
|
+
if (Object.values(slotProps).some((value) => value === void 0))
|
|
269
|
+
unresolved.add(binding);
|
|
270
|
+
else
|
|
271
|
+
resolved.add(binding);
|
|
272
|
+
}
|
|
273
|
+
content = processSlotExpressions(content, slotContext, unresolved, resolved);
|
|
265
274
|
}
|
|
266
275
|
return content;
|
|
267
276
|
}
|
|
268
|
-
function processSlotExpressions(content, context) {
|
|
269
|
-
return content.replace(/\{\{\s*([^}]+)\s*\}\}/g, (
|
|
277
|
+
function processSlotExpressions(content, context, unresolved, resolved) {
|
|
278
|
+
return content.replace(/\{\{\s*([^}]+)\s*\}\}/g, (match, expr) => {
|
|
270
279
|
try {
|
|
271
|
-
const trimmedExpr = expr.trim()
|
|
280
|
+
const trimmedExpr = expr.trim();
|
|
281
|
+
if (readsAnyName(trimmedExpr, unresolved))
|
|
282
|
+
return match;
|
|
283
|
+
if (Array.isArray(context.__stx_preserved_client_expressions) && context.__stx_preserved_client_expressions.includes(trimmedExpr) && !readsAnyName(trimmedExpr, resolved))
|
|
284
|
+
return match;
|
|
285
|
+
const result = evaluateSimpleExpression(trimmedExpr, context);
|
|
286
|
+
if (result === void 0)
|
|
287
|
+
return match;
|
|
272
288
|
return escapeHtml(String(result ?? ""));
|
|
273
289
|
} catch {
|
|
274
290
|
return `{{ ${expr} }}`;
|