@rindo/core 4.25.3 → 4.26.0

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 (40) hide show
  1. package/cli/index.cjs +1 -1
  2. package/cli/index.js +1 -1
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/rindo.js +37 -13
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +2 -2
  9. package/dev-server/index.js +1 -1
  10. package/dev-server/package.json +1 -1
  11. package/dev-server/server-process.js +2 -2
  12. package/internal/app-data/package.json +1 -1
  13. package/internal/client/index.js +405 -14
  14. package/internal/client/package.json +1 -1
  15. package/internal/client/patch-browser.js +1 -1
  16. package/internal/client/shadow-css.js +30 -6
  17. package/internal/hydrate/index.js +434 -15
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.d.ts +22 -5
  20. package/internal/hydrate/runner.js +29 -4
  21. package/internal/package.json +1 -1
  22. package/internal/rindo-public-compiler.d.ts +23 -6
  23. package/internal/testing/index.js +404 -23
  24. package/internal/testing/package.json +1 -1
  25. package/mock-doc/index.cjs +3 -3
  26. package/mock-doc/index.d.ts +5 -1
  27. package/mock-doc/index.js +3 -3
  28. package/mock-doc/package.json +1 -1
  29. package/package.json +1 -1
  30. package/screenshot/index.js +1 -1
  31. package/screenshot/package.json +1 -1
  32. package/screenshot/pixel-match.js +1 -1
  33. package/sys/node/index.js +1 -1
  34. package/sys/node/package.json +1 -1
  35. package/sys/node/worker.js +1 -1
  36. package/testing/index.js +1 -1
  37. package/testing/jest/jest-27-and-under/matchers/html.d.ts +2 -1
  38. package/testing/jest/jest-28/matchers/html.d.ts +2 -1
  39. package/testing/jest/jest-29/matchers/html.d.ts +2 -1
  40. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Rindo Hydrate Runner v4.25.3 | MIT Licensed | https://rindojs.web.app
2
+ Rindo Hydrate Runner v4.26.0 | MIT Licensed | https://rindojs.web.app
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -10416,7 +10416,7 @@ function normalizeSerializationOptions(opts = {}) {
10416
10416
  removeAttributeQuotes: typeof opts.removeAttributeQuotes !== "boolean" ? false : opts.removeAttributeQuotes,
10417
10417
  removeBooleanAttributeQuotes: typeof opts.removeBooleanAttributeQuotes !== "boolean" ? false : opts.removeBooleanAttributeQuotes,
10418
10418
  removeHtmlComments: typeof opts.removeHtmlComments !== "boolean" ? false : opts.removeHtmlComments,
10419
- serializeShadowRoot: typeof opts.serializeShadowRoot !== "boolean" ? true : opts.serializeShadowRoot,
10419
+ serializeShadowRoot: typeof opts.serializeShadowRoot === "undefined" ? "declarative-shadow-dom" : opts.serializeShadowRoot,
10420
10420
  fullDocument: typeof opts.fullDocument !== "boolean" ? true : opts.fullDocument
10421
10421
  };
10422
10422
  }
