@stencil/core 4.18.3 → 4.19.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 (47) hide show
  1. package/cli/index.cjs +43 -16
  2. package/cli/index.js +43 -16
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +175 -72
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +3 -3
  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/dev-server/ws.js +1 -1
  13. package/internal/app-data/package.json +1 -1
  14. package/internal/client/index.js +534 -507
  15. package/internal/client/package.json +3 -1
  16. package/internal/client/patch-browser.js +1 -1
  17. package/internal/hydrate/index.js +108 -50
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.d.ts +29 -11
  20. package/internal/hydrate/runner.js +239 -260
  21. package/internal/package.json +1 -1
  22. package/internal/stencil-private.d.ts +39 -14
  23. package/internal/stencil-public-compiler.d.ts +21 -0
  24. package/internal/stencil-public-runtime.d.ts +0 -2
  25. package/internal/testing/index.js +439 -407
  26. package/internal/testing/package.json +1 -1
  27. package/mock-doc/index.cjs +137 -131
  28. package/mock-doc/index.d.ts +18 -4
  29. package/mock-doc/index.js +137 -131
  30. package/mock-doc/package.json +1 -1
  31. package/package.json +34 -6
  32. package/screenshot/index.js +1 -1
  33. package/screenshot/package.json +1 -1
  34. package/screenshot/pixel-match.js +1 -1
  35. package/sys/node/index.js +10 -10
  36. package/sys/node/package.json +1 -1
  37. package/sys/node/worker.js +1 -1
  38. package/testing/index.js +95 -16
  39. package/testing/jest/jest-27-and-under/matchers/events.d.ts +4 -0
  40. package/testing/jest/jest-27-and-under/matchers/index.d.ts +2 -1
  41. package/testing/jest/jest-28/matchers/events.d.ts +4 -0
  42. package/testing/jest/jest-28/matchers/index.d.ts +2 -1
  43. package/testing/jest/jest-29/matchers/events.d.ts +4 -0
  44. package/testing/jest/jest-29/matchers/index.d.ts +2 -1
  45. package/testing/mocks.d.ts +9 -9
  46. package/testing/package.json +1 -1
  47. package/testing/puppeteer/puppeteer-declarations.d.ts +11 -0
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/client",
3
- "version": "4.18.3",
3
+ "version": "4.19.0",
4
4
  "description": "Stencil internal client platform to be imported by the Stencil Compiler and internal runtime. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
+ "exports": "./index.js",
7
+ "type": "module",
6
8
  "private": true,
7
9
  "sideEffects": false
8
10
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Patch Browser v4.18.3 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Browser v4.19.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
 
5
5
  // src/client/client-patch-browser.ts
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Hydrate Platform v4.18.3 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform v4.19.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -7,6 +7,9 @@ var __export = (target, all) => {
7
7
  __defProp(target, name, { get: all[name], enumerable: true });
8
8
  };
9
9
 
10
+ // src/hydrate/platform/index.ts
11
+ import { BUILD as BUILD22 } from "@stencil/core/internal/app-data";
12
+
10
13
  // src/runtime/asset-path.ts
