@stencil/core 5.0.0-alpha.1 → 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-B1nuvCd2.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-LX4_RKKd.mjs → compiler-D6iP7Bzb.mjs} +1391 -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-SxQIOCZE.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 -192
  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 -192
  30. package/dist/runtime/server/runner.d.mts +1 -17
  31. package/dist/runtime/server/runner.mjs +12 -368
  32. package/dist/{runtime-CF9DJtSu.js → runtime-BBCnuprF.js} +103 -192
  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-CaCgjw-f.mjs → validation-Byxie0Uk.mjs} +28 -24
  39. package/package.json +9 -13
  40. package/dist/serialize-BkYHk7Mi.mjs +0 -766
  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,98 +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
- * Deserialize a value from a string that was serialized earlier.
2289
- * @param {string} value - The string to deserialize.
2290
- * @returns {unknown} The deserialized value.
2291
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` decorator instead.
2292
- */
2293
- function deserializeProperty(value) {
2294
- if (typeof value !== "string" || !value.startsWith("serialized:")) return value;
2295
- return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(11))));
2296
- }
2297
- //#endregion
2298
2208
  //#region src/runtime/parse-property-value.ts
2299
2209
  /**
2300
2210
  * Parse a new property value for a given property type.
@@ -2321,14 +2231,6 @@ function deserializeProperty(value) {
2321
2231
  * @returns the parsed/coerced value
2322
2232
  */
2323
2233
  const parsePropertyValue = (propValue, propType, isFormAssociated) => {
2324
- /**
2325
- * Allow hydrate parameters that contain a complex non-serialized values.
2326
- * This is SSR-specific and should only run during hydration.
2327
- */
2328
- if ((BUILD$1.hydrateClientSide || BUILD$1.hydrateServerSide) && typeof propValue === "string" && propValue.startsWith("serialized:")) {
2329
- propValue = deserializeProperty(propValue);
2330
- return propValue;
2331
- }
2332
2234
  if (propValue != null && !isComplexType(propValue)) {
2333
2235
  /**
2334
2236
  * ensure this value is of the correct prop type
@@ -2357,9 +2259,6 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
2357
2259
  return propValue;
2358
2260
  };
2359
2261
  //#endregion
2360
- //#region src/runtime/element.ts
2361
- const getElement = (ref) => BUILD$1.lazyLoad ? getHostRef(ref)?.$hostElement$ : ref;
2362
- //#endregion
2363
2262
  //#region src/runtime/event-emitter.ts
2364
2263
  const createEvent = (ref, name, flags) => {
2365
2264
  const elm = getElement(ref);
@@ -2712,7 +2611,10 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
2712
2611
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
2713
2612
  let containerElm = BUILD$1.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
2714
2613
  let childNode;
2715
- 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
+ }
2716
2618
  if (parentVNode.$tag$ === "template") containerElm = containerElm.content;
2717
2619
  for (; startIdx <= endIdx; ++startIdx) if (vnodes[startIdx]) {
2718
2620
  childNode = createElm(null, parentVNode, startIdx);
@@ -3062,7 +2964,8 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
3062
2964
  if (BUILD$1.slotRelocation) {
3063
2965
  if (BUILD$1.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
3064
2966
  else if (typeof newNode["s-sn"] === "string") {
3065
- 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);
3066
2969
  parent.insertBefore(newNode, reference);
3067
2970
  const { slotNode } = findSlotFromSlottedNode(newNode);
3068
2971
  if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
@@ -3151,7 +3054,7 @@ render() {
3151
3054
  rootVnode.$tag$ = null;
3152
3055
  rootVnode.$flags$ |= VNODE_FLAGS.isHost;
3153
3056
  hostRef.$vnode$ = rootVnode;
3154
- rootVnode.$elm$ = oldVNode.$elm$ = BUILD$1.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
3057
+ rootVnode.$elm$ = oldVNode.$elm$ = BUILD$1.shadowDom ? getShadowRoot(hostElm) || hostElm : hostElm;
3155
3058
  if (BUILD$1.scoped || BUILD$1.shadowDom) scopeId = hostElm["s-sc"];
3156
3059
  useNativeShadowDom = supportsShadow && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && !(cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss);
3157
3060
  if (BUILD$1.slotRelocation) {
@@ -3306,13 +3209,13 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
3306
3209
  }
3307
3210
  if (hostRef.$fetchedCbList$.length) hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
3308
3211
  }
3309
- emitLifecycleEvent(elm, "componentWillLoad");
3212
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
3310
3213
  maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
3311
3214
  } else {
3312
- emitLifecycleEvent(elm, "componentWillUpdate");
3215
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
3313
3216
  maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
3314
3217
  }
3315
- emitLifecycleEvent(elm, "componentWillRender");
3218
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillRender");
3316
3219
  maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
3317
3220
  endSchedule();
3318
3221
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
@@ -3447,14 +3350,14 @@ const postUpdateComponent = (hostRef) => {
3447
3350
  if (BUILD$1.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnRender;
3448
3351
  safeCall(instance, "componentDidRender", void 0, elm);
3449
3352
  if (BUILD$1.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
3450
- emitLifecycleEvent(elm, "componentDidRender");
3353
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentDidRender");
3451
3354
  if (!(hostRef.$flags$ & HOST_FLAGS.hasLoadedComponent)) {
3452
3355
  hostRef.$flags$ |= HOST_FLAGS.hasLoadedComponent;
3453
3356
  if (BUILD$1.asyncLoading && BUILD$1.cssAnnotations) addHydratedFlag(elm);
3454
3357
  if (BUILD$1.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnDidLoad;
3455
3358
  safeCall(instance, "componentDidLoad", void 0, elm);
3456
3359
  if (BUILD$1.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnDidLoad;
3457
- emitLifecycleEvent(elm, "componentDidLoad");
3360
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentDidLoad");
3458
3361
  if (BUILD$1.propChangeCallback) hostRef.$flags$ |= HOST_FLAGS.isWatchReady;
3459
3362
  endPostUpdate();
3460
3363
  if (BUILD$1.asyncLoading) {
@@ -3465,7 +3368,7 @@ const postUpdateComponent = (hostRef) => {
3465
3368
  if (BUILD$1.isDev) hostRef.$flags$ |= HOST_FLAGS.devOnRender;
3466
3369
  safeCall(instance, "componentDidUpdate", void 0, elm);
3467
3370
  if (BUILD$1.isDev) hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
3468
- emitLifecycleEvent(elm, "componentDidUpdate");
3371
+ if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentDidUpdate");
3469
3372
  endPostUpdate();
3470
3373
  }
3471
3374
  if (BUILD$1.method && BUILD$1.lazyLoad) hostRef.$onInstanceResolve$(elm);
@@ -3888,7 +3791,6 @@ const connectedCallback = (elm) => {
3888
3791
  if (!hostRef) return;
3889
3792
  const cmpMeta = hostRef.$cmpMeta$;
3890
3793
  const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
3891
- if (BUILD$1.hostListenerTargetParent) addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
3892
3794
  if (!(hostRef.$flags$ & HOST_FLAGS.hasConnected)) {
3893
3795
  hostRef.$flags$ |= HOST_FLAGS.hasConnected;
3894
3796
  let hostId;
@@ -3896,7 +3798,8 @@ const connectedCallback = (elm) => {
3896
3798
  hostId = elm.getAttribute(HYDRATE_ID);
3897
3799
  if (hostId) {
3898
3800
  if (BUILD$1.shadowDom && supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
3899
- 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);
3900
3803
  elm.classList.remove(scopeId + "-h", scopeId + "-s");
3901
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);
3902
3805
  initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
@@ -3935,7 +3838,7 @@ const connectedCallback = (elm) => {
3935
3838
  if (BUILD$1.initializeNextTick) nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
3936
3839
  else initializeComponent(elm, hostRef, cmpMeta);
3937
3840
  } else {
3938
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3841
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
3939
3842
  if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
3940
3843
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
3941
3844
  }
@@ -3996,14 +3899,18 @@ const proxyCustomElement = (Cstr, compactMeta) => {
3996
3899
  }
3997
3900
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
3998
3901
  if (BUILD$1.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
3999
- 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);
4000
3903
  else {
4001
- if (BUILD$1.slotChildNodesFix) patchChildSlotNodes(Cstr.prototype);
4002
- if (BUILD$1.cloneNodeFix) patchCloneNode(Cstr.prototype);
4003
- 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
+ }
4004
3911
  if (BUILD$1.scopedSlotTextContentFix && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) patchTextContent(Cstr.prototype);
4005
3912
  }
4006
- 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);
4007
3914
  if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
4008
3915
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
4009
3916
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
@@ -4019,7 +3926,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4019
3926
  if (!this.__hasHostListenerAttached) {
4020
3927
  const hostRef = getHostRef(this);
4021
3928
  if (!hostRef) return;
4022
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
3929
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4023
3930
  this.__hasHostListenerAttached = true;
4024
3931
  }
4025
3932
  connectedCallback(this);
@@ -4031,8 +3938,13 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4031
3938
  },
4032
3939
  __attachShadow() {
4033
3940
  if (supportsShadow) {
4034
- if (!this.shadowRoot) createShadowRoot.call(this, cmpMeta);
4035
- 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
+ }
4036
3948
  } else this.shadowRoot = this;
4037
3949
  }
4038
3950
  });
@@ -4128,7 +4040,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4128
4040
  cmpMeta.$deserializers$ = compactMeta[6] ?? {};
4129
4041
  }
4130
4042
  if (BUILD$1.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4131
- const tagName = BUILD$1.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : transformTag(cmpMeta.$tagName$);
4043
+ const tagName = transformTag(cmpMeta.$tagName$);
4132
4044
  const HostElement = class extends HTMLElement {
4133
4045
  ["s-p"];
4134
4046
  ["s-rc"];
@@ -4155,7 +4067,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4155
4067
  */
4156
4068
  if (!this.hasRegisteredEventListeners) {
4157
4069
  this.hasRegisteredEventListeners = true;
4158
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
4070
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4159
4071
  }
4160
4072
  if (appLoadFallback) {
4161
4073
  clearTimeout(appLoadFallback);
@@ -4187,14 +4099,18 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4187
4099
  return getHostRef(this)?.$onReadyPromise$;
4188
4100
  }
4189
4101
  };
4190
- 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);
4191
4103
  else {
4192
- if (BUILD$1.slotChildNodesFix) patchChildSlotNodes(HostElement.prototype);
4193
- if (BUILD$1.cloneNodeFix) patchCloneNode(HostElement.prototype);
4194
- 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
+ }
4195
4111
  if (BUILD$1.scopedSlotTextContentFix && cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation) patchTextContent(HostElement.prototype);
4196
4112
  }
4197
- 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);
4198
4114
  if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
4199
4115
  if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
4200
4116
  hmrStart(this, cmpMeta, hmrVersionId);
@@ -4226,18 +4142,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4226
4142
  const Fragment = (_, children) => children;
4227
4143
  //#endregion
4228
4144
  //#region src/runtime/host-listener.ts
4229
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
4230
- if (BUILD$1.hostListener && listeners && win.document) {
4231
- if (BUILD$1.hostListenerTargetParent) if (attachParentListeners) listeners = listeners.filter(([flags]) => flags & LISTENER_FLAGS.TargetParent);
4232
- else listeners = listeners.filter(([flags]) => !(flags & LISTENER_FLAGS.TargetParent));
4233
- listeners.map(([flags, name, method]) => {
4234
- const target = BUILD$1.hostListenerTarget ? getHostListenerTarget(win.document, elm, flags) : elm;
4235
- const handler = hostListenerProxy(hostRef, method);
4236
- const opts = hostListenerOpts(flags);
4237
- plt.ael(target, name, handler, opts);
4238
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
4239
- });
4240
- }
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
+ });
4241
4153
  };
4242
4154
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
4243
4155
  try {
@@ -4252,7 +4164,6 @@ const getHostListenerTarget = (doc, elm, flags) => {
4252
4164
  if (BUILD$1.hostListenerTargetDocument && flags & LISTENER_FLAGS.TargetDocument) return doc;
4253
4165
  if (BUILD$1.hostListenerTargetWindow && flags & LISTENER_FLAGS.TargetWindow) return win;
4254
4166
  if (BUILD$1.hostListenerTargetBody && flags & LISTENER_FLAGS.TargetBody) return doc.body;
4255
- if (BUILD$1.hostListenerTargetParent && flags & LISTENER_FLAGS.TargetParent && elm.parentElement) return elm.parentElement;
4256
4167
  return elm;
4257
4168
  };
4258
4169
  const hostListenerOpts = (flags) => (flags & LISTENER_FLAGS.Capture) !== 0;
@@ -4623,7 +4534,7 @@ function hydrateApp(win, opts, results, afterHydrate, resolve) {
4623
4534
  $flags$: null
4624
4535
  }, null);
4625
4536
  if (Cstr != null && Cstr.cmpMeta != null) {
4626
- 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))) {
4627
4538
  const cmpMeta = Cstr.cmpMeta;
4628
4539
  cmpMeta.$flags$ |= CMP_FLAGS.shadowNeedsScopedCss;
4629
4540
  Object.defineProperty(Cstr, "cmpMeta", { get: function() {
@@ -4691,7 +4602,7 @@ async function hydrateComponent(win, results, tagName, elm, waitingElements) {
4691
4602
  waitingElements.add(elm);
4692
4603
  const hostRef = getHostRef(this);
4693
4604
  if (!hostRef) return;
4694
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
4605
+ addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4695
4606
  try {
4696
4607
  connectedCallback(elm);
4697
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 };