@stacksjs/stx 0.2.604 → 0.2.606
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-0d6b3eeb.js +2 -0
- package/dist/{chunk-9cgga2aw.js → chunk-0v89nfz1.js} +2 -2
- package/dist/chunk-1e28n9q2.js +2 -0
- package/dist/chunk-1fdrhfc0.js +2 -0
- package/dist/{chunk-htcptqtn.js → chunk-1jxdkp8x.js} +6 -6
- package/dist/chunk-1veeefpn.js +2 -0
- package/dist/{chunk-6eg9a3mt.js → chunk-20k77e2a.js} +4 -4
- package/dist/chunk-2r4an7bh.js +2 -0
- package/dist/chunk-304vaxnk.js +2 -0
- package/dist/chunk-327bt8zb.js +2 -0
- package/dist/chunk-36n8yz6t.js +2 -0
- package/dist/{chunk-jczknjbw.js → chunk-3cnwstra.js} +2 -2
- package/dist/chunk-3gm6013p.js +2 -0
- package/dist/chunk-3ttnn4t3.js +2 -0
- package/dist/chunk-3yttgk0s.js +2 -0
- package/dist/chunk-4ck2xc8m.js +2 -0
- package/dist/{chunk-rd7w0cx4.js → chunk-4dfqgmgs.js} +39 -39
- package/dist/chunk-4jasfhh6.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-67m2prah.js → chunk-5s47qfp6.js} +2 -2
- package/dist/{chunk-bn7fzfc2.js → chunk-5taenpfg.js} +1 -1
- package/dist/chunk-605c6zks.js +2 -0
- package/dist/chunk-61d0gr5b.js +2 -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-7renf4zp.js +2 -0
- package/dist/{chunk-9wtb959p.js → chunk-81qmj3sd.js} +7 -7
- package/dist/chunk-8t3c2myr.js +2 -0
- package/dist/chunk-8x2ejkcc.js +2 -0
- package/dist/chunk-915s0may.js +2 -0
- package/dist/chunk-93na8hh0.js +2 -0
- package/dist/{chunk-de3gknmn.js → chunk-9734nkc8.js} +3 -3
- package/dist/chunk-9fpnnfr3.js +2 -0
- package/dist/{chunk-ftr0fvw7.js → chunk-9zwdpa7p.js} +5 -5
- package/dist/chunk-ajd5w5c4.js +2 -0
- package/dist/{chunk-nfht2ryp.js → chunk-azpkje69.js} +8 -5
- package/dist/chunk-b4tbqz8r.js +2 -0
- package/dist/chunk-be2kmw0p.js +2 -0
- package/dist/{chunk-48s1nprc.js → chunk-bhf9yt2w.js} +2 -2
- package/dist/chunk-bkjre6xk.js +127 -0
- package/dist/chunk-bnpb6ez9.js +2 -0
- package/dist/{chunk-jtq8e3b0.js → chunk-bsy8v1xj.js} +2 -2
- package/dist/chunk-c0h9cxew.js +2 -0
- package/dist/{chunk-zrw1zf54.js → chunk-cfpenvc7.js} +3 -3
- package/dist/chunk-cw76y2p5.js +2 -0
- package/dist/chunk-d0kes50w.js +2 -0
- package/dist/{chunk-4st1qw62.js → chunk-dmdhbwmn.js} +3 -3
- package/dist/{chunk-t19th11m.js → chunk-dnqq1ze0.js} +3 -3
- package/dist/chunk-dzbkgsv8.js +4 -0
- package/dist/chunk-dzekcand.js +2 -0
- package/dist/{chunk-bfbmdjh4.js → chunk-efy3038a.js} +2 -2
- package/dist/chunk-en388k3h.js +2 -0
- package/dist/chunk-ewkza45r.js +2 -0
- package/dist/chunk-fcgf8d5k.js +2 -0
- package/dist/chunk-fese2cf6.js +2 -0
- package/dist/{chunk-79zfhk62.js → chunk-fwp1en28.js} +6 -6
- package/dist/{chunk-9x4r15mv.js → chunk-ghdyqt98.js} +2 -2
- package/dist/chunk-gk7mmc2e.js +2 -0
- package/dist/chunk-gw2dvp35.js +2 -0
- package/dist/chunk-h9drxwva.js +2 -0
- package/dist/chunk-hrr7k1qc.js +2 -0
- package/dist/{chunk-jb6zejnt.js → chunk-htf3z9et.js} +3 -3
- 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-k7spjpr0.js +2 -0
- package/dist/chunk-kgvm5ytn.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-mfery7a4.js +2 -0
- package/dist/chunk-mn7a5b55.js +3 -0
- package/dist/{chunk-vmsw9sdw.js → chunk-mtxs4fya.js} +2 -2
- 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-n882b1fy.js +2 -0
- package/dist/chunk-p8sv5fqs.js +2 -0
- package/dist/chunk-pndhb1nk.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-qygr4pv8.js +2 -0
- package/dist/{chunk-18ws9heh.js → chunk-r4h8fg1x.js} +1 -1
- package/dist/chunk-r4wqh5fd.js +2845 -0
- package/dist/{chunk-tnafnb23.js → chunk-r69jfs59.js} +1 -1
- package/dist/{chunk-xcyreehd.js → chunk-rg7wvcqw.js} +2 -2
- 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-kn2exbq7.js → chunk-s45envb5.js} +5 -5
- package/dist/{chunk-tds3d65g.js → chunk-s4pjf2pc.js} +2 -2
- package/dist/{chunk-b3c1gggs.js → chunk-sswjv8p9.js} +2 -2
- package/dist/{chunk-bsy10tz6.js → chunk-t9t66sz4.js} +6 -6
- package/dist/{chunk-pb7vste8.js → chunk-tbsjg23k.js} +4 -4
- 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-hvqjs9ps.js → chunk-tyb481p0.js} +1 -1
- package/dist/{chunk-a8n6mt7s.js → chunk-tydv84gj.js} +2 -2
- package/dist/{chunk-hsy9rhct.js → chunk-vehtypx0.js} +2 -2
- package/dist/{chunk-jmczvhpy.js → chunk-vhajhs44.js} +5 -5
- package/dist/{chunk-5c153w4j.js → chunk-vm2d4hap.js} +3 -3
- package/dist/{chunk-y3wdf7v7.js → chunk-vntpfbwy.js} +1 -1
- package/dist/{chunk-25zpd110.js → chunk-vp3fzjsc.js} +2 -2
- package/dist/{chunk-3xdfqn0d.js → chunk-vvfpb3k3.js} +5 -5
- package/dist/{chunk-q1cvef6b.js → chunk-vw62fjpv.js} +3 -3
- package/dist/{chunk-er5wxv0f.js → chunk-w67rrd1f.js} +10 -10
- 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-g6ew2drc.js → chunk-wy53pys4.js} +5 -5
- package/dist/{chunk-v8ze2q95.js → chunk-wzjf33es.js} +2 -2
- package/dist/{chunk-gh181dnr.js → chunk-x8q5przn.js} +10 -10
- package/dist/{chunk-vn6h03nq.js → chunk-xjxc4q3w.js} +27 -27
- package/dist/chunk-y2wr7c9e.js +2 -0
- package/dist/{chunk-kx52xt96.js → chunk-y54fz9rk.js} +2 -2
- package/dist/{chunk-788d9msn.js → chunk-y6gj9jq8.js} +6 -6
- package/dist/chunk-y8jjmwa9.js +2 -0
- package/dist/{chunk-xwatzxk5.js → chunk-y9a9cvke.js} +13 -13
- package/dist/{chunk-y0qjpcc8.js → chunk-yzj55rfs.js} +3 -3
- 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-zs3ezqy3.js +2 -0
- package/dist/{chunk-ydt4sd6m.js → chunk-zs3tmd12.js} +2 -2
- 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 +17 -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 +3 -1
- package/dist/native/compiler/render-screen.js +1 -1
- package/dist/native/components/primitives.d.ts +16 -14
- package/dist/native/components/primitives.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 +6 -0
- 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/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-00vp75pj.js +0 -2
- package/dist/chunk-04gt67sv.js +0 -2
- package/dist/chunk-08p1kxsj.js +0 -2
- package/dist/chunk-0hpw65yr.js +0 -2
- package/dist/chunk-0rekvsy4.js +0 -2
- package/dist/chunk-122y2fkw.js +0 -3
- package/dist/chunk-138zjhwa.js +0 -2
- package/dist/chunk-1sbj8yqe.js +0 -2
- package/dist/chunk-2c7ysn9s.js +0 -2
- package/dist/chunk-2qt63502.js +0 -2
- package/dist/chunk-2wb1w0p6.js +0 -2
- package/dist/chunk-38mt99p3.js +0 -2
- package/dist/chunk-3q312svf.js +0 -2
- package/dist/chunk-6djvj6hg.js +0 -2
- package/dist/chunk-6vncjspv.js +0 -2
- package/dist/chunk-7dkwf9h5.js +0 -2
- package/dist/chunk-7ejmya3v.js +0 -2
- package/dist/chunk-8992smwz.js +0 -2
- package/dist/chunk-8mffwm1f.js +0 -2
- package/dist/chunk-8txwa114.js +0 -2
- package/dist/chunk-9j6hk72q.js +0 -2
- package/dist/chunk-a1szmtn1.js +0 -127
- package/dist/chunk-acm2tym9.js +0 -2
- package/dist/chunk-afmzxwj1.js +0 -2
- package/dist/chunk-bk3yktq8.js +0 -2
- package/dist/chunk-bpz3yv92.js +0 -2
- package/dist/chunk-bx3qewwk.js +0 -2
- package/dist/chunk-ce2d0hz9.js +0 -2
- package/dist/chunk-d81h4mxd.js +0 -2
- package/dist/chunk-dgtxj56t.js +0 -3
- package/dist/chunk-djqmzzn6.js +0 -2
- package/dist/chunk-eactb0nz.js +0 -2
- package/dist/chunk-eqa0wdv9.js +0 -4
- package/dist/chunk-esac5ych.js +0 -2
- package/dist/chunk-esj49jvz.js +0 -2
- package/dist/chunk-et8wjgxw.js +0 -2
- package/dist/chunk-ffykng6w.js +0 -2
- package/dist/chunk-fwt5fh5w.js +0 -2
- package/dist/chunk-g3qbe5y2.js +0 -2
- package/dist/chunk-h5g8k974.js +0 -2
- package/dist/chunk-hhwnd24n.js +0 -2
- package/dist/chunk-hq4mtcp0.js +0 -2
- package/dist/chunk-hvd9qc98.js +0 -2
- package/dist/chunk-j0z7010x.js +0 -2845
- package/dist/chunk-jhswy523.js +0 -2
- package/dist/chunk-jjs6nqh1.js +0 -2
- package/dist/chunk-jyqanvwp.js +0 -2
- package/dist/chunk-khdvzjzd.js +0 -2
- package/dist/chunk-n06xznty.js +0 -2
- package/dist/chunk-p973efbe.js +0 -2
- package/dist/chunk-qq59xzwc.js +0 -2
- package/dist/chunk-r0e743c3.js +0 -2
- package/dist/chunk-r4adpej7.js +0 -2
- package/dist/chunk-rd9yv1n3.js +0 -3
- package/dist/chunk-shzesarq.js +0 -2
- package/dist/chunk-t9914jjh.js +0 -2
- package/dist/chunk-wf2wnmjg.js +0 -2
- package/dist/chunk-wn2gzwmv.js +0 -2
- package/dist/chunk-wr6gw263.js +0 -2
- package/dist/chunk-xarb7knj.js +0 -2
- package/dist/chunk-xe7jw7nn.js +0 -2
- package/dist/chunk-xfe2nzxd.js +0 -2
- package/dist/chunk-xjwgzp6s.js +0 -2
- package/dist/chunk-xmz2h8cb.js +0 -2
- package/dist/chunk-y6909jm7.js +0 -2
- package/dist/chunk-zg0pnh4w.js +0 -2
package/dist/expressions.js
CHANGED
|
@@ -10,6 +10,7 @@ import { isDangerousUrl, sanitizeSubstitutedUrl, schemeWindow, UNSAFE_URL_PREFIX
|
|
|
10
10
|
import { maskAtElementPosition, matchScriptElement, matchStyleElement, restoreStashedScripts, stashScriptElements } from "./html-masking.js";
|
|
11
11
|
import { importsSignalDeclarations } from "./imported-signals.js";
|
|
12
12
|
import { inheritedClientLoopNames, loopBoundNames, readsAnyName } from "./loop-binding.js";
|
|
13
|
+
import { collectSlotScopes } from "./slot-scopes.js";
|
|
13
14
|
const customFilters = {}, translateRegexCache = new Map;
|
|
14
15
|
function getTranslateRegex(key) {
|
|
15
16
|
let re = translateRegexCache.get(key);
|
|
@@ -589,9 +590,14 @@ export function processExpressions(template, context, filePath) {
|
|
|
589
590
|
});
|
|
590
591
|
output = maskInto(output, matchScriptElement, scriptBlocks, (n) => `<!--__STX_SCRIPT_EXPR_${n}__-->`);
|
|
591
592
|
output = maskInto(output, styleMatcher, styleBlocks, (n) => `<!--__STX_STYLE_${n}__-->`);
|
|
592
|
-
const loopScopes = hasSignals ? clientLoopScopes(output) : [],
|
|
593
|
+
const loopScopes = hasSignals ? clientLoopScopes(output) : [], slotScopes = collectSlotScopes(output).map((scope) => ({
|
|
594
|
+
...scope,
|
|
595
|
+
names: new Set(loopBoundNames(`${scope.binding} in __slot`))
|
|
596
|
+
})), enclosingLoopNames = new Set(inheritedClientLoopNames(context));
|
|
593
597
|
output = replaceInterpolations(output, (match, expr, offset) => {
|
|
594
598
|
const trimmedExpr = expr.trim();
|
|
599
|
+
if (readsEnclosingLoopVariable(slotScopes, offset, trimmedExpr))
|
|
600
|
+
return match;
|
|
595
601
|
if (readsAnyName(trimmedExpr, enclosingLoopNames))
|
|
596
602
|
return match;
|
|
597
603
|
if (loopScopes.length > 0 && readsEnclosingLoopVariable(loopScopes, offset, trimmedExpr))
|
|
@@ -16,3 +16,15 @@ export declare function accessibilityPatch(name: string, value: unknown, props:
|
|
|
16
16
|
* `accessibilityState` keeps its keys while ARIA fills in the rest.
|
|
17
17
|
*/
|
|
18
18
|
export declare function applyStaticAccessibility(props: Record<string, unknown>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Keep authored props separate from this projection: an ARIA attribute may
|
|
21
|
+
* disappear later, and explicit native props must still take precedence.
|
|
22
|
+
* Reuse the compiler's role/state vocabulary rather than a second mapping.
|
|
23
|
+
*/
|
|
24
|
+
export declare function projectAccessibility(props: Record<string, unknown>): Record<string, unknown>;
|
|
25
|
+
/** Patch derived fields including removals; native prop patches merge by key. */
|
|
26
|
+
export declare function accessibilityChanges(props: Record<string, unknown>, before: Record<string, unknown>, changedField: string): Record<string, unknown>;
|
|
27
|
+
/** Recover authored native fields from compiler IR before reactive updates. */
|
|
28
|
+
export declare function authoredAccessibilityProps(props: Record<string, unknown>, source?: Record<string, unknown>): Record<string, unknown>;
|
|
29
|
+
/** Fields derived from web semantics at the native transport boundary. */
|
|
30
|
+
export declare const ACCESSIBILITY_FIELDS: readonly ['accessibilityLabel', 'accessibilityRole', 'accessibilityState', 'accessibilityValue'];
|
|
@@ -87,3 +87,22 @@ export function applyStaticAccessibility(props) {
|
|
|
87
87
|
if (state)
|
|
88
88
|
props.accessibilityState = { ...state, ...authoredState };
|
|
89
89
|
}
|
|
90
|
+
export const ACCESSIBILITY_FIELDS = ["accessibilityLabel", "accessibilityRole", "accessibilityState", "accessibilityValue"];
|
|
91
|
+
export function projectAccessibility(props) {
|
|
92
|
+
const projected = { ...props };
|
|
93
|
+
applyStaticAccessibility(projected);
|
|
94
|
+
return Object.fromEntries(ACCESSIBILITY_FIELDS.filter((name) => (name in projected)).map((name) => [name, projected[name]]));
|
|
95
|
+
}
|
|
96
|
+
export function accessibilityChanges(props, before, changedField) {
|
|
97
|
+
const projected = projectAccessibility(props);
|
|
98
|
+
return Object.fromEntries(ACCESSIBILITY_FIELDS.filter((name) => name === changedField || JSON.stringify(before[name]) !== JSON.stringify(projected[name])).map((name) => [name, projected[name] ?? null]));
|
|
99
|
+
}
|
|
100
|
+
export function authoredAccessibilityProps(props, source) {
|
|
101
|
+
const result = { ...props };
|
|
102
|
+
if (source) {
|
|
103
|
+
for (const name of ACCESSIBILITY_FIELDS)
|
|
104
|
+
delete result[name];
|
|
105
|
+
Object.assign(result, source);
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
@@ -1010,37 +1010,31 @@ function parseBorderRadius(className, style) {
|
|
|
1010
1010
|
return !0;
|
|
1011
1011
|
}
|
|
1012
1012
|
function parseBorderWidth(className, style) {
|
|
1013
|
-
|
|
1013
|
+
const match = /^border(?:-([trblxy]))?(?:-(\d+|\[[^\]]+\]))?$/.exec(className);
|
|
1014
|
+
if (!match)
|
|
1014
1015
|
return !1;
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
return !0;
|
|
1023
|
-
}
|
|
1024
|
-
const sideMatch = className.match(/^border-(t|r|b|l)-?(\d*)$/);
|
|
1025
|
-
if (sideMatch) {
|
|
1026
|
-
const [, side, width] = sideMatch, w = width ? Number.parseInt(width) : 1;
|
|
1027
|
-
switch (side) {
|
|
1028
|
-
case "t":
|
|
1029
|
-
style.borderTopWidth = w;
|
|
1030
|
-
break;
|
|
1031
|
-
case "r":
|
|
1032
|
-
style.borderRightWidth = w;
|
|
1033
|
-
break;
|
|
1034
|
-
case "b":
|
|
1035
|
-
style.borderBottomWidth = w;
|
|
1036
|
-
break;
|
|
1037
|
-
case "l":
|
|
1038
|
-
style.borderLeftWidth = w;
|
|
1039
|
-
break;
|
|
1040
|
-
}
|
|
1041
|
-
return !0;
|
|
1016
|
+
const [, side = "", value] = match;
|
|
1017
|
+
let width = value === void 0 ? 1 : Number(value);
|
|
1018
|
+
if (value?.startsWith("[")) {
|
|
1019
|
+
const length = /^\[(\d+(?:\.\d+)?|\.\d+)(px|rem)?\]$/.exec(value);
|
|
1020
|
+
if (!length)
|
|
1021
|
+
return !1;
|
|
1022
|
+
width = Number(length[1]) * (length[2] === "rem" ? 16 : 1);
|
|
1042
1023
|
}
|
|
1043
|
-
|
|
1024
|
+
if (!Number.isFinite(width) || width < 0)
|
|
1025
|
+
return !1;
|
|
1026
|
+
const keys = {
|
|
1027
|
+
"": ["borderWidth"],
|
|
1028
|
+
t: ["borderTopWidth"],
|
|
1029
|
+
r: ["borderRightWidth"],
|
|
1030
|
+
b: ["borderBottomWidth"],
|
|
1031
|
+
l: ["borderLeftWidth"],
|
|
1032
|
+
x: ["borderLeftWidth", "borderRightWidth"],
|
|
1033
|
+
y: ["borderTopWidth", "borderBottomWidth"]
|
|
1034
|
+
};
|
|
1035
|
+
for (const key of keys[side])
|
|
1036
|
+
style[key] = width;
|
|
1037
|
+
return !0;
|
|
1044
1038
|
}
|
|
1045
1039
|
function parseBorderColor(className, style) {
|
|
1046
1040
|
if (!className.startsWith("border-"))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ACCESSIBILITY_FIELDS, projectAccessibility } from "../accessibility.js";
|
|
1
2
|
import { NATIVE_EVENT_NAMES as EVENT_NAMES } from "../event-names.js";
|
|
2
|
-
import { applyStaticAccessibility } from "../accessibility.js";
|
|
3
3
|
import { NATIVE_BOOLEAN_PROPS, nativePropName } from "../prop-names.js";
|
|
4
4
|
import { mapToNativeComponent } from "./component-mapping.js";
|
|
5
5
|
import { resolveIconName } from "./icons.js";
|
|
6
|
-
import { parseNativeStyle } from "./inline-style.js";
|
|
6
|
+
import { applyNativeLayoutDefaults, parseNativeStyle } from "./inline-style.js";
|
|
7
7
|
import { createStyleVariables } from "./style-variables.js";
|
|
8
8
|
import { extractStylesheetTheme } from "./stylesheet-theme.js";
|
|
9
9
|
import { parseViewBox, SVG_DROPPED, SVG_NODE_TYPES, SVG_TYPES, svgGeometry } from "./svg.js";
|
|
@@ -55,6 +55,7 @@ const NATIVE_TYPES = new Set([
|
|
|
55
55
|
"Text",
|
|
56
56
|
"TextInput",
|
|
57
57
|
"Button",
|
|
58
|
+
"Link",
|
|
58
59
|
"TouchableOpacity",
|
|
59
60
|
"TouchableHighlight",
|
|
60
61
|
"Pressable",
|
|
@@ -82,8 +83,7 @@ const NATIVE_TYPES = new Set([
|
|
|
82
83
|
["sections", "sections"],
|
|
83
84
|
["renderitem", "renderItem"],
|
|
84
85
|
["rendersectionheader", "renderSectionHeader"],
|
|
85
|
-
["keyextractor", "keyExtractor"]
|
|
86
|
-
["listrole", "listRole"]
|
|
86
|
+
["keyextractor", "keyExtractor"]
|
|
87
87
|
]), CONTAINER_TYPES = new Set(["View", "SafeAreaView", "ScrollView", "KeyboardAvoidingView"]), ENTITIES = {
|
|
88
88
|
amp: "&",
|
|
89
89
|
lt: "<",
|
|
@@ -156,7 +156,7 @@ function readAttributes(tag, attributes, diagnostics, styleContext = {}) {
|
|
|
156
156
|
const compiledClasses = classes ? compileClassStyles(classes, variables) : void 0;
|
|
157
157
|
for (const name of new Set(compiledClasses?.unknown ?? []))
|
|
158
158
|
diagnostics.push({ kind: "unknown-class", tag, name });
|
|
159
|
-
const style = { ...compiledClasses?.style, ...inline };
|
|
159
|
+
const style = applyNativeLayoutDefaults({ ...compiledClasses?.style, ...inline });
|
|
160
160
|
return { props, style, events, bindings, classes, inline };
|
|
161
161
|
}
|
|
162
162
|
function inlineStyle(tag, css, diagnostics, context) {
|
|
@@ -169,7 +169,7 @@ function settle(frame, diagnostics) {
|
|
|
169
169
|
const node = frame.node, elements = node.children.filter((child) => typeof child !== "string"), text = node.children.filter((child) => typeof child === "string").join("").trim();
|
|
170
170
|
if (frame.tag === "button" && node.type === "Button" && !frame.declaredNative && elements.length > 0) {
|
|
171
171
|
node.type = "Pressable";
|
|
172
|
-
node.props.
|
|
172
|
+
node.props.role ??= "button";
|
|
173
173
|
node.children = node.children.flatMap((child) => typeof child === "string" ? child.trim() ? [createNode("Text", {}, {}, {}, [child.trim()])] : [] : [child]);
|
|
174
174
|
return node;
|
|
175
175
|
}
|
|
@@ -318,7 +318,6 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
318
318
|
if (names.has(lowerName))
|
|
319
319
|
diagnostics.push({ kind: "unsupported-list-prop", tag: type, name: publicName });
|
|
320
320
|
}
|
|
321
|
-
applyStaticAccessibility(props);
|
|
322
321
|
const node = createNode(type, props, style, events);
|
|
323
322
|
node._inlineStyle = inline;
|
|
324
323
|
node._styleSource = decodeEntities(attributes.find(([name]) => name === "style")?.[1] ?? "");
|
|
@@ -430,6 +429,17 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
430
429
|
const root = roots.length === 1 ? roots[0] : createNode("View", {}, {}, {}, roots);
|
|
431
430
|
if (stylesheetTheme.light.length || stylesheetTheme.dark.length)
|
|
432
431
|
root._stylesheetTheme = stylesheetTheme;
|
|
432
|
+
const project = (node) => {
|
|
433
|
+
const projected = projectAccessibility(node.props);
|
|
434
|
+
if (Object.keys(projected).length) {
|
|
435
|
+
node._accessibilitySource = Object.fromEntries(ACCESSIBILITY_FIELDS.filter((name) => (name in node.props)).map((name) => [name, node.props[name]]));
|
|
436
|
+
Object.assign(node.props, projected);
|
|
437
|
+
}
|
|
438
|
+
for (const child of node.children)
|
|
439
|
+
if (typeof child !== "string")
|
|
440
|
+
project(child);
|
|
441
|
+
};
|
|
442
|
+
project(root);
|
|
433
443
|
return { root, diagnostics };
|
|
434
444
|
}
|
|
435
445
|
export async function translateHtmlToDocument(html, options = {}) {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { type NativeStyleVariables } from './style-variables';
|
|
2
2
|
import type { STXStyle } from './ir';
|
|
3
|
+
/**
|
|
4
|
+
* CSS flex containers default to row; native stacks default to column.
|
|
5
|
+
* Apply only after all authored style layers have been combined: adding a
|
|
6
|
+
* default to an inline display declaration would override a class direction.
|
|
7
|
+
* Views without an explicit flex display retain the native stack default.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyNativeLayoutDefaults(style: STXStyle): STXStyle;
|
|
3
10
|
export declare function parseNativeStyle(input: unknown, report?: (diagnostic: NativeStyleDiagnostic) => void, context?: NativeStyleContext): STXStyle;
|
|
4
11
|
/** Resolve all same-element variable declarations before evaluating any style layer. */
|
|
5
12
|
export declare function parseNativeStyleLayers(inputs: unknown[], inheritedVariables: NativeStyleVariables | undefined, report: (diagnostic: NativeStyleDiagnostic) => void): { variables: NativeStyleVariables, styles: STXStyle[] };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { createStyleVariables } from "./style-variables.js";
|
|
2
|
+
export function applyNativeLayoutDefaults(style) {
|
|
3
|
+
if (style.display === "flex" && style.flexDirection == null)
|
|
4
|
+
return { ...style, flexDirection: "row" };
|
|
5
|
+
return style;
|
|
6
|
+
}
|
|
2
7
|
const STYLE_KEYS = new Set([
|
|
3
8
|
"display",
|
|
4
9
|
"gridColumns",
|
|
@@ -265,7 +270,9 @@ function parseEntries(entries, variables, report) {
|
|
|
265
270
|
translated = numericValue(value);
|
|
266
271
|
if (!finite(translated) && !(DIMENSION_STYLE_KEYS.has(property) && typeof translated === "string" && translated.endsWith("%") && NUMBER.test(translated.slice(0, -1)) && Number.isFinite(Number(translated.slice(0, -1)))))
|
|
267
272
|
translated = void 0;
|
|
268
|
-
} else if (property === "
|
|
273
|
+
} else if (property === "display" && value === "inline-flex")
|
|
274
|
+
translated = "flex";
|
|
275
|
+
else if (property === "shadowOffset" || property === "transform")
|
|
269
276
|
translated = structuredStyle(property, value);
|
|
270
277
|
else if (property === "gridTemplateColumns" || property === "gridTemplateRows")
|
|
271
278
|
translated = finite(value) || typeof value === "string" ? value : void 0;
|
|
@@ -10,6 +10,7 @@ export declare interface STXNode {
|
|
|
10
10
|
bindingId?: number
|
|
11
11
|
key?: string
|
|
12
12
|
props: Record<string, unknown>
|
|
13
|
+
_accessibilitySource?: Record<string, unknown>
|
|
13
14
|
style: STXStyle
|
|
14
15
|
events: Record<string, string>
|
|
15
16
|
bindings?: Record<string, string>
|
|
@@ -56,7 +57,7 @@ export declare interface STXStyle {
|
|
|
56
57
|
justifyContent?: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
|
|
57
58
|
alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'
|
|
58
59
|
alignSelf?: 'auto' | 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'
|
|
59
|
-
alignContent?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'space-between' | 'space-around'
|
|
60
|
+
alignContent?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'space-between' | 'space-around' | 'space-evenly'
|
|
60
61
|
position?: 'relative' | 'absolute'
|
|
61
62
|
top?: number | string
|
|
62
63
|
right?: number | string
|
|
@@ -203,6 +204,7 @@ export type STXComponentType = | 'Sidebar'
|
|
|
203
204
|
| 'TextInput'
|
|
204
205
|
// Interactive
|
|
205
206
|
| 'Button'
|
|
207
|
+
| 'Link'
|
|
206
208
|
| 'TouchableOpacity'
|
|
207
209
|
| 'TouchableHighlight'
|
|
208
210
|
| 'Pressable'
|
|
@@ -25,7 +25,7 @@ export async function compileScreenSource(source, filePath, options = {}) {
|
|
|
25
25
|
buildMode: "serve",
|
|
26
26
|
cache: !1,
|
|
27
27
|
_targetComponentDirs: [nativePrimitivesDir()],
|
|
28
|
-
_targetComponentFallbackNames: ["Button"],
|
|
28
|
+
_targetComponentFallbackNames: ["Button", "Checkbox", "Switch"],
|
|
29
29
|
_nativeHostAttrs: !0,
|
|
30
30
|
skipEventDirectives: !0,
|
|
31
31
|
_pluginComponentDirs: loaded._pluginComponentDirs ?? []
|
|
@@ -8,6 +8,7 @@ export declare const ComponentRegistry: {
|
|
|
8
8
|
Text: 'Text';
|
|
9
9
|
TextInput: 'TextInput';
|
|
10
10
|
Button: 'Button';
|
|
11
|
+
Link: 'Link';
|
|
11
12
|
TouchableOpacity: 'TouchableOpacity';
|
|
12
13
|
TouchableHighlight: 'TouchableHighlight';
|
|
13
14
|
Pressable: 'Pressable';
|
|
@@ -41,6 +42,7 @@ export declare interface BaseProps {
|
|
|
41
42
|
accessibilityLabel?: string
|
|
42
43
|
accessibilityHint?: string
|
|
43
44
|
accessibilityRole?: AccessibilityRole
|
|
45
|
+
listRole?: 'header' | 'item' | 'separator' | 'empty' | 'footer'
|
|
44
46
|
transitionID?: string
|
|
45
47
|
}
|
|
46
48
|
// ============================================================================
|
|
@@ -117,6 +119,15 @@ export declare interface ButtonProps extends BaseProps {
|
|
|
117
119
|
disabled?: boolean
|
|
118
120
|
color?: string
|
|
119
121
|
}
|
|
122
|
+
/** An underlined navigation action. Craft resolves `href`/`to` in the host. */
|
|
123
|
+
export declare interface LinkProps extends BaseProps {
|
|
124
|
+
href?: string
|
|
125
|
+
to?: string
|
|
126
|
+
title?: string
|
|
127
|
+
onPress?: () => void
|
|
128
|
+
disabled?: boolean
|
|
129
|
+
color?: string
|
|
130
|
+
}
|
|
120
131
|
export declare interface TouchableOpacityProps extends ViewProps {
|
|
121
132
|
activeOpacity?: number
|
|
122
133
|
disabled?: boolean
|
|
@@ -221,9 +232,12 @@ export declare interface VideoProps extends BaseProps {
|
|
|
221
232
|
autoplay?: boolean
|
|
222
233
|
loop?: boolean
|
|
223
234
|
muted?: boolean
|
|
235
|
+
currentTime?: number
|
|
224
236
|
paused?: boolean
|
|
225
237
|
resizeMode?: 'contain' | 'cover' | 'stretch'
|
|
226
238
|
onLoad?: (event: { duration: number }) => void
|
|
239
|
+
onLoadStart?: () => void
|
|
240
|
+
onLoadEnd?: () => void
|
|
227
241
|
onPlay?: () => void
|
|
228
242
|
onPause?: () => void
|
|
229
243
|
onEnd?: () => void
|
|
@@ -295,26 +309,14 @@ export declare interface MapMarkerProps extends BaseProps {
|
|
|
295
309
|
// List Components
|
|
296
310
|
// ============================================================================
|
|
297
311
|
export declare interface FlatListProps<T> extends ScrollViewProps {
|
|
298
|
-
data: T[]
|
|
299
|
-
renderItem: (info: { item: T; index: number }) => unknown
|
|
300
|
-
keyExtractor?: (item: T, index: number) => string
|
|
301
|
-
ItemSeparatorComponent?: () => unknown
|
|
302
|
-
ListHeaderComponent?: () => unknown
|
|
303
|
-
ListFooterComponent?: () => unknown
|
|
304
|
-
ListEmptyComponent?: () => unknown
|
|
305
312
|
numColumns?: number
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
windowSize?: number
|
|
313
|
+
onRefresh?: () => void
|
|
314
|
+
refreshing?: boolean
|
|
309
315
|
onEndReached?: () => void
|
|
310
316
|
onEndReachedThreshold?: number
|
|
311
317
|
inverted?: boolean
|
|
312
318
|
}
|
|
313
319
|
export declare interface SectionListProps<T> extends ScrollViewProps {
|
|
314
|
-
sections: Array<{ title?: string; data: T[] }>
|
|
315
|
-
renderItem: (info: { item: T; index: number; section: { title?: string; data: T[] } }) => unknown
|
|
316
|
-
renderSectionHeader?: (info: { section: { title?: string; data: T[] } }) => unknown
|
|
317
|
-
keyExtractor?: (item: T, index: number) => string
|
|
318
320
|
}
|
|
319
321
|
// ============================================================================
|
|
320
322
|
// Overlay Components
|
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",
|
|
@@ -30,6 +31,7 @@ const NATIVE_PROP_NAMES = [
|
|
|
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",
|
|
@@ -115,6 +119,8 @@ export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
|
115
119
|
"showsVerticalScrollIndicator",
|
|
116
120
|
"transparent",
|
|
117
121
|
"visible",
|
|
122
|
+
"nonModal",
|
|
123
|
+
"dismissOnOutsideTap",
|
|
118
124
|
"fitToBounds",
|
|
119
125
|
"showsUserLocation",
|
|
120
126
|
"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
|