@stencil/core 4.18.3-dev.1718168510.0a11aac → 4.18.3-dev.1718220868.532557e
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 +43 -44
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/index.js +32 -19
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/hydrate/index.js +62 -28
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.d.ts +19 -1
- package/internal/hydrate/runner.js +222 -249
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +5 -0
- package/internal/stencil-public-compiler.d.ts +13 -0
- package/internal/testing/index.js +30 -14
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +127 -125
- package/mock-doc/index.d.ts +17 -3
- package/mock-doc/index.js +127 -125
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- 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 +1 -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.1718220868.532557e | 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,25 @@ 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
|
-
|
|
10686
|
+
yield "<!--" + nodeValue + "-->";
|
|
10698
10687
|
output.currentLineWidth += nodeValue.length + 7;
|
|
10699
10688
|
} else if (node.nodeType === 10 /* DOCUMENT_TYPE_NODE */) {
|
|
10700
|
-
|
|
10689
|
+
yield "<!doctype html>";
|
|
10701
10690
|
}
|
|
10702
10691
|
}
|
|
10703
10692
|
var AMP_REGEX = /&/g;
|
|
@@ -11038,6 +11027,10 @@ Testing components with ElementInternals is fully supported in e2e tests.`
|
|
|
11038
11027
|
get shadowRoot() {
|
|
11039
11028
|
return this.__shadowRoot || null;
|
|
11040
11029
|
}
|
|
11030
|
+
/**
|
|
11031
|
+
* Set shadow root for element
|
|
11032
|
+
* @param shadowRoot - ShadowRoot to set
|
|
11033
|
+
*/
|
|
11041
11034
|
set shadowRoot(shadowRoot) {
|
|
11042
11035
|
if (shadowRoot != null) {
|
|
11043
11036
|
shadowRoot.host = this;
|
|
@@ -13042,6 +13035,7 @@ var nativeClearTimeout = clearTimeout;
|
|
|
13042
13035
|
var nativeSetInterval = setInterval;
|
|
13043
13036
|
var nativeSetTimeout = setTimeout;
|
|
13044
13037
|
var nativeURL = URL;
|
|
13038
|
+
var nativeWindow = globalThis.window;
|
|
13045
13039
|
var MockWindow = class {
|
|
13046
13040
|
constructor(html = null) {
|
|
13047
13041
|
if (html !== false) {
|
|
@@ -13068,10 +13062,10 @@ var MockWindow = class {
|
|
|
13068
13062
|
blur() {
|
|
13069
13063
|
}
|
|
13070
13064
|
cancelAnimationFrame(id) {
|
|
13071
|
-
this.__clearTimeout(id);
|
|
13065
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
13072
13066
|
}
|
|
13073
13067
|
cancelIdleCallback(id) {
|
|
13074
|
-
this.__clearTimeout(id);
|
|
13068
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
13075
13069
|
}
|
|
13076
13070
|
get CharacterData() {
|
|
13077
13071
|
if (this.__charDataCstr == null) {
|
|
@@ -13089,10 +13083,10 @@ var MockWindow = class {
|
|
|
13089
13083
|
this.__charDataCstr = charDataCstr;
|
|
13090
13084
|
}
|
|
13091
13085
|
clearInterval(id) {
|
|
13092
|
-
this.__clearInterval(id);
|
|
13086
|
+
this.__clearInterval.call(nativeWindow || this, id);
|
|
13093
13087
|
}
|
|
13094
13088
|
clearTimeout(id) {
|
|
13095
|
-
this.__clearTimeout(id);
|
|
13089
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
13096
13090
|
}
|
|
13097
13091
|
close() {
|
|
13098
13092
|
resetWindow(this);
|
|
@@ -13392,20 +13386,24 @@ var MockWindow = class {
|
|
|
13392
13386
|
}
|
|
13393
13387
|
return intervalId;
|
|
13394
13388
|
}
|
|
13395
|
-
const timeoutId = this.__setTimeout(
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13389
|
+
const timeoutId = this.__setTimeout.call(
|
|
13390
|
+
nativeWindow || this,
|
|
13391
|
+
() => {
|
|
13392
|
+
if (this.__timeouts) {
|
|
13393
|
+
this.__timeouts.delete(timeoutId);
|
|
13394
|
+
try {
|
|
13395
|
+
callback(...args);
|
|
13396
|
+
} catch (e) {
|
|
13397
|
+
if (this.console) {
|
|
13398
|
+
this.console.error(e);
|
|
13399
|
+
} else {
|
|
13400
|
+
console.error(e);
|
|
13401
|
+
}
|
|
13405
13402
|
}
|
|
13406
13403
|
}
|
|
13407
|
-
}
|
|
13408
|
-
|
|
13404
|
+
},
|
|
13405
|
+
ms
|
|
13406
|
+
);
|
|
13409
13407
|
if (this.__timeouts) {
|
|
13410
13408
|
this.__timeouts.add(timeoutId);
|
|
13411
13409
|
}
|
|
@@ -13416,20 +13414,24 @@ var MockWindow = class {
|
|
|
13416
13414
|
this.__timeouts = /* @__PURE__ */ new Set();
|
|
13417
13415
|
}
|
|
13418
13416
|
ms = Math.min(ms, this.__maxTimeout);
|
|
13419
|
-
const timeoutId = this.__setTimeout(
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13417
|
+
const timeoutId = this.__setTimeout.call(
|
|
13418
|
+
nativeWindow || this,
|
|
13419
|
+
() => {
|
|
13420
|
+
if (this.__timeouts) {
|
|
13421
|
+
this.__timeouts.delete(timeoutId);
|
|
13422
|
+
try {
|
|
13423
|
+
callback(...args);
|
|
13424
|
+
} catch (e) {
|
|
13425
|
+
if (this.console) {
|
|
13426
|
+
this.console.error(e);
|
|
13427
|
+
} else {
|
|
13428
|
+
console.error(e);
|
|
13429
|
+
}
|
|
13429
13430
|
}
|
|
13430
13431
|
}
|
|
13431
|
-
}
|
|
13432
|
-
|
|
13432
|
+
},
|
|
13433
|
+
ms
|
|
13434
|
+
);
|
|
13433
13435
|
if (this.__timeouts) {
|
|
13434
13436
|
this.__timeouts.add(timeoutId);
|
|
13435
13437
|
}
|
|
@@ -14003,11 +14005,11 @@ function createWindowFromHtml(templateHtml, uniqueId) {
|
|
|
14003
14005
|
}
|
|
14004
14006
|
|
|
14005
14007
|
// src/hydrate/runner/render.ts
|
|
14008
|
+
import { Readable } from "stream";
|
|
14006
14009
|
import { hydrateFactory } from "@stencil/core/hydrate-factory";
|
|
14007
14010
|
|
|
14008
14011
|
// src/utils/helpers.ts
|
|
14009
14012
|
var isString = (v) => typeof v === "string";
|
|
14010
|
-
var isPromise = (v) => !!v && (typeof v === "object" || typeof v === "function") && typeof v.then === "function";
|
|
14011
14013
|
|
|
14012
14014
|
// src/utils/message-utils.ts
|
|
14013
14015
|
var catchError = (diagnostics, err2, msg) => {
|
|
@@ -15262,134 +15264,99 @@ function initializeWindow(win, doc, opts, results) {
|
|
|
15262
15264
|
}
|
|
15263
15265
|
|
|
15264
15266
|
// src/hydrate/runner/render.ts
|
|
15265
|
-
|
|
15267
|
+
var NOOP = () => {
|
|
15268
|
+
};
|
|
15269
|
+
function streamToString(html, option) {
|
|
15270
|
+
return renderToString(html, option, true);
|
|
15271
|
+
}
|
|
15272
|
+
function renderToString(html, options, asStream) {
|
|
15266
15273
|
const opts = normalizeHydrateOptions(options);
|
|
15267
15274
|
opts.serializeToHtml = true;
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15275
|
+
opts.fullDocument = typeof opts.fullDocument === "boolean" ? opts.fullDocument : true;
|
|
15276
|
+
opts.serializeShadowRoot = Boolean(opts.serializeShadowRoot);
|
|
15277
|
+
opts.constrainTimeouts = false;
|
|
15278
|
+
return hydrateDocument(html, opts, asStream);
|
|
15279
|
+
}
|
|
15280
|
+
function hydrateDocument(doc, options, asStream) {
|
|
15281
|
+
const opts = normalizeHydrateOptions(options);
|
|
15282
|
+
let win;
|
|
15283
|
+
const results = generateHydrateResults(opts);
|
|
15284
|
+
if (hasError(results.diagnostics)) {
|
|
15285
|
+
return Promise.resolve(results);
|
|
15286
|
+
}
|
|
15287
|
+
if (typeof doc === "string") {
|
|
15288
|
+
try {
|
|
15289
|
+
opts.destroyWindow = true;
|
|
15290
|
+
opts.destroyDocument = true;
|
|
15291
|
+
win = new MockWindow(doc);
|
|
15292
|
+
if (!asStream) {
|
|
15293
|
+
return render(win, opts, results).then(() => results);
|
|
15286
15294
|
}
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15290
|
-
win
|
|
15291
|
-
render(win, opts, results, resolve);
|
|
15292
|
-
} catch (e) {
|
|
15293
|
-
if (win && win.close) {
|
|
15294
|
-
win.close();
|
|
15295
|
-
}
|
|
15296
|
-
win = null;
|
|
15297
|
-
renderCatchError(results, e);
|
|
15298
|
-
resolve(results);
|
|
15295
|
+
return renderStream(win, opts, results);
|
|
15296
|
+
} catch (e) {
|
|
15297
|
+
if (win && win.close) {
|
|
15298
|
+
win.close();
|
|
15299
15299
|
}
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
resolve(results);
|
|
15300
|
+
win = null;
|
|
15301
|
+
renderCatchError(results, e);
|
|
15302
|
+
return Promise.resolve(results);
|
|
15303
15303
|
}
|
|
15304
|
-
}
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
const results = generateHydrateResults(opts);
|
|
15312
|
-
if (hasError(results.diagnostics)) {
|
|
15313
|
-
resolve(results);
|
|
15314
|
-
} else if (typeof doc === "string") {
|
|
15315
|
-
try {
|
|
15316
|
-
opts.destroyWindow = true;
|
|
15317
|
-
opts.destroyDocument = true;
|
|
15318
|
-
win = new MockWindow(doc);
|
|
15319
|
-
render(win, opts, results, resolve);
|
|
15320
|
-
} catch (e) {
|
|
15321
|
-
if (win && win.close) {
|
|
15322
|
-
win.close();
|
|
15323
|
-
}
|
|
15324
|
-
win = null;
|
|
15325
|
-
renderCatchError(results, e);
|
|
15326
|
-
resolve(results);
|
|
15304
|
+
}
|
|
15305
|
+
if (isValidDocument(doc)) {
|
|
15306
|
+
try {
|
|
15307
|
+
opts.destroyDocument = false;
|
|
15308
|
+
win = patchDomImplementation(doc, opts);
|
|
15309
|
+
if (!asStream) {
|
|
15310
|
+
return render(win, opts, results).then(() => results);
|
|
15327
15311
|
}
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
win
|
|
15332
|
-
render(win, opts, results, resolve);
|
|
15333
|
-
} catch (e) {
|
|
15334
|
-
if (win && win.close) {
|
|
15335
|
-
win.close();
|
|
15336
|
-
}
|
|
15337
|
-
win = null;
|
|
15338
|
-
renderCatchError(results, e);
|
|
15339
|
-
resolve(results);
|
|
15312
|
+
return renderStream(win, opts, results);
|
|
15313
|
+
} catch (e) {
|
|
15314
|
+
if (win && win.close) {
|
|
15315
|
+
win.close();
|
|
15340
15316
|
}
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
resolve(results);
|
|
15317
|
+
win = null;
|
|
15318
|
+
renderCatchError(results, e);
|
|
15319
|
+
return Promise.resolve(results);
|
|
15344
15320
|
}
|
|
15345
|
-
}
|
|
15321
|
+
}
|
|
15322
|
+
renderBuildError(results, `Invalid html or document. Must be either a valid "html" string, or DOM "document".`);
|
|
15323
|
+
return Promise.resolve(results);
|
|
15346
15324
|
}
|
|
15347
|
-
function render(win, opts, results
|
|
15348
|
-
if (!process.__stencilErrors) {
|
|
15325
|
+
async function render(win, opts, results) {
|
|
15326
|
+
if ("process" in globalThis && typeof process.on === "function" && !process.__stencilErrors) {
|
|
15349
15327
|
process.__stencilErrors = true;
|
|
15350
15328
|
process.on("unhandledRejection", (e) => {
|
|
15351
15329
|
console.log("unhandledRejection", e);
|
|
15352
15330
|
});
|
|
15353
15331
|
}
|
|
15354
15332
|
initializeWindow(win, win.document, opts, results);
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
} else {
|
|
15363
|
-
hydrateFactory(win, opts, results, afterHydrate, resolve);
|
|
15364
|
-
}
|
|
15365
|
-
} catch (e) {
|
|
15366
|
-
renderCatchError(results, e);
|
|
15367
|
-
finalizeHydrate(win, win.document, opts, results, resolve);
|
|
15368
|
-
}
|
|
15369
|
-
} else {
|
|
15370
|
-
hydrateFactory(win, opts, results, afterHydrate, resolve);
|
|
15333
|
+
const beforeHydrateFn = typeof opts.beforeHydrate === "function" ? opts.beforeHydrate(win.document) : NOOP;
|
|
15334
|
+
try {
|
|
15335
|
+
await Promise.resolve(beforeHydrateFn(win.document));
|
|
15336
|
+
return new Promise((resolve) => hydrateFactory(win, opts, results, afterHydrate, resolve));
|
|
15337
|
+
} catch (e) {
|
|
15338
|
+
renderCatchError(results, e);
|
|
15339
|
+
return finalizeHydrate(win, win.document, opts, results);
|
|
15371
15340
|
}
|
|
15372
15341
|
}
|
|
15373
|
-
function
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
} else {
|
|
15389
|
-
finalizeHydrate(win, win.document, opts, results, resolve);
|
|
15342
|
+
function renderStream(win, opts, results) {
|
|
15343
|
+
async function* processRender() {
|
|
15344
|
+
const renderResult = await render(win, opts, results);
|
|
15345
|
+
yield renderResult.html;
|
|
15346
|
+
}
|
|
15347
|
+
return Readable.from(processRender());
|
|
15348
|
+
}
|
|
15349
|
+
async function afterHydrate(win, opts, results, resolve) {
|
|
15350
|
+
const afterHydrateFn = typeof opts.afterHydrate === "function" ? opts.afterHydrate(win.document) : NOOP;
|
|
15351
|
+
try {
|
|
15352
|
+
await Promise.resolve(afterHydrateFn(win.document));
|
|
15353
|
+
return resolve(finalizeHydrate(win, win.document, opts, results));
|
|
15354
|
+
} catch (e) {
|
|
15355
|
+
renderCatchError(results, e);
|
|
15356
|
+
return resolve(finalizeHydrate(win, win.document, opts, results));
|
|
15390
15357
|
}
|
|
15391
15358
|
}
|
|
15392
|
-
function finalizeHydrate(win, doc, opts, results
|
|
15359
|
+
function finalizeHydrate(win, doc, opts, results) {
|
|
15393
15360
|
try {
|
|
15394
15361
|
inspectElement(results, doc.documentElement, 0);
|
|
15395
15362
|
if (opts.removeUnusedStyles !== false) {
|
|
@@ -15441,20 +15408,24 @@ function finalizeHydrate(win, doc, opts, results, resolve) {
|
|
|
15441
15408
|
} catch (e) {
|
|
15442
15409
|
renderCatchError(results, e);
|
|
15443
15410
|
}
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15411
|
+
destroyWindow(win, doc, opts, results);
|
|
15412
|
+
return results;
|
|
15413
|
+
}
|
|
15414
|
+
function destroyWindow(win, doc, opts, results) {
|
|
15415
|
+
if (!opts.destroyWindow) {
|
|
15416
|
+
return;
|
|
15417
|
+
}
|
|
15418
|
+
try {
|
|
15419
|
+
if (!opts.destroyDocument) {
|
|
15420
|
+
win.document = null;
|
|
15421
|
+
doc.defaultView = null;
|
|
15422
|
+
}
|
|
15423
|
+
if (win.close) {
|
|
15424
|
+
win.close();
|
|
15455
15425
|
}
|
|
15426
|
+
} catch (e) {
|
|
15427
|
+
renderCatchError(results, e);
|
|
15456
15428
|
}
|
|
15457
|
-
resolve(results);
|
|
15458
15429
|
}
|
|
15459
15430
|
function serializeDocumentToString(doc, opts) {
|
|
15460
15431
|
return serializeNodeToHtml(doc, {
|
|
@@ -15465,7 +15436,8 @@ function serializeDocumentToString(doc, opts) {
|
|
|
15465
15436
|
removeBooleanAttributeQuotes: opts.removeBooleanAttributeQuotes,
|
|
15466
15437
|
removeEmptyAttributes: opts.removeEmptyAttributes,
|
|
15467
15438
|
removeHtmlComments: opts.removeHtmlComments,
|
|
15468
|
-
serializeShadowRoot:
|
|
15439
|
+
serializeShadowRoot: opts.serializeShadowRoot,
|
|
15440
|
+
fullDocument: opts.fullDocument
|
|
15469
15441
|
});
|
|
15470
15442
|
}
|
|
15471
15443
|
function isValidDocument(doc) {
|
|
@@ -15485,5 +15457,6 @@ export {
|
|
|
15485
15457
|
createWindowFromHtml,
|
|
15486
15458
|
hydrateDocument,
|
|
15487
15459
|
renderToString,
|
|
15488
|
-
serializeDocumentToString
|
|
15460
|
+
serializeDocumentToString,
|
|
15461
|
+
streamToString
|
|
15489
15462
|
};
|