@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/parser.js CHANGED
@@ -43,10 +43,14 @@ var peg$SyntaxError = class extends SyntaxError {
43
43
  return s;
44
44
  }
45
45
  function literalEscape(s) {
46
- 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)));
46
+ return unicodeEscape(
47
+ 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))
48
+ );
47
49
  }
48
50
  function classEscape(s) {
49
- 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)));
51
+ return unicodeEscape(
52
+ 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))
53
+ );
50
54
  }
51
55
  const DESCRIBE_EXPECTATION_FNS = {
52
56
  literal(expectation) {
@@ -283,7 +287,12 @@ function peg$parse(input, options) {
283
287
  const peg$e75 = peg$classExpectation([["0", "9"]], false, false, false);
284
288
  const peg$e76 = peg$literalExpectation("at", false);
285
289
  const peg$e77 = peg$classExpectation(["=", "[", "{", "}"], false, false, false);
286
- const peg$e78 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], false, false, false);
290
+ const peg$e78 = peg$classExpectation(
291
+ [["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"],
292
+ false,
293
+ false,
294
+ false
295
+ );
287
296
  const peg$e79 = peg$otherExpectation("string");
288
297
  const peg$e80 = peg$literalExpectation('"', false);
289
298
  const peg$e81 = peg$literalExpectation("'", false);
@@ -6028,7 +6037,10 @@ function peg$parse(input, options) {
6028
6037
  }
6029
6038
  }
6030
6039
  if (s1 === peg$FAILED) {
6031
- if (input.substr(peg$currPos, 5) === peg$c57) {
6040
+ if (input.substr(
6041
+ peg$currPos,
6042
+ 5
6043
+ ) === peg$c57) {
6032
6044
  s1 = peg$c57;
6033
6045
  peg$currPos += 5;
6034
6046
  } else {
@@ -6038,7 +6050,10 @@ function peg$parse(input, options) {
6038
6050
  }
6039
6051
  }
6040
6052
  if (s1 === peg$FAILED) {
6041
- if (input.substr(peg$currPos, 8) === peg$c58) {
6053
+ if (input.substr(
6054
+ peg$currPos,
6055
+ 8
6056
+ ) === peg$c58) {
6042
6057
  s1 = peg$c58;
6043
6058
  peg$currPos += 8;
6044
6059
  } else {
@@ -6048,7 +6063,10 @@ function peg$parse(input, options) {
6048
6063
  }
6049
6064
  }
6050
6065
  if (s1 === peg$FAILED) {
6051
- if (input.substr(peg$currPos, 7) === peg$c59) {
6066
+ if (input.substr(
6067
+ peg$currPos,
6068
+ 7
6069
+ ) === peg$c59) {
6052
6070
  s1 = peg$c59;
6053
6071
  peg$currPos += 7;
6054
6072
  } else {
@@ -6058,7 +6076,10 @@ function peg$parse(input, options) {
6058
6076
  }
6059
6077
  }
6060
6078
  if (s1 === peg$FAILED) {
6061
- if (input.substr(peg$currPos, 7) === peg$c60) {
6079
+ if (input.substr(
6080
+ peg$currPos,
6081
+ 7
6082
+ ) === peg$c60) {
6062
6083
  s1 = peg$c60;
6063
6084
  peg$currPos += 7;
6064
6085
  } else {
@@ -6068,7 +6089,10 @@ function peg$parse(input, options) {
6068
6089
  }
6069
6090
  }
6070
6091
  if (s1 === peg$FAILED) {
6071
- if (input.substr(peg$currPos, 7) === peg$c61) {
6092
+ if (input.substr(
6093
+ peg$currPos,
6094
+ 7
6095
+ ) === peg$c61) {
6072
6096
  s1 = peg$c61;
6073
6097
  peg$currPos += 7;
6074
6098
  } else {
@@ -6078,7 +6102,10 @@ function peg$parse(input, options) {
6078
6102
  }
6079
6103
  }
6080
6104
  if (s1 === peg$FAILED) {
6081
- if (input.substr(peg$currPos, 8) === peg$c62) {
6105
+ if (input.substr(
6106
+ peg$currPos,
6107
+ 8
6108
+ ) === peg$c62) {
6082
6109
  s1 = peg$c62;
6083
6110
  peg$currPos += 8;
6084
6111
  } else {
@@ -6088,143 +6115,213 @@ function peg$parse(input, options) {
6088
6115
  }
6089
6116
  }
6090
6117
  if (s1 === peg$FAILED) {
6091
- if (input.substr(peg$currPos, 7) === peg$c63) {
6118
+ if (input.substr(
6119
+ peg$currPos,
6120
+ 7
6121
+ ) === peg$c63) {
6092
6122
  s1 = peg$c63;
6093
6123
  peg$currPos += 7;
6094
6124
  } else {
6095
6125
  s1 = peg$FAILED;
6096
6126
  if (peg$silentFails === 0) {
6097
- peg$fail(peg$e66);
6127
+ peg$fail(
6128
+ peg$e66
6129
+ );
6098
6130
  }
6099
6131
  }
6100
6132
  if (s1 === peg$FAILED) {
6101
- if (input.substr(peg$currPos, 3) === peg$c64) {
6133
+ if (input.substr(
6134
+ peg$currPos,
6135
+ 3
6136
+ ) === peg$c64) {
6102
6137
  s1 = peg$c64;
6103
6138
  peg$currPos += 3;
6104
6139
  } else {
6105
6140
  s1 = peg$FAILED;
6106
6141
  if (peg$silentFails === 0) {
6107
- peg$fail(peg$e67);
6142
+ peg$fail(
6143
+ peg$e67
6144
+ );
6108
6145
  }
6109
6146
  }
6110
6147
  if (s1 === peg$FAILED) {
6111
- if (input.substr(peg$currPos, 4) === peg$c66) {
6148
+ if (input.substr(
6149
+ peg$currPos,
6150
+ 4
6151
+ ) === peg$c66) {
6112
6152
  s1 = peg$c66;
6113
6153
  peg$currPos += 4;
6114
6154
  } else {
6115
6155
  s1 = peg$FAILED;
6116
6156
  if (peg$silentFails === 0) {
6117
- peg$fail(peg$e69);
6157
+ peg$fail(
6158
+ peg$e69
6159
+ );
6118
6160
  }
6119
6161
  }
6120
6162
  if (s1 === peg$FAILED) {
6121
- if (input.substr(peg$currPos, 3) === peg$c67) {
6163
+ if (input.substr(
6164
+ peg$currPos,
6165
+ 3
6166
+ ) === peg$c67) {
6122
6167
  s1 = peg$c67;
6123
6168
  peg$currPos += 3;
6124
6169
  } else {
6125
6170
  s1 = peg$FAILED;
6126
6171
  if (peg$silentFails === 0) {
6127
- peg$fail(peg$e70);
6172
+ peg$fail(
6173
+ peg$e70
6174
+ );
6128
6175
  }
6129
6176
  }
6130
6177
  if (s1 === peg$FAILED) {
6131
- if (input.substr(peg$currPos, 10) === peg$c68) {
6178
+ if (input.substr(
6179
+ peg$currPos,
6180
+ 10
6181
+ ) === peg$c68) {
6132
6182
  s1 = peg$c68;
6133
6183
  peg$currPos += 10;
6134
6184
  } else {
6135
6185
  s1 = peg$FAILED;
6136
6186
  if (peg$silentFails === 0) {
6137
- peg$fail(peg$e71);
6187
+ peg$fail(
6188
+ peg$e71
6189
+ );
6138
6190
  }
6139
6191
  }
6140
6192
  if (s1 === peg$FAILED) {
6141
- if (input.substr(peg$currPos, 5) === peg$c65) {
6193
+ if (input.substr(
6194
+ peg$currPos,
6195
+ 5
6196
+ ) === peg$c65) {
6142
6197
  s1 = peg$c65;
6143
6198
  peg$currPos += 5;
6144
6199
  } else {
6145
6200
  s1 = peg$FAILED;
6146
6201
  if (peg$silentFails === 0) {
6147
- peg$fail(peg$e68);
6202
+ peg$fail(
6203
+ peg$e68
6204
+ );
6148
6205
  }
6149
6206
  }
6150
6207
  if (s1 === peg$FAILED) {
6151
- if (input.substr(peg$currPos, 6) === peg$c69) {
6208
+ if (input.substr(
6209
+ peg$currPos,
6210
+ 6
6211
+ ) === peg$c69) {
6152
6212
  s1 = peg$c69;
6153
6213
  peg$currPos += 6;
6154
6214
  } else {
6155
6215
  s1 = peg$FAILED;
6156
6216
  if (peg$silentFails === 0) {
6157
- peg$fail(peg$e72);
6217
+ peg$fail(
6218
+ peg$e72
6219
+ );
6158
6220
  }
6159
6221
  }
6160
6222
  if (s1 === peg$FAILED) {
6161
- if (input.substr(peg$currPos, 11) === peg$c70) {
6223
+ if (input.substr(
6224
+ peg$currPos,
6225
+ 11
6226
+ ) === peg$c70) {
6162
6227
  s1 = peg$c70;
6163
6228
  peg$currPos += 11;
6164
6229
  } else {
6165
6230
  s1 = peg$FAILED;
6166
6231
  if (peg$silentFails === 0) {
6167
- peg$fail(peg$e73);
6232
+ peg$fail(
6233
+ peg$e73
6234
+ );
6168
6235
  }
6169
6236
  }
6170
6237
  if (s1 === peg$FAILED) {
6171
- if (input.substr(peg$currPos, 6) === peg$c20) {
6238
+ if (input.substr(
6239
+ peg$currPos,
6240
+ 6
6241
+ ) === peg$c20) {
6172
6242
  s1 = peg$c20;
6173
6243
  peg$currPos += 6;
6174
6244
  } else {
6175
6245
  s1 = peg$FAILED;
6176
6246
  if (peg$silentFails === 0) {
6177
- peg$fail(peg$e23);
6247
+ peg$fail(
6248
+ peg$e23
6249
+ );
6178
6250
  }
6179
6251
  }
6180
6252
  if (s1 === peg$FAILED) {
6181
- if (input.substr(peg$currPos, 6) === peg$c3) {
6253
+ if (input.substr(
6254
+ peg$currPos,
6255
+ 6
6256
+ ) === peg$c3) {
6182
6257
  s1 = peg$c3;
6183
6258
  peg$currPos += 6;
6184
6259
  } else {
6185
6260
  s1 = peg$FAILED;
6186
6261
  if (peg$silentFails === 0) {
6187
- peg$fail(peg$e3);
6262
+ peg$fail(
6263
+ peg$e3
6264
+ );
6188
6265
  }
6189
6266
  }
6190
6267
  if (s1 === peg$FAILED) {
6191
- if (input.substr(peg$currPos, 9) === peg$c4) {
6268
+ if (input.substr(
6269
+ peg$currPos,
6270
+ 9
6271
+ ) === peg$c4) {
6192
6272
  s1 = peg$c4;
6193
6273
  peg$currPos += 9;
6194
6274
  } else {
6195
6275
  s1 = peg$FAILED;
6196
6276
  if (peg$silentFails === 0) {
6197
- peg$fail(peg$e4);
6277
+ peg$fail(
6278
+ peg$e4
6279
+ );
6198
6280
  }
6199
6281
  }
6200
6282
  if (s1 === peg$FAILED) {
6201
- if (input.substr(peg$currPos, 3) === peg$c12) {
6283
+ if (input.substr(
6284
+ peg$currPos,
6285
+ 3
6286
+ ) === peg$c12) {
6202
6287
  s1 = peg$c12;
6203
6288
  peg$currPos += 3;
6204
6289
  } else {
6205
6290
  s1 = peg$FAILED;
6206
6291
  if (peg$silentFails === 0) {
6207
- peg$fail(peg$e12);
6292
+ peg$fail(
6293
+ peg$e12
6294
+ );
6208
6295
  }
6209
6296
  }
6210
6297
  if (s1 === peg$FAILED) {
6211
- if (input.substr(peg$currPos, 4) === peg$c15) {
6298
+ if (input.substr(
6299
+ peg$currPos,
6300
+ 4
6301
+ ) === peg$c15) {
6212
6302
  s1 = peg$c15;
6213
6303
  peg$currPos += 4;
6214
6304
  } else {
6215
6305
  s1 = peg$FAILED;
6216
6306
  if (peg$silentFails === 0) {
6217
- peg$fail(peg$e15);
6307
+ peg$fail(
6308
+ peg$e15
6309
+ );
6218
6310
  }
6219
6311
  }
6220
6312
  if (s1 === peg$FAILED) {
6221
- if (input.substr(peg$currPos, 4) === peg$c16) {
6313
+ if (input.substr(
6314
+ peg$currPos,
6315
+ 4
6316
+ ) === peg$c16) {
6222
6317
  s1 = peg$c16;
6223
6318
  peg$currPos += 4;
6224
6319
  } else {
6225
6320
  s1 = peg$FAILED;
6226
6321
  if (peg$silentFails === 0) {
6227
- peg$fail(peg$e16);
6322
+ peg$fail(
6323
+ peg$e16
6324
+ );
6228
6325
  }
6229
6326
  }
6230
6327
  }
package/dist/renderer.cjs CHANGED
@@ -2608,12 +2608,7 @@ var GRAMMAR_ELEMENTS = {
2608
2608
  annotations: "Annotations",
2609
2609
  item: "AnnotationItem"
2610
2610
  };
2611
- var GRAMMAR_BLOCK_NODE_TYPES = [
2612
- "ListItem",
2613
- "DropdownItem",
2614
- "NavGroup",
2615
- "NavItem"
2616
- ];
2611
+ var GRAMMAR_BLOCK_NODE_TYPES = ["ListItem", "DropdownItem", "NavGroup", "NavItem"];
2617
2612
 
2618
2613
  // src/spec/attributes.ts
2619
2614
  var ATTRIBUTE_SPECS = [
@@ -4001,6 +3996,7 @@ var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
4001
3996
  var TYPED_INTERACTION_ATTR = "data-wf-on";
4002
3997
  var VISIBLE_GUARD_ATTR = "data-wf-visible-when";
4003
3998
  var ENABLED_GUARD_ATTR = "data-wf-enabled-when";
3999
+ var VARIANT_SCOPE_ATTR = "data-wf-variant-scope";
4004
4000
  var INERT_HREF = "#";
4005
4001
  function guardedOutcomeAttrs(node) {
4006
4002
  const visible = normalizeStateGuard(node.visibleWhen);
@@ -51570,6 +51566,28 @@ function injectAnchorAttrs(html, path, loc) {
51570
51566
  const attrs2 = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
51571
51567
  return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs2}`);
51572
51568
  }
51569
+ var GUARD_ATTR_RENDERERS = /* @__PURE__ */ new Set([
51570
+ "Card",
51571
+ "Button",
51572
+ "Image",
51573
+ "Avatar",
51574
+ "Badge",
51575
+ "Icon",
51576
+ "Link"
51577
+ ]);
51578
+ function collectNodeMarkerAttrs(node) {
51579
+ const markers = /* @__PURE__ */ new Map();
51580
+ if (!GUARD_ATTR_RENDERERS.has(node.type)) {
51581
+ for (const [name, value] of Object.entries(
51582
+ guardedOutcomeAttrs(node)
51583
+ )) {
51584
+ if (value !== void 0) markers.set(name, value);
51585
+ }
51586
+ }
51587
+ const scope = variantScope(node);
51588
+ if (scope !== void 0) markers.set(VARIANT_SCOPE_ATTR, JSON.stringify(scope));
51589
+ return Object.fromEntries(markers);
51590
+ }
51573
51591
  var SPACING_TOKENS = {
51574
51592
  0: "0px",
51575
51593
  1: "4px",
@@ -51807,14 +51825,9 @@ ${annotationsContent}
51807
51825
  renderNode(node) {
51808
51826
  const renderer = this.nodeRenderers[node.type];
51809
51827
  let html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
51810
- const guardAttrs = Object.fromEntries(
51811
- Object.entries(guardedOutcomeAttrs(node)).filter(
51812
- ([name, value]) => value !== void 0 && !html.includes(` ${name}=`)
51813
- )
51814
- );
51815
- const guardAttrString = this.buildAttrsString(guardAttrs);
51816
- if (guardAttrString.length > 0) {
51817
- html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${guardAttrString}`);
51828
+ const markerAttrString = this.buildAttrsString(collectNodeMarkerAttrs(node));
51829
+ if (markerAttrString.length > 0) {
51830
+ html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${markerAttrString}`);
51818
51831
  }
51819
51832
  if (this.pathMap && node.type !== "Page") {
51820
51833
  const path = this.pathMap.get(node);
@@ -52689,6 +52702,18 @@ function siteRuntime(registry, prefix) {
52689
52702
  }
52690
52703
  }
52691
52704
 
52705
+ function applyVariantScopes() {
52706
+ var screen = current === null ? null : screens[current];
52707
+ var variant = screen ? screen.getAttribute('data-wf-variant') : null;
52708
+ var scoped = site.querySelectorAll('[' + ${embedJson(VARIANT_SCOPE_ATTR)} + ']');
52709
+ for (var i = 0; i < scoped.length; i++) {
52710
+ var names = parseJson(scoped[i].getAttribute(${embedJson(VARIANT_SCOPE_ATTR)}), []);
52711
+ var visible = variant !== null && names.indexOf(variant) >= 0;
52712
+ if (visible) scoped[i].removeAttribute('hidden');
52713
+ else scoped[i].setAttribute('hidden', 'hidden');
52714
+ }
52715
+ }
52716
+
52692
52717
  function applyEffects(handler) {
52693
52718
  for (var i = 0; i < handler.effects.length; i++) {
52694
52719
  var effect = handler.effects[i];
@@ -52772,6 +52797,7 @@ function siteRuntime(registry, prefix) {
52772
52797
  current = key;
52773
52798
  closeOverlays(key);
52774
52799
  markActive(key);
52800
+ applyVariantScopes();
52775
52801
  applyOutcomes();
52776
52802
 
52777
52803
  if (writeFragment) {
package/dist/renderer.js CHANGED
@@ -2554,12 +2554,7 @@ var GRAMMAR_ELEMENTS = {
2554
2554
  annotations: "Annotations",
2555
2555
  item: "AnnotationItem"
2556
2556
  };
2557
- var GRAMMAR_BLOCK_NODE_TYPES = [
2558
- "ListItem",
2559
- "DropdownItem",
2560
- "NavGroup",
2561
- "NavItem"
2562
- ];
2557
+ var GRAMMAR_BLOCK_NODE_TYPES = ["ListItem", "DropdownItem", "NavGroup", "NavItem"];
2563
2558
 
2564
2559
  // src/spec/attributes.ts
2565
2560
  var ATTRIBUTE_SPECS = [
@@ -3947,6 +3942,7 @@ var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
3947
3942
  var TYPED_INTERACTION_ATTR = "data-wf-on";
3948
3943
  var VISIBLE_GUARD_ATTR = "data-wf-visible-when";
3949
3944
  var ENABLED_GUARD_ATTR = "data-wf-enabled-when";
3945
+ var VARIANT_SCOPE_ATTR = "data-wf-variant-scope";
3950
3946
  var INERT_HREF = "#";
3951
3947
  function guardedOutcomeAttrs(node) {
3952
3948
  const visible = normalizeStateGuard(node.visibleWhen);
@@ -51516,6 +51512,28 @@ function injectAnchorAttrs(html, path, loc) {
51516
51512
  const attrs2 = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
51517
51513
  return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs2}`);
51518
51514
  }
51515
+ var GUARD_ATTR_RENDERERS = /* @__PURE__ */ new Set([
51516
+ "Card",
51517
+ "Button",
51518
+ "Image",
51519
+ "Avatar",
51520
+ "Badge",
51521
+ "Icon",
51522
+ "Link"
51523
+ ]);
51524
+ function collectNodeMarkerAttrs(node) {
51525
+ const markers = /* @__PURE__ */ new Map();
51526
+ if (!GUARD_ATTR_RENDERERS.has(node.type)) {
51527
+ for (const [name, value] of Object.entries(
51528
+ guardedOutcomeAttrs(node)
51529
+ )) {
51530
+ if (value !== void 0) markers.set(name, value);
51531
+ }
51532
+ }
51533
+ const scope = variantScope(node);
51534
+ if (scope !== void 0) markers.set(VARIANT_SCOPE_ATTR, JSON.stringify(scope));
51535
+ return Object.fromEntries(markers);
51536
+ }
51519
51537
  var SPACING_TOKENS = {
51520
51538
  0: "0px",
51521
51539
  1: "4px",
@@ -51753,14 +51771,9 @@ ${annotationsContent}
51753
51771
  renderNode(node) {
51754
51772
  const renderer = this.nodeRenderers[node.type];
51755
51773
  let html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
51756
- const guardAttrs = Object.fromEntries(
51757
- Object.entries(guardedOutcomeAttrs(node)).filter(
51758
- ([name, value]) => value !== void 0 && !html.includes(` ${name}=`)
51759
- )
51760
- );
51761
- const guardAttrString = this.buildAttrsString(guardAttrs);
51762
- if (guardAttrString.length > 0) {
51763
- html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${guardAttrString}`);
51774
+ const markerAttrString = this.buildAttrsString(collectNodeMarkerAttrs(node));
51775
+ if (markerAttrString.length > 0) {
51776
+ html = html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${markerAttrString}`);
51764
51777
  }
51765
51778
  if (this.pathMap && node.type !== "Page") {
51766
51779
  const path = this.pathMap.get(node);
@@ -52635,6 +52648,18 @@ function siteRuntime(registry, prefix) {
52635
52648
  }
52636
52649
  }
52637
52650
 
52651
+ function applyVariantScopes() {
52652
+ var screen = current === null ? null : screens[current];
52653
+ var variant = screen ? screen.getAttribute('data-wf-variant') : null;
52654
+ var scoped = site.querySelectorAll('[' + ${embedJson(VARIANT_SCOPE_ATTR)} + ']');
52655
+ for (var i = 0; i < scoped.length; i++) {
52656
+ var names = parseJson(scoped[i].getAttribute(${embedJson(VARIANT_SCOPE_ATTR)}), []);
52657
+ var visible = variant !== null && names.indexOf(variant) >= 0;
52658
+ if (visible) scoped[i].removeAttribute('hidden');
52659
+ else scoped[i].setAttribute('hidden', 'hidden');
52660
+ }
52661
+ }
52662
+
52638
52663
  function applyEffects(handler) {
52639
52664
  for (var i = 0; i < handler.effects.length; i++) {
52640
52665
  var effect = handler.effects[i];
@@ -52718,6 +52743,7 @@ function siteRuntime(registry, prefix) {
52718
52743
  current = key;
52719
52744
  closeOverlays(key);
52720
52745
  markActive(key);
52746
+ applyVariantScopes();
52721
52747
  applyOutcomes();
52722
52748
 
52723
52749
  if (writeFragment) {
package/dist/spec.cjs CHANGED
@@ -99,12 +99,7 @@ var GRAMMAR_ELEMENTS = {
99
99
  annotations: "Annotations",
100
100
  item: "AnnotationItem"
101
101
  };
102
- var GRAMMAR_BLOCK_NODE_TYPES = [
103
- "ListItem",
104
- "DropdownItem",
105
- "NavGroup",
106
- "NavItem"
107
- ];
102
+ var GRAMMAR_BLOCK_NODE_TYPES = ["ListItem", "DropdownItem", "NavGroup", "NavItem"];
108
103
  var GRAMMAR_CHILD_KEYWORDS = [
109
104
  "page",
110
105
  "header",
package/dist/spec.js CHANGED
@@ -52,12 +52,7 @@ var GRAMMAR_ELEMENTS = {
52
52
  annotations: "Annotations",
53
53
  item: "AnnotationItem"
54
54
  };
55
- var GRAMMAR_BLOCK_NODE_TYPES = [
56
- "ListItem",
57
- "DropdownItem",
58
- "NavGroup",
59
- "NavItem"
60
- ];
55
+ var GRAMMAR_BLOCK_NODE_TYPES = ["ListItem", "DropdownItem", "NavGroup", "NavItem"];
61
56
  var GRAMMAR_CHILD_KEYWORDS = [
62
57
  "page",
63
58
  "header",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireweave/core",
3
- "version": "3.1.0-beta.10",
3
+ "version": "3.1.0-beta.11",
4
4
  "description": "Core parser and renderer for wireweave",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -98,6 +98,7 @@
98
98
  },
99
99
  "scripts": {
100
100
  "build:grammar": "peggy --format es -o src/parser/generated-parser.js src/grammar/wireframe.peggy",
101
+ "postbuild:grammar": "node scripts/format-generated.mjs src/parser/generated-parser.js",
101
102
  "build:spec": "node scripts/extract-grammar-elements.mjs",
102
103
  "build:icons": "node scripts/generate-icons.mjs",
103
104
  "build:icon-names": "node scripts/extract-icon-names.mjs",