11
14
  var getAssetPath = (path) => {
12
15
  const assetUrl = new URL(path, plt.$resourcesUrl$);
@@ -28,7 +31,6 @@ var isComplexType = (o) => {
28
31
  o = typeof o;
29
32
  return o === "object" || o === "function";
30
33
  };
31
- var isPromise = (v) => !!v && (typeof v === "object" || typeof v === "function") && typeof v.then === "function";
32
34
 
33
35
  // src/utils/query-nonce-meta-tag-content.ts
34
36
  function queryNonceMetaTagContent(doc2) {
@@ -613,6 +615,8 @@ var registerStyle = (scopeId2, cssText, allowCS) => {
613
615
  };
614
616
  var addStyle = (styleContainerNode, cmpMeta, mode) => {
615
617
  var _a;
618
+ const styleContainerDocument = styleContainerNode;
619
+ const styleContainerShadowRoot = styleContainerNode;
616
620
  const scopeId2 = getScopeId(cmpMeta, mode);
617
621
  const style = styles.get(scopeId2);
618
622
  if (!BUILD7.attachStyles) {
@@ -621,14 +625,14 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
621
625
  styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
622
626
  if (style) {
623
627
  if (typeof style === "string") {
624
- styleContainerNode = styleContainerNode.head || styleContainerNode;
628
+ styleContainerNode = styleContainerDocument.head || styleContainerNode;
625
629
  let appliedStyles = rootAppliedStyles.get(styleContainerNode);
626
630
  let styleElm;
627
631
  if (!appliedStyles) {
628
632
  rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
629
633
  }
630
634
  if (!appliedStyles.has(scopeId2)) {
631
- if (BUILD7.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
635
+ if (BUILD7.hydrateClientSide && styleContainerShadowRoot.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
632
636
  styleElm.innerHTML = style;
633
637
  } else {
634
638
  styleElm = doc.createElement("style");
@@ -649,8 +653,8 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
649
653
  appliedStyles.add(scopeId2);
650
654
  }
651
655
  }
652
- } else if (BUILD7.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
653
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
656
+ } else if (BUILD7.constructableCSS && !styleContainerDocument.adoptedStyleSheets.includes(style)) {
657
+ styleContainerDocument.adoptedStyleSheets = [...styleContainerDocument.adoptedStyleSheets, style];
654
658
  }
655
659
  }
656
660
  return scopeId2;
@@ -861,9 +865,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
861
865
  }
862
866
  elm = newVNode2.$elm$ = BUILD10.svg ? doc.createElementNS(
863
867
  isSvgMode ? SVG_NS : HTML_NS,
864
- BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
868
+ !useNativeShadowDom && BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
865
869
  ) : doc.createElement(
866
- BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
870
+ !useNativeShadowDom && BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
867
871
  );
868
872
  if (BUILD10.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
869
873
  isSvgMode = false;
@@ -1450,7 +1454,10 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
1450
1454
  endSchedule();
1451
1455
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1452
1456
  };
1453
- var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1457
+ var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
1458
+ console.error(err2);
1459
+ fn();
1460
+ }) : fn();
1454
1461
  var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
1455
1462
  var updateComponent = async (hostRef, instance, isInitialLoad) => {
1456
1463
  var _a;
@@ -1739,7 +1746,7 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1739
1746
 
1740
1747
  // src/runtime/proxy-component.ts
1741
1748
  var proxyComponent = (Cstr, cmpMeta, flags) => {
1742
- var _a;
1749
+ var _a, _b;
1743
1750
  const prototype = Cstr.prototype;
1744
1751
  if (BUILD13.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
1745
1752
  FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach(
@@ -1761,11 +1768,11 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1761
1768
  })
1762
1769
  );
1763
1770
  }
1764
- if (BUILD13.member && cmpMeta.$members$) {
1765
- if (BUILD13.watchCallback && Cstr.watchers) {
1771
+ if (BUILD13.member && cmpMeta.$members$ || BUILD13.watchCallback && (cmpMeta.$watchers$ || Cstr.watchers)) {
1772
+ if (BUILD13.watchCallback && Cstr.watchers && !cmpMeta.$watchers$) {
1766
1773
  cmpMeta.$watchers$ = Cstr.watchers;
1767
1774
  }
1768
- const members = Object.entries(cmpMeta.$members$);
1775
+ const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
1769
1776
  members.map(([memberName, [memberFlags]]) => {
1770
1777
  if ((BUILD13.prop || BUILD13.state) && (memberFlags & 31 /* Prop */ || (!BUILD13.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
1771
1778
  Object.defineProperty(prototype, memberName, {
@@ -1837,7 +1844,7 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
1837
1844
  };
1838
1845
  Cstr.observedAttributes = Array.from(
1839
1846
  /* @__PURE__ */ new Set([
1840
- ...Object.keys((_a = cmpMeta.$watchers$) != null ? _a : {}),
1847
+ ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1841
1848
  ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
1842
1849
  var _a2;
1843
1850
  const attrName = m[1] || propName;
@@ -1905,11 +1912,13 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1905
1912
  customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
1906
1913
  }
1907
1914
  if (BUILD14.style && Cstr && Cstr.style) {
1908
- let style = Cstr.style;
1909
- if (BUILD14.mode && typeof style !== "string") {
1915
+ let style;
1916
+ if (typeof Cstr.style === "string") {
1917
+ style = Cstr.style;
1918
+ } else if (BUILD14.mode && typeof Cstr.style !== "string") {
1910
1919
  hostRef.$modeName$ = computeMode(elm);
1911
1920
  if (hostRef.$modeName$) {
1912
- style = style[hostRef.$modeName$];
1921
+ style = Cstr.style[hostRef.$modeName$];
1913
1922
  }
1914
1923
  if (BUILD14.hydrateServerSide && hostRef.$modeName$) {
1915
1924
  elm.setAttribute("s-mode", hostRef.$modeName$);
@@ -2402,6 +2411,8 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2402
2411
  registerHost(this, cmpMeta);
2403
2412
  },
2404
2413
  connectedCallback() {
2414
+ const hostRef = getHostRef(this);
2415
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2405
2416
  connectedCallback(this);
2406
2417
  if (BUILD18.connectedCallback && originalConnectedCallback) {
2407
2418
  originalConnectedCallback.call(this);
@@ -2415,13 +2426,21 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2415
2426
  },
2416
2427
  __attachShadow() {
2417
2428
  if (supportsShadow) {
2418
- if (BUILD18.shadowDelegatesFocus) {
2419
- this.attachShadow({
2420
- mode: "open",
2421
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2422
- });
2429
+ if (!this.shadowRoot) {
2430
+ if (BUILD18.shadowDelegatesFocus) {
2431
+ this.attachShadow({
2432
+ mode: "open",
2433
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2434
+ });
2435
+ } else {
2436
+ this.attachShadow({ mode: "open" });
2437
+ }
2423
2438
  } else {
2424
- this.attachShadow({ mode: "open" });
2439
+ if (this.shadowRoot.mode !== "open") {
2440
+ throw new Error(
2441
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
2442
+ );
2443
+ }
2425
2444
  }
2426
2445
  } else {
2427
2446
  this.shadowRoot = this;
@@ -2531,17 +2550,26 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2531
2550
  // StencilLazyHost
2532
2551
  constructor(self) {
2533
2552
  super(self);
2553
+ this.hasRegisteredEventListeners = false;
2534
2554
  self = this;
2535
2555
  registerHost(self, cmpMeta);
2536
2556
  if (BUILD19.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2537
2557
  if (supportsShadow) {
2538
- if (BUILD19.shadowDelegatesFocus) {
2539
- self.attachShadow({
2540
- mode: "open",
2541
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2542
- });
2558
+ if (!self.shadowRoot) {
2559
+ if (BUILD19.shadowDelegatesFocus) {
2560
+ self.attachShadow({
2561
+ mode: "open",
2562
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2563
+ });
2564
+ } else {
2565
+ self.attachShadow({ mode: "open" });
2566
+ }
2543
2567
  } else {
2544
- self.attachShadow({ mode: "open" });
2568
+ if (self.shadowRoot.mode !== "open") {
2569
+ throw new Error(
2570
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
2571
+ );
2572
+ }
2545
2573
  }
2546
2574
  } else if (!BUILD19.hydrateServerSide && !("shadowRoot" in self)) {
2547
2575
  self.shadowRoot = self;
@@ -2549,6 +2577,11 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2549
2577
  }
2550
2578
  }
2551
2579
  connectedCallback() {
2580
+ const hostRef = getHostRef(this);
2581
+ if (!this.hasRegisteredEventListeners) {
2582
+ this.hasRegisteredEventListeners = true;
2583
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2584
+ }
2552
2585
  if (appLoadFallback) {
2553
2586
  clearTimeout(appLoadFallback);
2554
2587
  appLoadFallback = null;
@@ -2607,7 +2640,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2607
2640
  dataStyles.textContent += SLOT_FB_CSS;
2608
2641
  }
2609
2642
  if (BUILD19.invisiblePrehydration && (BUILD19.hydratedClass || BUILD19.hydratedAttribute)) {
2610
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
2643
+ dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
2611
2644
  }
2612
2645
  if (dataStyles.innerHTML.length) {
2613
2646
  dataStyles.setAttribute("data-styles", "");
@@ -2738,6 +2771,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
2738
2771
  }
2739
2772
  };
2740
2773
  var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
2774
+ var _a;
2741
2775
  if (node == null) {
2742
2776
  return;
2743
2777
  }
@@ -2745,7 +2779,8 @@ var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
2745
2779
  orgLocationNodes.push(node);
2746
2780
  }
2747
2781
  if (node.nodeType === 1 /* ElementNode */) {
2748
- node.childNodes.forEach((childNode) => {
2782
+ const childNodes = [...Array.from(node.childNodes), ...Array.from(((_a = node.shadowRoot) == null ? void 0 : _a.childNodes) || [])];
2783
+ childNodes.forEach((childNode) => {
2749
2784
  const hostRef = getHostRef(childNode);
2750
2785
  if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
2751
2786
  const cmpData = {
@@ -2826,7 +2861,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2826
2861
  var hAsync = (nodeName, vnodeData, ...children) => {
2827
2862
  if (Array.isArray(children) && children.length > 0) {
2828
2863
  const flatChildren = children.flat(Infinity);
2829
- if (flatChildren.some(isPromise)) {
2864
+ if (flatChildren.some((child) => child instanceof Promise)) {
2830
2865
  return Promise.all(flatChildren).then((resolvedChildren) => {
2831
2866
  return h(nodeName, vnodeData, ...resolvedChildren);
2832
2867
  }).catch((err2) => {
@@ -2834,7 +2869,7 @@ var hAsync = (nodeName, vnodeData, ...children) => {
2834
2869
  return h(nodeName, vnodeData);
2835
2870
  });
2836
2871
  }
2837
- return h(nodeName, vnodeData, ...children);
2872
+ return h(nodeName, vnodeData, ...flatChildren);
2838
2873
  }
2839
2874
  return h(nodeName, vnodeData);
2840
2875
  };
@@ -2847,31 +2882,48 @@ var globalScripts = (
2847
2882
  );
2848
2883
 
2849
2884
  // src/hydrate/platform/proxy-host-element.ts
2850
- function proxyHostElement(elm, cmpMeta) {
2885
+ import { BUILD as BUILD21 } from "@stencil/core/internal/app-data";
2886
+ function proxyHostElement(elm, cmpMeta, opts) {
2851
2887
  if (typeof elm.componentOnReady !== "function") {
2852
2888
  elm.componentOnReady = componentOnReady;
2853
2889
  }
2854
2890
  if (typeof elm.forceUpdate !== "function") {
2855
2891
  elm.forceUpdate = forceUpdate2;
2856
2892
  }
2857
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2858
- elm.shadowRoot = elm;
2893
+ if (!elm.shadowRoot && !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2894
+ if (BUILD21.shadowDelegatesFocus) {
2895
+ elm.attachShadow({
2896
+ mode: "open",
2897
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2898
+ });
2899
+ } else if (opts.serializeShadowRoot) {
2900
+ elm.attachShadow({ mode: "open" });
2901
+ } else {
2902
+ elm.shadowRoot = elm;
2903
+ }
2859
2904
  }
2860
2905
  if (cmpMeta.$members$ != null) {
2861
2906
  const hostRef = getHostRef(elm);
2862
2907
  const members = Object.entries(cmpMeta.$members$);
2863
2908
  members.forEach(([memberName, m]) => {
2909
+ var _a, _b;
2864
2910
  const memberFlags = m[0];
2865
2911
  if (memberFlags & 31 /* Prop */) {
2866
2912
  const attributeName = m[1] || memberName;
2867
- const attrValue = elm.getAttribute(attributeName);
2913
+ let attrValue = elm.getAttribute(attributeName);
2914
+ if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
2915
+ try {
2916
+ attrValue = JSON.parse(attrValue);
2917
+ } catch (e) {
2918
+ }
2919
+ }
2868
2920
  if (attrValue != null) {
2869
2921
  const parsedAttrValue = parsePropertyValue(attrValue, memberFlags);
2870
- hostRef.$instanceValues$.set(memberName, parsedAttrValue);
2922
+ (_a = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _a.set(memberName, parsedAttrValue);
2871
2923
  }
2872
2924
  const ownValue = elm[memberName];
2873
2925
  if (ownValue !== void 0) {
2874
- hostRef.$instanceValues$.set(memberName, ownValue);
2926
+ (_b = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _b.set(memberName, ownValue);
2875
2927
  delete elm[memberName];
2876
2928
  }
2877
2929
  Object.defineProperty(elm, memberName, {
@@ -2887,8 +2939,12 @@ function proxyHostElement(elm, cmpMeta) {
2887
2939
  } else if (memberFlags & 64 /* Method */) {
2888
2940
  Object.defineProperty(elm, memberName, {
2889
2941
  value(...args) {
2942
+ var _a2;
2890
2943
  const ref = getHostRef(this);
2891
- return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args)).catch(consoleError);
2944
+ return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
2945
+ var _a3;
2946
+ return (_a3 = ref == null ? void 0 : ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
2947
+ }).catch(consoleError);
2892
2948
  }
2893
2949
  });
2894
2950
  }
@@ -2896,7 +2952,8 @@ function proxyHostElement(elm, cmpMeta) {
2896
2952
  }
2897
2953
  }
2898
2954
  function componentOnReady() {
2899
- return getHostRef(this).$onReadyPromise$;
2955
+ var _a;
2956
+ return (_a = getHostRef(this)) == null ? void 0 : _a.$onReadyPromise$;
2900
2957
  }
2901
2958
  function forceUpdate2() {
2902
2959
  }
@@ -2912,7 +2969,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2912
2969
  let tmrId;
2913
2970
  let ranCompleted = false;
2914
2971
  function hydratedComplete() {
2915
- global.clearTimeout(tmrId);
2972
+ globalThis.clearTimeout(tmrId);
2916
2973
  createdElements.clear();
2917
2974
  connectedElements.clear();
2918
2975
  if (!ranCompleted) {
@@ -2955,7 +3012,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2955
3012
  createdElements.add(elm);
2956
3013
  elm.connectedCallback = patchedConnectedCallback2;
2957
3014
  registerHost(elm, Cstr.cmpMeta);
2958
- proxyHostElement(elm, Cstr.cmpMeta);
3015
+ proxyHostElement(elm, Cstr.cmpMeta, opts);
2959
3016
  }
2960
3017
  }
2961
3018
  }
@@ -2994,7 +3051,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2994
3051
  patchElement2(elm);
2995
3052
  return elm;
2996
3053
  };
2997
- tmrId = global.setTimeout(timeoutExceeded, opts.timeout);
3054
+ tmrId = globalThis.setTimeout(timeoutExceeded, opts.timeout);
2998
3055
  plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", doc.baseURI).href;
2999
3056
  globalScripts();
3000
3057
  patchChild2(win2.document.body);
@@ -3016,6 +3073,8 @@ async function hydrateComponent(win2, results, tagName, elm, waitingElements) {
3016
3073
  const cmpMeta = Cstr.cmpMeta;
3017
3074
  if (cmpMeta != null) {
3018
3075
  waitingElements.add(elm);
3076
+ const hostRef = getHostRef(this);
3077
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
3019
3078
  try {
3020
3079
  connectedCallback(elm);
3021
3080
  await elm.componentOnReady();
@@ -3148,7 +3207,7 @@ function waitingOnElementsMsg(waitingElements) {
3148
3207
  }
3149
3208
 
3150
3209
  // src/hydrate/platform/index.ts
3151
- import { BUILD as BUILD21, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
3210
+ import { BUILD as BUILD23, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
3152
3211
  var customError;
3153
3212
  var cmpModules = /* @__PURE__ */ new Map();
3154
3213
  var getModule = (tagName) => {
@@ -3190,7 +3249,7 @@ var registerComponents = (Cstrs) => {
3190
3249
  var win = window;
3191
3250
  var doc = win.document;
3192
3251
  var readTask = (cb) => {
3193
- process.nextTick(() => {
3252
+ nextTick(() => {
3194
3253
  try {
3195
3254
  cb();
3196
3255
  } catch (e) {
@@ -3199,7 +3258,7 @@ var readTask = (cb) => {
3199
3258
  });
3200
3259
  };
3201
3260
  var writeTask = (cb) => {
3202
- process.nextTick(() => {
3261
+ nextTick(() => {
3203
3262
  try {
3204
3263
  cb();
3205
3264
  } catch (e) {
@@ -3234,7 +3293,7 @@ var plt = {
3234
3293
  var setPlatformHelpers = (helpers) => {
3235
3294
  Object.assign(plt, helpers);
3236
3295
  };
3237
- var supportsShadow = false;
3296
+ var supportsShadow = BUILD22.shadowDom;
3238
3297
  var supportsListenerOptions = false;
3239
3298
  var supportsConstructableStylesheets = false;
3240
3299
  var hostRefs = /* @__PURE__ */ new WeakMap();
@@ -3252,7 +3311,6 @@ var registerHost = (elm, cmpMeta) => {
3252
3311
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
3253
3312
  elm["s-p"] = [];
3254
3313
  elm["s-rc"] = [];
3255
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3256
3314
  return hostRefs.set(elm, hostRef);
3257
3315
  };
3258
3316
  var Build = {
@@ -3264,7 +3322,7 @@ var Build = {
3264
3322
  var styles = /* @__PURE__ */ new Map();
3265
3323
  var modeResolutionChain = [];
3266
3324
  export {
3267
- BUILD21 as BUILD,
3325
+ BUILD23 as BUILD,
3268
3326
  Build,
3269
3327
  Env,
3270
3328
  Fragment,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "4.18.3",
3
+ "version": "4.19.0",
4
4
  "description": "Stencil internal hydrate platform to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "private": true
@@ -1,5 +1,7 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
+ import { Readable } from 'node:stream';
4
+
3
5
  export declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
4
6
  export interface HydrateDocumentOptions {
5
7
  /**
@@ -134,6 +136,19 @@ export interface SerializeDocumentOptions extends HydrateDocumentOptions {
134
136
  * Remove HTML comments. Defaults to `true`.
135
137
  */
136
138
  removeHtmlComments?: boolean;
139
+ /**
140
+ * If set to `false` Stencil will ignore the fact that a component has a `shadow: true`
141
+ * flag and serializes it as a scoped component. If set to `true` the component will
142
+ * be rendered within a Declarative Shadow DOM.
143
+ * @default false
144
+ */
145
+ serializeShadowRoot?: boolean;
146
+ /**
147
+ * The `fullDocument` flag determines the format of the rendered output. Set it to true to
148
+ * generate a complete HTML document, or false to render only the component.
149
+ * @default true
150
+ */
151
+ fullDocument?: boolean;
137
152
  }
138
153
  export interface HydrateFactoryOptions extends SerializeDocumentOptions {
139
154
  serializeToHtml: boolean;
@@ -165,23 +180,23 @@ export interface HydrateResults {
165
180
  buildId: string;
166
181
  diagnostics: Diagnostic[];
167
182
  url: string;
168
- host: string;
169
- hostname: string;
170
- href: string;
171
- port: string;
172
- pathname: string;
173
- search: string;
174
- hash: string;
175
- html: string;
183
+ host: string | null;
184
+ hostname: string | null;
185
+ href: string | null;
186
+ port: string | null;
187
+ pathname: string | null;
188
+ search: string | null;
189
+ hash: string | null;
190
+ html: string | null;
176
191
  components: HydrateComponent[];
177
192
  anchors: HydrateAnchorElement[];
178
193
  imgs: HydrateImgElement[];
179
194
  scripts: HydrateScriptElement[];
180
195
  styles: HydrateStyleElement[];
181
196
  staticData: HydrateStaticData[];
182
- title: string;
197
+ title: string | null;
183
198
  hydratedCount: number;
184
- httpStatus: number;
199
+ httpStatus: number | null;
185
200
  }
186
201
  export interface HydrateComponent {
187
202
  tag: string;
@@ -211,8 +226,11 @@ export interface HydrateStaticData {
211
226
  type: string;
212
227
  content: string;
213
228
  }
229
+ export declare function streamToString(html: string | any, option?: SerializeDocumentOptions): Readable;
230
+ export declare function renderToString(html: string | any, options: SerializeDocumentOptions | undefined, asStream: true): Readable;
214
231
  export declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<HydrateResults>;
232
+ export declare function hydrateDocument(doc: any | string, options: HydrateDocumentOptions | undefined, asStream?: boolean): Readable;
215
233
  export declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
216
- export declare function serializeDocumentToString(doc: any, opts: HydrateFactoryOptions): string;
234
+ export declare function serializeDocumentToString(doc: Document, opts: HydrateFactoryOptions): string;
217
235
 
218
236
  export {};