@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.cjs CHANGED
@@ -830,10 +830,14 @@ var peg$SyntaxError = class extends SyntaxError {
830
830
  return s;
831
831
  }
832
832
  function literalEscape(s) {
833
- 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)));
833
+ return unicodeEscape(
834
+ 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))
835
+ );
834
836
  }
835
837
  function classEscape(s) {
836
- 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)));
838
+ return unicodeEscape(
839
+ 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))
840
+ );
837
841
  }
838
842
  const DESCRIBE_EXPECTATION_FNS = {
839
843
  literal(expectation) {
@@ -1070,7 +1074,12 @@ function peg$parse(input, options) {
1070
1074
  const peg$e75 = peg$classExpectation([["0", "9"]], false, false, false);
1071
1075
  const peg$e76 = peg$literalExpectation("at", false);
1072
1076
  const peg$e77 = peg$classExpectation(["=", "[", "{", "}"], false, false, false);
1073
- const peg$e78 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], false, false, false);
1077
+ const peg$e78 = peg$classExpectation(
1078
+ [["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"],
1079
+ false,
1080
+ false,
1081
+ false
1082
+ );
1074
1083
  const peg$e79 = peg$otherExpectation("string");
1075
1084
  const peg$e80 = peg$literalExpectation('"', false);
1076
1085
  const peg$e81 = peg$literalExpectation("'", false);
@@ -6815,7 +6824,10 @@ function peg$parse(input, options) {
6815
6824
  }
6816
6825
  }
6817
6826
  if (s1 === peg$FAILED) {
6818
- if (input.substr(peg$currPos, 5) === peg$c57) {
6827
+ if (input.substr(
6828
+ peg$currPos,
6829
+ 5
6830
+ ) === peg$c57) {
6819
6831
  s1 = peg$c57;
6820
6832
  peg$currPos += 5;
6821
6833
  } else {
@@ -6825,7 +6837,10 @@ function peg$parse(input, options) {
6825
6837
  }
6826
6838
  }
6827
6839
  if (s1 === peg$FAILED) {
6828
- if (input.substr(peg$currPos, 8) === peg$c58) {
6840
+ if (input.substr(
6841
+ peg$currPos,
6842
+ 8
6843
+ ) === peg$c58) {
6829
6844
  s1 = peg$c58;
6830
6845
  peg$currPos += 8;
6831
6846
  } else {
@@ -6835,7 +6850,10 @@ function peg$parse(input, options) {
6835
6850
  }
6836
6851
  }
6837
6852
  if (s1 === peg$FAILED) {
6838
- if (input.substr(peg$currPos, 7) === peg$c59) {
6853
+ if (input.substr(
6854
+ peg$currPos,
6855
+ 7
6856
+ ) === peg$c59) {
6839
6857
  s1 = peg$c59;
6840
6858
  peg$currPos += 7;
6841
6859
  } else {
@@ -6845,7 +6863,10 @@ function peg$parse(input, options) {
6845
6863
  }
6846
6864
  }
6847
6865
  if (s1 === peg$FAILED) {
6848
- if (input.substr(peg$currPos, 7) === peg$c60) {
6866
+ if (input.substr(
6867
+ peg$currPos,
6868
+ 7
6869
+ ) === peg$c60) {
6849
6870
  s1 = peg$c60;
6850
6871
  peg$currPos += 7;
6851
6872
  } else {
@@ -6855,7 +6876,10 @@ function peg$parse(input, options) {
6855
6876
  }
6856
6877
  }
6857
6878
  if (s1 === peg$FAILED) {
6858
- if (input.substr(peg$currPos, 7) === peg$c61) {
6879
+ if (input.substr(
6880
+ peg$currPos,
6881
+ 7
6882
+ ) === peg$c61) {
6859
6883
  s1 = peg$c61;
6860
6884
  peg$currPos += 7;
6861
6885
  } else {
@@ -6865,7 +6889,10 @@ function peg$parse(input, options) {
6865
6889
  }
6866
6890
  }
6867
6891
  if (s1 === peg$FAILED) {
6868
- if (input.substr(peg$currPos, 8) === peg$c62) {
6892
+ if (input.substr(
6893
+ peg$currPos,
6894
+ 8
6895
+ ) === peg$c62) {
6869
6896
  s1 = peg$c62;
6870
6897
  peg$currPos += 8;
6871
6898
  } else {
@@ -6875,143 +6902,213 @@ function peg$parse(input, options) {
6875
6902
  }
6876
6903
  }
6877
6904
  if (s1 === peg$FAILED) {
6878
- if (input.substr(peg$currPos, 7) === peg$c63) {
6905
+ if (input.substr(
6906
+ peg$currPos,
6907
+ 7
6908
+ ) === peg$c63) {
6879
6909
  s1 = peg$c63;
6880
6910
  peg$currPos += 7;
6881
6911
  } else {
6882
6912
  s1 = peg$FAILED;
6883
6913
  if (peg$silentFails === 0) {
6884
- peg$fail(peg$e66);
6914
+ peg$fail(
6915
+ peg$e66
6916
+ );
6885
6917
  }
6886
6918
  }
6887
6919
  if (s1 === peg$FAILED) {
6888
- if (input.substr(peg$currPos, 3) === peg$c64) {
6920
+ if (input.substr(
6921
+ peg$currPos,
6922
+ 3
6923
+ ) === peg$c64) {
6889
6924
  s1 = peg$c64;
6890
6925
  peg$currPos += 3;
6891
6926
  } else {
6892
6927
  s1 = peg$FAILED;
6893
6928
  if (peg$silentFails === 0) {
6894
- peg$fail(peg$e67);
6929
+ peg$fail(
6930
+ peg$e67
6931
+ );
6895
6932
  }
6896
6933
  }
6897
6934
  if (s1 === peg$FAILED) {
6898
- if (input.substr(peg$currPos, 4) === peg$c66) {
6935
+ if (input.substr(
6936
+ peg$currPos,
6937
+ 4
6938
+ ) === peg$c66) {
6899
6939
  s1 = peg$c66;
6900
6940
  peg$currPos += 4;
6901
6941
  } else {
6902
6942
  s1 = peg$FAILED;
6903
6943
  if (peg$silentFails === 0) {
6904
- peg$fail(peg$e69);
6944
+ peg$fail(
6945
+ peg$e69
6946
+ );
6905
6947
  }
6906
6948
  }
6907
6949
  if (s1 === peg$FAILED) {
6908
- if (input.substr(peg$currPos, 3) === peg$c67) {
6950
+ if (input.substr(
6951
+ peg$currPos,
6952
+ 3
6953
+ ) === peg$c67) {
6909
6954
  s1 = peg$c67;
6910
6955
  peg$currPos += 3;
6911
6956
  } else {
6912
6957
  s1 = peg$FAILED;
6913
6958
  if (peg$silentFails === 0) {
6914
- peg$fail(peg$e70);
6959
+ peg$fail(
6960
+ peg$e70
6961
+ );
6915
6962
  }
6916
6963
  }
6917
6964
  if (s1 === peg$FAILED) {
6918
- if (input.substr(peg$currPos, 10) === peg$c68) {
6965
+ if (input.substr(
6966
+ peg$currPos,
6967
+ 10
6968
+ ) === peg$c68) {
6919
6969
  s1 = peg$c68;
6920
6970
  peg$currPos += 10;
6921
6971
  } else {
6922
6972
  s1 = peg$FAILED;
6923
6973
  if (peg$silentFails === 0) {
6924
- peg$fail(peg$e71);
6974
+ peg$fail(
6975
+ peg$e71
6976
+ );
6925
6977
  }
6926
6978
  }
6927
6979
  if (s1 === peg$FAILED) {
6928
- if (input.substr(peg$currPos, 5) === peg$c65) {
6980
+ if (input.substr(
6981
+ peg$currPos,
6982
+ 5
6983
+ ) === peg$c65) {
6929
6984
  s1 = peg$c65;
6930
6985
  peg$currPos += 5;
6931
6986
  } else {
6932
6987
  s1 = peg$FAILED;
6933
6988
  if (peg$silentFails === 0) {
6934
- peg$fail(peg$e68);
6989
+ peg$fail(
6990
+ peg$e68
6991
+ );
6935
6992
  }
6936
6993
  }
6937
6994
  if (s1 === peg$FAILED) {
6938
- if (input.substr(peg$currPos, 6) === peg$c69) {
6995
+ if (input.substr(
6996
+ peg$currPos,
6997
+ 6
6998
+ ) === peg$c69) {
6939
6999
  s1 = peg$c69;
6940
7000
  peg$currPos += 6;
6941
7001
  } else {
6942
7002
  s1 = peg$FAILED;
6943
7003
  if (peg$silentFails === 0) {
6944
- peg$fail(peg$e72);
7004
+ peg$fail(
7005
+ peg$e72
7006
+ );
6945
7007
  }
6946
7008
  }
6947
7009
  if (s1 === peg$FAILED) {
6948
- if (input.substr(peg$currPos, 11) === peg$c70) {
7010
+ if (input.substr(
7011
+ peg$currPos,
7012
+ 11
7013
+ ) === peg$c70) {
6949
7014
  s1 = peg$c70;
6950
7015
  peg$currPos += 11;
6951
7016
  } else {
6952
7017
  s1 = peg$FAILED;
6953
7018
  if (peg$silentFails === 0) {
6954
- peg$fail(peg$e73);
7019
+ peg$fail(
7020
+ peg$e73
7021
+ );
6955
7022
  }
6956
7023
  }
6957
7024
  if (s1 === peg$FAILED) {
6958
- if (input.substr(peg$currPos, 6) === peg$c20) {
7025
+ if (input.substr(
7026
+ peg$currPos,
7027
+ 6
7028
+ ) === peg$c20) {
6959
7029
  s1 = peg$c20;
6960
7030
  peg$currPos += 6;
6961
7031
  } else {
6962
7032
  s1 = peg$FAILED;
6963
7033
  if (peg$silentFails === 0) {
6964
- peg$fail(peg$e23);
7034
+ peg$fail(
7035
+ peg$e23
7036
+ );
6965
7037
  }
6966
7038
  }
6967
7039
  if (s1 === peg$FAILED) {
6968
- if (input.substr(peg$currPos, 6) === peg$c3) {
7040
+ if (input.substr(
7041
+ peg$currPos,
7042
+ 6
7043
+ ) === peg$c3) {
6969
7044
  s1 = peg$c3;
6970
7045
  peg$currPos += 6;
6971
7046
  } else {
6972
7047
  s1 = peg$FAILED;
6973
7048
  if (peg$silentFails === 0) {
6974
- peg$fail(peg$e3);
7049
+ peg$fail(
7050
+ peg$e3
7051
+ );
6975
7052
  }
6976
7053
  }
6977
7054
  if (s1 === peg$FAILED) {
6978
- if (input.substr(peg$currPos, 9) === peg$c4) {
7055
+ if (input.substr(
7056
+ peg$currPos,
7057
+ 9
7058
+ ) === peg$c4) {
6979
7059
  s1 = peg$c4;
6980
7060
  peg$currPos += 9;
6981
7061
  } else {
6982
7062
  s1 = peg$FAILED;
6983
7063
  if (peg$silentFails === 0) {
6984
- peg$fail(peg$e4);
7064
+ peg$fail(
7065
+ peg$e4
7066
+ );
6985
7067
  }
6986
7068
  }
6987
7069
  if (s1 === peg$FAILED) {
6988
- if (input.substr(peg$currPos, 3) === peg$c12) {
7070
+ if (input.substr(
7071
+ peg$currPos,
7072
+ 3
7073
+ ) === peg$c12) {
6989
7074
  s1 = peg$c12;
6990
7075
  peg$currPos += 3;
6991
7076
  } else {
6992
7077
  s1 = peg$FAILED;
6993
7078
  if (peg$silentFails === 0) {
6994
- peg$fail(peg$e12);
7079
+ peg$fail(
7080
+ peg$e12
7081
+ );
6995
7082
  }
6996
7083
  }
6997
7084
  if (s1 === peg$FAILED) {
6998
- if (input.substr(peg$currPos, 4) === peg$c15) {
7085
+ if (input.substr(
7086
+ peg$currPos,
7087
+ 4
7088
+ ) === peg$c15) {
6999
7089
  s1 = peg$c15;
7000
7090
  peg$currPos += 4;
7001
7091
  } else {
7002
7092
  s1 = peg$FAILED;
7003
7093
  if (peg$silentFails === 0) {
7004
- peg$fail(peg$e15);
7094
+ peg$fail(
7095
+ peg$e15
7096
+ );
7005
7097
  }
7006
7098
  }
7007
7099
  if (s1 === peg$FAILED) {
7008
- if (input.substr(peg$currPos, 4) === peg$c16) {
7100
+ if (input.substr(
7101
+ peg$currPos,
7102
+ 4
7103
+ ) === peg$c16) {
7009
7104
  s1 = peg$c16;
7010
7105
  peg$currPos += 4;
7011
7106
  } else {
7012
7107
  s1 = peg$FAILED;
7013
7108
  if (peg$silentFails === 0) {
7014
- peg$fail(peg$e16);
7109
+ peg$fail(
7110
+ peg$e16
7111
+ );
7015
7112
  }
7016
7113
  }
7017
7114
  }
@@ -8639,12 +8736,7 @@ var GRAMMAR_ELEMENTS = {
8639
8736
  annotations: "Annotations",
8640
8737
  item: "AnnotationItem"
8641
8738
  };
8642
- var GRAMMAR_BLOCK_NODE_TYPES = [
8643
- "ListItem",
8644
- "DropdownItem",
8645
- "NavGroup",
8646
- "NavItem"
8647
- ];
8739
+ var GRAMMAR_BLOCK_NODE_TYPES = ["ListItem", "DropdownItem", "NavGroup", "NavItem"];
8648
8740
  var GRAMMAR_CHILD_KEYWORDS = [
8649
8741
  "page",
8650
8742
  "header",
@@ -14610,6 +14702,7 @@ var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
14610
14702
  var TYPED_INTERACTION_ATTR = "data-wf-on";
14611
14703
  var VISIBLE_GUARD_ATTR = "data-wf-visible-when";
14612
14704
  var ENABLED_GUARD_ATTR = "data-wf-enabled-when";
14705
+ var VARIANT_SCOPE_ATTR = "data-wf-variant-scope";
14613
14706
  var INERT_HREF = "#";
14614
14707
  function guardedOutcomeAttrs(node) {
14615
14708
  const visible = normalizeStateGuard(node.visibleWhen);
@@ -62179,6 +62272,28 @@ function injectAnchorAttrs(html, path, loc) {
62179
62272
  const attrs2 = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
62180
62273
  return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs2}`);
62181
62274
  }
62275
+ var GUARD_ATTR_RENDERERS = /* @__PURE__ */ new Set([
62276
+ "Card",
62277
+ "Button",
62278
+ "Image",
62279
+ "Avatar",
62280
+ "Badge",
62281
+ "Icon",
62282
+ "Link"
62283
+ ]);
62284
+ function collectNodeMarkerAttrs(node) {
62285
+ const markers = /* @__PURE__ */ new Map();
62286
+ if (!GUARD_ATTR_RENDERERS.has(node.type)) {
62287
+ for (const [name, value] of Object.entries(
62288
+ guardedOutcomeAttrs(node)
62289
+ )) {
62290
+ if (value !== void 0) markers.set(name, value);
62291
+ }
62292
+ }
62293
+ const scope = variantScope(node);
62294
+ if (scope !== void 0) markers.set(VARIANT_SCOPE_ATTR, JSON.stringify(scope));
62295
+ return Object.fromEntries(markers);
62296
+ }
62182
62297
  var SPACING_TOKENS = {
62183
62298
  0: "0px",
62184
62299
  1: "4px",
@@ -62416,14 +62531,9 @@ ${annotationsContent}
62416
62531
  renderNode(node) {
62417
62532
  const renderer = this.nodeRenderers[node.type];
62418
62533
  let html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
62419
- const guardAttrs = Object.fromEntries(
62420
- Object.entries(guardedOutcomeAttrs(node)).filter(
62421
- ([name, value]) => value !== void 0 && !html.includes(` ${name}=`)
62422
- )
62423
- );
62424
- const guardAttrString = this.buildAttrsString(guardAttrs);
62425
- if (guardAttrString.length > 0) {
62426
- html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${guardAttrString}`);
62534
+ const markerAttrString = this.buildAttrsString(collectNodeMarkerAttrs(node));
62535
+ if (markerAttrString.length > 0) {
62536
+ html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${markerAttrString}`);
62427
62537
  }
62428
62538
  if (this.pathMap && node.type !== "Page") {
62429
62539
  const path = this.pathMap.get(node);
@@ -63298,6 +63408,18 @@ function siteRuntime(registry, prefix) {
63298
63408
  }
63299
63409
  }
63300
63410
 
63411
+ function applyVariantScopes() {
63412
+ var screen = current === null ? null : screens[current];
63413
+ var variant = screen ? screen.getAttribute('data-wf-variant') : null;
63414
+ var scoped = site.querySelectorAll('[' + ${embedJson(VARIANT_SCOPE_ATTR)} + ']');
63415
+ for (var i = 0; i < scoped.length; i++) {
63416
+ var names = parseJson(scoped[i].getAttribute(${embedJson(VARIANT_SCOPE_ATTR)}), []);
63417
+ var visible = variant !== null && names.indexOf(variant) >= 0;
63418
+ if (visible) scoped[i].removeAttribute('hidden');
63419
+ else scoped[i].setAttribute('hidden', 'hidden');
63420
+ }
63421
+ }
63422
+
63301
63423
  function applyEffects(handler) {
63302
63424
  for (var i = 0; i < handler.effects.length; i++) {
63303
63425
  var effect = handler.effects[i];
@@ -63381,6 +63503,7 @@ function siteRuntime(registry, prefix) {
63381
63503
  current = key;
63382
63504
  closeOverlays(key);
63383
63505
  markActive(key);
63506
+ applyVariantScopes();
63384
63507
  applyOutcomes();
63385
63508
 
63386
63509
  if (writeFragment) {