@stacksjs/stx 0.2.656 → 0.2.661

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.
Files changed (112) hide show
  1. package/dist/{chunk-qc5wyxvc.js → chunk-0961mx93.js} +1 -1
  2. package/dist/{chunk-3p7xp7de.js → chunk-09a8tn6e.js} +1 -1
  3. package/dist/{chunk-zfeq5h13.js → chunk-2cb9r3r9.js} +11 -11
  4. package/dist/{chunk-zyv28182.js → chunk-2jv7g2fs.js} +1 -1
  5. package/dist/{chunk-5cyznacz.js → chunk-2x9h3whx.js} +1 -1
  6. package/dist/{chunk-jfmjw734.js → chunk-2yvqydak.js} +3 -3
  7. package/dist/{chunk-s2qv0y4x.js → chunk-3fyj98v9.js} +1 -1
  8. package/dist/{chunk-27v1ehy0.js → chunk-3p8p8sfw.js} +1 -1
  9. package/dist/{chunk-31yb0253.js → chunk-57nbg2f9.js} +2 -2
  10. package/dist/{chunk-2qf9vt7y.js → chunk-5em9ak8r.js} +1 -1
  11. package/dist/{chunk-80fkh83p.js → chunk-5n6sej6b.js} +1 -1
  12. package/dist/{chunk-hzjvpcmj.js → chunk-5nfc2tw2.js} +71 -71
  13. package/dist/{chunk-v5r6abrq.js → chunk-6qd27t9k.js} +1 -1
  14. package/dist/{chunk-qkasqamj.js → chunk-714gdfj9.js} +1 -1
  15. package/dist/{chunk-a2dnv6n9.js → chunk-7ek9yvwk.js} +1 -1
  16. package/dist/chunk-7j486x8f.js +2 -0
  17. package/dist/{chunk-1z1fmda6.js → chunk-7rjm58gn.js} +1 -1
  18. package/dist/chunk-8xypmt6s.js +2 -0
  19. package/dist/{chunk-k9amsnfj.js → chunk-9rh5anvd.js} +2 -2
  20. package/dist/{chunk-cjj9b9wf.js → chunk-9zy4kzqk.js} +1 -1
  21. package/dist/{chunk-yr34z9ey.js → chunk-afavkkkq.js} +1 -1
  22. package/dist/chunk-avmqg5t6.js +2 -0
  23. package/dist/{chunk-v3kc2anv.js → chunk-bt4bd4f5.js} +1 -1
  24. package/dist/{chunk-vm26nak1.js → chunk-d5k8gx93.js} +1 -1
  25. package/dist/{chunk-zaj65qc1.js → chunk-d5vz53t1.js} +2 -2
  26. package/dist/{chunk-y4waj1p4.js → chunk-dah90qrm.js} +1 -1
  27. package/dist/{chunk-yb89cj9s.js → chunk-dn2h9g79.js} +1 -1
  28. package/dist/{chunk-p314pg80.js → chunk-dr1vedj2.js} +1 -1
  29. package/dist/{chunk-6c2pvrw8.js → chunk-dv709hnm.js} +1 -1
  30. package/dist/{chunk-rccpf74y.js → chunk-dyzgrvg3.js} +8 -8
  31. package/dist/{chunk-vmwdt8fr.js → chunk-een2wqah.js} +6 -6
  32. package/dist/chunk-eqrkhc18.js +12 -0
  33. package/dist/{chunk-jvv9p6v6.js → chunk-eyvex6fk.js} +39 -39
  34. package/dist/{chunk-26qc9v36.js → chunk-f9fty8ty.js} +1 -1
  35. package/dist/{chunk-nn138y2w.js → chunk-ghge79wv.js} +1 -1
  36. package/dist/chunk-j02834qv.js +2 -0
  37. package/dist/{chunk-889evdcy.js → chunk-jtheqwp2.js} +5 -5
  38. package/dist/{chunk-vmzkbdmp.js → chunk-k99f2njc.js} +1 -1
  39. package/dist/chunk-mdk323pn.js +2 -0
  40. package/dist/{chunk-mz1npbyk.js → chunk-mmern3j1.js} +1 -1
  41. package/dist/{chunk-p7096wfv.js → chunk-mvv5cpen.js} +1 -1
  42. package/dist/{chunk-dv7dm5z1.js → chunk-n4x9hytk.js} +56 -56
  43. package/dist/{chunk-ds3qn1ty.js → chunk-nw9x9gsb.js} +1 -1
  44. package/dist/chunk-p6p29613.js +2 -0
  45. package/dist/chunk-pnnqftq6.js +2 -0
  46. package/dist/{chunk-wp0jtntj.js → chunk-pp4pyeg4.js} +4 -4
  47. package/dist/{chunk-x2wgczak.js → chunk-px8e8qgp.js} +1 -1
  48. package/dist/{chunk-jf17b7y9.js → chunk-qzv0mqw5.js} +1 -1
  49. package/dist/{chunk-2h92dm3t.js → chunk-r1y1k2ky.js} +38 -38
  50. package/dist/{chunk-qkq8at1r.js → chunk-rzxhdmz9.js} +1 -1
  51. package/dist/{chunk-sdknbvh8.js → chunk-sk82mf97.js} +1 -1
  52. package/dist/chunk-snwps673.js +129 -0
  53. package/dist/{chunk-x5777qkq.js → chunk-t1fxzg0m.js} +2 -2
  54. package/dist/{chunk-28jtt8hn.js → chunk-vp9hse5k.js} +48 -48
  55. package/dist/chunk-w7dcy972.js +2 -0
  56. package/dist/{chunk-p7bqzhe1.js → chunk-w82nvp7r.js} +1 -1
  57. package/dist/{chunk-0gqmp9sa.js → chunk-wc3e138p.js} +2 -2
  58. package/dist/{chunk-g96m1a69.js → chunk-wcmzr1sk.js} +1 -1
  59. package/dist/{chunk-kpycf9tz.js → chunk-xt9t5wvx.js} +1 -1
  60. package/dist/chunk-yharrk8v.js +2 -0
  61. package/dist/{chunk-teahew39.js → chunk-z4fa7nsm.js} +5 -5
  62. package/dist/{chunk-kg54zsda.js → chunk-z5qj7enn.js} +1 -1
  63. package/dist/chunk-zdfja1ap.js +2 -0
  64. package/dist/{chunk-e7z85137.js → chunk-zjnh64wm.js} +1 -1
  65. package/dist/cli.js +8 -8
  66. package/dist/craft-entry.js +1 -1
  67. package/dist/craft.js +1 -1
  68. package/dist/expressions.js +9 -0
  69. package/dist/native/bridge/protocol.d.ts +1 -0
  70. package/dist/native/compiler/bundle.d.ts +1 -0
  71. package/dist/native/compiler/bundle.js +3 -2
  72. package/dist/native/compiler/headwind-to-style.d.ts +5 -1
  73. package/dist/native/compiler/headwind-to-style.js +54 -15
  74. package/dist/native/compiler/html-to-ir.d.ts +12 -0
  75. package/dist/native/compiler/html-to-ir.js +63 -8
  76. package/dist/native/compiler/ir.d.ts +2 -0
  77. package/dist/native/compiler/render-screen.js +31 -5
  78. package/dist/native/compiler/stylesheet-rules.d.ts +2 -2
  79. package/dist/native/compiler/stylesheet-rules.js +20 -16
  80. package/dist/native/runtime/binding-tree.js +2 -1
  81. package/dist/native/runtime/craft-bridge.d.ts +2 -0
  82. package/dist/native/runtime/craft-bridge.js +13 -3
  83. package/dist/native/runtime/native-host.d.ts +1 -0
  84. package/dist/native/runtime/native-host.js +83 -13
  85. package/dist/native/runtime/shared-screen.js +4 -3
  86. package/dist/native/runtime/web-navigation.d.ts +18 -0
  87. package/dist/native/runtime/web-navigation.js +59 -0
  88. package/dist/native/runtime/web-storage.d.ts +40 -1
  89. package/dist/native/runtime/web-storage.js +123 -26
  90. package/dist/native/testing.d.ts +1 -0
  91. package/dist/native/testing.js +1 -0
  92. package/dist/native/text-entry.d.ts +51 -0
  93. package/dist/native/text-entry.js +101 -0
  94. package/dist/native-build.js +3 -1
  95. package/dist/pwa.js +1 -1
  96. package/dist/ssg.js +25 -25
  97. package/dist/stx-virtual-ts.d.ts +1 -1
  98. package/dist/stx-virtual-ts.js +3 -1
  99. package/dist/utils.js +2 -0
  100. package/package.json +5 -5
  101. package/dist/chunk-67rvd6qy.js +0 -2
  102. package/dist/chunk-9c3cq8ks.js +0 -2
  103. package/dist/chunk-9q23eed0.js +0 -2
  104. package/dist/chunk-ajjcp56c.js +0 -128
  105. package/dist/chunk-bpm8tyvc.js +0 -2
  106. package/dist/chunk-da6qbwqs.js +0 -2
  107. package/dist/chunk-dknd9nhz.js +0 -2
  108. package/dist/chunk-egg54kd0.js +0 -12
  109. package/dist/chunk-fjqphdvp.js +0 -2
  110. package/dist/chunk-j2hkxwjy.js +0 -2
  111. package/dist/chunk-ne72vxmc.js +0 -2
  112. package/dist/chunk-xesyd9nx.js +0 -2
