@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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Platform v4.18.3-dev.1718168510.0a11aac | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Platform 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) => {
@@ -872,9 +872,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
872
872
  }
873
873
  elm = newVNode2.$elm$ = BUILD11.svg ? doc.createElementNS(
874
874
  isSvgMode ? SVG_NS : HTML_NS,
875
- BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
875
+ !useNativeShadowDom && BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
876
876
  ) : doc.createElement(
877
- BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
877
+ !useNativeShadowDom && BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
878
878
  );
879
879
  if (BUILD11.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
880
880
  isSvgMode = false;
@@ -2426,13 +2426,21 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2426
2426
  },
2427
2427
  __attachShadow() {
2428
2428
  if (supportsShadow) {
2429
- if (BUILD19.shadowDelegatesFocus) {
2430
- this.attachShadow({
2431
- mode: "open",
2432
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2433
- });
2429
+ if (!this.shadowRoot) {
2430
+ if (BUILD19.shadowDelegatesFocus) {
2431
+ this.attachShadow({
2432
+ mode: "open",
2433
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2434
+ });
2435
+ } else {
2436
+ this.attachShadow({ mode: "open" });
2437
+ }
2434
2438
  } else {
2435
- 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
+ }
2436
2444
  }
2437
2445
  } else {
2438
2446
  this.shadowRoot = this;
@@ -2546,13 +2554,21 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2546
2554
  registerHost(self, cmpMeta);
2547
2555
  if (BUILD20.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2548
2556
  if (supportsShadow) {
2549
- if (BUILD20.shadowDelegatesFocus) {
2550
- self.attachShadow({
2551
- mode: "open",
2552
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2553
- });
2557
+ if (!self.shadowRoot) {
2558
+ if (BUILD20.shadowDelegatesFocus) {
2559
+ self.attachShadow({
2560
+ mode: "open",
2561
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2562
+ });
2563
+ } else {
2564
+ self.attachShadow({ mode: "open" });
2565
+ }
2554
2566
  } else {
2555
- self.attachShadow({ mode: "open" });
2567
+ if (self.shadowRoot.mode !== "open") {
2568
+ throw new Error(
2569
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
2570
+ );
2571
+ }
2556
2572
  }
2557
2573
  } else if (!BUILD20.hydrateServerSide && !("shadowRoot" in self)) {
2558
2574
  self.shadowRoot = self;
@@ -2937,10 +2953,7 @@ var plt = {
2937
2953
  var setPlatformHelpers = (helpers) => {
2938
2954
  Object.assign(plt, helpers);
2939
2955
  };
2940
- var supportsShadow = (
2941
- // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2942
- BUILD25.shadowDomShim && BUILD25.shadowDom ? /* @__PURE__ */ (() => (doc.head.attachShadow + "").indexOf("[native") > -1)() : true
2943
- );
2956
+ var supportsShadow = BUILD25.shadowDom;
2944
2957
  var supportsListenerOptions = /* @__PURE__ */ (() => {
2945
2958
  let supportsListenerOptions2 = false;
2946
2959
  try {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/client",
3
- "version": "4.18.3-dev.1718168510.0a11aac",
3
+ "version": "4.18.3-dev.1718220868.532557e",
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
6
  "private": true,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Patch Browser v4.18.3-dev.1718168510.0a11aac | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Browser v4.18.3-dev.1718220868.532557e | 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-dev.1718168510.0a11aac | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform 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) => {
@@ -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) {
@@ -861,9 +863,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
861
863
  }
862
864
  elm = newVNode2.$elm$ = BUILD10.svg ? doc.createElementNS(
863
865
  isSvgMode ? SVG_NS : HTML_NS,
864
- BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
866
+ !useNativeShadowDom && BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
865
867
  ) : doc.createElement(
866
- BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
868
+ !useNativeShadowDom && BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
867
869
  );
868
870
  if (BUILD10.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
869
871
  isSvgMode = false;
@@ -2415,13 +2417,21 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2415
2417
  },
2416
2418
  __attachShadow() {
2417
2419
  if (supportsShadow) {
2418
- if (BUILD18.shadowDelegatesFocus) {
2419
- this.attachShadow({
2420
- mode: "open",
2421
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2422
- });
2420
+ if (!this.shadowRoot) {
2421
+ if (BUILD18.shadowDelegatesFocus) {
2422
+ this.attachShadow({
2423
+ mode: "open",
2424
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2425
+ });
2426
+ } else {
2427
+ this.attachShadow({ mode: "open" });
2428
+ }
2423
2429
  } else {
2424
- this.attachShadow({ mode: "open" });
2430
+ if (this.shadowRoot.mode !== "open") {
2431
+ throw new Error(
2432
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
2433
+ );
2434
+ }
2425
2435
  }
2426
2436
  } else {
2427
2437
  this.shadowRoot = this;
@@ -2535,13 +2545,21 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2535
2545
  registerHost(self, cmpMeta);
2536
2546
  if (BUILD19.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2537
2547
  if (supportsShadow) {
2538
- if (BUILD19.shadowDelegatesFocus) {
2539
- self.attachShadow({
2540
- mode: "open",
2541
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2542
- });
2548
+ if (!self.shadowRoot) {
2549
+ if (BUILD19.shadowDelegatesFocus) {
2550
+ self.attachShadow({
2551
+ mode: "open",
2552
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2553
+ });
2554
+ } else {
2555
+ self.attachShadow({ mode: "open" });
2556
+ }
2543
2557
  } else {
2544
- self.attachShadow({ mode: "open" });
2558
+ if (self.shadowRoot.mode !== "open") {
2559
+ throw new Error(
2560
+ `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
2561
+ );
2562
+ }
2545
2563
  }
2546
2564
  } else if (!BUILD19.hydrateServerSide && !("shadowRoot" in self)) {
2547
2565
  self.shadowRoot = self;
@@ -2826,7 +2844,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2826
2844
  var hAsync = (nodeName, vnodeData, ...children) => {
2827
2845
  if (Array.isArray(children) && children.length > 0) {
2828
2846
  const flatChildren = children.flat(Infinity);
2829
- if (flatChildren.some(isPromise)) {
2847
+ if (flatChildren.some((child) => child instanceof Promise)) {
2830
2848
  return Promise.all(flatChildren).then((resolvedChildren) => {
2831
2849
  return h(nodeName, vnodeData, ...resolvedChildren);
2832
2850
  }).catch((err2) => {
@@ -2834,7 +2852,7 @@ var hAsync = (nodeName, vnodeData, ...children) => {
2834
2852
  return h(nodeName, vnodeData);
2835
2853
  });
2836
2854
  }
2837
- return h(nodeName, vnodeData, ...children);
2855
+ return h(nodeName, vnodeData, ...flatChildren);
2838
2856
  }
2839
2857
  return h(nodeName, vnodeData);
2840
2858
  };
@@ -2847,15 +2865,25 @@ var globalScripts = (
2847
2865
  );
2848
2866
 
2849
2867
  // src/hydrate/platform/proxy-host-element.ts
2850
- function proxyHostElement(elm, cmpMeta) {
2868
+ import { BUILD as BUILD21 } from "@stencil/core/internal/app-data";
2869
+ function proxyHostElement(elm, cmpMeta, opts) {
2851
2870
  if (typeof elm.componentOnReady !== "function") {
2852
2871
  elm.componentOnReady = componentOnReady;
2853
2872
  }
2854
2873
  if (typeof elm.forceUpdate !== "function") {
2855
2874
  elm.forceUpdate = forceUpdate2;
2856
2875
  }
2857
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2858
- elm.shadowRoot = elm;
2876
+ if (!elm.shadowRoot && !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2877
+ if (BUILD21.shadowDelegatesFocus) {
2878
+ elm.attachShadow({
2879
+ mode: "open",
2880
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2881
+ });
2882
+ } else if (opts.serializeShadowRoot) {
2883
+ elm.attachShadow({ mode: "open" });
2884
+ } else {
2885
+ elm.shadowRoot = elm;
2886
+ }
2859
2887
  }
2860
2888
  if (cmpMeta.$members$ != null) {
2861
2889
  const hostRef = getHostRef(elm);
@@ -2864,7 +2892,13 @@ function proxyHostElement(elm, cmpMeta) {
2864
2892
  const memberFlags = m[0];
2865
2893
  if (memberFlags & 31 /* Prop */) {
2866
2894
  const attributeName = m[1] || memberName;
2867
- const attrValue = elm.getAttribute(attributeName);
2895
+ let attrValue = elm.getAttribute(attributeName);
2896
+ if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
2897
+ try {
2898
+ attrValue = JSON.parse(attrValue);
2899
+ } catch (e) {
2900
+ }
2901
+ }
2868
2902
  if (attrValue != null) {
2869
2903
  const parsedAttrValue = parsePropertyValue(attrValue, memberFlags);
2870
2904
  hostRef.$instanceValues$.set(memberName, parsedAttrValue);
@@ -2912,7 +2946,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2912
2946
  let tmrId;
2913
2947
  let ranCompleted = false;
2914
2948
  function hydratedComplete() {
2915
- global.clearTimeout(tmrId);
2949
+ globalThis.clearTimeout(tmrId);
2916
2950
  createdElements.clear();
2917
2951
  connectedElements.clear();
2918
2952
  if (!ranCompleted) {
@@ -2955,7 +2989,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2955
2989
  createdElements.add(elm);
2956
2990
  elm.connectedCallback = patchedConnectedCallback2;
2957
2991
  registerHost(elm, Cstr.cmpMeta);
2958
- proxyHostElement(elm, Cstr.cmpMeta);
2992
+ proxyHostElement(elm, Cstr.cmpMeta, opts);
2959
2993
  }
2960
2994
  }
2961
2995
  }
@@ -2994,7 +3028,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2994
3028
  patchElement2(elm);
2995
3029
  return elm;
2996
3030
  };
2997
- tmrId = global.setTimeout(timeoutExceeded, opts.timeout);
3031
+ tmrId = globalThis.setTimeout(timeoutExceeded, opts.timeout);
2998
3032
  plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", doc.baseURI).href;
2999
3033
  globalScripts();
3000
3034
  patchChild2(win2.document.body);
@@ -3148,7 +3182,7 @@ function waitingOnElementsMsg(waitingElements) {
3148
3182
  }
3149
3183
 
3150
3184
  // src/hydrate/platform/index.ts
3151
- import { BUILD as BUILD21, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
3185
+ import { BUILD as BUILD23, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
3152
3186
  var customError;
3153
3187
  var cmpModules = /* @__PURE__ */ new Map();
3154
3188
  var getModule = (tagName) => {
@@ -3234,7 +3268,7 @@ var plt = {
3234
3268
  var setPlatformHelpers = (helpers) => {
3235
3269
  Object.assign(plt, helpers);
3236
3270
  };
3237
- var supportsShadow = false;
3271
+ var supportsShadow = BUILD22.shadowDom;
3238
3272
  var supportsListenerOptions = false;
3239
3273
  var supportsConstructableStylesheets = false;
3240
3274
  var hostRefs = /* @__PURE__ */ new WeakMap();
@@ -3264,7 +3298,7 @@ var Build = {
3264
3298
  var styles = /* @__PURE__ */ new Map();
3265
3299
  var modeResolutionChain = [];
3266
3300
  export {
3267
- BUILD21 as BUILD,
3301
+ BUILD23 as BUILD,
3268
3302
  Build,
3269
3303
  Env,
3270
3304
  Fragment,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "4.18.3-dev.1718168510.0a11aac",
3
+ "version": "4.18.3-dev.1718220868.532557e",
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;
@@ -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: true): 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 {};