@wireweave/core 3.1.0-beta.10 → 3.1.0-beta.11

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/index.js CHANGED
@@ -624,10 +624,14 @@ var peg$SyntaxError = class extends SyntaxError {
624
624
  return s;
625
625
  }
626
626
  function literalEscape(s) {
627
- return unicodeEscape(s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)));
627
+ return unicodeEscape(
628
+ s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch))
629
+ );
628
630
  }
629
631
  function classEscape(s) {
630
- return unicodeEscape(s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)));
632
+ return unicodeEscape(
633
+ s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch))
634
+ );
631
635
  }
632
636
  const DESCRIBE_EXPECTATION_FNS = {
633
637
  literal(expectation) {
@@ -864,7 +868,12 @@ function peg$parse(input, options) {
864
868
  const peg$e75 = peg$classExpectation([["0", "9"]], false, false, false);
865
869
  const peg$e76 = peg$literalExpectation("at", false);
866
870
  const peg$e77 = peg$classExpectation(["=", "[", "{", "}"], false, false, false);
867
- const peg$e78 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], false, false, false);
871
+ const peg$e78 = peg$classExpectation(
872
+ [["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"],
873
+ false,
874
+ false,
875
+ false
876
+ );
868
877
  const peg$e79 = peg$otherExpectation("string");
869
878
  const peg$e80 = peg$literalExpectation('"', false);
870
879
  const peg$e81 = peg$literalExpectation("'", false);
@@ -6609,7 +6618,10 @@ function peg$parse(input, options) {
6609
6618
  }
6610
6619
  }
6611
6620
  if (s1 === peg$FAILED) {
6612
- if (input.substr(peg$currPos, 5) === peg$c57) {
6621
+ if (input.substr(
6622
+ peg$currPos,
6623
+ 5
6624
+ ) === peg$c57) {
6613
6625
  s1 = peg$c57;
6614
6626
  peg$currPos += 5;
6615
6627
  } else {
@@ -6619,7 +6631,10 @@ function peg$parse(input, options) {
6619
6631
  }
6620
6632
  }
6621
6633
  if (s1 === peg$FAILED) {
6622
- if (input.substr(peg$currPos, 8) === peg$c58) {
6634
+ if (input.substr(
6635
+ peg$currPos,
6636
+ 8
6637
+ ) === peg$c58) {
6623
6638
  s1 = peg$c58;
6624
6639
  peg$currPos += 8;
6625
6640
  } else {
@@ -6629,7 +6644,10 @@ function peg$parse(input, options) {
6629
6644
  }
6630
6645
  }
6631
6646
  if (s1 === peg$FAILED) {
6632
- if (input.substr(peg$currPos, 7) === peg$c59) {
6647
+ if (input.substr(
6648
+ peg$currPos,
6649
+ 7
6650
+ ) === peg$c59) {
6633
6651
  s1 = peg$c59;
6634
6652
  peg$currPos += 7;
6635
6653
  } else {
@@ -6639,7 +6657,10 @@ function peg$parse(input, options) {
6639
6657
  }
6640
6658
  }
6641
6659
  if (s1 === peg$FAILED) {
6642
- if (input.substr(peg$currPos, 7) === peg$c60) {
6660
+ if (input.substr(
6661
+ peg$currPos,
6662
+ 7
6663
+ ) === peg$c60) {
6643
6664
  s1 = peg$c60;
6644
6665
  peg$currPos += 7;
6645
6666
  } else {
@@ -6649,7 +6670,10 @@ function peg$parse(input, options) {
6649
6670
  }
6650
6671
  }
6651
6672
  if (s1 === peg$FAILED) {
6652
- if (input.substr(peg$currPos, 7) === peg$c61) {
6673
+ if (input.substr(
6674
+ peg$currPos,
6675
+ 7
6676
+ ) === peg$c61) {
6653
6677
  s1 = peg$c61;
6654
6678
  peg$currPos += 7;
6655
6679
  } else {
@@ -6659,7 +6683,10 @@ function peg$parse(input, options) {
6659
6683
  }
6660
6684
  }
6661
6685
  if (s1 === peg$FAILED) {
6662
- if (input.substr(peg$currPos, 8) === peg$c62) {
6686
+ if (input.substr(
6687
+ peg$currPos,
6688
+ 8
6689
+ ) === peg$c62) {
6663
6690
  s1 = peg$c62;
6664
6691
  peg$currPos += 8;
6665
6692
  } else {
@@ -6669,143 +6696,213 @@ function peg$parse(input, options) {
6669
6696
  }
6670
6697
  }
6671
6698
  if (s1 === peg$FAILED) {
6672
- if (input.substr(peg$currPos, 7) === peg$c63) {
6699
+ if (input.substr(
6700
+ peg$currPos,
6701
+ 7
6702
+ ) === peg$c63) {
6673
6703
  s1 = peg$c63;
6674
6704
  peg$currPos += 7;
6675
6705
  } else {
6676
6706
  s1 = peg$FAILED;
6677
6707
  if (peg$silentFails === 0) {
6678
- peg$fail(peg$e66);
6708
+ peg$fail(
6709
+ peg$e66
6710
+ );
6679
6711
  }
6680
6712
  }
6681
6713
  if (s1 === peg$FAILED) {
6682
- if (input.substr(peg$currPos, 3) === peg$c64) {
6714
+ if (input.substr(
6715
+ peg$currPos,
6716
+ 3
6717
+ ) === peg$c64) {
6683
6718
  s1 = peg$c64;
6684
6719
  peg$currPos += 3;
6685
6720
  } else {
6686
6721
  s1 = peg$FAILED;
6687
6722
  if (peg$silentFails === 0) {
6688
- peg$fail(peg$e67);
6723
+ peg$fail(
6724
+ peg$e67
6725
+ );
6689
6726
  }
6690
6727
  }
6691
6728
  if (s1 === peg$FAILED) {
6692
- if (input.substr(peg$currPos, 4) === peg$c66) {
6729
+ if (input.substr(
6730
+ peg$currPos,
6731
+ 4
6732
+ ) === peg$c66) {
6693
6733
  s1 = peg$c66;
6694
6734
  peg$currPos += 4;
6695
6735
  } else {
6696
6736
  s1 = peg$FAILED;
6697
6737
  if (peg$silentFails === 0) {
6698
- peg$fail(peg$e69);
6738
+ peg$fail(
6739
+ peg$e69
6740
+ );
6699
6741
  }
6700
6742
  }
6701
6743
  if (s1 === peg$FAILED) {
6702
- if (input.substr(peg$currPos, 3) === peg$c67) {
6744
+ if (input.substr(
6745
+ peg$currPos,
6746
+ 3
6747
+ ) === peg$c67) {
6703
6748
  s1 = peg$c67;
6704
6749
  peg$currPos += 3;
6705
6750
  } else {
6706
6751
  s1 = peg$FAILED;
6707
6752
  if (peg$silentFails === 0) {
6708
- peg$fail(peg$e70);
6753
+ peg$fail(
6754
+ peg$e70
6755
+ );
6709
6756
  }
6710
6757
  }
6711
6758
  if (s1 === peg$FAILED) {
6712
- if (input.substr(peg$currPos, 10) === peg$c68) {
6759
+ if (input.substr(
6760
+ peg$currPos,
6761
+ 10
6762
+ ) === peg$c68) {
6713
6763
  s1 = peg$c68;
6714
6764
  peg$currPos += 10;
6715
6765
  } else {
6716
6766
  s1 = peg$FAILED;
6717
6767
  if (peg$silentFails === 0) {
6718
- peg$fail(peg$e71);
6768
+ peg$fail(
6769
+ peg$e71
6770
+ );
6719
6771
  }
6720
6772
  }
6721
6773
  if (s1 === peg$FAILED) {
6722
- if (input.substr(peg$currPos, 5) === peg$c65) {
6774
+ if (input.substr(
6775
+ peg$currPos,
6776
+ 5
6777
+ ) === peg$c65) {
6723
6778
  s1 = peg$c65;
6724
6779
  peg$currPos += 5;
6725
6780
  } else {
6726
6781
  s1 = peg$FAILED;
6727
6782
  if (peg$silentFails === 0) {
6728
- peg$fail(peg$e68);
6783
+ peg$fail(
6784
+ peg$e68
6785
+ );
6729
6786
  }
6730
6787
  }
6731
6788
  if (s1 === peg$FAILED) {
6732
- if (input.substr(peg$currPos, 6) === peg$c69) {
6789
+ if (input.substr(
6790
+ peg$currPos,
6791
+ 6
6792
+ ) === peg$c69) {
6733
6793
  s1 = peg$c69;
6734
6794
  peg$currPos += 6;
6735
6795
  } else {
6736
6796
  s1 = peg$FAILED;
6737
6797
  if (peg$silentFails === 0) {
6738
- peg$fail(peg$e72);
6798
+ peg$fail(
6799
+ peg$e72
6800
+ );
6739
6801
  }
6740
6802
  }
6741
6803
  if (s1 === peg$FAILED) {
6742
- if (input.substr(peg$currPos, 11) === peg$c70) {
6804
+ if (input.substr(
6805
+ peg$currPos,
6806
+ 11
6807
+ ) === peg$c70) {
6743
6808
  s1 = peg$c70;
6744
6809
  peg$currPos += 11;
6745
6810
  } else {
6746
6811
  s1 = peg$FAILED;
6747
6812
  if (peg$silentFails === 0) {
6748
- peg$fail(peg$e73);
6813
+ peg$fail(
6814
+ peg$e73
6815
+ );
6749
6816
  }
6750
6817
  }
6751
6818
  if (s1 === peg$FAILED) {
6752
- if (input.substr(peg$currPos, 6) === peg$c20) {
6819
+ if (input.substr(
6820
+ peg$currPos,
6821
+ 6
6822
+ ) === peg$c20) {
6753
6823
  s1 = peg$c20;
6754
6824
  peg$currPos += 6;
6755
6825
  } else {
6756
6826
  s1 = peg$FAILED;
6757
6827
  if (peg$silentFails === 0) {
6758
- peg$fail(peg$e23);
6828
+ peg$fail(
6829
+ peg$e23
6830
+ );
6759
6831
  }
6760
6832
  }
6761
6833
  if (s1 === peg$FAILED) {
6762
- if (input.substr(peg$currPos, 6) === peg$c3) {
6834
+ if (input.substr(
6835
+ peg$currPos,
6836
+ 6
6837
+ ) === peg$c3) {
6763
6838
  s1 = peg$c3;
6764
6839
  peg$currPos += 6;
6765
6840
  } else {
6766
6841
  s1 = peg$FAILED;
6767
6842
  if (peg$silentFails === 0) {
6768
- peg$fail(peg$e3);
6843
+ peg$fail(
6844
+ peg$e3
6845
+ );
6769
6846
  }
6770
6847
  }
6771
6848
  if (s1 === peg$FAILED) {
6772
- if (input.substr(peg$currPos, 9) === peg$c4) {
6849
+ if (input.substr(
6850
+ peg$currPos,
6851
+ 9
6852
+ ) === peg$c4) {
6773
6853
  s1 = peg$c4;
6774
6854
  peg$currPos += 9;
6775
6855
  } else {
6776
6856
  s1 = peg$FAILED;
6777
6857
  if (peg$silentFails === 0) {
6778
- peg$fail(peg$e4);
6858
+ peg$fail(
6859
+ peg$e4
6860
+ );
6779
6861
  }
6780
6862
  }
6781
6863
  if (s1 === peg$FAILED) {
6782
- if (input.substr(peg$currPos, 3) === peg$c12) {
6864
+ if (input.substr(
6865
+ peg$currPos,
6866
+ 3
6867
+ ) === peg$c12) {
6783
6868
  s1 = peg$c12;
6784
6869
  peg$currPos += 3;
6785
6870
  } else {
6786
6871
  s1 = peg$FAILED;
6787
6872
  if (peg$silentFails === 0) {
6788
- peg$fail(peg$e12);
6873
+ peg$fail(
6874
+ peg$e12
6875
+ );
6789
6876
  }
6790
6877
  }
6791
6878
  if (s1 === peg$FAILED) {
6792
- if (input.substr(peg$currPos, 4) === peg$c15) {
6879
+ if (input.substr(
6880
+ peg$currPos,
6881
+ 4
6882
+ ) === peg$c15) {
6793
6883
  s1 = peg$c15;
6794
6884
  peg$currPos += 4;
6795
6885
  } else {
6796
6886
  s1 = peg$FAILED;
6797
6887
  if (peg$silentFails === 0) {
6798
- peg$fail(peg$e15);
6888
+ peg$fail(
6889
+ peg$e15
6890
+ );
6799
6891
  }
6800
6892
  }
6801
6893
  if (s1 === peg$FAILED) {
6802
- if (input.substr(peg$currPos, 4) === peg$c16) {
6894
+ if (input.substr(
6895
+ peg$currPos,
6896
+ 4
6897
+ ) === peg$c16) {
6803
6898
  s1 = peg$c16;
6804
6899
  peg$currPos += 4;
6805
6900
  } else {
6806
6901
  s1 = peg$FAILED;
6807
6902
  if (peg$silentFails === 0) {
6808
- peg$fail(peg$e16);
6903
+ peg$fail(
6904
+ peg$e16
6905
+ );
6809
6906
  }
6810
6907
  }
6811
6908
  }
@@ -8433,12 +8530,7 @@ var GRAMMAR_ELEMENTS = {
8433
8530
  annotations: "Annotations",
8434
8531
  item: "AnnotationItem"
8435
8532
  };
8436
- var GRAMMAR_BLOCK_NODE_TYPES = [
8437
- "ListItem",
8438
- "DropdownItem",
8439
- "NavGroup",
8440
- "NavItem"
8441
- ];
8533
+ var GRAMMAR_BLOCK_NODE_TYPES = ["ListItem", "DropdownItem", "NavGroup", "NavItem"];
8442
8534
  var GRAMMAR_CHILD_KEYWORDS = [
8443
8535
  "page",
8444
8536
  "header",
@@ -14404,6 +14496,7 @@ var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
14404
14496
  var TYPED_INTERACTION_ATTR = "data-wf-on";
14405
14497
  var VISIBLE_GUARD_ATTR = "data-wf-visible-when";
14406
14498
  var ENABLED_GUARD_ATTR = "data-wf-enabled-when";
14499
+ var VARIANT_SCOPE_ATTR = "data-wf-variant-scope";
14407
14500
  var INERT_HREF = "#";
14408
14501
  function guardedOutcomeAttrs(node) {
14409
14502
  const visible = normalizeStateGuard(node.visibleWhen);
@@ -61973,6 +62066,28 @@ function injectAnchorAttrs(html, path, loc) {
61973
62066
  const attrs2 = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
61974
62067
  return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs2}`);
61975
62068
  }
62069
+ var GUARD_ATTR_RENDERERS = /* @__PURE__ */ new Set([
62070
+ "Card",
62071
+ "Button",
62072
+ "Image",
62073
+ "Avatar",
62074
+ "Badge",
62075
+ "Icon",
62076
+ "Link"
62077
+ ]);
62078
+ function collectNodeMarkerAttrs(node) {
62079
+ const markers = /* @__PURE__ */ new Map();
62080
+ if (!GUARD_ATTR_RENDERERS.has(node.type)) {
62081
+ for (const [name, value] of Object.entries(
62082
+ guardedOutcomeAttrs(node)
62083
+ )) {
62084
+ if (value !== void 0) markers.set(name, value);
62085
+ }
62086
+ }
62087
+ const scope = variantScope(node);
62088
+ if (scope !== void 0) markers.set(VARIANT_SCOPE_ATTR, JSON.stringify(scope));
62089
+ return Object.fromEntries(markers);
62090
+ }
61976
62091
  var SPACING_TOKENS = {
61977
62092
  0: "0px",
61978
62093
  1: "4px",
@@ -62210,14 +62325,9 @@ ${annotationsContent}
62210
62325
  renderNode(node) {
62211
62326
  const renderer = this.nodeRenderers[node.type];
62212
62327
  let html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
62213
- const guardAttrs = Object.fromEntries(
62214
- Object.entries(guardedOutcomeAttrs(node)).filter(
62215
- ([name, value]) => value !== void 0 && !html.includes(` ${name}=`)
62216
- )
62217
- );
62218
- const guardAttrString = this.buildAttrsString(guardAttrs);
62219
- if (guardAttrString.length > 0) {
62220
- html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${guardAttrString}`);
62328
+ const markerAttrString = this.buildAttrsString(collectNodeMarkerAttrs(node));
62329
+ if (markerAttrString.length > 0) {
62330
+ html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${markerAttrString}`);
62221
62331
  }
62222
62332
  if (this.pathMap && node.type !== "Page") {
62223
62333
  const path = this.pathMap.get(node);
@@ -63092,6 +63202,18 @@ function siteRuntime(registry, prefix) {
63092
63202
  }
63093
63203
  }
63094
63204
 
63205
+ function applyVariantScopes() {
63206
+ var screen = current === null ? null : screens[current];
63207
+ var variant = screen ? screen.getAttribute('data-wf-variant') : null;
63208
+ var scoped = site.querySelectorAll('[' + ${embedJson(VARIANT_SCOPE_ATTR)} + ']');
63209
+ for (var i = 0; i < scoped.length; i++) {
63210
+ var names = parseJson(scoped[i].getAttribute(${embedJson(VARIANT_SCOPE_ATTR)}), []);
63211
+ var visible = variant !== null && names.indexOf(variant) >= 0;
63212
+ if (visible) scoped[i].removeAttribute('hidden');
63213
+ else scoped[i].setAttribute('hidden', 'hidden');
63214
+ }
63215
+ }
63216
+
63095
63217
  function applyEffects(handler) {
63096
63218
  for (var i = 0; i < handler.effects.length; i++) {
63097
63219
  var effect = handler.effects[i];
@@ -63175,6 +63297,7 @@ function siteRuntime(registry, prefix) {
63175
63297
  current = key;
63176
63298
  closeOverlays(key);
63177
63299
  markActive(key);
63300
+ applyVariantScopes();
63178
63301
  applyOutcomes();
63179
63302
 
63180
63303
  if (writeFragment) {