@@ -10545,7 +10545,7 @@ style="${cssText}">`;
10545
10545
  }
10546
10546
  if (EMPTY_ELEMENTS.has(tagName) === false) {
10547
10547
  const shadowRoot = node.shadowRoot;
10548
- if (shadowRoot != null && opts.serializeShadowRoot) {
10548
+ if (shadowRoot != null && opts.serializeShadowRoot !== false) {
10549
10549
  output.indent = output.indent + ((_c = opts.indentSpaces) != null ? _c : 0);
10550
10550
  yield* streamToHtml(shadowRoot, opts, output);
10551
10551
  output.indent = output.indent - ((_d = opts.indentSpaces) != null ? _d : 0);
@@ -14342,6 +14342,31 @@ import { BUILD as BUILD11 } from "@rindo/core/internal/app-data";
14342
14342
  // src/runtime/initialize-component.ts
14343
14343
  import { BUILD as BUILD23 } from "@rindo/core/internal/app-data";
14344
14344
 
14345
+ // src/utils/shadow-css.ts
14346
+ /**
14347
+ * @license
14348
+ * Copyright Google Inc. All Rights Reserved.
14349
+ *
14350
+ * Use of this source code is governed by an MIT-style license that can be
14351
+ * found in the LICENSE file at https://angular.io/license
14352
+ *
14353
+ * This file is a port of shadowCSS from `webcomponents.js` to TypeScript.
14354
+ * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
14355
+ * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
14356
+ */
14357
+ var _polyfillHost = "-shadowcsshost";
14358
+ var _polyfillSlotted = "-shadowcssslotted";
14359
+ var _polyfillHostContext = "-shadowcsscontext";
14360
+ var _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
14361
+ var _cssColonHostRe = new RegExp("(" + _polyfillHost + _parenSuffix, "gim");
14362
+ var _cssColonHostContextRe = new RegExp("(" + _polyfillHostContext + _parenSuffix, "gim");
14363
+ var _cssColonSlottedRe = new RegExp("(" + _polyfillSlotted + _parenSuffix, "gim");
14364
+ var _polyfillHostNoCombinator = _polyfillHost + "-no-combinator";
14365
+ var createSupportsRuleRe = (selector) => new RegExp(`((?<!(^@supports(.*)))|(?<={.*))(${selector}\\b)`, "gim");
14366
+ var _colonSlottedRe = createSupportsRuleRe("::slotted");
14367
+ var _colonHostRe = createSupportsRuleRe(":host");
14368
+ var _colonHostContextRe = createSupportsRuleRe(":host-context");
14369
+
14345
14370
  // src/runtime/mode.ts
14346
14371
  var setMode = (handler) => modeResolutionChain.push(handler);
14347
14372
 
@@ -15569,7 +15594,7 @@ function renderToString(html, options, asStream) {
15569
15594
  const opts = normalizeHydrateOptions(options);
15570
15595
  opts.serializeToHtml = true;
15571
15596
  opts.fullDocument = typeof opts.fullDocument === "boolean" ? opts.fullDocument : true;
15572
- opts.serializeShadowRoot = typeof opts.serializeShadowRoot === "boolean" ? opts.serializeShadowRoot : true;
15597
+ opts.serializeShadowRoot = typeof opts.serializeShadowRoot === "undefined" ? "declarative-shadow-dom" : opts.serializeShadowRoot;
15573
15598
  opts.constrainTimeouts = false;
15574
15599
  return hydrateDocument(html, opts, asStream);
15575
15600
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rindo/core/internal",
3
- "version": "4.25.3",
3
+ "version": "4.26.0",
4
4
  "description": "Rindo internals only to be imported by the Rindo Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -849,12 +849,29 @@ export interface SerializeDocumentOptions extends HydrateDocumentOptions {
849
849
  */
850
850
  removeHtmlComments?: boolean;
851
851
  /**
852
- * If set to `true` the component will be rendered within a Declarative Shadow DOM.
853
- * If set to `false` Rindo will ignore the contents of the shadow root and render the
854
- * element as given in provided template.
855
- * @default true
856
- */
857
- serializeShadowRoot?: boolean;
852
+ * Configure how Rindo serializes the components shadow root.
853
+ * - If set to `declarative-shadow-dom` the component will be rendered within a Declarative Shadow DOM.
854
+ * - If set to `scoped` Rindo will render the contents of the shadow root as a `scoped: true` component
855
+ * and the shadow DOM will be created during client-side hydration.
856
+ * - Alternatively you can mix and match the two by providing an object with `declarative-shadow-dom` and `scoped` keys,
857
+ * the value arrays containing the tag names of the components that should be rendered in that mode.
858
+ *
859
+ * Examples:
860
+ * - `{ 'declarative-shadow-dom': ['my-component-1', 'another-component'], default: 'scoped' }`
861
+ * Render all components as `scoped` apart from `my-component-1` and `another-component`
862
+ * - `{ 'scoped': ['an-option-component'], default: 'declarative-shadow-dom' }`
863
+ * Render all components within `declarative-shadow-dom` apart from `an-option-component`
864
+ * - `'scoped'` Render all components as `scoped`
865
+ * - `false` disables shadow root serialization
866
+ *
867
+ * *NOTE* `true` has been deprecated in favor of `declarative-shadow-dom` and `scoped`
868
+ * @default 'declarative-shadow-dom'
869
+ */
870
+ serializeShadowRoot?: 'declarative-shadow-dom' | 'scoped' | {
871
+ 'declarative-shadow-dom'?: string[];
872
+ scoped?: string[];
873
+ default: 'declarative-shadow-dom' | 'scoped';
874
+ } | boolean;
858
875
  /**
859
876
  * The `fullDocument` flag determines the format of the rendered output. Set it to true to
860
877
  * generate a complete HTML document, or false to render only the component.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/testing/platform/index.ts
@@ -411,6 +401,11 @@ function queryNonceMetaTagContent(doc2) {
411
401
  return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
412
402
  }
413
403
 
404
+ // src/utils/regular-expression.ts
405
+ var escapeRegExpSpecialCharacters = (text) => {
406
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
407
+ };
408
+
414
409
  // src/utils/result.ts
415
410
  var result_exports = {};
416
411
  __export(result_exports, {
@@ -1225,7 +1220,7 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1225
1220
  delete hostElm["s-sc"];
1226
1221
  }
1227
1222
  }
1228
- if (!plt.$orgLocNodes$) {
1223
+ if (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size) {
1229
1224
  initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1230
1225
  }
1231
1226
  hostElm[HYDRATE_ID] = hostId;
@@ -1319,13 +1314,25 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1319
1314
  slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1320
1315
  });
1321
1316
  }
1322
- if (import_app_data5.BUILD.shadowDom && shadowRoot) {
1317
+ if (import_app_data5.BUILD.shadowDom && shadowRoot && !shadowRoot.childNodes.length) {
1323
1318
  let rnIdex = 0;
1324
1319
  const rnLen = shadowRootNodes.length;
1325
- for (rnIdex; rnIdex < rnLen; rnIdex++) {
1326
- shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1320
+ if (rnLen) {
1321
+ for (rnIdex; rnIdex < rnLen; rnIdex++) {
1322
+ shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1323
+ }
1324
+ Array.from(hostElm.childNodes).forEach((node) => {
1325
+ if (typeof node["s-sn"] !== "string") {
1326
+ if (node.nodeType === 1 /* ElementNode */ && node.slot && node.hidden) {
1327
+ node.removeAttribute("hidden");
1328
+ } else if (node.nodeType === 8 /* CommentNode */ || node.nodeType === 3 /* TextNode */ && !node.wholeText.trim()) {
1329
+ node.parentNode.removeChild(node);
1330
+ }
1331
+ }
1332
+ });
1327
1333
  }
1328
1334
  }
1335
+ plt.$orgLocNodes$.delete(hostElm["s-id"]);
1329
1336
  hostRef.$hostElement$ = hostElm;
1330
1337
  endHydrate();
1331
1338
  };
@@ -1436,7 +1443,7 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
1436
1443
  $text$: null
1437
1444
  });
1438
1445
  if (childNodeType === TEXT_NODE_ID) {
1439
- childVNode.$elm$ = node.nextSibling;
1446
+ childVNode.$elm$ = findCorrespondingNode(node, 3 /* TextNode */);
1440
1447
  if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1441
1448
  childVNode.$text$ = childVNode.$elm$.textContent;
1442
1449
  childRenderNodes.push(childVNode);
@@ -1452,7 +1459,7 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
1452
1459
  }
1453
1460
  }
1454
1461
  } else if (childNodeType === COMMENT_NODE_ID) {
1455
- childVNode.$elm$ = node.nextSibling;
1462
+ childVNode.$elm$ = findCorrespondingNode(node, 8 /* CommentNode */);
1456
1463
  if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1457
1464
  childRenderNodes.push(childVNode);
1458
1465
  node.remove();
@@ -1486,6 +1493,10 @@ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes,
1486
1493
  vnode.$elm$ = node;
1487
1494
  vnode.$index$ = "0";
1488
1495
  parentVNode.$children$ = [vnode];
1496
+ } else {
1497
+ if (node.nodeType === 3 /* TextNode */ && !node.wholeText.trim()) {
1498
+ node.remove();
1499
+ }
1489
1500
  }
1490
1501
  return parentVNode;
1491
1502
  };
@@ -1575,10 +1586,367 @@ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =>
1575
1586
  slottedNode = slottedNode.nextSibling;
1576
1587
  }
1577
1588
  };
1589
+ var findCorrespondingNode = (node, type) => {
1590
+ let sibling = node;
1591
+ do {
1592
+ sibling = sibling.nextSibling;
1593
+ } while (sibling && (sibling.nodeType !== type || !sibling.nodeValue));
1594
+ return sibling;
1595
+ };
1578
1596
 
1579
1597
  // src/runtime/initialize-component.ts
1580
1598
  var import_app_data16 = require("@rindo/core/internal/app-data");
1581
1599
 
1600
+ // src/utils/shadow-css.ts
1601
+ /**
1602
+ * @license
1603
+ * Copyright Google Inc. All Rights Reserved.
1604
+ *
1605
+ * Use of this source code is governed by an MIT-style license that can be
1606
+ * found in the LICENSE file at https://angular.io/license
1607
+ *
1608
+ * This file is a port of shadowCSS from `webcomponents.js` to TypeScript.
1609
+ * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
1610
+ * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
1611
+ */
1612
+ var safeSelector = (selector) => {
1613
+ const placeholders = [];
1614
+ let index = 0;
1615
+ selector = selector.replace(/(\[[^\]]*\])/g, (_, keep) => {
1616
+ const replaceBy = `__ph-${index}__`;
1617
+ placeholders.push(keep);
1618
+ index++;
1619
+ return replaceBy;
1620
+ });
1621
+ const content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, (_, pseudo, exp) => {
1622
+ const replaceBy = `__ph-${index}__`;
1623
+ placeholders.push(exp);
1624
+ index++;
1625
+ return pseudo + replaceBy;
1626
+ });
1627
+ const ss = {
1628
+ content,
1629
+ placeholders
1630
+ };
1631
+ return ss;
1632
+ };
1633
+ var restoreSafeSelector = (placeholders, content) => {
1634
+ return content.replace(/__ph-(\d+)__/g, (_, index) => placeholders[+index]);
1635
+ };
1636
+ var _polyfillHost = "-shadowcsshost";
1637
+ var _polyfillSlotted = "-shadowcssslotted";
1638
+ var _polyfillHostContext = "-shadowcsscontext";
1639
+ var _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
1640
+ var _cssColonHostRe = new RegExp("(" + _polyfillHost + _parenSuffix, "gim");
1641
+ var _cssColonHostContextRe = new RegExp("(" + _polyfillHostContext + _parenSuffix, "gim");
1642
+ var _cssColonSlottedRe = new RegExp("(" + _polyfillSlotted + _parenSuffix, "gim");
1643
+ var _polyfillHostNoCombinator = _polyfillHost + "-no-combinator";
1644
+ var _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
1645
+ var _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
1646
+ var _selectorReSuffix = "([>\\s~+[.,{:][\\s\\S]*)?$";
1647
+ var _polyfillHostRe = /-shadowcsshost/gim;
1648
+ var createSupportsRuleRe = (selector) => new RegExp(`((?<!(^@supports(.*)))|(?<={.*))(${selector}\\b)`, "gim");
1649
+ var _colonSlottedRe = createSupportsRuleRe("::slotted");
1650
+ var _colonHostRe = createSupportsRuleRe(":host");
1651
+ var _colonHostContextRe = createSupportsRuleRe(":host-context");
1652
+ var _commentRe = /\/\*\s*[\s\S]*?\*\//g;
1653
+ var stripComments = (input) => {
1654
+ return input.replace(_commentRe, "");
1655
+ };
1656
+ var _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
1657
+ var extractCommentsWithHash = (input) => {
1658
+ return input.match(_commentWithHashRe) || [];
1659
+ };
1660
+ var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
1661
+ var _curlyRe = /([{}])/g;
1662
+ var _selectorPartsRe = /(^.*?[^\\])??((:+)(.*)|$)/;
1663
+ var OPEN_CURLY = "{";
1664
+ var CLOSE_CURLY = "}";
1665
+ var BLOCK_PLACEHOLDER = "%BLOCK%";
1666
+ var processRules = (input, ruleCallback) => {
1667
+ const inputWithEscapedBlocks = escapeBlocks(input);
1668
+ let nextBlockIndex = 0;
1669
+ return inputWithEscapedBlocks.escapedString.replace(_ruleRe, (...m) => {
1670
+ const selector = m[2];
1671
+ let content = "";
1672
+ let suffix = m[4];
1673
+ let contentPrefix = "";
1674
+ if (suffix && suffix.startsWith("{" + BLOCK_PLACEHOLDER)) {
1675
+ content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
1676
+ suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
1677
+ contentPrefix = "{";
1678
+ }
1679
+ const cssRule = {
1680
+ selector,
1681
+ content
1682
+ };
1683
+ const rule = ruleCallback(cssRule);
1684
+ return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;
1685
+ });
1686
+ };
1687
+ var escapeBlocks = (input) => {
1688
+ const inputParts = input.split(_curlyRe);
1689
+ const resultParts = [];
1690
+ const escapedBlocks = [];
1691
+ let bracketCount = 0;
1692
+ let currentBlockParts = [];
1693
+ for (let partIndex = 0; partIndex < inputParts.length; partIndex++) {
1694
+ const part = inputParts[partIndex];
1695
+ if (part === CLOSE_CURLY) {
1696
+ bracketCount--;
1697
+ }
1698
+ if (bracketCount > 0) {
1699
+ currentBlockParts.push(part);
1700
+ } else {
1701
+ if (currentBlockParts.length > 0) {
1702
+ escapedBlocks.push(currentBlockParts.join(""));
1703
+ resultParts.push(BLOCK_PLACEHOLDER);
1704
+ currentBlockParts = [];
1705
+ }
1706
+ resultParts.push(part);
1707
+ }
1708
+ if (part === OPEN_CURLY) {
1709
+ bracketCount++;
1710
+ }
1711
+ }
1712
+ if (currentBlockParts.length > 0) {
1713
+ escapedBlocks.push(currentBlockParts.join(""));
1714
+ resultParts.push(BLOCK_PLACEHOLDER);
1715
+ }
1716
+ const strEscapedBlocks = {
1717
+ escapedString: resultParts.join(""),
1718
+ blocks: escapedBlocks
1719
+ };
1720
+ return strEscapedBlocks;
1721
+ };
1722
+ var insertPolyfillHostInCssText = (cssText) => {
1723
+ cssText = cssText.replace(_colonHostContextRe, `$1${_polyfillHostContext}`).replace(_colonHostRe, `$1${_polyfillHost}`).replace(_colonSlottedRe, `$1${_polyfillSlotted}`);
1724
+ return cssText;
1725
+ };
1726
+ var convertColonRule = (cssText, regExp, partReplacer) => {
1727
+ return cssText.replace(regExp, (...m) => {
1728
+ if (m[2]) {
1729
+ const parts = m[2].split(",");
1730
+ const r = [];
1731
+ for (let i2 = 0; i2 < parts.length; i2++) {
1732
+ const p = parts[i2].trim();
1733
+ if (!p) break;
1734
+ r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
1735
+ }
1736
+ return r.join(",");
1737
+ } else {
1738
+ return _polyfillHostNoCombinator + m[3];
1739
+ }
1740
+ });
1741
+ };
1742
+ var colonHostPartReplacer = (host, part, suffix) => {
1743
+ return host + part.replace(_polyfillHost, "") + suffix;
1744
+ };
1745
+ var convertColonHost = (cssText) => {
1746
+ return convertColonRule(cssText, _cssColonHostRe, colonHostPartReplacer);
1747
+ };
1748
+ var colonHostContextPartReplacer = (host, part, suffix) => {
1749
+ if (part.indexOf(_polyfillHost) > -1) {
1750
+ return colonHostPartReplacer(host, part, suffix);
1751
+ } else {
1752
+ return host + part + suffix + ", " + part + " " + host + suffix;
1753
+ }
1754
+ };
1755
+ var convertColonSlotted = (cssText, slotScopeId) => {
1756
+ const slotClass = "." + slotScopeId + " > ";
1757
+ const selectors = [];
1758
+ cssText = cssText.replace(_cssColonSlottedRe, (...m) => {
1759
+ if (m[2]) {
1760
+ const compound = m[2].trim();
1761
+ const suffix = m[3];
1762
+ const slottedSelector = slotClass + compound + suffix;
1763
+ let prefixSelector = "";
1764
+ for (let i2 = m[4] - 1; i2 >= 0; i2--) {
1765
+ const char = m[5][i2];
1766
+ if (char === "}" || char === ",") {
1767
+ break;
1768
+ }
1769
+ prefixSelector = char + prefixSelector;
1770
+ }
1771
+ const orgSelector = (prefixSelector + slottedSelector).trim();
1772
+ const addedSelector = `${prefixSelector.trimEnd()}${slottedSelector.trim()}`.trim();
1773
+ if (orgSelector !== addedSelector) {
1774
+ const updatedSelector = `${addedSelector}, ${orgSelector}`;
1775
+ selectors.push({
1776
+ orgSelector,
1777
+ updatedSelector
1778
+ });
1779
+ }
1780
+ return slottedSelector;
1781
+ } else {
1782
+ return _polyfillHostNoCombinator + m[3];
1783
+ }
1784
+ });
1785
+ return {
1786
+ selectors,
1787
+ cssText
1788
+ };
1789
+ };
1790
+ var convertColonHostContext = (cssText) => {
1791
+ return convertColonRule(cssText, _cssColonHostContextRe, colonHostContextPartReplacer);
1792
+ };
1793
+ var convertShadowDOMSelectors = (cssText) => {
1794
+ return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, " "), cssText);
1795
+ };
1796
+ var makeScopeMatcher = (scopeSelector2) => {
1797
+ const lre = /\[/g;
1798
+ const rre = /\]/g;
1799
+ scopeSelector2 = scopeSelector2.replace(lre, "\\[").replace(rre, "\\]");
1800
+ return new RegExp("^(" + scopeSelector2 + ")" + _selectorReSuffix, "m");
1801
+ };
1802
+ var selectorNeedsScoping = (selector, scopeSelector2) => {
1803
+ const re = makeScopeMatcher(scopeSelector2);
1804
+ return !re.test(selector);
1805
+ };
1806
+ var injectScopingSelector = (selector, scopingSelector) => {
1807
+ return selector.replace(_selectorPartsRe, (_, before = "", _colonGroup, colon = "", after = "") => {
1808
+ return before + scopingSelector + colon + after;
1809
+ });
1810
+ };
1811
+ var applySimpleSelectorScope = (selector, scopeSelector2, hostSelector) => {
1812
+ _polyfillHostRe.lastIndex = 0;
1813
+ if (_polyfillHostRe.test(selector)) {
1814
+ const replaceBy = `.${hostSelector}`;
1815
+ return selector.replace(_polyfillHostNoCombinatorRe, (_, selector2) => injectScopingSelector(selector2, replaceBy)).replace(_polyfillHostRe, replaceBy + " ");
1816
+ }
1817
+ return scopeSelector2 + " " + selector;
1818
+ };
1819
+ var applyStrictSelectorScope = (selector, scopeSelector2, hostSelector) => {
1820
+ const isRe = /\[is=([^\]]*)\]/g;
1821
+ scopeSelector2 = scopeSelector2.replace(isRe, (_, ...parts) => parts[0]);
1822
+ const className = "." + scopeSelector2;
1823
+ const _scopeSelectorPart = (p) => {
1824
+ let scopedP = p.trim();
1825
+ if (!scopedP) {
1826
+ return "";
1827
+ }
1828
+ if (p.indexOf(_polyfillHostNoCombinator) > -1) {
1829
+ scopedP = applySimpleSelectorScope(p, scopeSelector2, hostSelector);
1830
+ } else {
1831
+ const t = p.replace(_polyfillHostRe, "");
1832
+ if (t.length > 0) {
1833
+ scopedP = injectScopingSelector(t, className);
1834
+ }
1835
+ }
1836
+ return scopedP;
1837
+ };
1838
+ const safeContent = safeSelector(selector);
1839
+ selector = safeContent.content;
1840
+ let scopedSelector = "";
1841
+ let startIndex = 0;
1842
+ let res;
1843
+ const sep = /( |>|\+|~(?!=))\s*/g;
1844
+ const hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1;
1845
+ let shouldScope = !hasHost;
1846
+ while ((res = sep.exec(selector)) !== null) {
1847
+ const separator = res[1];
1848
+ const part2 = selector.slice(startIndex, res.index).trim();
1849
+ shouldScope = shouldScope || part2.indexOf(_polyfillHostNoCombinator) > -1;
1850
+ const scopedPart = shouldScope ? _scopeSelectorPart(part2) : part2;
1851
+ scopedSelector += `${scopedPart} ${separator} `;
1852
+ startIndex = sep.lastIndex;
1853
+ }
1854
+ const part = selector.substring(startIndex);
1855
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
1856
+ scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
1857
+ return restoreSafeSelector(safeContent.placeholders, scopedSelector);
1858
+ };
1859
+ var scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector) => {
1860
+ return selector.split(",").map((shallowPart) => {
1861
+ if (slotSelector && shallowPart.indexOf("." + slotSelector) > -1) {
1862
+ return shallowPart.trim();
1863
+ }
1864
+ if (selectorNeedsScoping(shallowPart, scopeSelectorText)) {
1865
+ return applyStrictSelectorScope(shallowPart, scopeSelectorText, hostSelector).trim();
1866
+ } else {
1867
+ return shallowPart.trim();
1868
+ }
1869
+ }).join(", ");
1870
+ };
1871
+ var scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
1872
+ return processRules(cssText, (rule) => {
1873
+ let selector = rule.selector;
1874
+ let content = rule.content;
1875
+ if (rule.selector[0] !== "@") {
1876
+ selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
1877
+ } else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
1878
+ content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
1879
+ }
1880
+ const cssRule = {
1881
+ selector: selector.replace(/\s{2,}/g, " ").trim(),
1882
+ content
1883
+ };
1884
+ return cssRule;
1885
+ });
1886
+ };
1887
+ var scopeCssText = (cssText, scopeId2, hostScopeId, slotScopeId, commentOriginalSelector) => {
1888
+ cssText = insertPolyfillHostInCssText(cssText);
1889
+ cssText = convertColonHost(cssText);
1890
+ cssText = convertColonHostContext(cssText);
1891
+ const slotted = convertColonSlotted(cssText, slotScopeId);
1892
+ cssText = slotted.cssText;
1893
+ cssText = convertShadowDOMSelectors(cssText);
1894
+ if (scopeId2) {
1895
+ cssText = scopeSelectors(cssText, scopeId2, hostScopeId, slotScopeId, commentOriginalSelector);
1896
+ }
1897
+ cssText = replaceShadowCssHost(cssText, hostScopeId);
1898
+ cssText = cssText.replace(/>\s*\*\s+([^{, ]+)/gm, " $1 ");
1899
+ return {
1900
+ cssText: cssText.trim(),
1901
+ // We need to replace the shadow CSS host string in each of these selectors since we created
1902
+ // them prior to the replacement happening in the components CSS text.
1903
+ slottedSelectors: slotted.selectors.map((ref) => ({
1904
+ orgSelector: replaceShadowCssHost(ref.orgSelector, hostScopeId),
1905
+ updatedSelector: replaceShadowCssHost(ref.updatedSelector, hostScopeId)
1906
+ }))
1907
+ };
1908
+ };
1909
+ var replaceShadowCssHost = (cssText, hostScopeId) => {
1910
+ return cssText.replace(/-shadowcsshost-no-combinator/g, `.${hostScopeId}`);
1911
+ };
1912
+ var scopeCss = (cssText, scopeId2, commentOriginalSelector) => {
1913
+ const hostScopeId = scopeId2 + "-h";
1914
+ const slotScopeId = scopeId2 + "-s";
1915
+ const commentsWithHash = extractCommentsWithHash(cssText);
1916
+ cssText = stripComments(cssText);
1917
+ const orgSelectors = [];
1918
+ if (commentOriginalSelector) {
1919
+ const processCommentedSelector = (rule) => {
1920
+ const placeholder = `/*!@___${orgSelectors.length}___*/`;
1921
+ const comment = `/*!@${rule.selector}*/`;
1922
+ orgSelectors.push({ placeholder, comment });
1923
+ rule.selector = placeholder + rule.selector;
1924
+ return rule;
1925
+ };
1926
+ cssText = processRules(cssText, (rule) => {
1927
+ if (rule.selector[0] !== "@") {
1928
+ return processCommentedSelector(rule);
1929
+ } else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
1930
+ rule.content = processRules(rule.content, processCommentedSelector);
1931
+ return rule;
1932
+ }
1933
+ return rule;
1934
+ });
1935
+ }
1936
+ const scoped = scopeCssText(cssText, scopeId2, hostScopeId, slotScopeId, commentOriginalSelector);
1937
+ cssText = [scoped.cssText, ...commentsWithHash].join("\n");
1938
+ if (commentOriginalSelector) {
1939
+ orgSelectors.forEach(({ placeholder, comment }) => {
1940
+ cssText = cssText.replace(placeholder, comment);
1941
+ });
1942
+ }
1943
+ scoped.slottedSelectors.forEach((slottedSelector) => {
1944
+ const regex = new RegExp(escapeRegExpSpecialCharacters(slottedSelector.orgSelector), "g");
1945
+ cssText = cssText.replace(regex, slottedSelector.updatedSelector);
1946
+ });
1947
+ return cssText;
1948
+ };
1949
+
1582
1950
  // src/runtime/mode.ts
1583
1951
  var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
1584
1952
  var setMode = (handler) => modeResolutionChain.push(handler);
@@ -1684,7 +2052,7 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1684
2052
  if (nonce != null) {
1685
2053
  styleElm.setAttribute("nonce", nonce);
1686
2054
  }
1687
- if ((import_app_data9.BUILD.hydrateServerSide || import_app_data9.BUILD.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2055
+ if ((import_app_data9.BUILD.hydrateServerSide || import_app_data9.BUILD.hotModuleReplacement) && (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */ || cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */)) {
1688
2056
  styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
1689
2057
  }
1690
2058
  if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
@@ -1712,7 +2080,7 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1712
2080
  styleContainerNode.append(styleElm);
1713
2081
  }
1714
2082
  }
1715
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
2083
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1716
2084
  styleContainerNode.insertBefore(styleElm, null);
1717
2085
  }
1718
2086
  }
@@ -1739,13 +2107,21 @@ var attachStyles = (hostRef) => {
1739
2107
  cmpMeta,
1740
2108
  hostRef.$modeName$
1741
2109
  );
1742
- if ((import_app_data9.BUILD.shadowDom || import_app_data9.BUILD.scoped) && import_app_data9.BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
2110
+ if ((import_app_data9.BUILD.shadowDom || import_app_data9.BUILD.scoped) && import_app_data9.BUILD.cssAnnotations && (flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */ || flags & 128 /* shadowNeedsScopedCss */)) {
1743
2111
  elm["s-sc"] = scopeId2;
1744
2112
  elm.classList.add(scopeId2 + "-h");
1745
2113
  }
1746
2114
  endAttachStyles();
1747
2115
  };
1748
2116
  var getScopeId = (cmp, mode) => "sc-" + (import_app_data9.BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2117
+ var convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{");
2118
+ var hydrateScopedToShadow = () => {
2119
+ const styles2 = doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2120
+ let i2 = 0;
2121
+ for (; i2 < styles2.length; i2++) {
2122
+ registerStyle(styles2[i2].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles2[i2].innerHTML), true);
2123
+ }
2124
+ };
1749
2125
 
1750
2126
  // src/runtime/vdom/vdom-render.ts
1751
2127
  var import_app_data12 = require("@rindo/core/internal/app-data");
@@ -2386,7 +2762,7 @@ render() {
2386
2762
  if (import_app_data12.BUILD.scoped || import_app_data12.BUILD.shadowDom) {
2387
2763
  scopeId = hostElm["s-sc"];
2388
2764
  }
2389
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
2765
+ useNativeShadowDom = supportsShadow && !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */);
2390
2766
  if (import_app_data12.BUILD.slotRelocation) {
2391
2767
  contentRef = hostElm["s-cr"];
2392
2768
  checkSlotFallbackVisibility = false;
@@ -3078,9 +3454,8 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3078
3454
  const scopeId2 = getScopeId(cmpMeta, hostRef.$modeName$);
3079
3455
  if (!styles.has(scopeId2)) {
3080
3456
  const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
3081
- if (!import_app_data16.BUILD.hydrateServerSide && import_app_data16.BUILD.shadowDom && // TODO(RINDO-854): Remove code related to legacy shadowDomShim field
3082
- import_app_data16.BUILD.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
3083
- style = await import("../client/shadow-css.js").then((m) => m.scopeCss(style, scopeId2));
3457
+ if (import_app_data16.BUILD.hydrateServerSide && import_app_data16.BUILD.shadowDom && cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */) {
3458
+ style = scopeCss(style, scopeId2, true);
3084
3459
  }
3085
3460
  registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
3086
3461
  endRegisterStyles();
@@ -3251,6 +3626,9 @@ var proxyCustomElement = (Cstr, compactMeta) => {
3251
3626
  patchTextContent(Cstr.prototype);
3252
3627
  }
3253
3628
  }
3629
+ if (import_app_data19.BUILD.hydrateClientSide && import_app_data19.BUILD.shadowDom) {
3630
+ hydrateScopedToShadow();
3631
+ }
3254
3632
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
3255
3633
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
3256
3634
  Object.assign(Cstr.prototype, {
@@ -3371,6 +3749,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3371
3749
  if (import_app_data20.BUILD.hydrateClientSide) {
3372
3750
  plt.$flags$ |= 2 /* appLoaded */;
3373
3751
  }
3752
+ if (import_app_data20.BUILD.hydrateClientSide && import_app_data20.BUILD.shadowDom) {
3753
+ hydrateScopedToShadow();
3754
+ }
3374
3755
  let hasSlotRelocation = false;
3375
3756
  lazyBundles.map((lazyBundle) => {
3376
3757
  lazyBundle[1].map((compactMeta) => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rindo/core/internal/testing",
3
- "version": "4.25.3",
3
+ "version": "4.26.0",
4
4
  "description": "Rindo internal testing platform to be imported by the Rindo Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "private": true