@@ -188,6 +188,7 @@ var bridge = browserBridge;
188
188
  g.__stxNativeRoute = ${JSON.stringify(initialScreen)};` : "var bridge = g.__stxNativeBridge;"}
189
189
  if (!bridge) throw new Error('Missing __stxNativeBridge');
190
190
  var routeNames = ${JSON.stringify(routed ? names : ["main"])};
191
+ var shareStorage = ${JSON.stringify(options.shareStorage ?? {})};
191
192
  ${route}
192
193
  g.__stxNativeRoute = routeName;
193
194
  var nativeDocument;
@@ -196,11 +197,11 @@ ${selections}
196
197
  var screen = null;
197
198
  var app = null;
198
199
  if (isApp) {
199
- app = prepareNativeApp(bridge, { routeName: routeName, routeNames: routeNames });
200
+ app = prepareNativeApp(bridge, { routeName: routeName, routeNames: routeNames, shareStorage: shareStorage });
200
201
  g.__stxNativeUnmount = function() { app.unmount(); };
201
202
  }
202
203
  else {
203
- screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames });
204
+ screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames, shareStorage: shareStorage });
204
205
  g.__stx_host = screen.host;
205
206
  g.__stxNativeUnmount = function() { screen.unmount(); };
206
207
  }
@@ -407,6 +407,8 @@ declare const fontSizes: Record<string, number>;
407
407
  * ```
408
408
  */
409
409
  declare const borderRadius: Record<string, number>;
410
+ /** ARIA state variants a native node can carry: its attribute is on the node, so the layer can follow it. */
411
+ export declare const NATIVE_STATE_VARIANTS: Set<any>;
410
412
  // ============================================================================
411
413
  // Main Compiler Function
412
414
  // ============================================================================
@@ -419,8 +421,10 @@ export declare interface ClassStyles {
419
421
  numberOfLines?: number
420
422
  icon?: string
421
423
  resizeMode?: string
422
- responsive?: Array<{ min: number, style: STXStyle, dark?: STXStyle }>
424
+ responsive?: Array<{ min: number, max?: number, style: STXStyle, dark?: STXStyle }>
423
425
  disabled?: { style: STXStyle, dark?: STXStyle }
426
+ states?: Record<string, { style: STXStyle, dark?: STXStyle }>
427
+ divide?: { style: STXStyle, dark?: STXStyle }
424
428
  }
425
429
  // ============================================================================
426
430
  // Class Parsers
@@ -1254,6 +1254,17 @@ function parseShadow(className, style) {
1254
1254
  Object.assign(style, { shadowColor: "#000000", shadowOpacity: opacity, shadowRadius: radius, shadowOffset: { width: 0, height: offset }, elevation });
1255
1255
  return !0;
1256
1256
  }
1257
+ function divideAsBorder(name) {
1258
+ const rule = /^divide-(?:(y|x)(?:-(.+))?|(.+))$/.exec(name);
1259
+ if (!rule)
1260
+ return null;
1261
+ if (rule[2] === "reverse")
1262
+ return "";
1263
+ if (rule[1])
1264
+ return `border-${rule[1] === "y" ? "t" : "l"}${rule[2] ? `-${rule[2]}` : ""}`;
1265
+ return `border-${rule[3]}`;
1266
+ }
1267
+ export const NATIVE_STATE_VARIANTS = new Set(["aria-selected", "aria-pressed", "aria-checked", "aria-expanded"]);
1257
1268
  const POINTER_ONLY_VARIANTS = new Set(["hover", "group-hover", "peer-hover", "active", "group-active", "visited", "placeholder", "selection", "print", "motion-safe"]), WEB_ONLY_UTILITY = /^(?:transition(?:-[a-z]+)?|duration-\S+|ease-\S+|delay-\S+|will-change-\S+|cursor-\S+|select-(?:none|text|all|auto)|outline-none|outline-0|appearance-none|scroll-smooth|scroll-auto|antialiased|subpixel-antialiased|touch-\S+|resize(?:-\S+)?|backdrop-blur(?:-\S+)?|isolate|contain-\S+)$/;
