@stencil/core 5.0.0-alpha.2 → 5.0.0-alpha.3

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 (42) hide show
  1. package/dist/{client-DucyoZT4.mjs → client-CSm3x5ke.mjs} +81 -60
  2. package/dist/compiler/index.d.mts +3 -3
  3. package/dist/compiler/index.mjs +2 -2
  4. package/dist/compiler/utils/index.d.mts +2 -2
  5. package/dist/compiler/utils/index.mjs +3 -3
  6. package/dist/{compiler-DyK1_szo.mjs → compiler-D6iP7Bzb.mjs} +1390 -1631
  7. package/dist/declarations/stencil-public-compiler.d.ts +4031 -2
  8. package/dist/declarations/stencil-public-compiler.js +0 -1
  9. package/dist/declarations/stencil-public-docs.d.ts +494 -1
  10. package/dist/declarations/stencil-public-runtime.d.ts +1943 -2
  11. package/dist/{index-fIuYTL9f.d.mts → index-CXHCTQNt.d.mts} +14 -2
  12. package/dist/{index-BONzXKJt.d.ts → index-CyrGY82h.d.ts} +5 -7
  13. package/dist/{index-CHjZtib0.d.ts → index-hS-KBdAP.d.ts} +1 -1
  14. package/dist/{index-D-LlB2nw.d.mts → index-tUR6pD3J.d.mts} +145 -809
  15. package/dist/index.d.mts +1 -0
  16. package/dist/index.mjs +2 -2
  17. package/dist/{jsx-runtime-DBzBJLKk.d.ts → jsx-runtime-DlDkTqps.d.ts} +1 -1
  18. package/dist/jsx-runtime.d.ts +1 -1
  19. package/dist/jsx-runtime.js +1 -1
  20. package/dist/{node-BWBQAh8C.mjs → node-Bg-mO5dw.mjs} +3 -14
  21. package/dist/regular-expression-D5pGVpCu.mjs +415 -0
  22. package/dist/runtime/app-data/index.d.ts +1 -1
  23. package/dist/runtime/app-data/index.js +1 -2
  24. package/dist/runtime/client/index.d.ts +14 -4
  25. package/dist/runtime/client/index.js +103 -205
  26. package/dist/runtime/index.d.ts +16 -4
  27. package/dist/runtime/index.js +2 -2
  28. package/dist/runtime/server/index.d.mts +1 -3
  29. package/dist/runtime/server/index.mjs +103 -205
  30. package/dist/runtime/server/runner.d.mts +1 -17
  31. package/dist/runtime/server/runner.mjs +12 -394
  32. package/dist/{runtime-CqlPYKjW.js → runtime-BBCnuprF.js} +103 -205
  33. package/dist/sys/node/index.d.mts +1 -1
  34. package/dist/sys/node/index.mjs +1 -1
  35. package/dist/sys/node/worker.mjs +2 -2
  36. package/dist/testing/index.d.mts +3 -3
  37. package/dist/testing/index.mjs +18 -17
  38. package/dist/{validation-BR7tMYEv.mjs → validation-Byxie0Uk.mjs} +28 -24
  39. package/package.json +9 -13
  40. package/dist/serialize-o-Sj1lvg.mjs +0 -792
  41. package/dist/stencil-public-compiler-C_X1iolo.d.ts +0 -4455
  42. package/dist/stencil-public-runtime-DlV8o7-z.d.ts +0 -1845
@@ -29,8 +29,7 @@ const LISTENER_FLAGS = {
29
29
  Capture: 2,
30
30
  TargetDocument: 4,
31
31
  TargetWindow: 8,
32
- TargetBody: 16,
33
- TargetParent: 32
32
+ TargetBody: 16
34
33
  };
