@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.
Files changed (45) hide show
  1. package/cli/index.cjs +1 -1
  2. package/cli/index.js +1 -1
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +53 -48
  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 +515 -497
  15. package/internal/client/package.json +3 -1
  16. package/internal/client/patch-browser.js +1 -1
  17. package/internal/hydrate/index.js +82 -33
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.d.ts +29 -11
  20. package/internal/hydrate/runner.js +235 -258
  21. package/internal/package.json +1 -1
  22. package/internal/stencil-private.d.ts +21 -11
  23. package/internal/stencil-public-compiler.d.ts +13 -0
  24. package/internal/stencil-public-runtime.d.ts +0 -1
  25. package/internal/testing/index.js +416 -393
  26. package/internal/testing/package.json +1 -1
  27. package/mock-doc/index.cjs +133 -129
  28. package/mock-doc/index.d.ts +18 -4
  29. package/mock-doc/index.js +133 -129
  30. package/mock-doc/package.json +1 -1
  31. package/package.json +30 -2
  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 +64 -1
  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/package.json +1 -1
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/client",
3
- "version": "4.18.3-dev.1718859699.dac3e33",
3
+ "version": "4.18.3-dev.1719000800.2790882",
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-dev.1718859699.dac3e33 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Browser v4.18.3-dev.1719000800.2790882 | 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.1718859699.dac3e33 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform 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) => {
@@ -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) {
@@ -863,9 +865,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
863
865
  }
864
866
  elm = newVNode2.$elm$ = BUILD10.svg ? doc.createElementNS(
865
867
  isSvgMode ? SVG_NS : HTML_NS,
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
  ) : doc.createElement(
868
- BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
870
+ !useNativeShadowDom && BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
869
871
  );
870
872
  if (BUILD10.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
871
873
  isSvgMode = false;
@@ -2409,6 +2411,8 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2409
2411
  registerHost(this, cmpMeta);
2410
2412
  },
2411
2413
  connectedCallback() {
2414
+ const hostRef = getHostRef(this);
2415
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2412
2416
  connectedCallback(this);
2413
2417
  if (BUILD18.connectedCallback && originalConnectedCallback) {
2414
2418
  originalConnectedCallback.call(this);
@@ -2422,13 +2426,21 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2422
2426
  },
2423
2427
  __attachShadow() {
2424
2428
  if (supportsShadow) {
2425
- if (BUILD18.shadowDelegatesFocus) {
2426
- this.attachShadow({
2427
- mode: "open",
2428
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2429
- });
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
+ }
2430
2438
  } else {
2431
- 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
+ }
2432
2444
  }
2433
2445
  } else {
2434
2446
  this.shadowRoot = this;
@@ -2538,17 +2550,26 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2538
2550
  // StencilLazyHost
2539
2551
  constructor(self) {
2540
2552
  super(self);
2553
+ this.hasRegisteredEventListeners = false;
2541
2554
  self = this;
2542
2555
  registerHost(self, cmpMeta);
2543
2556
  if (BUILD19.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2544
2557
  if (supportsShadow) {
2545
- if (BUILD19.shadowDelegatesFocus) {
2546
- self.attachShadow({
2547
- mode: "open",
2548
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2549
- });
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
+ }
2550
2567
  } else {
2551
- 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
+ }
2552
2573
  }
2553
2574
  } else if (!BUILD19.hydrateServerSide && !("shadowRoot" in self)) {
2554
2575
  self.shadowRoot = self;
@@ -2556,6 +2577,11 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2556
2577
  }
2557
2578
  }