1258
1269
  function splitVariants(token) {
1259
1270
  const parts = [];
@@ -1286,10 +1297,17 @@ export function compileClassStyles(classes, variables, options = {}) {
1286
1297
  return groups.get(key);
1287
1298
  };
1288
1299
  group("base", {});
1289
- const ruleNames = [];
1290
- for (const authored of classes.split(/\s+/).filter(Boolean)) {
1300
+ const singleRules = [], compoundRules = [], authoredClasses = classes.split(/\s+/).filter(Boolean);
1301
+ if (options.rules) {
1302
+ const present = new Set(authoredClasses);
1303
+ for (const key of Object.keys(options.rules))
1304
+ if (key.includes(".") && key.split(".").every((name) => present.has(name)))
1305
+ compoundRules.push(key);
1306
+ compoundRules.sort((a, b) => a.split(".").length - b.split(".").length);
1307
+ }
1308
+ for (const authored of authoredClasses) {
1291
1309
  if (options.rules && Object.hasOwn(options.rules, authored)) {
1292
- ruleNames.push(authored);
1310
+ singleRules.push(authored);
1293
1311
  continue;
1294
1312
  }
1295
1313
  for (const token of expandShortcuts(authored)) {
@@ -1298,19 +1316,23 @@ export function compileClassStyles(classes, variables, options = {}) {
1298
1316
  continue;
1299
1317
  if (WEB_ONLY_UTILITY.test(utility) || !focusing && parts.some((variant) => POINTER_ONLY_VARIANTS.has(variant)))
1300
1318
  continue;
1301
- let min, disabled = !1;
1319
+ let min, max, disabled = !1, state;
1302
1320
  const kept = [];
1303
1321
  for (const variant of parts) {
1304
- const width = nativeBreakpoint(variant);
1322
+ const width = nativeBreakpoint(variant), below = variant.startsWith("max-") ? nativeBreakpoint(variant.slice(4)) : void 0;
1305
1323
  if (width !== void 0 && min === void 0)
1306
1324
  min = width;
1325
+ else if (below !== void 0 && max === void 0)
1326
+ max = below - 0.02;
1307
1327
  else if (variant === "disabled" && !disabled)
1308
1328
  disabled = !0;
1329
+ else if (NATIVE_STATE_VARIANTS.has(variant) && state === void 0)
1330
+ state = variant;
1309
1331
  else
1310
1332
  kept.push(variant);
1311
1333
  }
1312
- const stripped = [...kept, utility].join(":"), target = disabled ? group("disabled", { disabled: !0 }) : min !== void 0 ? group(`min:${min}`, { min }) : groups.get("base");
1313
- if (disabled && min !== void 0) {
1334
+ const stripped = [...kept, utility].join(":"), ranged = min !== void 0 || max !== void 0, target = disabled ? group("disabled", { disabled: !0 }) : state ? group(`state:${state}`, { state }) : ranged ? group(`range:${min ?? 0}:${max ?? ""}`, { min: min ?? 0, max }) : groups.get("base");
1335
+ if ((disabled || state) && (ranged || disabled && state)) {
1314
1336
  groups.get("base").authored.set(token, authored);
1315
1337
  groups.get("base").classes.push(token);
1316
1338
  continue;
@@ -1320,7 +1342,7 @@ export function compileClassStyles(classes, variables, options = {}) {
1320
1342
  target.authored.set(stripped, authored === token ? token : `${authored} (${token})`);
1321
1343
  }
1322
1344
  }
1323
- const authoredNames = (layer, names) => names.map((name) => layer.authored.get(name) ?? name), base = groups.get("base"), result = compileLayer(base.classes.join(" "), variables, options), ruleResponsive = new Map;
1345
+ const ruleNames = [...singleRules, ...compoundRules], authoredNames = (layer, names) => names.map((name) => layer.authored.get(name) ?? name), base = groups.get("base"), result = compileLayer(base.classes.join(" "), variables, options), ruleResponsive = new Map;
1324
1346
  if (ruleNames.length) {
1325
1347
  const parse = (css) => css ? parseNativeStyle(css, () => {}, { inheritedVariables: variables }) : {};
1326
1348
  let light = {}, dark = {};
@@ -1329,11 +1351,11 @@ export function compileClassStyles(classes, variables, options = {}) {
1329
1351
  light = { ...light, ...parse(rule.light) };
1330
1352
  dark = { ...dark, ...parse(rule.dark) };
1331
1353
  for (const layer of rule.responsive ?? []) {
1332
- const entry = ruleResponsive.get(layer.min) ?? { style: {} };
1354
+ const key = `${layer.min}:${layer.max ?? ""}`, entry = ruleResponsive.get(key) ?? { min: layer.min, ...layer.max === void 0 ? {} : { max: layer.max }, style: {} };
1333
1355
  entry.style = { ...entry.style, ...parse(layer.light) };
1334
1356
  if (layer.dark)
1335
1357
  entry.dark = { ...entry.dark, ...parse(layer.dark) };
1336
- ruleResponsive.set(layer.min, entry);
1358
+ ruleResponsive.set(key, entry);
1337
1359
  }
1338
1360
  }
1339
1361
  result.style = { ...light, ...result.style };
@@ -1350,20 +1372,22 @@ export function compileClassStyles(classes, variables, options = {}) {
1350
1372
  const entry = { style: compiled.style, ...compiled.dark ? { dark: compiled.dark } : {} };
1351
1373
  if (layer.disabled)
1352
1374
  result.disabled = entry;
1375
+ else if (layer.state)
1376
+ (result.states ??= {})[layer.state] = entry;
1353
1377
  else
1354
- responsive.push({ min: layer.min, ...entry });
1378
+ responsive.push({ min: layer.min ?? 0, ...layer.max === void 0 ? {} : { max: layer.max }, ...entry });
1355
1379
  }
1356
- for (const [min, layer] of ruleResponsive) {
1357
- const existing = responsive.find((entry) => entry.min === min);
1380
+ for (const layer of ruleResponsive.values()) {
1381
+ const existing = responsive.find((entry) => entry.min === layer.min && entry.max === layer.max);
1358
1382
  if (existing) {
1359
1383
  existing.style = { ...layer.style, ...existing.style };
1360
1384
  if (layer.dark || existing.dark)
1361
1385
  existing.dark = { ...layer.dark, ...existing.dark };
1362
1386
  } else
1363
- responsive.push({ min, ...layer });
1387
+ responsive.push(layer);
1364
1388
  }
1365
1389
  if (responsive.length)
1366
- result.responsive = responsive.sort((a, b) => a.min - b.min);
1390
+ result.responsive = responsive.sort((a, b) => a.min - b.min || (a.max ?? 1 / 0) - (b.max ?? 1 / 0));
1367
1391
  return result;
1368
1392
  }
1369
1393
  function compileLayer(classes, variables, options = {}) {
@@ -1407,7 +1431,17 @@ function compileLayer(classes, variables, options = {}) {
1407
1431
  originals.get(translated).add(original);
1408
1432
  return translated;
1409
1433
  }
1434
+ const dividers = [], dividerOriginals = new Map;
1410
1435
  for (const name of classes.split(/\s+/).filter(Boolean)) {
1436
+ const darkDivide = name.startsWith("dark:") ? name.slice(5) : name, border = divideAsBorder(darkDivide);
1437
+ if (border !== null) {
1438
+ const translated = border && `${name === darkDivide ? "" : "dark:"}${border}`;
1439
+ if (translated) {
1440
+ dividers.push(translated);
1441
+ dividerOriginals.set(translated, name);
1442
+ }
1443
+ continue;
1444
+ }
1411
1445
  const focused = /^(dark:)?(focus|focus-within):(dark:)?(.+)$/.exec(name), focusKey = focused?.[2] === "focus" ? "focus" : "focusWithin";
1412
1446
  if (focused && options[focusKey] && !(focused[1] && focused[3])) {
1413
1447
  const translated = `${focused[1] || focused[3] ? "dark:" : ""}${focused[4]}`, layer = focusLayers[focusKey];
@@ -1454,6 +1488,11 @@ function compileLayer(classes, variables, options = {}) {
1454
1488
  }
1455
1489
  const authoredUnknown = unknown.flatMap((name) => [...originals.get(name) ?? [name]]);
1456
1490
  result.unknown = [...new Set([...authoredUnknown.filter((name) => !/^line-clamp-\d+$/.test(name)), ...unsupported])];
1491
+ if (dividers.length) {
1492
+ const divided = compileLayer(dividers.join(" "), variables);
1493
+ result.divide = { style: divided.style, ...divided.dark ? { dark: divided.dark } : {} };
1494
+ result.unknown = [...new Set([...result.unknown, ...divided.unknown.map((name) => dividerOriginals.get(name) ?? name)])];
1495
+ }
1457
1496
  for (const key of ["focus", "focusWithin"]) {
1458
1497
  const layer = focusLayers[key];
1459
1498
  if (!layer.classes.length)
@@ -1,4 +1,16 @@
1
1
  import type { STXDocument, STXNode } from './ir';
2
+ /**
3
+ * The binding a `{{ }}`-templated string makes, or null when it has none.
4
+ *
5
+ * The server evaluates what it can of a web view's mustaches and leaves the
6
+ * rest (a client signal, a call the device answers) for the browser's
7
+ * runtime, which binds them in the page's text. A native screen has no text
8
+ * nodes for that runtime to find, so a leftover mustache is a binding here,
9
+ * the `:text` or `:placeholder` an author could have written: a single one is
10
+ * its expression, words around it are joined in, and null or undefined reads
11
+ * as nothing, as the browser shows it.
12
+ */
13
+ export declare function mustacheBinding(text: string): string | null;
2
14
  /**
3
15
  * Translate stx's rendered HTML into the native view IR.
4
16
  *
@@ -1,4 +1,5 @@
1
1
  import { ACCESSIBILITY_FIELDS, projectAccessibility } from "../accessibility.js";
2
+ import { applyStaticTextEntry } from "../text-entry.js";
2
3
  import { NATIVE_EVENT_NAMES as EVENT_NAMES } from "../event-names.js";
3
4
  import { NATIVE_BOOLEAN_PROPS, nativePropName } from "../prop-names.js";
4
5
  import { mapToNativeComponent } from "./component-mapping.js";
@@ -10,7 +11,7 @@ import { extractStylesheetTheme } from "./stylesheet-theme.js";
10
11
  import { applySvgAnimation, parseViewBox, SVG_DROPPED, SVG_NODE_TYPES, SVG_TYPES, svgGeometry } from "./svg.js";
11
12
  import { compileClassStyles } from "./headwind-to-style.js";
12
13
  import { createDocument, createNode } from "./ir.js";
13
- const DROP_SUBTREE = new Set(["script", "style", "head", "meta", "link", "title", "base", "noscript"]), UNWRAP = new Set(["template", "body", "html", "main", "fragment"]), BOX_ONLY = new Set;
14
+ const BROWSER_ONLY_EVENTS = /^(?:key(?:down|up|press)|mouse[a-z]+|pointer[a-z]+|dbl(?:click)?|contextmenu|wheel|drag[a-z]*|drop|copy|cut|paste|beforeinput|compositionstart|compositionupdate|compositionend|animation[a-z]+|transition[a-z]+|resize|hashchange|popstate|beforeunload|unload|visibilitychange|selectionchange|selectstart|auxclick)$/, DROP_SUBTREE = new Set(["script", "style", "head", "meta", "link", "title", "base", "noscript"]), UNWRAP = new Set(["template", "body", "html", "main", "fragment"]), BOX_ONLY = new Set;
14
15
  export const NATIVE_EVENTS = new Set([
15
16
  "onBlur",
16
17
  "onChange",
@@ -109,9 +110,28 @@ function decodeEntities(text) {
109
110
  return whole;
110
111
  });
111
112
  }
113
+ export function mustacheBinding(text) {
114
+ if (!text.includes("{{"))
115
+ return null;
116
+ const parts = [];
117
+ let last = 0;
118
+ for (const match of text.matchAll(/\{\{([\s\S]+?)\}\}/g)) {
119
+ if (match.index > last)
120
+ parts.push(JSON.stringify(text.slice(last, match.index)));
121
+ parts.push(`(${match[1].trim()})`);
122
+ last = match.index + match[0].length;
123
+ }
124
+ if (!parts.some((part) => part.startsWith("(")))
125
+ return null;
126
+ if (last < text.length)
127
+ parts.push(JSON.stringify(text.slice(last)));
128
+ if (parts.length === 1)
129
+ return parts[0].slice(1, -1);
130
+ return `[${parts.join(", ")}].map(__stxPart => __stxPart == null ? '' : __stxPart).join('')`;
131
+ }
112
132
  function readAttributes(tag, attributes, diagnostics, styleContext = {}) {
113
133
  let variables = styleContext.inheritedVariables;
114
- const props = {}, events = {}, bindings = {};
134
+ const props = {}, events = {}, bindings = {}, fromMustaches = [];
115
135
  let classes = "", inline = {};
116
136
  for (const [rawName, value] of attributes) {
117
137
  const name = rawName.toLowerCase();
@@ -135,7 +155,8 @@ function readAttributes(tag, attributes, diagnostics, styleContext = {}) {
135
155
  if (name.startsWith("@") || name.startsWith("v-on:")) {
136
156
  const spelling = name.startsWith("@") ? name.slice(1) : name.slice(5), [base] = spelling.split("."), native = EVENT_NAMES[base] ?? (base.startsWith("on") ? base : "");
137
157
  if (!native || !NATIVE_EVENTS.has(native)) {
138
- diagnostics.push({ kind: "unread-event", tag, name: rawName });
158
+ if (BROWSER_ONLY_EVENTS.test(base) || /\./.test(spelling))
159
+ diagnostics.push({ kind: "unread-event", tag, name: rawName });
139
160
  continue;
140
161
  }
141
162
  events[native] = decodeEntities(value);
@@ -145,7 +166,13 @@ function readAttributes(tag, attributes, diagnostics, styleContext = {}) {
145
166
  props.key = value;
146
167
  continue;
147
168
  }
148
- const decoded = decodeEntities(value), prop = nativePropName(rawName);
169
+ const decoded = decodeEntities(value), templated = mustacheBinding(decoded);
170
+ if (templated) {
171
+ bindings[name] = templated;
172
+ fromMustaches.push(name);
173
+ continue;
174
+ }
175
+ const prop = nativePropName(rawName);
149
176
  if (decoded === "" && NATIVE_BOOLEAN_PROPS.has(prop)) {
150
177
  props[prop] = !0;
151
178
  continue;
@@ -160,7 +187,7 @@ function readAttributes(tag, attributes, diagnostics, styleContext = {}) {
160
187
  for (const name of new Set(compiledClasses?.unknown ?? []))
161
188
  diagnostics.push({ kind: "unknown-class", tag, name });
162
189
  const style = applyNativeLayoutDefaults({ ...compiledClasses?.style, ...inline });
163
- return { props, style, events, bindings, classes, inline };
190
+ return { props, style, events, bindings, classes, inline, templated: fromMustaches };
164
191
  }
165
192
  function inlineStyle(tag, css, diagnostics, context) {
166
193
  return parseNativeStyle(decodeEntities(css), (diagnostic) => diagnostics.push({ ...diagnostic, tag }), context);
@@ -215,7 +242,10 @@ function settle(frame, diagnostics) {
215
242
  return node;
216
243
  }
217
244
  export async function translateHtmlToIR(html, options = {}) {
218
- const diagnostics = [], stylesheetTheme = await extractStylesheetTheme(html, (name) => diagnostics.push({ kind: "unsupported-theme-rule", tag: "style", name })), stylesheetVariables = createStyleVariables(stylesheetTheme.light).computed(), stylesheetRules = await extractStylesheetRules(html, (name) => diagnostics.push({ kind: "unsupported-style-rule", tag: "style", name })), roots = [], stack = [], seenUnmapped = new Set;
245
+ const diagnostics = [], stylesheetTheme = await extractStylesheetTheme(html, (name) => diagnostics.push({ kind: "unsupported-theme-rule", tag: "style", name })), stylesheetVariables = createStyleVariables(stylesheetTheme.light).computed(), usedClasses = new Set([...html.matchAll(/\sclass(?:name)?\s*=\s*"([^"]*)"/gi)].flatMap((match) => match[1].split(/\s+/))), stylesheetRules = await extractStylesheetRules(html, (name, classes) => {
246
+ if (!classes.length || classes.some((name) => usedClasses.has(name)))
247
+ diagnostics.push({ kind: "unsupported-style-rule", tag: "style", name });
248
+ }), roots = [], stack = [], seenUnmapped = new Set;
219
249
  function attach(node) {
220
250
  const parent = stack[stack.length - 1];
221
251
  if (!parent)
@@ -257,7 +287,7 @@ export async function translateHtmlToIR(html, options = {}) {
257
287
  return openSvg(tag, attributes, parentFrame);
258
288
  const dropped = DROP_SUBTREE.has(tag) && !BOX_ONLY.has(tag), inheritedDrop = stack[stack.length - 1]?.dropped ?? !1;
259
289
  let variables = parentFrame?.variables ?? stylesheetVariables;
260
- const { props, style, events, bindings, classes, inline } = dropped || inheritedDrop ? { props: {}, style: {}, events: {}, bindings: {}, classes: "", inline: {} } : readAttributes(tag, attributes, diagnostics, { inheritedVariables: variables, onVariables: (value) => {
290
+ const { props, style, events, bindings, classes, inline, templated } = dropped || inheritedDrop ? { props: {}, style: {}, events: {}, bindings: {}, classes: "", inline: {}, templated: [] } : readAttributes(tag, attributes, diagnostics, { inheritedVariables: variables, onVariables: (value) => {
261
291
  variables = value;
262
292
  }, rules: stylesheetRules });
263
293
  if (tag === "html")
@@ -334,6 +364,8 @@ export async function translateHtmlToIR(html, options = {}) {
334
364
  node._classes = classes;
335
365
  if (Object.keys(bindings).length > 0)
336
366
  node.bindings = bindings;
367
+ if (templated.length > 0)
368
+ node._templated = templated;
337
369
  if (typeof props.key === "string") {
338
370
  node.key = props.key;
339
371
  delete props.key;
@@ -358,7 +390,7 @@ export async function translateHtmlToIR(html, options = {}) {
358
390
  return { tag, node: createNode("G", {}, {}, {}), svg: !0, dropped: !0, discard: !0, unwrap: !1 };
359
391
  }
360
392
  let variables = parent?.variables ?? stylesheetVariables;
361
- const { props, style, events, bindings, classes, inline } = readAttributes(tag, attributes, diagnostics, { inheritedVariables: variables, onVariables: (value) => {
393
+ const { props, style, events, bindings, classes, inline, templated } = readAttributes(tag, attributes, diagnostics, { inheritedVariables: variables, onVariables: (value) => {
362
394
  variables = value;
363
395
  }, rules: stylesheetRules });
364
396
  if (type === "Svg") {
@@ -393,6 +425,8 @@ export async function translateHtmlToIR(html, options = {}) {
393
425
  node._classes = classes;
394
426
  if (Object.keys(bindings).length > 0)
395
427
  node.bindings = bindings;
428
+ if (templated.length > 0)
429
+ node._templated = templated;
396
430
  if (typeof props.key === "string") {
397
431
  node.key = props.key;
398
432
  delete props.key;
@@ -439,11 +473,13 @@ export async function translateHtmlToIR(html, options = {}) {
439
473
  if (Object.keys(stylesheetRules).length)
440
474
  root._stylesheetRules = stylesheetRules;
441
475
  const project = (node) => {
476
+ bindMustaches(node);
442
477
  const projected = projectAccessibility(node.props);
443
478
  if (Object.keys(projected).length) {
444
479
  node._accessibilitySource = Object.fromEntries(ACCESSIBILITY_FIELDS.filter((name) => (name in node.props)).map((name) => [name, node.props[name]]));
445
480
  Object.assign(node.props, projected);
446
481
  }
482
+ applyStaticTextEntry(node);
447
483
  for (const child of node.children)
448
484
  if (typeof child !== "string")
449
485
  project(child);
@@ -451,6 +487,25 @@ export async function translateHtmlToIR(html, options = {}) {
451
487
  project(root);
452
488
  return { root, diagnostics };
453
489
  }
490
+ function bindMustaches(node) {
491
+ if (node.bindings?.text || node.children.length === 0 || !node.children.every((child) => typeof child === "string"))
492
+ return;
493
+ const expression = mustacheBinding(node.children.join(""));
494
+ if (!expression)
495
+ return;
496
+ if (node.type === "Text") {
497
+ node.bindings = { ...node.bindings, text: expression };
498
+ node._templated = [...node._templated ?? [], "text"];
499
+ node.children = [];
500
+ } else if (node.type === "Button") {
501
+ node.type = "Pressable";
502
+ node.props.role ??= "button";
503
+ const label = createNode("Text", {}, {}, {}, []);
504
+ label.bindings = { text: expression };
505
+ label._templated = ["text"];
506
+ node.children = [label];
507
+ }
508
+ }
454
509
  export async function translateHtmlToDocument(html, options = {}) {
455
510
  const { root, diagnostics } = await translateHtmlToIR(html, options), script = options.script ?? { exports: {}, functions: [], code: "" };
456
511
  return {
@@ -12,6 +12,7 @@ export declare interface STXNode {
12
12
  key?: string
13
13
  props: Record<string, unknown>
14
14
  _accessibilitySource?: Record<string, unknown>
15
+ _textEntrySource?: Record<string, unknown>
15
16
  style: STXStyle
16
17
  events: Record<string, string>
17
18
  bindings?: Record<string, string>
@@ -24,6 +25,7 @@ export declare interface STXNode {
24
25
  _stylesheetTheme?: NativeStylesheetTheme
25
26
  _stylesheetRules?: NativeStylesheetRules
26
27
  _classes?: string
28
+ _templated?: string[]
27
29
  _source?: {
28
30
  file: string
29
31
  line: number
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { loadStxConfig } from "../../config.js";
4
- import { extractBindingManifest } from "../../binding-manifest.js";
4
+ import { classifyAttribute, extractBindingManifest } from "../../binding-manifest.js";
5
5
  import { processDirectives } from "../../process.js";
6
6
  import { processScriptSetup } from "../../signal-processing.js";
7
7
  import { appThemeCSS } from "./app-theme.js";
@@ -20,12 +20,12 @@ export function nativePrimitivesDir() {
20
20
  return candidates[0];
21
21
  }
22
22
  export async function compileScreenSource(source, filePath, options = {}) {
23
- const root = options.root ?? path.dirname(filePath), loaded = await loadStxConfig(root), fromRoot = (dir, fallback) => dir ? path.isAbsolute(dir) ? dir : path.resolve(root, dir) : path.join(root, fallback), config = {
23
+ const root = options.root ?? path.dirname(filePath), loaded = await loadStxConfig(root), sourceRoot = typeof loaded.root === "string" && loaded.root ? path.resolve(root, loaded.root) : root, fromRoot = (dir, fallback) => dir ? path.isAbsolute(dir) ? dir : path.resolve(sourceRoot, dir) : path.join(sourceRoot, fallback), config = {
24
24
  root,
25
25
  layoutsDir: fromRoot(loaded.layoutsDir, "layouts"),
26
26
  partialsDir: fromRoot(loaded.partialsDir, "partials"),
27
27
  storesDir: fromRoot(loaded.storesDir, "stores"),
28
- componentsDir: options.componentsDir ?? loaded.componentsDir ?? path.join(root, "components"),
28
+ componentsDir: options.componentsDir ?? (loaded.componentsDir ? fromRoot(loaded.componentsDir, "components") : path.join(sourceRoot, "components")),
29
29
  buildMode: "serve",
30
30
  cache: !1,
31
31
  _targetComponentDirs: [nativePrimitivesDir()],
@@ -33,10 +33,12 @@ export async function compileScreenSource(source, filePath, options = {}) {
33
33
  _nativeHostAttrs: !0,
34
34
  skipEventDirectives: !0,
35
35
  _pluginComponentDirs: loaded._pluginComponentDirs ?? []
36
- }, context = { ...options.context ?? {}, __stx_inject_css: !1 }, dependencies = new Set([filePath]), renderedHtml = await processDirectives(source, context, filePath, config, dependencies), { html: content, chrome } = await extractLayoutChrome(renderedHtml), { html, manifest } = extractBindingManifest(content), theme = await appThemeCSS(root), { document, diagnostics } = await translateHtmlToDocument(theme ? `<style>${theme}</style>${html}` : html, {
36
+ }, context = { ...options.context ?? {}, __stx_inject_css: !1, __stx_native_screen: !0 }, dependencies = new Set([filePath]), renderedHtml = await processDirectives(source, context, filePath, config, dependencies), { html: content, chrome } = await extractLayoutChrome(renderedHtml), { html, manifest } = extractBindingManifest(content), theme = await appThemeCSS(root), { document, diagnostics } = await translateHtmlToDocument(theme ? `<style>${theme}</style>${html}` : html, {
37
37
  source: filePath,
38
38
  script: extractClientScript(source)
39
- }), head = context.__stx_runtime_head;
39
+ });
40
+ enterTemplatedBindings(document.root, manifest);
41
+ const head = context.__stx_runtime_head;
40
42
  if (typeof head?.title === "string" && head.title.trim())
41
43
  document.title = head.title.trim();
42
44
  if (chrome)
@@ -66,6 +68,30 @@ export async function compileScreenSource(source, filePath, options = {}) {
66
68
  scripts.unshift({ code: modules });
67
69
  return { document, manifest, setup, scripts, diagnostics, html, dependencies: [...dependencies] };
68
70
  }
71
+ function enterTemplatedBindings(root, manifest) {
72
+ const entries = new Map(manifest.entries.map((entry) => [entry.id, entry]));
73
+ let next = manifest.entries.reduce((highest, entry) => Math.max(highest, entry.id), -1) + 1;
74
+ const visit = (node) => {
75
+ if (node._templated?.length && node.bindings) {
76
+ if (node.bindingId === void 0 || !entries.has(node.bindingId)) {
77
+ const entry = { id: node.bindingId ?? next++, bindings: [] };
78
+ node.bindingId = entry.id;
79
+ entries.set(entry.id, entry);
80
+ manifest.entries.push(entry);
81
+ }
82
+ const entry = entries.get(node.bindingId);
83
+ for (const name of node._templated) {
84
+ const attribute = `:${name}`, kind = classifyAttribute(attribute);
85
+ if (kind && !entry.bindings.some((binding) => binding.name === attribute))
86
+ entry.bindings.push({ name: attribute, value: node.bindings[name], kind });
87
+ }
88
+ }
89
+ for (const child of node.children)
90
+ if (typeof child !== "string")
91
+ visit(child);
92
+ };
93
+ visit(root);
94
+ }
69
95
  export async function compileScreenFile(filePath, options = {}) {
70
96
  return compileScreenSource(await Bun.file(filePath).text(), filePath, options);
71
97
  }
@@ -1,5 +1,5 @@
1
1
  /** The page's simple class rules; anything more involved is reported, not guessed at. */
2
- export declare function extractStylesheetRules(html: string, report: (name: string) => void): Promise<NativeStylesheetRules>;
2
+ export declare function extractStylesheetRules(html: string, report: (name: string, classes: string[]) => void): Promise<NativeStylesheetRules>;
3
3
  /**
4
4
  * A class's declarations from the page's own stylesheets, as CSS text, by
5
5
  * layer: what `.stat-value { ... }` gives an element with that class.
@@ -12,6 +12,6 @@ export declare function extractStylesheetRules(html: string, report: (name: stri
12
12
  export declare interface NativeStylesheetRule {
13
13
  light?: string
14
14
  dark?: string
15
- responsive?: Array<{ min: number, light?: string, dark?: string }>
15
+ responsive?: Array<{ min: number, max?: number, light?: string, dark?: string }>
16
16
  }
17
17
  export type NativeStylesheetRules = Record<string, NativeStylesheetRule>;
@@ -10,29 +10,33 @@ function mediaLayer(query) {
10
10
  return {};
11
11
  if (/prefers-reduced-motion|\(hover|\(pointer|print|forced-colors|prefers-contrast/.test(normalized))
12
12
  return "skip";
13
- const width = /^(?:screenand)?\(min-width:([\d.]+)(px|rem|em)\)$/.exec(normalized);
14
- if (width)
15
- return { min: Number(width[1]) * (width[2] === "px" ? 1 : 16) };
16
- return;
13
+ const parts = normalized.replace(/^screenand/, "").split("and"), layer = {};
14
+ for (const part of parts) {
15
+ const width = /^\((min|max)-width:([\d.]+)(px|rem|em)\)$/.exec(part);
16
+ if (!width)
17
+ return;
18
+ layer[width[1]] = Number(width[2]) * (width[3] === "px" ? 1 : 16);
19
+ }
20
+ return layer;
17
21
  }
18
22
  export async function extractStylesheetRules(html, report) {
19
23
  const rules = {}, reported = new Set, warn = (name) => {
20
- if (!reported.has(name)) {
21
- reported.add(name);
22
- report(name);
23
- }
24
+ if (reported.has(name))
25
+ return;
26
+ reported.add(name);
27
+ report(name, [...name.matchAll(/\.(-?[a-z_][\w-]*)/gi)].map((match) => match[1]));
24
28
  }, append = (name, declarations, layer) => {
25
29
  if (!declarations.trim())
26
30
  return;
27
31
  const rule = rules[name] ??= {}, key = layer.dark ? "dark" : "light";
28
- if (layer.min === void 0) {
32
+ if (layer.min === void 0 && layer.max === void 0) {
29
33
  rule[key] = rule[key] ? `${rule[key]};${declarations}` : declarations;
30
34
  return;
31
35
  }
32
- const responsive = rule.responsive ??= [];
33
- let entry = responsive.find((item) => item.min === layer.min);
36
+ const responsive = rule.responsive ??= [], min = layer.min ?? 0;
37
+ let entry = responsive.find((item) => item.min === min && item.max === layer.max);
34
38
  if (!entry)
35
- responsive.push(entry = { min: layer.min });
39
+ responsive.push(entry = { min, ...layer.max === void 0 ? {} : { max: layer.max } });
36
40
  entry[key] = entry[key] ? `${entry[key]};${declarations}` : declarations;
37
41
  };
38
42
  function visit(nodes, layer) {
@@ -55,14 +59,14 @@ export async function extractStylesheetRules(html, report) {
55
59
  warn(`@media ${query}`);
56
60
  continue;
57
61
  }
58
- visit(node.block.children, { dark: layer.dark || media.dark, min: media.min ?? layer.min });
62
+ visit(node.block.children, { dark: layer.dark || media.dark, min: media.min ?? layer.min, max: media.max ?? layer.max });
59
63
  continue;
60
64
  }
61
65
  if (node.type !== "Rule" || node.block.type !== "Block")
62
66
  continue;
63
67
  const declarations = [...node.block.children].filter((child) => child.type === "Declaration").map((child) => generate(child)).join(";"), selectors = node.prelude.type === "SelectorList" ? [...node.prelude.children].map(generate) : [generate(node.prelude)];
64
68
  for (const selector of selectors) {
65
- const match = /^(?:(?:html|:root)?\.dark\s+)?\.(-?[a-z_][\w-]*)((?::{1,2}[a-z-]+)*)$/i.exec(selector.trim());
69
+ const match = /^(?:(?:html|:root)?\.dark\s+)?((?:\.-?[a-z_][\w-]*)+)((?::{1,2}[a-z-]+)*)$/i.exec(selector.trim());
66
70
  if (!match) {
67
71
  if (!/^(?:html|:root|body|\*|::?[a-z-]+)/i.test(selector.trim()))
68
72
  warn(selector.trim());
@@ -75,7 +79,7 @@ export async function extractStylesheetRules(html, report) {
75
79
  continue;
76
80
  }
77
81
  const dark = layer.dark || /^(?:(?:html|:root)?\.dark\s+)/i.test(selector.trim());
78
- append(match[1], declarations, { dark, min: layer.min });
82
+ append(match[1].slice(1), declarations, { dark, min: layer.min, max: layer.max });
79
83
  }
80
84
  }
81
85
  }
@@ -102,6 +106,6 @@ export async function extractStylesheetRules(html, report) {
102
106
  }
103
107
  }).transform(new Response(html)).text();
104
108
  for (const rule of Object.values(rules))
105
- rule.responsive?.sort((a, b) => a.min - b.min);
109
+ rule.responsive?.sort((a, b) => a.min - b.min || (a.max ?? 1 / 0) - (b.max ?? 1 / 0));
106
110
  return rules;
107
111
  }
@@ -1,4 +1,5 @@
1
1
  import { authoredAccessibilityProps } from "../accessibility.js";
2
+ import { authoredTextEntryProps } from "../text-entry.js";
2
3
  function decodeBindingValue(value) {
3
4
  return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#0?39;/g, "'").replace(/&#x27;/gi, "'").replace(/&amp;/g, "&");
4
5
  }
@@ -107,7 +108,7 @@ export function materializeNativeBindingTree(document, manifest, host) {
107
108
  const node = createBindingNode(id, source.type, runtimeBindings, !0, source._classes, (value) => host.setAttribute(node, "class", value));
108
109
  if (source.type === "Checkbox" && source.props.type === "checkbox")
109
110
  node.tagName = "INPUT";
110
- for (const [name, value] of Object.entries(authoredAccessibilityProps(source.props, source._accessibilitySource))) {
111
+ for (const [name, value] of Object.entries(authoredTextEntryProps(authoredAccessibilityProps(source.props, source._accessibilitySource), source._textEntrySource))) {
111
112
  if (value === void 0 || value === null || name === "__stxId")
112
113
  continue;
113
114
  node.setAttribute(name, typeof value === "object" ? JSON.stringify(value) : String(value));
@@ -8,5 +8,7 @@ export declare interface CraftBridgeOptions {
8
8
  routeNames?: string[]
9
9
  title?: string
10
10
  chrome?: NativeLayoutChrome
11
+ shareStorage?: Record<string, string>
12
+ source?: string
11
13
  }
12
14
  declare type AnyRecord = Record<string, any>;
@@ -2,7 +2,7 @@ import { STXBridge } from "../bridge/protocol.js";
2
2
  import { createEventSourceClass, createStreamingBody } from "./event-stream.js";
3
3
  import { abortError, isNativeDocument, NativeFormData, nativeFormParts, updateNativeDocumentVisibility } from "./jsc-globals.js";
4
4
  import { buttonsKey, changedTabItems, chromePath, hostButton, mergeChromeButtons } from "./navigation-chrome.js";
5
- import { installNativeNavigation } from "./web-navigation.js";
5
+ import { installNativeNavigation, nativeRouteParams } from "./web-navigation.js";
6
6
  import { installNativeWebStorage } from "./web-storage.js";
7
7
  function capabilityFlags(capabilities) {
8
8
  return {
@@ -186,8 +186,6 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
186
186
  return request("Storage", "compareAndSet", [key, expectedValue, nextValue]);
187
187
  }
188
188
  });
189
- if (isNativeDocument(target.document))
190
- installNativeWebStorage(target, craft);
191
189
  craft.secureStorage = Object.assign({ getSync: () => null }, craft.secureStorage || {}, {
192
190
  get: (key) => request("SecureStorage", "get", [key]),
193
191
  set: (key, value) => request("SecureStorage", "set", [key, value]),
@@ -212,6 +210,15 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
212
210
  callback(token, previous);
213
211
  })
214
212
  });
213
+ if (isNativeDocument(target.document)) {
214
+ const shareStorage = { ...options.shareStorage, ...nativeBridge.shareStorage }, shared = installNativeWebStorage(target, craft, {
215
+ shareStorage,
216
+ ...capabilities.has("secureStorage") ? { secure: () => craft.secureStorage } : {},
217
+ adopted: (key, value) => target.dispatchEvent?.(new target.CustomEvent("craftsharedstorage", { detail: { key, value } }))
218
+ });
219
+ if (shared)
220
+ craft.session.onChange(() => shared.changed(sessionKey));
221
+ }
215
222
  craft.snapshots = Object.assign({ get: () => null, set: () => Promise.resolve(!1) }, craft.snapshots || {}, {
216
223
  onChange: (callback) => protocol.on("SNAPSHOT_CHANGED", (message) => {
217
224
  if (typeof message.payload?.name === "string")
@@ -709,6 +716,9 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
709
716
  }
710
717
  if (isNativeDocument(target.document)) {
711
718
  installNativeNavigation(target, craft, { routeURL: nativeBridge.routeURL, appURL: craft.app?.url });
719
+ const pathParams = options.source ? nativeRouteParams(options.source, String(target.location?.pathname ?? "/")) : {};
720
+ target.__stx_rp = { ...pathParams, ...craft.route.params };
721
+ craft.route.onParams((params) => target.stx?.setRouteParams?.({ ...pathParams, ...params }));
712
722
  let title = typeof options.title === "string" ? options.title : "";
713
723
  Object.defineProperty(target.document, "title", {
714
724
  configurable: !0,
@@ -23,6 +23,7 @@ export declare interface NativeHostOptions {
23
23
  send: (operations: NativeMutationOperation[]) => void
24
24
  schedule?: (flush: () => void) => void
25
25
  followLink?: (href: string) => void
26
+ linkState?: (href: string, match: string | null) => { active: boolean, exact: boolean } | null
26
27
  }
27
28
  export declare interface NativeHost {
28
29
  readonly isNative: true