35
34
  const HOST_FLAGS = {
36
35
  hasConnected: 1,
@@ -66,7 +65,12 @@ const CMP_FLAGS = {
66
65
  shadowNeedsScopedCss: 128,
67
66
  hasSlot: 256,
68
67
  hasModernPropertyDecls: 512,
69
- shadowSlotAssignmentManual: 1024
68
+ shadowSlotAssignmentManual: 1024,
69
+ shadowModeClosed: 2048,
70
+ patchChildren: 4096,
71
+ patchClone: 8192,
72
+ patchInsert: 16384,
73
+ patchAll: 32768
70
74
  };
71
75
  /**
72
76
  * Namespaces
@@ -97,38 +101,6 @@ const NODE_TYPES = {
97
101
  DOCUMENT_FRAGMENT_NODE: 11,
98
102
  NOTATION_NODE: 12
99
103
  };
100
- /**
101
- * Represents a primitive type.
102
- * Described in https://w3c.github.io/webdriver-bidi/#type-script-PrimitiveProtocolValue.
103
- */
104
- const PrimitiveType = {
105
- Undefined: "undefined",
106
- Null: "null",
107
- String: "string",
108
- Number: "number",
109
- SpecialNumber: "number",
110
- Boolean: "boolean",
111
- BigInt: "bigint"
112
- };
113
- /**
114
- * Represents a non-primitive type.
115
- * Described in https://w3c.github.io/webdriver-bidi/#type-script-RemoteValue.
116
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead.
117
- */
118
- const NonPrimitiveType = {
119
- Array: "array",
120
- Date: "date",
121
- Map: "map",
122
- Object: "object",
123
- RegularExpression: "regexp",
124
- Set: "set",
125
- Channel: "channel",
126
- Symbol: "symbol"
127
- };
128
- /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
129
- const TYPE_CONSTANT = "type";
130
- /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
131
- const VALUE_CONSTANT = "value";
132
104
  //#endregion
133
105
  //#region src/utils/get-prop-descriptor.ts
134
106
  /**
@@ -284,12 +256,14 @@ function createStyleSheetIfNeededAndSupported(styles) {}
284
256
  let globalStyleSheet;
285
257
  const GLOBAL_STYLE_ID = "sc-global";
286
258
  function createShadowRoot(cmpMeta) {
287
- const opts = { mode: "open" };
259
+ const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
260
+ const opts = { mode: isClosed ? "closed" : "open" };
288
261
  if (BUILD$1.shadowDelegatesFocus) opts.delegatesFocus = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDelegatesFocus);
289
262
  if (BUILD$1.shadowSlotAssignmentManual) {
290
263
  if (!!(cmpMeta.$flags$ & CMP_FLAGS.shadowSlotAssignmentManual)) opts.slotAssignment = "manual";
291
264
  }
292
265
  const shadowRoot = this.attachShadow(opts);
266
+ if (BUILD$1.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
293
267
  if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported(globalStyles) ?? null;
294
268
  if (globalStyleSheet) shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
295
269
  else if (globalStyles && true) {
@@ -940,6 +914,24 @@ function internalCall(node, method) {
940
914
  }
941
915
  }
942
916
  //#endregion
917
+ //#region src/runtime/element.ts
918
+ const getElement = (ref) => BUILD$1.lazyLoad ? getHostRef(ref)?.$hostElement$ : ref;
919
+ /**
920
+ * Get the shadow root for a Stencil component's host element.
921
+ * This works for both open and closed shadow DOM modes.
922
+ *
923
+ * For closed shadow DOM, `element.shadowRoot` returns `null` by design,
924
+ * but Stencil stores the reference internally so components can still
925
+ * access their own shadow root.
926
+ *
927
+ * @param element The host element (from @Element() decorator)
928
+ * @returns The shadow root, or null if no shadow root exists
929
+ */
930
+ const getShadowRoot = (element) => {
931
+ if (BUILD$1.shadowModeClosed && element.__shadowRoot) return element.__shadowRoot;
932
+ return element.shadowRoot;
933
+ };
934
+ //#endregion
943
935
  //#region src/runtime/profile.ts
944
936
  let i = 0;
945
937
  const createTime = (fnName, tagName = "") => {
@@ -1096,7 +1088,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1096
1088
  if (!BUILD$1.attachStyles || !win.document) return scopeId;
1097
1089
  let style = styles.get(scopeId);
1098
1090
  if (cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) style = getStyleWithSlotCss(style);
1099
- styleContainerNode = styleContainerNode.nodeType === NODE_TYPE.DocumentFragment ? styleContainerNode : win.document;
1091
+ const isClosedShadowSSR = BUILD$1.hydrateServerSide && BUILD$1.shadowModeClosed && cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss && cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed;
1092
+ if (styleContainerNode.nodeType !== NODE_TYPE.DocumentFragment && !isClosedShadowSSR) styleContainerNode = win.document;
1100
1093
  if (style) {
1101
1094
  if (typeof style === "string") {
1102
1095
  styleContainerNode = styleContainerNode.head || styleContainerNode;
@@ -1142,7 +1135,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1142
1135
  /**
1143
1136
  * attach styles at the beginning of a shadow root node if we render shadow components
1144
1137
  */
1145
- if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) styleContainerNode.insertBefore(styleElm, null);
1138
+ if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1139
+ else styleContainerNode.insertBefore(styleElm, null);
1146
1140
  if (appliedStyles) appliedStyles.add(scopeId);
1147
1141
  }
1148
1142
  } else if (BUILD$1.constructableCSS) {
@@ -1177,7 +1171,12 @@ const attachStyles = (hostRef) => {
1177
1171
  const elm = hostRef.$hostElement$;
1178
1172
  const flags = cmpMeta.$flags$;
1179
1173
  const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
1180
- const scopeId = addStyle(BUILD$1.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$);
1174
+ let styleContainerNode;
1175
+ const shadowRoot = BUILD$1.shadowDom && supportsShadow ? getShadowRoot(elm) : null;
1176
+ if (shadowRoot) styleContainerNode = shadowRoot;
1177
+ else if (BUILD$1.hydrateServerSide && BUILD$1.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
1178
+ else styleContainerNode = elm.getRootNode();
1179
+ const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
1181
1180
  if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
1182
1181
  elm["s-sc"] = scopeId;
1183
1182
  elm.classList.add(scopeId + "-h");
@@ -1411,7 +1410,7 @@ const validateInputProperties = (inputElm) => {
1411
1410
  */
1412
1411
  const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1413
1412
  const endHydrate = createTime("hydrateClient", tagName);
1414
- const shadowRoot = hostElm.shadowRoot;
1413
+ const shadowRoot = getShadowRoot(hostElm);
1415
1414
  const childRenderNodes = [];
1416
1415
  const slotNodes = [];
1417
1416
  const slottedNodes = [];
@@ -1492,7 +1491,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1492
1491
  }
1493
1492
  addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"] || currentPos);
1494
1493
  if (slottedItem.node.parentElement?.shadowRoot && slottedItem.node["getAttribute"] && slottedItem.node.getAttribute("slot")) slottedItem.node.removeAttribute("slot");
1495
- if (BUILD$1.experimentalSlotFixes) patchSlottedNode(slottedItem.node);
1494
+ if (BUILD$1.experimentalSlotFixes || BUILD$1.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSlottedNode(slottedItem.node);
1496
1495
  }
1497
1496
  currentPos = (slottedItem.node["s-oo"] || currentPos) + 1;
1498
1497
  }
@@ -1814,9 +1813,12 @@ const _polyfillHost = "-shadowcsshost";
1814
1813
  const _polyfillSlotted = "-shadowcssslotted";
1815
1814
  const _polyfillHostContext = "-shadowcsscontext";
1816
1815
  const _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
1817
- const _cssColonHostRe = new RegExp("(" + _polyfillHost + _parenSuffix, "gim");
1818
- const _cssColonHostContextRe = new RegExp("(" + _polyfillHostContext + _parenSuffix, "gim");
1819
- const _cssColonSlottedRe = new RegExp("(" + _polyfillSlotted + _parenSuffix, "gim");
1816
+ let _cssColonHostRe;
1817
+ let _cssColonHostContextRe;
1818
+ let _cssColonSlottedRe;
1819
+ const getCssColonHostRe = () => _cssColonHostRe ??= new RegExp("(" + _polyfillHost + _parenSuffix, "gim");
1820
+ const getCssColonHostContextRe = () => _cssColonHostContextRe ??= new RegExp("(" + _polyfillHostContext + _parenSuffix, "gim");
1821
+ const getCssColonSlottedRe = () => _cssColonSlottedRe ??= new RegExp("(" + _polyfillSlotted + _parenSuffix, "gim");
1820
1822
  const _polyfillHostNoCombinator = _polyfillHost + "-no-combinator";
1821
1823
  const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
1822
1824
  const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
@@ -1976,7 +1978,7 @@ const colonHostPartReplacer = (host, part, suffix) => {
1976
1978
  return host + part.replace(_polyfillHost, "") + suffix;
1977
1979
  };
1978
1980
  const convertColonHost = (cssText) => {
1979
- return convertColonRule(cssText, _cssColonHostRe, colonHostPartReplacer);
1981
+ return convertColonRule(cssText, getCssColonHostRe(), colonHostPartReplacer);
1980
1982
  };
1981
1983
  const colonHostContextPartReplacer = (host, part, suffix) => {
1982
1984
  if (part.indexOf(_polyfillHost) > -1) return colonHostPartReplacer(host, part, suffix);
@@ -1985,7 +1987,7 @@ const colonHostContextPartReplacer = (host, part, suffix) => {
1985
1987
  const convertColonSlotted = (cssText, slotScopeId) => {
1986
1988
  const slotClass = "." + slotScopeId + " > ";
1987
1989
  const selectors = [];
1988
- cssText = cssText.replace(_cssColonSlottedRe, (...m) => {
1990
+ cssText = cssText.replace(getCssColonSlottedRe(), (...m) => {
1989
1991
  if (m[2]) {
1990
1992
  const compound = m[2].trim();
1991
1993
  const suffix = m[3];
@@ -2014,7 +2016,7 @@ const convertColonSlotted = (cssText, slotScopeId) => {
2014
2016
  };
2015
2017
  };
2016
2018
  const convertColonHostContext = (cssText) => {
2017
- return convertColonRule(cssText, _cssColonHostContextRe, colonHostContextPartReplacer);
2019
+ return convertColonRule(cssText, getCssColonHostContextRe(), colonHostContextPartReplacer);
2018
2020
  };
2019
2021
  const convertShadowDOMSelectors = (cssText) => {
2020
2022
  return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, " "), cssText);
@@ -2203,111 +2205,6 @@ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) =>
2203
2205
  const setMode = (handler) => modeResolutionChain.push(handler);
2204
2206
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
2205
2207
  //#endregion
2206
- //#region src/utils/remote-value.ts
2207
- /**
2208
- * RemoteValue class for deserializing LocalValue serialized objects back into their original form
2209
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead.
2210
- */
2211
- var RemoteValue = class RemoteValue {
2212
- /**
2213
- * Deserializes a LocalValue serialized object back to its original JavaScript representation
2214
- *
2215
- * @param serialized The serialized LocalValue object
2216
- * @returns The original JavaScript value/object
2217
- */
2218
- static fromLocalValue(serialized) {
2219
- const type = serialized[TYPE_CONSTANT];
2220
- const value = "value" in serialized ? serialized[VALUE_CONSTANT] : void 0;
2221
- switch (type) {
2222
- case PrimitiveType.String: return value;
2223
- case PrimitiveType.Boolean: return value;
2224
- case PrimitiveType.BigInt: return BigInt(value);
2225
- case PrimitiveType.Undefined: return;
2226
- case PrimitiveType.Null: return null;
2227
- case PrimitiveType.Number:
2228
- if (value === "NaN") return NaN;
2229
- if (value === "-0") return -0;
2230
- if (value === "Infinity") return Infinity;
2231
- if (value === "-Infinity") return -Infinity;
2232
- return value;
2233
- case NonPrimitiveType.Array: return value.map((item) => RemoteValue.fromLocalValue(item));
2234
- case NonPrimitiveType.Date: return new Date(value);
2235
- case NonPrimitiveType.Map:
2236
- const map = /* @__PURE__ */ new Map();
2237
- for (const [key, val] of value) {
2238
- const deserializedKey = typeof key === "object" && key !== null ? RemoteValue.fromLocalValue(key) : key;
2239
- const deserializedValue = RemoteValue.fromLocalValue(val);
2240
- map.set(deserializedKey, deserializedValue);
2241
- }
2242
- return map;
2243
- case NonPrimitiveType.Object:
2244
- const obj = {};
2245
- for (const [key, val] of value) obj[key] = RemoteValue.fromLocalValue(val);
2246
- return obj;
2247
- case NonPrimitiveType.RegularExpression:
2248
- const { pattern, flags } = value;
2249
- return new RegExp(pattern, flags);
2250
- case NonPrimitiveType.Set:
2251
- const set = /* @__PURE__ */ new Set();
2252
- for (const item of value) set.add(RemoteValue.fromLocalValue(item));
2253
- return set;
2254
- case NonPrimitiveType.Symbol: return Symbol(value);
2255
- default: throw new Error(`Unsupported type: ${type}`);
2256
- }
2257
- }
2258
- /**
2259
- * Utility method to deserialize multiple LocalValues at once
2260
- *
2261
- * @param serializedValues Array of serialized LocalValue objects
2262
- * @returns Array of deserialized JavaScript values
2263
- */
2264
- static fromLocalValueArray(serializedValues) {
2265
- return serializedValues.map((value) => RemoteValue.fromLocalValue(value));
2266
- }
2267
- /**
2268
- * Verifies if the given object matches the structure of a serialized LocalValue
2269
- *
2270
- * @param obj Object to verify
2271
- * @returns boolean indicating if the object has LocalValue structure
2272
- */
2273
- static isLocalValueObject(obj) {
2274
- if (typeof obj !== "object" || obj === null) return false;
2275
- if (!obj.hasOwnProperty("type")) return false;
2276
- const type = obj[TYPE_CONSTANT];
2277
- if (!Object.values({
2278
- ...PrimitiveType,
2279
- ...NonPrimitiveType
2280
- }).includes(type)) return false;
2281
- if (type !== PrimitiveType.Null && type !== PrimitiveType.Undefined) return obj.hasOwnProperty(VALUE_CONSTANT);
2282
- return true;
2283
- }
2284
- };
2285
- //#endregion
2286
- //#region src/utils/serialize.ts
2287
- /**
2288
- * Unicode-safe base64 decoding that handles characters outside Latin1 range.
2289
- * Unlike atob(), this properly decodes Unicode characters including emoji,
2290
- * CJK characters, and currency symbols like €.
2291
- * @param {string} base64 - The base64 string to decode.
2292
- * @returns {string} Decoded string.
2293
- */
2294
- function decodeBase64Unicode(base64) {
2295
- const binary = atob(base64);
2296
- const bytes = new Uint8Array(binary.length);
2297
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
2298
- return new TextDecoder().decode(bytes);
2299
- }
2300
- /**
2301
- * Deserialize a value from a string that was serialized earlier.
2302
- * @param {string} value - The string to deserialize.
2303
- * @returns {unknown} The deserialized value.
2304
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` decorator instead.
2305
- */
2306
- function deserializeProperty(value) {
2307
- if (typeof value !== "string" || !value.startsWith("serialized:")) return value;
2308
- return RemoteValue.fromLocalValue(JSON.parse(decodeBase64Unicode(value.slice(11))));
2309
- }
2310
- //#endregion
2311
2208
  //#region src/runtime/parse-property-value.ts
2312
2209
  /**
2313
2210
  * Parse a new property value for a given property type.
@@ -2334,14 +2231,6 @@ function deserializeProperty(value) {
2334
2231
  * @returns the parsed/coerced value
2335
2232
  */
2336
2233
  const parsePropertyValue = (propValue, propType, isFormAssociated) => {
2337
- /**
2338
- * Allow hydrate parameters that contain a complex non-serialized values.
2339
- * This is SSR-specific and should only run during hydration.
2340
- */
2341
- if ((BUILD$1.hydrateClientSide || BUILD$1.hydrateServerSide) && typeof propValue === "string" && propValue.startsWith("serialized:")) {
2342
- propValue = deserializeProperty(propValue);
2343
- return propValue;
2344
- }
2345
2234
  if (propValue != null && !isComplexType(propValue)) {
2346
2235
  /**
2347
2236
  * ensure this value is of the correct prop type
@@ -2370,9 +2259,6 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
2370
2259
  return propValue;
2371
2260
  };
2372
2261
  //#endregion
2373
- //#region src/runtime/element.ts
2374
- const getElement = (ref) => BUILD$1.lazyLoad ? getHostRef(ref)?.$hostElement$ : ref;
2375
- //#endregion
2376
2262
  //#region src/runtime/event-emitter.ts
2377
2263
  const createEvent = (ref, name, flags) => {
2378
2264
  const elm = getElement(ref);
@@ -2725,7 +2611,10 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
2725
2611
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
2726
2612
  let containerElm = BUILD$1.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
2727
2613
  let childNode;
2728
- if (BUILD$1.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) containerElm = containerElm.shadowRoot;
2614
+ if (BUILD$1.shadowDom && containerElm.tagName === hostTagName) {
2615
+ const shadow = getShadowRoot(containerElm);
2616
+ if (shadow) containerElm = shadow;
2617
+ }
2729
2618
  if (parentVNode.$tag$ === "template") containerElm = containerElm.content;
2730
2619
  for (; startIdx <= endIdx; ++startIdx) if (vnodes[startIdx]) {
2731
2620
  childNode = createElm(null, parentVNode, startIdx);
@@ -3075,7 +2964,8 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
3075
2964
  if (BUILD$1.slotRelocation) {
3076
2965
  if (BUILD$1.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
3077
2966
  else if (typeof newNode["s-sn"] === "string") {
3078
- if (BUILD$1.experimentalSlotFixes && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchParentNode(newNode);
2967
+ const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
2968
+ if ((BUILD$1.experimentalSlotFixes || BUILD$1.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchParentNode(newNode);
3079
2969
  parent.insertBefore(newNode, reference);
3080
2970
  const { slotNode } = findSlotFromSlottedNode(newNode);
3081
2971
  if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
@@ -3164,7 +3054,7 @@ render() {
3164
3054
  rootVnode.$tag$ = null;
3165
3055
  rootVnode.$flags$ |= VNODE_FLAGS.isHost;
3166
3056
  hostRef.$vnode$ = rootVnode;
3167
- rootVnode.$elm$ = oldVNode.$elm$ = BUILD$1.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
3057
+ rootVnode.$elm$ = oldVNode.$elm$ = BUILD$1.shadowDom ? getShadowRoot(hostElm) || hostElm : hostElm;
3168
3058
  if (BUILD$1.scoped || BUILD$1.shadowDom) scopeId = hostElm["s-sc"];
3169
3059
  useNativeShadowDom = supportsShadow && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && !(cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss);
3170
3060
  if (BUILD$1.slotRelocation) {
@@ -3319,13 +3209,13 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
3319
3209
  }
3320
3210
  if (hostRef.$fetchedCbList$.length) hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
3321
3211
  }
3322
- emitLifecycleEvent(elm, "componentWillLoad");
3212
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
3323
3213
  maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
3324
3214
  } else {
3325
- emitLifecycleEvent(elm, "componentWillUpdate");
3215
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
3326
3216
  maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
3327
3217
  }
3328
- emitLifecycleEvent(elm, "componentWillRender");
3218
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillRender");
3329
3219
  maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
3330
3220
  endSchedule();
3331
3221
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
@@ -3460,14 +3350,14 @@ const postUpdateComponent = (hostRef) => {
3460
3350
  if (BUILD$1.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnRender;
3461
3351
  safeCall(instance, "componentDidRender", void 0, elm);
3462
3352
  if (BUILD$1.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
3463
- emitLifecycleEvent(elm, "componentDidRender");
3353
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentDidRender");
3464
3354
  if (!(hostRef.$flags$ & HOST_FLAGS.hasLoadedComponent)) {
3465
3355
  hostRef.$flags$ |= HOST_FLAGS.hasLoadedComponent;
3466
3356
  if (BUILD$1.asyncLoading && BUILD$1.cssAnnotations) addHydratedFlag(elm);
3467
3357
  if (BUILD$1.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnDidLoad;
3468
3358
  safeCall(instance, "componentDidLoad", void 0, elm);
3469
3359
  if (BUILD$1.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnDidLoad;
3470
- emitLifecycleEvent(elm, "componentDidLoad");
3360
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentDidLoad");
3471
3361
  if (BUILD$1.propChangeCallback) hostRef.$flags$ |= HOST_FLAGS.isWatchReady;
3472
3362
  endPostUpdate();
3473
3363
  if (BUILD$1.asyncLoading) {
@@ -3478,7 +3368,7 @@ const postUpdateComponent = (hostRef) => {
3478
3368
  if (BUILD$1.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnRender;
3479
3369
  safeCall(instance, "componentDidUpdate", void 0, elm);
3480
3370
  if (BUILD$1.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
3481
- emitLifecycleEvent(elm, "componentDidUpdate");
3371
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentDidUpdate");
3482
3372
  endPostUpdate();
3483
3373
  }
3484
3374
  if (BUILD$1.method && BUILD$1.lazyLoad) hostRef.$onInstanceResolve$(elm);
@@ -3901,7 +3791,6 @@ const connectedCallback = (elm) => {
3901
3791
  if (!hostRef) return;
3902
3792
  const cmpMeta = hostRef.$cmpMeta$;
3903
3793
  const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
3904
- if (BUILD$1.hostListenerTargetParent) addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
3905
3794
  if (!(hostRef.$flags$ & HOST_FLAGS.hasConnected)) {
3906
3795
  hostRef.$flags$ |= HOST_FLAGS.hasConnected;
3907
3796
  let hostId;
@@ -3909,7 +3798,8 @@ const connectedCallback = (elm) => {
3909
3798
  hostId = elm.getAttribute(HYDRATE_ID);
3910
3799
  if (hostId) {
3911
3800
  if (BUILD$1.shadowDom && supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
3912
- const scopeId = BUILD$1.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute("s-mode")) : addStyle(elm.shadowRoot, cmpMeta);
3801
+ const shadowRoot = getShadowRoot(elm);
3802
+ const scopeId = BUILD$1.mode ? addStyle(shadowRoot, cmpMeta, elm.getAttribute("s-mode")) : addStyle(shadowRoot, cmpMeta);
3913
3803
  elm.classList.remove(scopeId + "-h", scopeId + "-s");
3914
3804
  } else if (BUILD$1.scoped && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) elm["s-sc"] = getScopeId(cmpMeta, BUILD$1.mode ? elm.getAttribute("s-mode") : void 0);
3915
3805
  initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
@@ -3948,7 +3838,7 @@ const connectedCallback = (elm) => {
3948
3838
  if (BUILD$1.initializeNextTick) nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
3949
3839
  else initializeComponent(elm, hostRef, cmpMeta);
3950
3840
  } else {
3951
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3841
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
3952
3842
  if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
3953
3843
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
3954
3844
  }
@@ -4009,14 +3899,18 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4009
3899
  }
4010
3900
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
4011
3901
  if (BUILD$1.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4012
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.experimentalSlotFixes) patchPseudoShadowDom(Cstr.prototype);
3902
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.experimentalSlotFixes || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) patchPseudoShadowDom(Cstr.prototype);
4013
3903
  else {
4014
- if (BUILD$1.slotChildNodesFix) patchChildSlotNodes(Cstr.prototype);
4015
- if (BUILD$1.cloneNodeFix) patchCloneNode(Cstr.prototype);
4016
- if (BUILD$1.appendChildSlotFix) patchSlotAppendChild(Cstr.prototype);
3904
+ if (BUILD$1.slotChildNodesFix || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
3905
+ if (BUILD$1.cloneNodeFix || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone) patchCloneNode(Cstr.prototype);
3906
+ if (BUILD$1.appendChildSlotFix || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
3907
+ patchSlotAppendChild(Cstr.prototype);
3908
+ patchInsertBefore(Cstr.prototype);
3909
+ patchSlotRemoveChild(Cstr.prototype);
3910
+ }
4017
3911
  if (BUILD$1.scopedSlotTextContentFix && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) patchTextContent(Cstr.prototype);
4018
3912
  }
4019
- else if (BUILD$1.cloneNodeFix) patchCloneNode(Cstr.prototype);
3913
+ else if (BUILD$1.cloneNodeFix || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone) patchCloneNode(Cstr.prototype);
4020
3914
  if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
4021
3915
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
4022
3916
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
@@ -4032,7 +3926,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4032
3926
  if (!this.__hasHostListenerAttached) {
4033
3927
  const hostRef = getHostRef(this);
4034
3928
  if (!hostRef) return;
4035
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
3929
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4036
3930
  this.__hasHostListenerAttached = true;
4037
3931
  }
4038
3932
  connectedCallback(this);
@@ -4044,8 +3938,13 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4044
3938
  },
4045
3939
  __attachShadow() {
4046
3940
  if (supportsShadow) {
4047
- if (!this.shadowRoot) createShadowRoot.call(this, cmpMeta);
4048
- else if (this.shadowRoot.mode !== "open") throw new Error(`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`);
3941
+ const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
3942
+ let existingRoot = this.shadowRoot;
3943
+ if (BUILD$1.shadowModeClosed && isClosed) existingRoot = this.__shadowRoot ?? null;
3944
+ if (!existingRoot) createShadowRoot.call(this, cmpMeta);
3945
+ else if (BUILD$1.shadowModeClosed && isClosed) {
3946
+ if (existingRoot.mode !== "closed") throw new Error(`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${existingRoot.mode} but expected closed.`);
3947
+ }
4049
3948
  } else this.shadowRoot = this;
4050
3949
  }
4051
3950
  });
@@ -4141,7 +4040,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4141
4040
  cmpMeta.$deserializers$ = compactMeta[6] ?? {};
4142
4041
  }
4143
4042
  if (BUILD$1.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4144
- const tagName = BUILD$1.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : transformTag(cmpMeta.$tagName$);
4043
+ const tagName = transformTag(cmpMeta.$tagName$);
4145
4044
  const HostElement = class extends HTMLElement {
4146
4045
  ["s-p"];
4147
4046
  ["s-rc"];
@@ -4168,7 +4067,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4168
4067
  */
4169
4068
  if (!this.hasRegisteredEventListeners) {
4170
4069
  this.hasRegisteredEventListeners = true;
4171
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
4070
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4172
4071
  }
4173
4072
  if (appLoadFallback) {
4174
4073
  clearTimeout(appLoadFallback);
@@ -4200,14 +4099,18 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4200
4099
  return getHostRef(this)?.$onReadyPromise$;
4201
4100
  }
4202
4101
  };
4203
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.experimentalSlotFixes) patchPseudoShadowDom(HostElement.prototype);
4102
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.experimentalSlotFixes || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) patchPseudoShadowDom(HostElement.prototype);
4204
4103
  else {
4205
- if (BUILD$1.slotChildNodesFix) patchChildSlotNodes(HostElement.prototype);
4206
- if (BUILD$1.cloneNodeFix) patchCloneNode(HostElement.prototype);
4207
- if (BUILD$1.appendChildSlotFix) patchSlotAppendChild(HostElement.prototype);
4104
+ if (BUILD$1.slotChildNodesFix || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4105
+ if (BUILD$1.cloneNodeFix || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone) patchCloneNode(HostElement.prototype);
4106
+ if (BUILD$1.appendChildSlotFix || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4107
+ patchSlotAppendChild(HostElement.prototype);
4108
+ patchInsertBefore(HostElement.prototype);
4109
+ patchSlotRemoveChild(HostElement.prototype);
4110
+ }
4208
4111
  if (BUILD$1.scopedSlotTextContentFix && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) patchTextContent(HostElement.prototype);
4209
4112
  }
4210
- else if (BUILD$1.cloneNodeFix) patchCloneNode(HostElement.prototype);
4113
+ else if (BUILD$1.cloneNodeFix || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone) patchCloneNode(HostElement.prototype);
4211
4114
  if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
4212
4115
  if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
4213
4116
  hmrStart(this, cmpMeta, hmrVersionId);
@@ -4239,18 +4142,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4239
4142
  const Fragment = (_, children) => children;
4240
4143
  //#endregion
4241
4144
  //#region src/runtime/host-listener.ts
4242
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
4243
- if (BUILD$1.hostListener && listeners && win.document) {
4244
- if (BUILD$1.hostListenerTargetParent) if (attachParentListeners) listeners = listeners.filter(([flags]) => flags & LISTENER_FLAGS.TargetParent);
4245
- else listeners = listeners.filter(([flags]) => !(flags & LISTENER_FLAGS.TargetParent));
4246
- listeners.map(([flags, name, method]) => {
4247
- const target = BUILD$1.hostListenerTarget ? getHostListenerTarget(win.document, elm, flags) : elm;
4248
- const handler = hostListenerProxy(hostRef, method);
4249
- const opts = hostListenerOpts(flags);
4250
- plt.ael(target, name, handler, opts);
4251
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
4252
- });
4253
- }
4145
+ const addHostEventListeners = (elm, hostRef, listeners) => {
4146
+ if (BUILD$1.hostListener && listeners && win.document) listeners.map(([flags, name, method]) => {
4147
+ const target = BUILD$1.hostListenerTarget ? getHostListenerTarget(win.document, elm, flags) : elm;
4148
+ const handler = hostListenerProxy(hostRef, method);
4149
+ const opts = hostListenerOpts(flags);
4150
+ plt.ael(target, name, handler, opts);
4151
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
4152
+ });
4254
4153
  };
4255
4154
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
4256
4155
  try {
@@ -4265,7 +4164,6 @@ const getHostListenerTarget = (doc, elm, flags) => {
4265
4164
  if (BUILD$1.hostListenerTargetDocument && flags & LISTENER_FLAGS.TargetDocument) return doc;
4266
4165
  if (BUILD$1.hostListenerTargetWindow && flags & LISTENER_FLAGS.TargetWindow) return win;
4267
4166
  if (BUILD$1.hostListenerTargetBody && flags & LISTENER_FLAGS.TargetBody) return doc.body;
4268
- if (BUILD$1.hostListenerTargetParent && flags & LISTENER_FLAGS.TargetParent && elm.parentElement) return elm.parentElement;
4269
4167
  return elm;
4270
4168
  };
4271
4169
  const hostListenerOpts = (flags) => (flags & LISTENER_FLAGS.Capture) !== 0;
@@ -4636,7 +4534,7 @@ function hydrateApp(win, opts, results, afterHydrate, resolve) {
4636
4534
  $flags$: null
4637
4535
  }, null);
4638
4536
  if (Cstr != null && Cstr.cmpMeta != null) {
4639
- if (opts.serializeShadowRoot !== false && !!(Cstr.cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && tagRequiresScoped(elm.tagName, opts.serializeShadowRoot)) {
4537
+ if (opts.serializeShadowRoot !== false && !!(Cstr.cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (tagRequiresScoped(elm.tagName, opts.serializeShadowRoot) || !!(Cstr.cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed))) {
4640
4538
  const cmpMeta = Cstr.cmpMeta;
4641
4539
  cmpMeta.$flags$ |= CMP_FLAGS.shadowNeedsScopedCss;
4642
4540
  Object.defineProperty(Cstr, "cmpMeta", { get: function() {
@@ -4704,7 +4602,7 @@ async function hydrateComponent(win, results, tagName, elm, waitingElements) {
4704
4602
  waitingElements.add(elm);
4705
4603
  const hostRef = getHostRef(this);
4706
4604
  if (!hostRef) return;
4707
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
4605
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4708
4606
  try {
4709
4607
  connectedCallback(elm);
4710
4608
  await elm.componentOnReady();
@@ -2,22 +2,6 @@ import { Readable } from "node:stream";
2
2
  //#region src/server/runner/create-window.d.ts
3
3
  declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
4
4
  //#endregion
5
- //#region src/utils/serialize.d.ts
6
- /**
7
- * Serialize a value to a string that can be deserialized later.
8
- * @param {unknown} value - The value to serialize.
9
- * @returns {string} A string that can be deserialized later.
10
- * @deprecated will be removed in v5. Use `@PropSerialize()` decorator instead.
11
- */
12
- declare function serializeProperty(value: unknown): string | number | boolean;
13
- /**
14
- * Deserialize a value from a string that was serialized earlier.
15
- * @param {string} value - The string to deserialize.
16
- * @returns {unknown} The deserialized value.
17
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` decorator instead.
18
- */
19
- declare function deserializeProperty(value: string): any;
20
- //#endregion
21
5
  //#region src/declarations/stencil-public-runtime.d.ts
22
6
  type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
23
7
  type TagTransformer = (tag: string) => string;
@@ -320,4 +304,4 @@ declare function transformTag<T extends string>(tag: T): T;
320
304
  */
321
305
  declare function setTagTransformer(transformer: TagTransformer): void;
322
306
  //#endregion
323
- export { createWindowFromHtml, deserializeProperty, hydrateDocument, renderToString, resetHydrateDocData, serializeDocumentToString, serializeProperty, setTagTransformer, streamToString, transformTag };
307
+ export { createWindowFromHtml, hydrateDocument, renderToString, resetHydrateDocData, serializeDocumentToString, setTagTransformer, streamToString, transformTag };