2558
2579
  connectedCallback() {
2580
+ const hostRef = getHostRef(this);
2581
+ if (!this.hasRegisteredEventListeners) {
2582
+ this.hasRegisteredEventListeners = true;
2583
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
2584
+ }
2559
2585
  if (appLoadFallback) {
2560
2586
  clearTimeout(appLoadFallback);
2561
2587
  appLoadFallback = null;
@@ -2833,7 +2859,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
2833
2859
  var hAsync = (nodeName, vnodeData, ...children) => {
2834
2860
  if (Array.isArray(children) && children.length > 0) {
2835
2861
  const flatChildren = children.flat(Infinity);
2836
- if (flatChildren.some(isPromise)) {
2862
+ if (flatChildren.some((child) => child instanceof Promise)) {
2837
2863
  return Promise.all(flatChildren).then((resolvedChildren) => {
2838
2864
  return h(nodeName, vnodeData, ...resolvedChildren);
2839
2865
  }).catch((err2) => {
@@ -2841,7 +2867,7 @@ var hAsync = (nodeName, vnodeData, ...children) => {
2841
2867
  return h(nodeName, vnodeData);
2842
2868
  });
2843
2869
  }
2844
- return h(nodeName, vnodeData, ...children);
2870
+ return h(nodeName, vnodeData, ...flatChildren);
2845
2871
  }
2846
2872
  return h(nodeName, vnodeData);
2847
2873
  };
@@ -2854,31 +2880,48 @@ var globalScripts = (
2854
2880
  );
2855
2881
 
2856
2882
  // src/hydrate/platform/proxy-host-element.ts
2857
- function proxyHostElement(elm, cmpMeta) {
2883
+ import { BUILD as BUILD21 } from "@stencil/core/internal/app-data";
2884
+ function proxyHostElement(elm, cmpMeta, opts) {
2858
2885
  if (typeof elm.componentOnReady !== "function") {
2859
2886
  elm.componentOnReady = componentOnReady;
2860
2887
  }
2861
2888
  if (typeof elm.forceUpdate !== "function") {
2862
2889
  elm.forceUpdate = forceUpdate2;
2863
2890
  }
2864
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2865
- elm.shadowRoot = elm;
2891
+ if (!elm.shadowRoot && !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2892
+ if (BUILD21.shadowDelegatesFocus) {
2893
+ elm.attachShadow({
2894
+ mode: "open",
2895
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
2896
+ });
2897
+ } else if (opts.serializeShadowRoot) {
2898
+ elm.attachShadow({ mode: "open" });
2899
+ } else {
2900
+ elm.shadowRoot = elm;
2901
+ }
2866
2902
  }
2867
2903
  if (cmpMeta.$members$ != null) {
2868
2904
  const hostRef = getHostRef(elm);
2869
2905
  const members = Object.entries(cmpMeta.$members$);
2870
2906
  members.forEach(([memberName, m]) => {
2907
+ var _a, _b;
2871
2908
  const memberFlags = m[0];
2872
2909
  if (memberFlags & 31 /* Prop */) {
2873
2910
  const attributeName = m[1] || memberName;
2874
- const attrValue = elm.getAttribute(attributeName);
2911
+ let attrValue = elm.getAttribute(attributeName);
2912
+ if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
2913
+ try {
2914
+ attrValue = JSON.parse(attrValue);
2915
+ } catch (e) {
2916
+ }
2917
+ }
2875
2918
  if (attrValue != null) {
2876
2919
  const parsedAttrValue = parsePropertyValue(attrValue, memberFlags);
2877
- hostRef.$instanceValues$.set(memberName, parsedAttrValue);
2920
+ (_a = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _a.set(memberName, parsedAttrValue);
2878
2921
  }
2879
2922
  const ownValue = elm[memberName];
2880
2923
  if (ownValue !== void 0) {
2881
- hostRef.$instanceValues$.set(memberName, ownValue);
2924
+ (_b = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _b.set(memberName, ownValue);
2882
2925
  delete elm[memberName];
2883
2926
  }
2884
2927
  Object.defineProperty(elm, memberName, {
@@ -2894,8 +2937,12 @@ function proxyHostElement(elm, cmpMeta) {
2894
2937
  } else if (memberFlags & 64 /* Method */) {
2895
2938
  Object.defineProperty(elm, memberName, {
2896
2939
  value(...args) {
2940
+ var _a2;
2897
2941
  const ref = getHostRef(this);
2898
- return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args)).catch(consoleError);
2942
+ return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
2943
+ var _a3;
2944
+ return (_a3 = ref == null ? void 0 : ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
2945
+ }).catch(consoleError);
2899
2946
  }
2900
2947
  });
2901
2948
  }
@@ -2903,7 +2950,8 @@ function proxyHostElement(elm, cmpMeta) {
2903
2950
  }
2904
2951
  }
2905
2952
  function componentOnReady() {
2906
- return getHostRef(this).$onReadyPromise$;
2953
+ var _a;
2954
+ return (_a = getHostRef(this)) == null ? void 0 : _a.$onReadyPromise$;
2907
2955
  }
2908
2956
  function forceUpdate2() {
2909
2957
  }
@@ -2919,7 +2967,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2919
2967
  let tmrId;
2920
2968
  let ranCompleted = false;
2921
2969
  function hydratedComplete() {
2922
- global.clearTimeout(tmrId);
2970
+ globalThis.clearTimeout(tmrId);
2923
2971
  createdElements.clear();
2924
2972
  connectedElements.clear();
2925
2973
  if (!ranCompleted) {
@@ -2962,7 +3010,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
2962
3010
  createdElements.add(elm);
2963
3011
  elm.connectedCallback = patchedConnectedCallback2;
2964
3012
  registerHost(elm, Cstr.cmpMeta);
2965
- proxyHostElement(elm, Cstr.cmpMeta);
3013
+ proxyHostElement(elm, Cstr.cmpMeta, opts);
2966
3014
  }
2967
3015
  }
2968
3016
  }
@@ -3001,7 +3049,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
3001
3049
  patchElement2(elm);
3002
3050
  return elm;
3003
3051
  };
3004
- tmrId = global.setTimeout(timeoutExceeded, opts.timeout);
3052
+ tmrId = globalThis.setTimeout(timeoutExceeded, opts.timeout);
3005
3053
  plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", doc.baseURI).href;
3006
3054
  globalScripts();
3007
3055
  patchChild2(win2.document.body);
@@ -3023,6 +3071,8 @@ async function hydrateComponent(win2, results, tagName, elm, waitingElements) {
3023
3071
  const cmpMeta = Cstr.cmpMeta;
3024
3072
  if (cmpMeta != null) {
3025
3073
  waitingElements.add(elm);
3074
+ const hostRef = getHostRef(this);
3075
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
3026
3076
  try {
3027
3077
  connectedCallback(elm);
3028
3078
  await elm.componentOnReady();
@@ -3155,7 +3205,7 @@ function waitingOnElementsMsg(waitingElements) {
3155
3205
  }
3156
3206
 
3157
3207
  // src/hydrate/platform/index.ts
3158
- import { BUILD as BUILD21, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
3208
+ import { BUILD as BUILD23, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
3159
3209
  var customError;
3160
3210
  var cmpModules = /* @__PURE__ */ new Map();
3161
3211
  var getModule = (tagName) => {
@@ -3241,7 +3291,7 @@ var plt = {
3241
3291
  var setPlatformHelpers = (helpers) => {
3242
3292
  Object.assign(plt, helpers);
3243
3293
  };
3244
- var supportsShadow = false;
3294
+ var supportsShadow = BUILD22.shadowDom;
3245
3295
  var supportsListenerOptions = false;
3246
3296
  var supportsConstructableStylesheets = false;
3247
3297
  var hostRefs = /* @__PURE__ */ new WeakMap();
@@ -3259,7 +3309,6 @@ var registerHost = (elm, cmpMeta) => {
3259
3309
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
3260
3310
  elm["s-p"] = [];
3261
3311
  elm["s-rc"] = [];
3262
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3263
3312
  return hostRefs.set(elm, hostRef);
3264
3313
  };
3265
3314
  var Build = {
@@ -3271,7 +3320,7 @@ var Build = {
3271
3320
  var styles = /* @__PURE__ */ new Map();
3272
3321
  var modeResolutionChain = [];
3273
3322
  export {
3274
- BUILD21 as BUILD,
3323
+ BUILD23 as BUILD,
3275
3324
  Build,
3276
3325
  Env,
3277
3326
  Fragment,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "4.18.3-dev.1718859699.dac3e33",
3
+ "version": "4.18.3-dev.1719000800.2790882",
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 {};