@stencil/core 4.18.3-dev.1718859699.dac3e33 → 4.18.3-dev.1719000800.2790882
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/cli/index.cjs +1 -1
- package/cli/index.js +1 -1
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +53 -48
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +3 -3
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/dev-server/ws.js +1 -1
- package/internal/app-data/package.json +1 -1
- package/internal/client/index.js +515 -497
- package/internal/client/package.json +3 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/hydrate/index.js +82 -33
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.d.ts +29 -11
- package/internal/hydrate/runner.js +235 -258
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +21 -11
- package/internal/stencil-public-compiler.d.ts +13 -0
- package/internal/stencil-public-runtime.d.ts +0 -1
- package/internal/testing/index.js +416 -393
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +133 -129
- package/mock-doc/index.d.ts +18 -4
- package/mock-doc/index.js +133 -129
- package/mock-doc/package.json +1 -1
- package/package.json +30 -2
- package/screenshot/index.js +1 -1
- package/screenshot/package.json +1 -1
- package/screenshot/pixel-match.js +1 -1
- package/sys/node/index.js +10 -10
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +64 -1
- package/testing/jest/jest-27-and-under/matchers/events.d.ts +4 -0
- package/testing/jest/jest-27-and-under/matchers/index.d.ts +2 -1
- package/testing/jest/jest-28/matchers/events.d.ts +4 -0
- package/testing/jest/jest-28/matchers/index.d.ts +2 -1
- package/testing/jest/jest-29/matchers/events.d.ts +4 -0
- package/testing/jest/jest-29/matchers/index.d.ts +2 -1
- package/testing/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Stencil Hydrate Runner v4.18.3-dev.
|
|
2
|
+
Stencil Hydrate Runner v4.18.3-dev.1719000800.2790882 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
@@ -10397,67 +10397,50 @@ function humanReadableList(items) {
|
|
|
10397
10397
|
}
|
|
10398
10398
|
|
|
10399
10399
|
// src/mock-doc/serialize-node.ts
|
|
10400
|
-
function
|
|
10400
|
+
function normalizeSerializationOptions(opts = {}) {
|
|
10401
|
+
return {
|
|
10402
|
+
...opts,
|
|
10403
|
+
outerHtml: typeof opts.outerHtml !== "boolean" ? false : opts.outerHtml,
|
|
10404
|
+
...opts.prettyHtml ? {
|
|
10405
|
+
indentSpaces: typeof opts.indentSpaces !== "number" ? 2 : opts.indentSpaces,
|
|
10406
|
+
newLines: typeof opts.newLines !== "boolean" ? true : opts.newLines
|
|
10407
|
+
} : {
|
|
10408
|
+
prettyHtml: false,
|
|
10409
|
+
indentSpaces: typeof opts.indentSpaces !== "number" ? 0 : opts.indentSpaces,
|
|
10410
|
+
newLines: typeof opts.newLines !== "boolean" ? false : opts.newLines
|
|
10411
|
+
},
|
|
10412
|
+
approximateLineWidth: typeof opts.approximateLineWidth !== "number" ? -1 : opts.approximateLineWidth,
|
|
10413
|
+
removeEmptyAttributes: typeof opts.removeEmptyAttributes !== "boolean" ? true : opts.removeEmptyAttributes,
|
|
10414
|
+
removeAttributeQuotes: typeof opts.removeAttributeQuotes !== "boolean" ? false : opts.removeAttributeQuotes,
|
|
10415
|
+
removeBooleanAttributeQuotes: typeof opts.removeBooleanAttributeQuotes !== "boolean" ? false : opts.removeBooleanAttributeQuotes,
|
|
10416
|
+
removeHtmlComments: typeof opts.removeHtmlComments !== "boolean" ? false : opts.removeHtmlComments,
|
|
10417
|
+
serializeShadowRoot: typeof opts.serializeShadowRoot !== "boolean" ? false : opts.serializeShadowRoot,
|
|
10418
|
+
fullDocument: typeof opts.fullDocument !== "boolean" ? true : opts.fullDocument
|
|
10419
|
+
};
|
|
10420
|
+
}
|
|
10421
|
+
function serializeNodeToHtml(elm, serializationOptions = {}) {
|
|
10422
|
+
const opts = normalizeSerializationOptions(serializationOptions);
|
|
10401
10423
|
const output = {
|
|
10402
10424
|
currentLineWidth: 0,
|
|
10403
10425
|
indent: 0,
|
|
10404
10426
|
isWithinBody: false,
|
|
10405
10427
|
text: []
|
|
10406
10428
|
};
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
}
|
|
10414
|
-
opts.approximateLineWidth = -1;
|
|
10415
|
-
} else {
|
|
10416
|
-
opts.prettyHtml = false;
|
|
10417
|
-
if (typeof opts.newLines !== "boolean") {
|
|
10418
|
-
opts.newLines = false;
|
|
10419
|
-
}
|
|
10420
|
-
if (typeof opts.indentSpaces !== "number") {
|
|
10421
|
-
opts.indentSpaces = 0;
|
|
10422
|
-
}
|
|
10423
|
-
}
|
|
10424
|
-
if (typeof opts.approximateLineWidth !== "number") {
|
|
10425
|
-
opts.approximateLineWidth = -1;
|
|
10426
|
-
}
|
|
10427
|
-
if (typeof opts.removeEmptyAttributes !== "boolean") {
|
|
10428
|
-
opts.removeEmptyAttributes = true;
|
|
10429
|
-
}
|
|
10430
|
-
if (typeof opts.removeAttributeQuotes !== "boolean") {
|
|
10431
|
-
opts.removeAttributeQuotes = false;
|
|
10432
|
-
}
|
|
10433
|
-
if (typeof opts.removeBooleanAttributeQuotes !== "boolean") {
|
|
10434
|
-
opts.removeBooleanAttributeQuotes = false;
|
|
10435
|
-
}
|
|
10436
|
-
if (typeof opts.removeHtmlComments !== "boolean") {
|
|
10437
|
-
opts.removeHtmlComments = false;
|
|
10438
|
-
}
|
|
10439
|
-
if (typeof opts.serializeShadowRoot !== "boolean") {
|
|
10440
|
-
opts.serializeShadowRoot = false;
|
|
10441
|
-
}
|
|
10442
|
-
if (opts.outerHtml) {
|
|
10443
|
-
serializeToHtml(elm, opts, output, false);
|
|
10444
|
-
} else {
|
|
10445
|
-
for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
|
|
10446
|
-
serializeToHtml(elm.childNodes[i], opts, output, false);
|
|
10447
|
-
}
|
|
10448
|
-
}
|
|
10449
|
-
if (output.text[0] === "\n") {
|
|
10450
|
-
output.text.shift();
|
|
10451
|
-
}
|
|
10452
|
-
if (output.text[output.text.length - 1] === "\n") {
|
|
10453
|
-
output.text.pop();
|
|
10429
|
+
let renderedNode = "";
|
|
10430
|
+
const children = !opts.fullDocument && elm.body ? Array.from(elm.body.childNodes) : opts.outerHtml ? [elm] : Array.from(elm.childNodes);
|
|
10431
|
+
for (let i = 0, ii = children.length; i < ii; i++) {
|
|
10432
|
+
const child = children[i];
|
|
10433
|
+
const chunks = Array.from(streamToHtml(child, opts, output));
|
|
10434
|
+
renderedNode += chunks.join("");
|
|
10454
10435
|
}
|
|
10455
|
-
return
|
|
10436
|
+
return renderedNode.trim();
|
|
10456
10437
|
}
|
|
10457
|
-
|
|
10438
|
+
var shadowRootTag = "mock:shadow-root";
|
|
10439
|
+
function* streamToHtml(node, opts, output) {
|
|
10458
10440
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
10441
|
+
const isShadowRoot = node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */;
|
|
10459
10442
|
if (node.nodeType === 1 /* ELEMENT_NODE */ || isShadowRoot) {
|
|
10460
|
-
const tagName = isShadowRoot ?
|
|
10443
|
+
const tagName = isShadowRoot ? shadowRootTag : getTagName(node);
|
|
10461
10444
|
if (tagName === "body") {
|
|
10462
10445
|
output.isWithinBody = true;
|
|
10463
10446
|
}
|
|
@@ -10465,17 +10448,23 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
|
|
|
10465
10448
|
if (ignoreTag === false) {
|
|
10466
10449
|
const isWithinWhitespaceSensitiveNode = opts.newLines || ((_a2 = opts.indentSpaces) != null ? _a2 : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
|
|
10467
10450
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
10468
|
-
|
|
10451
|
+
yield "\n";
|
|
10469
10452
|
output.currentLineWidth = 0;
|
|
10470
10453
|
}
|
|
10471
10454
|
if (((_b = opts.indentSpaces) != null ? _b : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
10472
10455
|
for (let i = 0; i < output.indent; i++) {
|
|
10473
|
-
|
|
10456
|
+
yield " ";
|
|
10474
10457
|
}
|
|
10475
10458
|
output.currentLineWidth += output.indent;
|
|
10476
10459
|
}
|
|
10477
|
-
|
|
10478
|
-
|
|
10460
|
+
const tag = tagName === shadowRootTag ? "template" : tagName;
|
|
10461
|
+
yield "<" + tag;
|
|
10462
|
+
output.currentLineWidth += tag.length + 1;
|
|
10463
|
+
if (tag === "template") {
|
|
10464
|
+
const mode = ` shadowrootmode="open"`;
|
|
10465
|
+
yield mode;
|
|
10466
|
+
output.currentLineWidth += mode.length;
|
|
10467
|
+
}
|
|
10479
10468
|
const attrsLength = node.attributes.length;
|
|
10480
10469
|
const attributes = opts.prettyHtml && attrsLength > 1 ? cloneAttributes(node.attributes, true) : node.attributes;
|
|
10481
10470
|
for (let i = 0; i < attrsLength; i++) {
|
|
@@ -10492,27 +10481,27 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
|
|
|
10492
10481
|
if (attrNamespaceURI == null) {
|
|
10493
10482
|
output.currentLineWidth += attrName.length + 1;
|
|
10494
10483
|
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
|
|
10495
|
-
|
|
10484
|
+
yield "\n" + attrName;
|
|
10496
10485
|
output.currentLineWidth = 0;
|
|
10497
10486
|
} else {
|
|
10498
|
-
|
|
10487
|
+
yield " " + attrName;
|
|
10499
10488
|
}
|
|
10500
10489
|
} else if (attrNamespaceURI === "http://www.w3.org/XML/1998/namespace") {
|
|
10501
|
-
|
|
10490
|
+
yield " xml:" + attrName;
|
|
10502
10491
|
output.currentLineWidth += attrName.length + 5;
|
|
10503
10492
|
} else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/") {
|
|
10504
10493
|
if (attrName !== "xmlns") {
|
|
10505
|
-
|
|
10494
|
+
yield " xmlns:" + attrName;
|
|
10506
10495
|
output.currentLineWidth += attrName.length + 7;
|
|
10507
10496
|
} else {
|
|
10508
|
-
|
|
10497
|
+
yield " " + attrName;
|
|
10509
10498
|
output.currentLineWidth += attrName.length + 1;
|
|
10510
10499
|
}
|
|
10511
10500
|
} else if (attrNamespaceURI === XLINK_NS) {
|
|
10512
|
-
|
|
10501
|
+
yield " xlink:" + attrName;
|
|
10513
10502
|
output.currentLineWidth += attrName.length + 7;
|
|
10514
10503
|
} else {
|
|
10515
|
-
|
|
10504
|
+
yield " " + attrNamespaceURI + ":" + attrName;
|
|
10516
10505
|
output.currentLineWidth += attrNamespaceURI.length + attrName.length + 2;
|
|
10517
10506
|
}
|
|
10518
10507
|
if (opts.prettyHtml && attrName === "class") {
|
|
@@ -10527,43 +10516,45 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
|
|
|
10527
10516
|
}
|
|
10528
10517
|
}
|
|
10529
10518
|
if (opts.removeAttributeQuotes && CAN_REMOVE_ATTR_QUOTES.test(attrValue)) {
|
|
10530
|
-
|
|
10519
|
+
yield "=" + escapeString(attrValue, true);
|
|
10531
10520
|
output.currentLineWidth += attrValue.length + 1;
|
|
10532
10521
|
} else {
|
|
10533
|
-
|
|
10522
|
+
yield '="' + escapeString(attrValue, true) + '"';
|
|
10534
10523
|
output.currentLineWidth += attrValue.length + 3;
|
|
10535
10524
|
}
|
|
10536
10525
|
}
|
|
10537
10526
|
if (node.hasAttribute("style")) {
|
|
10538
10527
|
const cssText = node.style.cssText;
|
|
10539
10528
|
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + cssText.length + 10 > opts.approximateLineWidth) {
|
|
10540
|
-
|
|
10541
|
-
style="${cssText}"
|
|
10529
|
+
yield `
|
|
10530
|
+
style="${cssText}">`;
|
|
10542
10531
|
output.currentLineWidth = 0;
|
|
10543
10532
|
} else {
|
|
10544
|
-
|
|
10533
|
+
yield ` style="${cssText}">`;
|
|
10545
10534
|
output.currentLineWidth += cssText.length + 10;
|
|
10546
10535
|
}
|
|
10547
10536
|
} else {
|
|
10548
|
-
|
|
10537
|
+
yield ">";
|
|
10549
10538
|
output.currentLineWidth += 1;
|
|
10550
10539
|
}
|
|
10551
10540
|
}
|
|
10552
10541
|
if (EMPTY_ELEMENTS.has(tagName) === false) {
|
|
10553
|
-
|
|
10542
|
+
const shadowRoot = node.shadowRoot;
|
|
10543
|
+
if (opts.serializeShadowRoot && shadowRoot != null) {
|
|
10554
10544
|
output.indent = output.indent + ((_c = opts.indentSpaces) != null ? _c : 0);
|
|
10555
|
-
|
|
10545
|
+
yield* streamToHtml(shadowRoot, opts, output);
|
|
10556
10546
|
output.indent = output.indent - ((_d = opts.indentSpaces) != null ? _d : 0);
|
|
10557
10547
|
if (opts.newLines && (node.childNodes.length === 0 || node.childNodes.length === 1 && node.childNodes[0].nodeType === 3 /* TEXT_NODE */ && ((_e = node.childNodes[0].nodeValue) == null ? void 0 : _e.trim()) === "")) {
|
|
10558
|
-
|
|
10548
|
+
yield "\n";
|
|
10559
10549
|
output.currentLineWidth = 0;
|
|
10560
10550
|
for (let i = 0; i < output.indent; i++) {
|
|
10561
|
-
|
|
10551
|
+
yield " ";
|
|
10562
10552
|
}
|
|
10563
10553
|
output.currentLineWidth += output.indent;
|
|
10564
10554
|
}
|
|
10565
10555
|
}
|
|
10566
10556
|
if (opts.excludeTagContent == null || opts.excludeTagContent.includes(tagName) === false) {
|
|
10557
|
+
const tag = tagName === shadowRootTag ? "template" : tagName;
|
|
10567
10558
|
const childNodes = tagName === "template" ? node.content.childNodes : node.childNodes;
|
|
10568
10559
|
const childNodeLength = childNodes.length;
|
|
10569
10560
|
if (childNodeLength > 0) {
|
|
@@ -10574,17 +10565,17 @@ style="${cssText}">`);
|
|
|
10574
10565
|
output.indent = output.indent + ((_h = opts.indentSpaces) != null ? _h : 0);
|
|
10575
10566
|
}
|
|
10576
10567
|
for (let i = 0; i < childNodeLength; i++) {
|
|
10577
|
-
|
|
10568
|
+
yield* streamToHtml(childNodes[i], opts, output);
|
|
10578
10569
|
}
|
|
10579
10570
|
if (ignoreTag === false) {
|
|
10580
10571
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
10581
|
-
|
|
10572
|
+
yield "\n";
|
|
10582
10573
|
output.currentLineWidth = 0;
|
|
10583
10574
|
}
|
|
10584
10575
|
if (((_i = opts.indentSpaces) != null ? _i : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
10585
10576
|
output.indent = output.indent - ((_j = opts.indentSpaces) != null ? _j : 0);
|
|
10586
10577
|
for (let i = 0; i < output.indent; i++) {
|
|
10587
|
-
|
|
10578
|
+
yield " ";
|
|
10588
10579
|
}
|
|
10589
10580
|
output.currentLineWidth += output.indent;
|
|
10590
10581
|
}
|
|
@@ -10592,13 +10583,13 @@ style="${cssText}">`);
|
|
|
10592
10583
|
}
|
|
10593
10584
|
}
|
|
10594
10585
|
if (ignoreTag === false) {
|
|
10595
|
-
|
|
10596
|
-
output.currentLineWidth +=
|
|
10586
|
+
yield "</" + tag + ">";
|
|
10587
|
+
output.currentLineWidth += tag.length + 3;
|
|
10597
10588
|
}
|
|
10598
10589
|
}
|
|
10599
10590
|
}
|
|
10600
10591
|
if (((_k = opts.approximateLineWidth) != null ? _k : 0) > 0 && STRUCTURE_ELEMENTS.has(tagName)) {
|
|
10601
|
-
|
|
10592
|
+
yield "\n";
|
|
10602
10593
|
output.currentLineWidth = 0;
|
|
10603
10594
|
}
|
|
10604
10595
|
if (tagName === "body") {
|
|
@@ -10610,27 +10601,27 @@ style="${cssText}">`);
|
|
|
10610
10601
|
const trimmedTextContent = textContent.trim();
|
|
10611
10602
|
if (trimmedTextContent === "") {
|
|
10612
10603
|
if (isWithinWhitespaceSensitive(node)) {
|
|
10613
|
-
|
|
10604
|
+
yield textContent;
|
|
10614
10605
|
output.currentLineWidth += textContent.length;
|
|
10615
10606
|
} else if (((_l = opts.approximateLineWidth) != null ? _l : 0) > 0 && !output.isWithinBody) {
|
|
10616
10607
|
} else if (!opts.prettyHtml) {
|
|
10617
10608
|
output.currentLineWidth += 1;
|
|
10618
10609
|
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
|
|
10619
|
-
|
|
10610
|
+
yield "\n";
|
|
10620
10611
|
output.currentLineWidth = 0;
|
|
10621
10612
|
} else {
|
|
10622
|
-
|
|
10613
|
+
yield " ";
|
|
10623
10614
|
}
|
|
10624
10615
|
}
|
|
10625
10616
|
} else {
|
|
10626
10617
|
const isWithinWhitespaceSensitiveNode = opts.newLines || ((_m = opts.indentSpaces) != null ? _m : 0) > 0 || opts.prettyHtml ? isWithinWhitespaceSensitive(node) : false;
|
|
10627
10618
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
10628
|
-
|
|
10619
|
+
yield "\n";
|
|
10629
10620
|
output.currentLineWidth = 0;
|
|
10630
10621
|
}
|
|
10631
10622
|
if (((_n = opts.indentSpaces) != null ? _n : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
10632
10623
|
for (let i = 0; i < output.indent; i++) {
|
|
10633
|
-
|
|
10624
|
+
yield " ";
|
|
10634
10625
|
}
|
|
10635
10626
|
output.currentLineWidth += output.indent;
|
|
10636
10627
|
}
|
|
@@ -10639,15 +10630,15 @@ style="${cssText}">`);
|
|
|
10639
10630
|
const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* ELEMENT_NODE */ ? node.parentNode.nodeName : null;
|
|
10640
10631
|
if (typeof parentTagName === "string" && NON_ESCAPABLE_CONTENT.has(parentTagName)) {
|
|
10641
10632
|
if (isWithinWhitespaceSensitive(node)) {
|
|
10642
|
-
|
|
10633
|
+
yield textContent;
|
|
10643
10634
|
} else {
|
|
10644
|
-
|
|
10635
|
+
yield trimmedTextContent;
|
|
10645
10636
|
textContentLength = trimmedTextContent.length;
|
|
10646
10637
|
}
|
|
10647
10638
|
output.currentLineWidth += textContentLength;
|
|
10648
10639
|
} else {
|
|
10649
10640
|
if (opts.prettyHtml && !isWithinWhitespaceSensitiveNode) {
|
|
10650
|
-
|
|
10641
|
+
yield escapeString(textContent.replace(/\s\s+/g, " ").trim(), false);
|
|
10651
10642
|
output.currentLineWidth += textContentLength;
|
|
10652
10643
|
} else {
|
|
10653
10644
|
if (isWithinWhitespaceSensitive(node)) {
|
|
@@ -10669,7 +10660,7 @@ style="${cssText}">`);
|
|
|
10669
10660
|
}
|
|
10670
10661
|
output.currentLineWidth += textContentLength;
|
|
10671
10662
|
}
|
|
10672
|
-
|
|
10663
|
+
yield escapeString(textContent, false);
|
|
10673
10664
|
}
|
|
10674
10665
|
}
|
|
10675
10666
|
}
|
|
@@ -10677,27 +10668,27 @@ style="${cssText}">`);
|
|
|
10677
10668
|
}
|
|
10678
10669
|
} else if (node.nodeType === 8 /* COMMENT_NODE */) {
|
|
10679
10670
|
const nodeValue = node.nodeValue;
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
return;
|
|
10684
|
-
}
|
|
10671
|
+
const isHydrateAnnotation = (nodeValue == null ? void 0 : nodeValue.startsWith(CONTENT_REF_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(ORG_LOCATION_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(SLOT_NODE_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(TEXT_NODE_ID + "."));
|
|
10672
|
+
if (opts.removeHtmlComments && !isHydrateAnnotation) {
|
|
10673
|
+
return;
|
|
10685
10674
|
}
|
|
10686
10675
|
const isWithinWhitespaceSensitiveNode = opts.newLines || ((_o = opts.indentSpaces) != null ? _o : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
|
|
10687
10676
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
10688
|
-
|
|
10677
|
+
yield "\n";
|
|
10689
10678
|
output.currentLineWidth = 0;
|
|
10690
10679
|
}
|
|
10691
10680
|
if (((_p = opts.indentSpaces) != null ? _p : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
10692
10681
|
for (let i = 0; i < output.indent; i++) {
|
|
10693
|
-
|
|
10682
|
+
yield " ";
|
|
10694
10683
|
}
|
|
10695
10684
|
output.currentLineWidth += output.indent;
|
|
10696
10685
|
}
|
|
10697
|
-
|
|
10698
|
-
|
|
10686
|
+
yield "<!--" + nodeValue + "-->";
|
|
10687
|
+
if (nodeValue) {
|
|
10688
|
+
output.currentLineWidth += nodeValue.length + 7;
|
|
10689
|
+
}
|
|
10699
10690
|
} else if (node.nodeType === 10 /* DOCUMENT_TYPE_NODE */) {
|
|
10700
|
-
|
|
10691
|
+
yield "<!doctype html>";
|
|
10701
10692
|
}
|
|
10702
10693
|
}
|
|
10703
10694
|
var AMP_REGEX = /&/g;
|
|
@@ -10722,7 +10713,7 @@ function escapeString(str, attrMode) {
|
|
|
10722
10713
|
}
|
|
10723
10714
|
function isWithinWhitespaceSensitive(node) {
|
|
10724
10715
|
let _node = node;
|
|
10725
|
-
while (_node
|
|
10716
|
+
while (_node == null ? void 0 : _node.nodeName) {
|
|
10726
10717
|
if (WHITESPACE_SENSITIVE.has(_node.nodeName)) {
|
|
10727
10718
|
return true;
|
|
10728
10719
|
}
|
|
@@ -11038,6 +11029,10 @@ Testing components with ElementInternals is fully supported in e2e tests.`
|
|
|
11038
11029
|
get shadowRoot() {
|
|
11039
11030
|
return this.__shadowRoot || null;
|
|
11040
11031
|
}
|
|
11032
|
+
/**
|
|
11033
|
+
* Set shadow root for element
|
|
11034
|
+
* @param shadowRoot - ShadowRoot to set
|
|
11035
|
+
*/
|
|
11041
11036
|
set shadowRoot(shadowRoot) {
|
|
11042
11037
|
if (shadowRoot != null) {
|
|
11043
11038
|
shadowRoot.host = this;
|
|
@@ -13044,6 +13039,7 @@ var nativeClearTimeout = clearTimeout;
|
|
|
13044
13039
|
var nativeSetInterval = setInterval;
|
|
13045
13040
|
var nativeSetTimeout = setTimeout;
|
|
13046
13041
|
var nativeURL = URL;
|
|
13042
|
+
var nativeWindow = globalThis.window;
|
|
13047
13043
|
var MockWindow = class {
|
|
13048
13044
|
constructor(html = null) {
|
|
13049
13045
|
if (html !== false) {
|
|
@@ -13070,10 +13066,10 @@ var MockWindow = class {
|
|
|
13070
13066
|
blur() {
|
|
13071
13067
|
}
|
|
13072
13068
|
cancelAnimationFrame(id) {
|
|
13073
|
-
this.__clearTimeout(id);
|
|
13069
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
13074
13070
|
}
|
|
13075
13071
|
cancelIdleCallback(id) {
|
|
13076
|
-
this.__clearTimeout(id);
|
|
13072
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
13077
13073
|
}
|
|
13078
13074
|
get CharacterData() {
|
|
13079
13075
|
if (this.__charDataCstr == null) {
|
|
@@ -13091,10 +13087,10 @@ var MockWindow = class {
|
|
|
13091
13087
|
this.__charDataCstr = charDataCstr;
|
|
13092
13088
|
}
|
|
13093
13089
|
clearInterval(id) {
|
|
13094
|
-
this.__clearInterval(id);
|
|
13090
|
+
this.__clearInterval.call(nativeWindow || this, id);
|
|
13095
13091
|
}
|
|
13096
13092
|
clearTimeout(id) {
|
|
13097
|
-
this.__clearTimeout(id);
|
|
13093
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
13098
13094
|
}
|
|
13099
13095
|
close() {
|
|
13100
13096
|
resetWindow(this);
|
|
@@ -13394,20 +13390,24 @@ var MockWindow = class {
|
|
|
13394
13390
|
}
|
|
13395
13391
|
return intervalId;
|
|
13396
13392
|
}
|
|
13397
|
-
const timeoutId = this.__setTimeout(
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13393
|
+
const timeoutId = this.__setTimeout.call(
|
|
13394
|
+
nativeWindow || this,
|
|
13395
|
+
() => {
|
|
13396
|
+
if (this.__timeouts) {
|
|
13397
|
+
this.__timeouts.delete(timeoutId);
|
|
13398
|
+
try {
|
|
13399
|
+
callback(...args);
|
|
13400
|
+
} catch (e) {
|
|
13401
|
+
if (this.console) {
|
|
13402
|
+
this.console.error(e);
|
|
13403
|
+
} else {
|
|
13404
|
+
console.error(e);
|
|
13405
|
+
}
|
|
13407
13406
|
}
|
|
13408
13407
|
}
|
|
13409
|
-
}
|
|
13410
|
-
|
|
13408
|
+
},
|
|
13409
|
+
ms
|
|
13410
|
+
);
|
|
13411
13411
|
if (this.__timeouts) {
|
|
13412
13412
|
this.__timeouts.add(timeoutId);
|
|
13413
13413
|
}
|
|
@@ -13418,20 +13418,24 @@ var MockWindow = class {
|
|
|
13418
13418
|
this.__timeouts = /* @__PURE__ */ new Set();
|
|
13419
13419
|
}
|
|
13420
13420
|
ms = Math.min(ms, this.__maxTimeout);
|
|
13421
|
-
const timeoutId = this.__setTimeout(
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13421
|
+
const timeoutId = this.__setTimeout.call(
|
|
13422
|
+
nativeWindow || this,
|
|
13423
|
+
() => {
|
|
13424
|
+
if (this.__timeouts) {
|
|
13425
|
+
this.__timeouts.delete(timeoutId);
|
|
13426
|
+
try {
|
|
13427
|
+
callback(...args);
|
|
13428
|
+
} catch (e) {
|
|
13429
|
+
if (this.console) {
|
|
13430
|
+
this.console.error(e);
|
|
13431
|
+
} else {
|
|
13432
|
+
console.error(e);
|
|
13433
|
+
}
|
|
13431
13434
|
}
|
|
13432
13435
|
}
|
|
13433
|
-
}
|
|
13434
|
-
|
|
13436
|
+
},
|
|
13437
|
+
ms
|
|
13438
|
+
);
|
|
13435
13439
|
if (this.__timeouts) {
|
|
13436
13440
|
this.__timeouts.add(timeoutId);
|
|
13437
13441
|
}
|
|
@@ -14005,11 +14009,11 @@ function createWindowFromHtml(templateHtml, uniqueId) {
|
|
|
14005
14009
|
}
|
|
14006
14010
|
|
|
14007
14011
|
// src/hydrate/runner/render.ts
|
|
14012
|
+
import { Readable } from "stream";
|
|
14008
14013
|
import { hydrateFactory } from "@stencil/core/hydrate-factory";
|
|
14009
14014
|
|
|
14010
14015
|
// src/utils/helpers.ts
|
|
14011
14016
|
var isString = (v) => typeof v === "string";
|
|
14012
|
-
var isPromise = (v) => !!v && (typeof v === "object" || typeof v === "function") && typeof v.then === "function";
|
|
14013
14017
|
|
|
14014
14018
|
// src/utils/message-utils.ts
|
|
14015
14019
|
var catchError = (diagnostics, err2, msg) => {
|
|
@@ -14100,6 +14104,7 @@ var unwrapErr = (result) => {
|
|
|
14100
14104
|
|
|
14101
14105
|
// src/compiler/html/canonical-link.ts
|
|
14102
14106
|
var updateCanonicalLink = (doc, href) => {
|
|
14107
|
+
var _a2;
|
|
14103
14108
|
let canonicalLinkElm = doc.head.querySelector('link[rel="canonical"]');
|
|
14104
14109
|
if (typeof href === "string") {
|
|
14105
14110
|
if (canonicalLinkElm == null) {
|
|
@@ -14112,7 +14117,7 @@ var updateCanonicalLink = (doc, href) => {
|
|
|
14112
14117
|
if (canonicalLinkElm != null) {
|
|
14113
14118
|
const existingHref = canonicalLinkElm.getAttribute("href");
|
|
14114
14119
|
if (!existingHref) {
|
|
14115
|
-
canonicalLinkElm.parentNode.removeChild(canonicalLinkElm);
|
|
14120
|
+
(_a2 = canonicalLinkElm.parentNode) == null ? void 0 : _a2.removeChild(canonicalLinkElm);
|
|
14116
14121
|
}
|
|
14117
14122
|
}
|
|
14118
14123
|
}
|
|
@@ -15146,10 +15151,10 @@ function renderBuildDiagnostic(results, level, header, msg) {
|
|
|
15146
15151
|
return diagnostic;
|
|
15147
15152
|
}
|
|
15148
15153
|
function renderBuildError(results, msg) {
|
|
15149
|
-
return renderBuildDiagnostic(results, "error", "Hydrate Error", msg);
|
|
15154
|
+
return renderBuildDiagnostic(results, "error", "Hydrate Error", msg || "");
|
|
15150
15155
|
}
|
|
15151
15156
|
function renderCatchError(results, err2) {
|
|
15152
|
-
const diagnostic = renderBuildError(results
|
|
15157
|
+
const diagnostic = renderBuildError(results);
|
|
15153
15158
|
if (err2 != null) {
|
|
15154
15159
|
if (err2.stack != null) {
|
|
15155
15160
|
diagnostic.messageText = err2.stack.toString();
|
|
@@ -15211,10 +15216,11 @@ function runtimeLog(pathname, type, msgs) {
|
|
|
15211
15216
|
|
|
15212
15217
|
// src/hydrate/runner/window-initialize.ts
|
|
15213
15218
|
function initializeWindow(win, doc, opts, results) {
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15219
|
+
if (typeof opts.url === "string") {
|
|
15220
|
+
try {
|
|
15221
|
+
win.location.href = opts.url;
|
|
15222
|
+
} catch (e) {
|
|
15223
|
+
}
|
|
15218
15224
|
}
|
|
15219
15225
|
if (typeof opts.userAgent === "string") {
|
|
15220
15226
|
try {
|
|
@@ -15264,134 +15270,99 @@ function initializeWindow(win, doc, opts, results) {
|
|
|
15264
15270
|
}
|
|
15265
15271
|
|
|
15266
15272
|
// src/hydrate/runner/render.ts
|
|
15267
|
-
|
|
15273
|
+
var NOOP = () => {
|
|
15274
|
+
};
|
|
15275
|
+
function streamToString(html, option) {
|
|
15276
|
+
return renderToString(html, option, true);
|
|
15277
|
+
}
|
|
15278
|
+
function renderToString(html, options, asStream) {
|
|
15268
15279
|
const opts = normalizeHydrateOptions(options);
|
|
15269
15280
|
opts.serializeToHtml = true;
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15281
|
+
opts.fullDocument = typeof opts.fullDocument === "boolean" ? opts.fullDocument : true;
|
|
15282
|
+
opts.serializeShadowRoot = Boolean(opts.serializeShadowRoot);
|
|
15283
|
+
opts.constrainTimeouts = false;
|
|
15284
|
+
return hydrateDocument(html, opts, asStream);
|
|
15285
|
+
}
|
|
15286
|
+
function hydrateDocument(doc, options, asStream) {
|
|
15287
|
+
const opts = normalizeHydrateOptions(options);
|
|
15288
|
+
let win = null;
|
|
15289
|
+
const results = generateHydrateResults(opts);
|
|
15290
|
+
if (hasError(results.diagnostics)) {
|
|
15291
|
+
return Promise.resolve(results);
|
|
15292
|
+
}
|
|
15293
|
+
if (typeof doc === "string") {
|
|
15294
|
+
try {
|
|
15295
|
+
opts.destroyWindow = true;
|
|
15296
|
+
opts.destroyDocument = true;
|
|
15297
|
+
win = new MockWindow(doc);
|
|
15298
|
+
if (!asStream) {
|
|
15299
|
+
return render(win, opts, results).then(() => results);
|
|
15288
15300
|
}
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
|
|
15292
|
-
win
|
|
15293
|
-
render(win, opts, results, resolve);
|
|
15294
|
-
} catch (e) {
|
|
15295
|
-
if (win && win.close) {
|
|
15296
|
-
win.close();
|
|
15297
|
-
}
|
|
15298
|
-
win = null;
|
|
15299
|
-
renderCatchError(results, e);
|
|
15300
|
-
resolve(results);
|
|
15301
|
+
return renderStream(win, opts, results);
|
|
15302
|
+
} catch (e) {
|
|
15303
|
+
if (win && win.close) {
|
|
15304
|
+
win.close();
|
|
15301
15305
|
}
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
resolve(results);
|
|
15306
|
+
win = null;
|
|
15307
|
+
renderCatchError(results, e);
|
|
15308
|
+
return Promise.resolve(results);
|
|
15305
15309
|
}
|
|
15306
|
-
}
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
const results = generateHydrateResults(opts);
|
|
15314
|
-
if (hasError(results.diagnostics)) {
|
|
15315
|
-
resolve(results);
|
|
15316
|
-
} else if (typeof doc === "string") {
|
|
15317
|
-
try {
|
|
15318
|
-
opts.destroyWindow = true;
|
|
15319
|
-
opts.destroyDocument = true;
|
|
15320
|
-
win = new MockWindow(doc);
|
|
15321
|
-
render(win, opts, results, resolve);
|
|
15322
|
-
} catch (e) {
|
|
15323
|
-
if (win && win.close) {
|
|
15324
|
-
win.close();
|
|
15325
|
-
}
|
|
15326
|
-
win = null;
|
|
15327
|
-
renderCatchError(results, e);
|
|
15328
|
-
resolve(results);
|
|
15310
|
+
}
|
|
15311
|
+
if (isValidDocument(doc)) {
|
|
15312
|
+
try {
|
|
15313
|
+
opts.destroyDocument = false;
|
|
15314
|
+
win = patchDomImplementation(doc, opts);
|
|
15315
|
+
if (!asStream) {
|
|
15316
|
+
return render(win, opts, results).then(() => results);
|
|
15329
15317
|
}
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
win
|
|
15334
|
-
render(win, opts, results, resolve);
|
|
15335
|
-
} catch (e) {
|
|
15336
|
-
if (win && win.close) {
|
|
15337
|
-
win.close();
|
|
15338
|
-
}
|
|
15339
|
-
win = null;
|
|
15340
|
-
renderCatchError(results, e);
|
|
15341
|
-
resolve(results);
|
|
15318
|
+
return renderStream(win, opts, results);
|
|
15319
|
+
} catch (e) {
|
|
15320
|
+
if (win && win.close) {
|
|
15321
|
+
win.close();
|
|
15342
15322
|
}
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
resolve(results);
|
|
15323
|
+
win = null;
|
|
15324
|
+
renderCatchError(results, e);
|
|
15325
|
+
return Promise.resolve(results);
|
|
15346
15326
|
}
|
|
15347
|
-
}
|
|
15327
|
+
}
|
|
15328
|
+
renderBuildError(results, `Invalid html or document. Must be either a valid "html" string, or DOM "document".`);
|
|
15329
|
+
return Promise.resolve(results);
|
|
15348
15330
|
}
|
|
15349
|
-
function render(win, opts, results
|
|
15350
|
-
if (!process.__stencilErrors) {
|
|
15331
|
+
async function render(win, opts, results) {
|
|
15332
|
+
if ("process" in globalThis && typeof process.on === "function" && !process.__stencilErrors) {
|
|
15351
15333
|
process.__stencilErrors = true;
|
|
15352
15334
|
process.on("unhandledRejection", (e) => {
|
|
15353
15335
|
console.log("unhandledRejection", e);
|
|
15354
15336
|
});
|
|
15355
15337
|
}
|
|
15356
15338
|
initializeWindow(win, win.document, opts, results);
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
} else {
|
|
15365
|
-
hydrateFactory(win, opts, results, afterHydrate, resolve);
|
|
15366
|
-
}
|
|
15367
|
-
} catch (e) {
|
|
15368
|
-
renderCatchError(results, e);
|
|
15369
|
-
finalizeHydrate(win, win.document, opts, results, resolve);
|
|
15370
|
-
}
|
|
15371
|
-
} else {
|
|
15372
|
-
hydrateFactory(win, opts, results, afterHydrate, resolve);
|
|
15339
|
+
const beforeHydrateFn = typeof opts.beforeHydrate === "function" ? opts.beforeHydrate(win.document) : NOOP;
|
|
15340
|
+
try {
|
|
15341
|
+
await Promise.resolve(beforeHydrateFn(win.document));
|
|
15342
|
+
return new Promise((resolve) => hydrateFactory(win, opts, results, afterHydrate, resolve));
|
|
15343
|
+
} catch (e) {
|
|
15344
|
+
renderCatchError(results, e);
|
|
15345
|
+
return finalizeHydrate(win, win.document, opts, results);
|
|
15373
15346
|
}
|
|
15374
15347
|
}
|
|
15375
|
-
function
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
} else {
|
|
15391
|
-
finalizeHydrate(win, win.document, opts, results, resolve);
|
|
15348
|
+
function renderStream(win, opts, results) {
|
|
15349
|
+
async function* processRender() {
|
|
15350
|
+
const renderResult = await render(win, opts, results);
|
|
15351
|
+
yield renderResult.html;
|
|
15352
|
+
}
|
|
15353
|
+
return Readable.from(processRender());
|
|
15354
|
+
}
|
|
15355
|
+
async function afterHydrate(win, opts, results, resolve) {
|
|
15356
|
+
const afterHydrateFn = typeof opts.afterHydrate === "function" ? opts.afterHydrate(win.document) : NOOP;
|
|
15357
|
+
try {
|
|
15358
|
+
await Promise.resolve(afterHydrateFn(win.document));
|
|
15359
|
+
return resolve(finalizeHydrate(win, win.document, opts, results));
|
|
15360
|
+
} catch (e) {
|
|
15361
|
+
renderCatchError(results, e);
|
|
15362
|
+
return resolve(finalizeHydrate(win, win.document, opts, results));
|
|
15392
15363
|
}
|
|
15393
15364
|
}
|
|
15394
|
-
function finalizeHydrate(win, doc, opts, results
|
|
15365
|
+
function finalizeHydrate(win, doc, opts, results) {
|
|
15395
15366
|
try {
|
|
15396
15367
|
inspectElement(results, doc.documentElement, 0);
|
|
15397
15368
|
if (opts.removeUnusedStyles !== false) {
|
|
@@ -15443,20 +15414,24 @@ function finalizeHydrate(win, doc, opts, results, resolve) {
|
|
|
15443
15414
|
} catch (e) {
|
|
15444
15415
|
renderCatchError(results, e);
|
|
15445
15416
|
}
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15417
|
+
destroyWindow(win, doc, opts, results);
|
|
15418
|
+
return results;
|
|
15419
|
+
}
|
|
15420
|
+
function destroyWindow(win, doc, opts, results) {
|
|
15421
|
+
if (!opts.destroyWindow) {
|
|
15422
|
+
return;
|
|
15423
|
+
}
|
|
15424
|
+
try {
|
|
15425
|
+
if (!opts.destroyDocument) {
|
|
15426
|
+
win.document = null;
|
|
15427
|
+
doc.defaultView = null;
|
|
15428
|
+
}
|
|
15429
|
+
if (win.close) {
|
|
15430
|
+
win.close();
|
|
15457
15431
|
}
|
|
15432
|
+
} catch (e) {
|
|
15433
|
+
renderCatchError(results, e);
|
|
15458
15434
|
}
|
|
15459
|
-
resolve(results);
|
|
15460
15435
|
}
|
|
15461
15436
|
function serializeDocumentToString(doc, opts) {
|
|
15462
15437
|
return serializeNodeToHtml(doc, {
|
|
@@ -15467,7 +15442,8 @@ function serializeDocumentToString(doc, opts) {
|
|
|
15467
15442
|
removeBooleanAttributeQuotes: opts.removeBooleanAttributeQuotes,
|
|
15468
15443
|
removeEmptyAttributes: opts.removeEmptyAttributes,
|
|
15469
15444
|
removeHtmlComments: opts.removeHtmlComments,
|
|
15470
|
-
serializeShadowRoot:
|
|
15445
|
+
serializeShadowRoot: opts.serializeShadowRoot,
|
|
15446
|
+
fullDocument: opts.fullDocument
|
|
15471
15447
|
});
|
|
15472
15448
|
}
|
|
15473
15449
|
function isValidDocument(doc) {
|
|
@@ -15487,5 +15463,6 @@ export {
|
|
|
15487
15463
|
createWindowFromHtml,
|
|
15488
15464
|
hydrateDocument,
|
|
15489
15465
|
renderToString,
|
|
15490
|
-
serializeDocumentToString
|
|
15466
|
+
serializeDocumentToString,
|
|
15467
|
+
streamToString
|
|
15491
15468
|
};
|