@stencil/core 5.0.0-alpha.9 → 5.0.0-beta.1

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 (49) hide show
  1. package/README.md +94 -0
  2. package/dist/app-data/index.d.ts +1 -1
  3. package/dist/app-data/index.js +4 -1
  4. package/dist/client-BRu0GtRn.mjs +2368 -0
  5. package/dist/compiler/browser.d.ts +1534 -0
  6. package/dist/compiler/browser.js +16436 -0
  7. package/dist/compiler/index.d.mts +167 -3
  8. package/dist/compiler/index.mjs +3 -3
  9. package/dist/compiler/utils/index.d.mts +272 -2
  10. package/dist/compiler/utils/index.mjs +4 -3
  11. package/dist/{compiler-C0qmPoKu.mjs → compiler-CJG6qvQt.mjs} +2978 -1231
  12. package/dist/declarations/stencil-ext-modules.d.ts +5 -5
  13. package/dist/declarations/stencil-public-compiler.d.ts +226 -69
  14. package/dist/declarations/stencil-public-docs.d.ts +9 -0
  15. package/dist/declarations/stencil-public-runtime.d.ts +111 -10
  16. package/dist/fragment-Di1hWOC8.mjs +4 -0
  17. package/dist/{regular-expression-CFVJOTUh.mjs → helpers-Cpp3qc3u.mjs} +31 -15
  18. package/dist/{index-xAkMgLX_.d.ts → index-BXAcVN2j.d.ts} +152 -20
  19. package/dist/{index-vY35H18z.d.mts → index-BopBfjPu.d.mts} +508 -848
  20. package/dist/index-DmHmu3y0.d.mts +100 -0
  21. package/dist/index.d.mts +6 -0
  22. package/dist/index.mjs +171 -2
  23. package/dist/jsx-runtime.mjs +2 -1
  24. package/dist/{node--akYC-sG.mjs → node-75gQKkFz.mjs} +60 -58
  25. package/dist/{chunk-z9aeyW2b.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
  26. package/dist/runtime/client/lazy.js +577 -189
  27. package/dist/runtime/client/runtime.d.ts +178 -21
  28. package/dist/runtime/client/runtime.js +577 -189
  29. package/dist/runtime/index.d.ts +32 -4
  30. package/dist/runtime/index.js +576 -187
  31. package/dist/runtime/server/index.d.mts +107 -9
  32. package/dist/runtime/server/index.mjs +499 -182
  33. package/dist/runtime/server/runner.d.mts +3 -0
  34. package/dist/runtime/server/runner.mjs +320 -337
  35. package/dist/signals/index.d.ts +2 -0
  36. package/dist/signals/index.js +4 -1
  37. package/dist/sys/node/index.d.mts +1 -2
  38. package/dist/sys/node/index.mjs +1 -1
  39. package/dist/sys/node/worker.d.mts +1 -1
  40. package/dist/sys/node/worker.mjs +6 -3
  41. package/dist/testing/index.d.mts +4731 -105
  42. package/dist/testing/index.mjs +7563 -797
  43. package/dist/util-IKfWWLJo.mjs +724 -0
  44. package/dist/validation-DAdGTrys.mjs +791 -0
  45. package/package.json +31 -27
  46. package/dist/client-aTQ7xHxx.mjs +0 -4678
  47. package/dist/index-BvkyxSY6.d.mts +0 -205
  48. package/dist/validation-ByxKj8bC.mjs +0 -1458
  49. /package/{LICENSE.md → LICENSE} +0 -0
@@ -43,8 +43,20 @@ const HOST_FLAGS = {
43
43
  isWatchReady: 128,
44
44
  isListenReady: 256,
45
45
  needsRerender: 512,
46
- devOnRender: 1024,
47
- devOnDidLoad: 2048
46
+ /**
47
+ * Set once this component's real (lazy-loaded) `connectedCallback` has fired for
48
+ * the first time. Lets a descendant skip creating/awaiting a connect-promise for
49
+ * an ancestor that's already connected. See {@link HostRef.$onFirstConnectResolve$}.
50
+ */
51
+ hasFiredConnected: 1024,
52
+ /**
53
+ * Set when a lazy component's dynamic `import()` fails to resolve a
54
+ * constructor. Distinct from `hasInitializedComponent` being unset, which
55
+ * is true while an initialization attempt is merely queued/in-flight.
56
+ */
57
+ hasFailedLoad: 2048,
58
+ devOnRender: 4096,
59
+ devOnDidLoad: 8192
48
60
  };
49
61
  const CF_scopedCssEncapsulation = 2;
50
62
  /**
@@ -129,7 +141,17 @@ const CMP_FLAGS = {
129
141
  * e.g. `encapsulation: { type: 'none', patches: ['all'] }`
130
142
  * Equivalent to the global `experimentalSlotFixes` config option.
131
143
  */
132
- patchAll: 32768
144
+ patchAll: 32768,
145
+ /**
146
+ * Determines if `clonable` is enabled for a component that uses the shadow DOM.
147
+ * e.g. `encapsulation: { type: 'shadow', clonable: true }` is set on the `@Component()` decorator
148
+ */
149
+ shadowClonable: 65536,
150
+ /**
151
+ * Determines if `serializable` is enabled for a component that uses the shadow DOM.
152
+ * e.g. `encapsulation: { type: 'shadow', serializable: true }` is set on the `@Component()` decorator
153
+ */
154
+ shadowSerializable: 1 << 17
133
155
  };
134
156
  /**
135
157
  * Namespaces
@@ -295,6 +317,10 @@ const DEFAULT_DOC_DATA = {
295
317
  */
296
318
  const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
297
319
  const XLINK_NS = "http://www.w3.org/1999/xlink";
320
+ /**
321
+ * Minimum delay, in milliseconds, before retrying a failed lazy component load.
322
+ */
323
+ const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
298
324
  const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
299
325
  "formAssociatedCallback",
300
326
  "formResetCallback",
@@ -314,6 +340,8 @@ function createShadowRoot(cmpMeta) {
314
340
  if (BUILD$1.shadowSlotAssignmentManual) {
315
341
  if (!!(cmpMeta.$flags$ & CMP_FLAGS.shadowSlotAssignmentManual)) opts.slotAssignment = "manual";
316
342
  }
343
+ if (BUILD$1.shadowClonable) opts.clonable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowClonable);
344
+ if (BUILD$1.shadowSerializable) opts.serializable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowSerializable);
317
345
  const shadowRoot = this.attachShadow(opts);
318
346
  if (BUILD$1.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
319
347
  if (globalStyleSheet === void 0) globalStyleSheet = null;
@@ -343,8 +371,10 @@ function createShadowRoot(cmpMeta) {
343
371
  const updateFallbackSlotVisibility = (elm) => {
344
372
  const childNodes = internalCall(elm, "childNodes");
345
373
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
346
- if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
347
- else slotNode.hidden = false;
374
+ if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") {
375
+ if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
376
+ else slotNode.hidden = false;
377
+ }
348
378
  });
349
379
  let i = 0;
350
380
  for (i = 0; i < childNodes.length; i++) {
@@ -387,7 +417,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
387
417
  slottedNodes.push(childNode);
388
418
  if (typeof slotName !== "undefined") return slottedNodes;
389
419
  }
390
- slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
420
+ slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
391
421
  }
392
422
  return slottedNodes;
393
423
  }
@@ -418,7 +448,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
418
448
  if (nodeToRelocate.getAttribute("slot") === slotName) return true;
419
449
  return false;
420
450
  }
421
- if (nodeToRelocate["s-sn"] === slotName) return true;
451
+ if (typeof nodeToRelocate["s-sa"] === "string") return nodeToRelocate["s-sa"] === slotName;
422
452
  return slotName === "";
423
453
  };
424
454
  /**
@@ -467,8 +497,10 @@ function patchSlotNode(node) {
467
497
  const assignedFactory = (elementsOnly) => function(opts) {
468
498
  const toReturn = [];
469
499
  const slotName = this["s-sn"];
470
- if (opts?.flatten) if (BUILD$1.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
471
- else console.error("Flattening not supported for Stencil non-shadow slots");
500
+ if (opts?.flatten) {
501
+ if (BUILD$1.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
502
+ else console.error("Flattening not supported for Stencil non-shadow slots");
503
+ }
472
504
  const parent = this["s-cr"].parentElement;
473
505
  (parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
474
506
  if (slotName === getSlotName(n)) toReturn.push(n);
@@ -559,8 +591,10 @@ const patchCloneNode = (HostElementPrototype) => {
559
591
  for (; i < childNodes.length; i++) {
560
592
  slotted = childNodes[i]["s-nr"];
561
593
  nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
562
- if (slotted) if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
563
- else clonedNode.appendChild(slotted.cloneNode(true));
594
+ if (slotted) {
595
+ if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
596
+ else clonedNode.appendChild(slotted.cloneNode(true));
597
+ }
564
598
  if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
565
599
  }
566
600
  }
@@ -763,11 +797,11 @@ const patchChildSlotNodes = (elm) => {
763
797
  } });
764
798
  patchHostOriginalAccessor("firstChild", elm);
765
799
  Object.defineProperty(elm, "firstChild", { get() {
766
- return this.childNodes[0];
800
+ return this.childNodes[0] || null;
767
801
  } });
768
802
  patchHostOriginalAccessor("lastChild", elm);
769
803
  Object.defineProperty(elm, "lastChild", { get() {
770
- return this.childNodes[this.childNodes.length - 1];
804
+ return this.childNodes[this.childNodes.length - 1] || null;
771
805
  } });
772
806
  patchHostOriginalAccessor("childNodes", elm);
773
807
  Object.defineProperty(elm, "childNodes", { get() {
@@ -813,7 +847,7 @@ const patchNextSibling = (node) => {
813
847
  Object.defineProperty(node, "nextSibling", { get: function() {
814
848
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
815
849
  const index = parentNodes?.indexOf(this);
816
- if (parentNodes && index > -1) return parentNodes[index + 1];
850
+ if (parentNodes && index > -1) return parentNodes[index + 1] || null;
817
851
  return this.__nextSibling;
818
852
  } });
819
853
  };
@@ -828,7 +862,7 @@ const patchNextElementSibling = (element) => {
828
862
  Object.defineProperty(element, "nextElementSibling", { get: function() {
829
863
  const parentEles = this["s-ol"]?.parentNode.children;
830
864
  const index = parentEles?.indexOf(this);
831
- if (parentEles && index > -1) return parentEles[index + 1];
865
+ if (parentEles && index > -1) return parentEles[index + 1] || null;
832
866
  return this.__nextElementSibling;
833
867
  } });
834
868
  };
@@ -843,7 +877,7 @@ const patchPreviousSibling = (node) => {
843
877
  Object.defineProperty(node, "previousSibling", { get: function() {
844
878
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
845
879
  const index = parentNodes?.indexOf(this);
846
- if (parentNodes && index > -1) return parentNodes[index - 1];
880
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
847
881
  return this.__previousSibling;
848
882
  } });
849
883
  };
@@ -858,7 +892,7 @@ const patchPreviousElementSibling = (element) => {
858
892
  Object.defineProperty(element, "previousElementSibling", { get: function() {
859
893
  const parentNodes = this["s-ol"]?.parentNode.children;
860
894
  const index = parentNodes?.indexOf(this);
861
- if (parentNodes && index > -1) return parentNodes[index - 1];
895
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
862
896
  return this.__previousElementSibling;
863
897
  } });
864
898
  };
@@ -1033,7 +1067,7 @@ function queryNonceMetaTagContent(doc) {
1033
1067
  }
1034
1068
  //#endregion
1035
1069
  //#region src/runtime/styles.ts
1036
- const rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1070
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
1037
1071
  /**
1038
1072
  * Get or initialize the set of applied style scope IDs for a container element.
1039
1073
  *
@@ -1123,37 +1157,41 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1123
1157
  /**
1124
1158
  * attach styles at the end of the head tag if we render scoped components
1125
1159
  */
1126
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) if (styleContainerNode.nodeName === "HEAD") {
1127
- /**
1128
- * if the page contains preconnect links, we want to insert the styles
1129
- * after the last preconnect link to ensure the styles are preloaded
1130
- */
1131
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1132
- const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1133
- styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1134
- } else if ("host" in styleContainerNode) {
1135
- /**
1136
- * If a scoped component is used within a shadow root and constructable stylesheets are
1137
- * not supported, we want to insert the styles at the beginning of the shadow root node.
1138
- *
1139
- * However, if there is already a style node in the shadow root, we just append
1140
- * the styles to the existing node.
1141
- *
1142
- * Note: order of how styles are applied is important. The new style node
1143
- * should be inserted before the existing style node.
1144
- *
1145
- * During HMR, create separate style elements for scoped components so they can be
1146
- * updated independently without affecting other components' styles.
1147
- */
1148
- const existingStyleContainer = styleContainerNode.querySelector("style");
1149
- if (existingStyleContainer && !BUILD$1.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1150
- else styleContainerNode.prepend(styleElm);
1151
- } else styleContainerNode.append(styleElm);
1160
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
1161
+ if (styleContainerNode.nodeName === "HEAD") {
1162
+ /**
1163
+ * if the page contains preconnect links, we want to insert the styles
1164
+ * after the last preconnect link to ensure the styles are preloaded
1165
+ */
1166
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1167
+ const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1168
+ styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1169
+ } else if ("host" in styleContainerNode) {
1170
+ /**
1171
+ * If a scoped component is used within a shadow root and constructable stylesheets are
1172
+ * not supported, we want to insert the styles at the beginning of the shadow root node.
1173
+ *
1174
+ * However, if there is already a style node in the shadow root, we just append
1175
+ * the styles to the existing node.
1176
+ *
1177
+ * Note: order of how styles are applied is important. The new style node
1178
+ * should be inserted before the existing style node.
1179
+ *
1180
+ * During HMR, create separate style elements for scoped components so they can be
1181
+ * updated independently without affecting other components' styles.
1182
+ */
1183
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1184
+ if (existingStyleContainer && !BUILD$1.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1185
+ else styleContainerNode.prepend(styleElm);
1186
+ } else styleContainerNode.append(styleElm);
1187
+ }
1152
1188
  /**
1153
1189
  * attach styles at the beginning of a shadow root node if we render shadow components
1154
1190
  */
1155
- if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1156
- else styleContainerNode.insertBefore(styleElm, null);
1191
+ if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
1192
+ if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1193
+ else styleContainerNode.insertBefore(styleElm, null);
1194
+ }
1157
1195
  if (appliedStyles) appliedStyles.add(scopeId);
1158
1196
  }
1159
1197
  } else if (BUILD$1.constructableCSS) {
@@ -1245,7 +1283,12 @@ const hydrateScopedToShadow = () => {
1245
1283
  if (!win.document) return;
1246
1284
  const styleElements = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1247
1285
  let i = 0;
1248
- for (; i < styleElements.length; i++) registerStyle(styleElements[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styleElements[i].innerHTML), true);
1286
+ for (; i < styleElements.length; i++) {
1287
+ const scopeId = styleElements[i].getAttribute(HYDRATED_STYLE_ID);
1288
+ const existing = styles.get(scopeId);
1289
+ const allowCS = existing !== void 0 ? existing instanceof CSSStyleSheet : true;
1290
+ registerStyle(scopeId, convertScopedToShadow(styleElements[i].innerHTML), allowCS);
1291
+ }
1249
1292
  };
1250
1293
  //#endregion
1251
1294
  //#region src/utils/helpers.ts
@@ -1371,11 +1414,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1371
1414
  }
1372
1415
  } else if (BUILD$1.vdomStyle && memberName === "style") {
1373
1416
  if (BUILD$1.updatable) {
1374
- for (const prop in oldValue) if (!newValue || newValue[prop] == null) if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1375
- else elm.style[prop] = "";
1417
+ for (const prop in oldValue) if (!newValue || newValue[prop] == null) {
1418
+ if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1419
+ else elm.style[prop] = "";
1420
+ }
1421
+ }
1422
+ for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) {
1423
+ if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1424
+ else elm.style[prop] = newValue[prop];
1376
1425
  }
1377
- for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1378
- else elm.style[prop] = newValue[prop];
1379
1426
  } else if (BUILD$1.vdomKey && memberName === "key") {} else if (BUILD$1.vdomRef && memberName === "ref") {
1380
1427
  if (newValue) queueRefAttachment(newValue, elm);
1381
1428
  } else if (BUILD$1.vdomListener && (BUILD$1.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
@@ -1384,11 +1431,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1384
1431
  else memberName = ln[2] + memberName.slice(3);
1385
1432
  if (oldValue || newValue) {
1386
1433
  const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1387
- memberName = memberName.replace(/* @__PURE__ */ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1434
+ memberName = memberName.replace(/*@__PURE__*/ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1388
1435
  if (oldValue) plt.rel(elm, memberName, oldValue, capture);
1389
1436
  if (newValue) plt.ael(elm, memberName, newValue, capture);
1390
1437
  }
1391
- } else if (BUILD$1.vdomPropOrAttr && memberName[0] === "a" && memberName.startsWith("attr:")) {
1438
+ } else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "a" && memberName.startsWith("attr:")) {
1392
1439
  const propName = memberName.slice(5);
1393
1440
  let attrName;
1394
1441
  if (BUILD$1.member) {
@@ -1403,7 +1450,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1403
1450
  if (newValue !== false || elm.getAttribute(attrName) === "") elm.removeAttribute(attrName);
1404
1451
  } else elm.setAttribute(attrName, newValue === true ? "" : newValue);
1405
1452
  return;
1406
- } else if (BUILD$1.vdomPropOrAttr && memberName[0] === "p" && memberName.startsWith("prop:")) {
1453
+ } else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "p" && memberName.startsWith("prop:")) {
1407
1454
  const propName = memberName.slice(5);
1408
1455
  try {
1409
1456
  elm[propName] = newValue;
@@ -1423,8 +1470,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1423
1470
  if (!elm.tagName.includes("-")) {
1424
1471
  const n = newValue == null ? "" : newValue;
1425
1472
  if (memberName === "list") isProp = false;
1426
- else if (oldValue == null || elm[memberName] !== n) if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1427
- else elm.setAttribute(memberName, n);
1473
+ else if (oldValue == null || elm[memberName] !== n) {
1474
+ if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1475
+ else elm.setAttribute(memberName, n);
1476
+ }
1428
1477
  } else if (elm[memberName] !== newValue) elm[memberName] = newValue;
1429
1478
  } catch {}
1430
1479
  /**
@@ -1442,8 +1491,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1442
1491
  }
1443
1492
  }
1444
1493
  if (newValue == null || newValue === false) {
1445
- if (newValue !== false || elm.getAttribute(memberName) === "") if (BUILD$1.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1446
- else elm.removeAttribute(memberName);
1494
+ if (newValue !== false || elm.getAttribute(memberName) === "" || flags & VNODE_FLAGS.isHost && !isEnumeratedAttribute(memberName)) {
1495
+ if (BUILD$1.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1496
+ else elm.removeAttribute(memberName);
1497
+ }
1447
1498
  } else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
1448
1499
  newValue = newValue === true ? "" : newValue;
1449
1500
  if (BUILD$1.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -1451,6 +1502,18 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1451
1502
  }
1452
1503
  }
1453
1504
  };
1505
+ /**
1506
+ * Attribute names that are enumerated (tri-state true/false/unset) rather than
1507
+ * plain boolean-presence attributes. An explicit `"false"` string on one of
1508
+ * these is semantically different from the attribute being absent, so a
1509
+ * reflected `false` value must not clear a pre-existing literal value.
1510
+ */
1511
+ const ENUMERATED_ATTRIBUTES = /*@__PURE__*/ new Set([
1512
+ "draggable",
1513
+ "contenteditable",
1514
+ "spellcheck"
1515
+ ]);
1516
+ const isEnumeratedAttribute = (attrName) => ENUMERATED_ATTRIBUTES.has(attrName) || attrName.startsWith("aria-");
1454
1517
  const parseClassListRegex = /\s/;
1455
1518
  /**
1456
1519
  * Parsed a string of classnames into an array
@@ -1574,6 +1637,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1574
1637
  }
1575
1638
  } else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1576
1639
  elm = newVNode.$elm$ = BUILD$1.isDebug || BUILD$1.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
1640
+ if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
1577
1641
  if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
1578
1642
  } else {
1579
1643
  if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
@@ -1849,8 +1913,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
1849
1913
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1850
1914
  newStartVnode = newCh[++newStartIdx];
1851
1915
  }
1852
- if (node) if (BUILD$1.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
1853
- else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1916
+ if (node) {
1917
+ if (BUILD$1.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
1918
+ else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1919
+ }
1854
1920
  }
1855
1921
  if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1856
1922
  else if (BUILD$1.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
@@ -1937,6 +2003,30 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
1937
2003
  */
1938
2004
  const relocateNodes = [];
1939
2005
  /**
2006
+ * When a forwarded `<slot>` gets relocated, drag along any content already forwarded through it,
2007
+ * to wherever it just landed (or nowhere, to be hidden, if it didn't match anything).
2008
+ *
2009
+ * Runs as its own pass after {@link markSlotContentForRelocation} rather than inside it, so that
2010
+ * function's matching order - which hydration's node/comment ordering depends on - is untouched.
2011
+ */
2012
+ const carryContentWithRelocatedSlotRefs = () => {
2013
+ for (const relocateData of relocateNodes.slice()) {
2014
+ const marker = relocateData.$nodeToRelocate$;
2015
+ if (!marker["s-sr"]) continue;
2016
+ const carriedSiblings = getSlotChildSiblings(marker, marker["s-sn"] || "", false);
2017
+ for (const carriedSibling of carriedSiblings) {
2018
+ if (!carriedSibling["s-ol"]) continue;
2019
+ let siblingRelocateData = relocateNodes.find((r) => r.$nodeToRelocate$ === carriedSibling);
2020
+ if (!siblingRelocateData) {
2021
+ siblingRelocateData = { $nodeToRelocate$: carriedSibling };
2022
+ relocateNodes.push(siblingRelocateData);
2023
+ }
2024
+ siblingRelocateData.$slotRefNode$ = relocateData.$slotRefNode$;
2025
+ if (relocateData.$slotRefNode$) carriedSibling["s-sh"] = relocateData.$slotRefNode$["s-hn"];
2026
+ }
2027
+ }
2028
+ };
2029
+ /**
1940
2030
  * Mark the contents of a slot for relocation via adding references to them to
1941
2031
  * the {@link relocateNodes} data structure. The actual work of relocating them
1942
2032
  * will then be handled in {@link renderVdom}.
@@ -2041,7 +2131,7 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2041
2131
  return newNode;
2042
2132
  }
2043
2133
  }
2044
- if (parent.__insertBefore) return parent.__insertBefore(newNode, reference);
2134
+ if (BUILD$1.slotRelocation && parent?.__insertBefore) return parent.__insertBefore(newNode, reference);
2045
2135
  else return parent?.insertBefore(newNode, reference);
2046
2136
  };
2047
2137
  /**
@@ -2135,6 +2225,7 @@ render() {
2135
2225
  plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
2136
2226
  if (checkSlotRelocate) {
2137
2227
  markSlotContentForRelocation(rootVnode.$elm$);
2228
+ carryContentWithRelocatedSlotRefs();
2138
2229
  for (const relocateData of relocateNodes) {
2139
2230
  const nodeToRelocate = relocateData.$nodeToRelocate$;
2140
2231
  if (!nodeToRelocate["s-ol"] && win.document) {
@@ -2194,7 +2285,7 @@ render() {
2194
2285
  }
2195
2286
  if (BUILD$1.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2196
2287
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2197
- for (const childNode of children) if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2288
+ for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2198
2289
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
2199
2290
  if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
2200
2291
  else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
@@ -2212,16 +2303,58 @@ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot
2212
2303
  const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
2213
2304
  //#endregion
2214
2305
  //#region src/runtime/update-component.ts
2306
+ /**
2307
+ * Get a promise that resolves once `hostRef`'s real `connectedCallback` has fired for the first time.
2308
+ *
2309
+ * @param hostRef the component's host reference
2310
+ * @returns a promise that resolves once the component's real `connectedCallback` has fired
2311
+ */
2312
+ const ensureFirstConnectPromise = (hostRef) => {
2313
+ if (!hostRef.$onFirstConnectPromise$) hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
2314
+ return hostRef.$onFirstConnectPromise$;
2315
+ };
2316
+ /**
2317
+ * Resolve `hostRef`'s first-connect promise and flag it connected. Called once this
2318
+ * component's real `connectedCallback` fires, plus from error/disconnect cleanup so a
2319
+ * component that never connects can't hang an ancestor or descendant forever.
2320
+ *
2321
+ * @param hostRef the component's host reference
2322
+ */
2323
+ const markFirstConnected = (hostRef) => {
2324
+ hostRef.$flags$ |= HOST_FLAGS.hasFiredConnected;
2325
+ hostRef.$onFirstConnectResolve$?.();
2326
+ hostRef.$onFirstConnectResolve$ = void 0;
2327
+ };
2328
+ /**
2329
+ * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
2330
+ * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
2331
+ * `connectedCallback` paths so a component never connects before its nearest Stencil
2332
+ * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
2333
+ * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
2334
+ * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
2335
+ * autoloader, where the ancestor tag may not be defined yet.
2336
+ *
2337
+ * @param ancestorElm the nearest Stencil ancestor element
2338
+ */
2339
+ const awaitAncestorConnected = async (ancestorElm) => {
2340
+ let ancestorHostRef = getHostRef(ancestorElm);
2341
+ if (!BUILD$1.lazyLoad && !ancestorHostRef) {
2342
+ await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
2343
+ ancestorHostRef = getHostRef(ancestorElm);
2344
+ }
2345
+ if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
2346
+ };
2215
2347
  const attachToAncestor = (hostRef, ancestorComponent) => {
2216
2348
  if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2217
2349
  const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
2218
2350
  ancestorComponent["s-p"].splice(index - 1, 1);
2219
2351
  r();
2220
2352
  }));
2353
+ if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
2221
2354
  }
2222
2355
  };
2223
2356
  const scheduleUpdate = (hostRef, isInitialLoad) => {
2224
- if (BUILD$1.taskQueue && BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2357
+ if (BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2225
2358
  if (BUILD$1.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
2226
2359
  hostRef.$flags$ |= HOST_FLAGS.needsRerender;
2227
2360
  return;
@@ -2229,6 +2362,8 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2229
2362
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2230
2363
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2231
2364
  if (isInitialLoad) {
2365
+ const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2366
+ if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
2232
2367
  queueMicrotask(() => {
2233
2368
  dispatch();
2234
2369
  });
@@ -2268,10 +2403,6 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2268
2403
  let maybePromise;
2269
2404
  if (isInitialLoad) {
2270
2405
  if (BUILD$1.lazyLoad) {
2271
- if (BUILD$1.slotRelocation && hostRef.$deferredConnectedCallback$) {
2272
- hostRef.$deferredConnectedCallback$ = false;
2273
- safeCall(instance, "connectedCallback", void 0, elm);
2274
- }
2275
2406
  if (BUILD$1.hostListener) {
2276
2407
  hostRef.$flags$ |= HOST_FLAGS.isListenReady;
2277
2408
  if (hostRef.$queuedListeners$) {
@@ -2284,6 +2415,14 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2284
2415
  if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
2285
2416
  maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
2286
2417
  } else {
2418
+ if (BUILD$1.updatable && hostRef.$queuedPropChanges$) {
2419
+ const changes = hostRef.$queuedPropChanges$;
2420
+ hostRef.$queuedPropChanges$ = void 0;
2421
+ if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
2422
+ hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2423
+ return;
2424
+ }
2425
+ }
2287
2426
  if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
2288
2427
  maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
2289
2428
  }
@@ -2398,7 +2537,6 @@ let renderingRef = null;
2398
2537
  const callRender = (hostRef, instance, elm, isInitialLoad) => {
2399
2538
  const allRenderFn = !!BUILD$1.allRenderFn;
2400
2539
  const lazyLoad = !!BUILD$1.lazyLoad;
2401
- const taskQueue = !!BUILD$1.taskQueue;
2402
2540
  const updatable = !!BUILD$1.updatable;
2403
2541
  try {
2404
2542
  renderingRef = instance;
@@ -2407,14 +2545,17 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
2407
2545
  * method, so we can call the method immediately. If not, check before calling it.
2408
2546
  */
2409
2547
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
2410
- if (updatable && taskQueue) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2548
+ if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2411
2549
  if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
2412
- if (BUILD$1.hasRenderFn || BUILD$1.reflect) if (BUILD$1.vdomRender || BUILD$1.reflect) if (BUILD$1.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2413
- else renderVdom(hostRef, instance, isInitialLoad);
2414
- else {
2415
- const shadowRoot = elm.shadowRoot;
2416
- if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2417
- else elm.textContent = instance;
2550
+ if (BUILD$1.hasRenderFn || BUILD$1.reflect) {
2551
+ if (BUILD$1.vdomRender || BUILD$1.reflect) {
2552
+ if (BUILD$1.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2553
+ else renderVdom(hostRef, instance, isInitialLoad);
2554
+ } else {
2555
+ const shadowRoot = elm.shadowRoot;
2556
+ if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2557
+ else elm.textContent = instance;
2558
+ }
2418
2559
  }
2419
2560
  } catch (e) {
2420
2561
  consoleError(e, hostRef.$hostElement$);
@@ -2554,17 +2695,19 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2554
2695
  const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
2555
2696
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
2556
2697
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
2557
- const sig = signal(hostRef.$instanceValues$.get(memberName));
2698
+ const initialVal = hostRef.$instanceValues$.get(memberName);
2699
+ const sig = signal(initialVal);
2558
2700
  hostRef.$signalValues$.set(memberName, sig);
2559
2701
  let prevScheduleVal = sig.peek();
2560
2702
  disposers.push(effect(() => {
2561
2703
  const newVal = sig.value;
2562
2704
  if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
2563
2705
  if (instance?.componentShouldUpdate) {
2564
- if (instance.componentShouldUpdate(newVal, prevScheduleVal, memberName) === false && !(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) {
2565
- prevScheduleVal = newVal;
2566
- return;
2567
- }
2706
+ const changes = hostRef.$queuedPropChanges$ ||= {};
2707
+ changes[memberName] = {
2708
+ newVal,
2709
+ oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
2710
+ };
2568
2711
  }
2569
2712
  if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
2570
2713
  }
@@ -2599,7 +2742,8 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2599
2742
  consoleError(e, elm);
2600
2743
  }
2601
2744
  }));
2602
- elm[STENCIL_SIGNALS_SYMBOL] = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
2745
+ const publicSignals = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
2746
+ elm[STENCIL_SIGNALS_SYMBOL] = publicSignals;
2603
2747
  hostRef.$signalCleanup$ = () => {
2604
2748
  disposers.forEach((d) => d());
2605
2749
  elm[STENCIL_SIGNALS_SYMBOL] = void 0;
@@ -2648,22 +2792,28 @@ const h = (nodeName, vnodeData, ...children) => {
2648
2792
  for (let i = 0; i < c.length; i++) {
2649
2793
  child = c[i];
2650
2794
  if (Array.isArray(child)) walk(child);
2651
- else if (child != null && typeof child !== "boolean") if (BUILD$1.vdomSignals && isSignalLike(child)) {
2652
- const sigVNode = newVNode(null, String(child.peek()));
2653
- sigVNode.$signal$ = child;
2654
- vNodeChildren.push(sigVNode);
2655
- lastSimple = false;
2656
- } else {
2657
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
2658
- else if (BUILD$1.isDev && typeof nodeName !== "function" && child.$flags$ === void 0);
2659
- if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
2660
- else vNodeChildren.push(simple ? newVNode(null, child) : child);
2661
- lastSimple = simple;
2795
+ else if (child != null && typeof child !== "boolean") {
2796
+ if (BUILD$1.vdomSignals && isSignalLike(child)) {
2797
+ const sigVNode = newVNode(null, String(child.peek()));
2798
+ sigVNode.$signal$ = child;
2799
+ vNodeChildren.push(sigVNode);
2800
+ lastSimple = false;
2801
+ } else {
2802
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
2803
+ else if (typeof nodeName !== "function" && child.$flags$ === void 0) {
2804
+ if (BUILD$1.isDev);
2805
+ else consoleError("Invalid vNode child");
2806
+ continue;
2807
+ }
2808
+ if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
2809
+ else vNodeChildren.push(simple ? newVNode(null, child) : child);
2810
+ lastSimple = simple;
2811
+ }
2662
2812
  }
2663
2813
  }
2664
2814
  };
2665
2815
  walk(children);
2666
- if (vnodeData) {
2816
+ if (vnodeData && typeof vnodeData === "object") {
2667
2817
  if (BUILD$1.isDev && nodeName === "input") validateInputProperties(vnodeData);
2668
2818
  if (BUILD$1.vdomKey && vnodeData.key) key = vnodeData.key;
2669
2819
  if (BUILD$1.slotRelocation && vnodeData.name) slotName = vnodeData.name;
@@ -2762,7 +2912,7 @@ const convertToPrivate = (node) => {
2762
2912
  /**
2763
2913
  * Validates the ordering of attributes on an input element
2764
2914
  *
2765
- * @param inputElm the element to validate
2915
+ * @param inputElm the vnode data (JSX props) for the element to validate
2766
2916
  */
2767
2917
  const validateInputProperties = (inputElm) => {
2768
2918
  const props = Object.keys(inputElm);
@@ -3179,12 +3329,13 @@ const restoreSafeSelector = (placeholders, content) => {
3179
3329
  const _polyfillHost = "-shadowcsshost";
3180
3330
  const _polyfillSlotted = "-shadowcssslotted";
3181
3331
  const _polyfillHostContext = "-shadowcsscontext";
3332
+ const _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
3182
3333
  let _cssColonHostRe;
3183
3334
  let _cssColonHostContextRe;
3184
3335
  let _cssColonSlottedRe;
3185
- const getCssColonHostRe = () => _cssColonHostRe ??= /* @__PURE__ */ new RegExp("(-shadowcsshost)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
3186
- const getCssColonHostContextRe = () => _cssColonHostContextRe ??= /* @__PURE__ */ new RegExp("(-shadowcsscontext)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
3187
- const getCssColonSlottedRe = () => _cssColonSlottedRe ??= /* @__PURE__ */ new RegExp("(-shadowcssslotted)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
3336
+ const getCssColonHostRe = () => _cssColonHostRe ??= new RegExp("(-shadowcsshost" + _parenSuffix, "gim");
3337
+ const getCssColonHostContextRe = () => _cssColonHostContextRe ??= new RegExp("(-shadowcsscontext" + _parenSuffix, "gim");
3338
+ const getCssColonSlottedRe = () => _cssColonSlottedRe ??= new RegExp("(-shadowcssslotted" + _parenSuffix, "gim");
3188
3339
  const _polyfillHostNoCombinator = "-shadowcsshost-no-combinator";
3189
3340
  const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
3190
3341
  const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
@@ -3641,14 +3792,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
3641
3792
  /**
3642
3793
  * ensure this value is of the correct prop type
3643
3794
  */
3644
- if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
3645
- /**
3646
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
3647
- * (regardless of its value, even "false") should make the property true.
3648
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
3649
- */
3650
- if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
3651
- else return propValue === "false" ? false : propValue === "" || !!propValue;
3795
+ if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) {
3796
+ /**
3797
+ * For form-associated components, according to HTML spec, the presence of any boolean attribute
3798
+ * (regardless of its value, even "false") should make the property true.
3799
+ * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
3800
+ */
3801
+ if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
3802
+ else return propValue === "false" ? false : propValue === "" || !!propValue;
3803
+ }
3652
3804
  /**
3653
3805
  * force it to be a number
3654
3806
  */
@@ -3736,7 +3888,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3736
3888
  }
3737
3889
  if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
3738
3890
  if (instance.componentShouldUpdate) {
3739
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false && !(flags & HOST_FLAGS.isQueuedForUpdate)) return;
3891
+ const changes = hostRef.$queuedPropChanges$ ||= {};
3892
+ changes[propName] = {
3893
+ newVal,
3894
+ oldVal: changes[propName]?.oldVal ?? oldVal
3895
+ };
3740
3896
  }
3741
3897
  if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3742
3898
  }
@@ -3745,6 +3901,14 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3745
3901
  //#endregion
3746
3902
  //#region src/runtime/proxy-component.ts
3747
3903
  /**
3904
+ * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
3905
+ * recognize an `attributeChangedCallback` it triggered itself.
3906
+ *
3907
+ * @param propValue the current value of a reflected prop
3908
+ * @returns the string the attribute would hold, or `null` if the attribute would be removed
3909
+ */
3910
+ const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
3911
+ /**
3748
3912
  * Attach a series of runtime constructs to a compiled Stencil component
3749
3913
  * constructor, including getters and setters for the `@Prop` and `@State`
3750
3914
  * decorators, callbacks for when attributes change, and so on.
@@ -3870,11 +4034,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3870
4034
  };
3871
4035
  for (const deserializer of cmpMeta.$deserializers$[propName]) {
3872
4036
  const [[methodName]] = Object.entries(deserializer);
3873
- if (BUILD$1.lazyLoad) if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
3874
- else hostRef.$fetchedCbList$.push(() => {
3875
- setVal(methodName, hostRef.$lazyInstance$);
3876
- });
3877
- else setVal(methodName, this);
4037
+ if (BUILD$1.lazyLoad) {
4038
+ if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
4039
+ else hostRef.$fetchedCbList$.push(() => {
4040
+ setVal(methodName, hostRef.$lazyInstance$);
4041
+ });
4042
+ } else setVal(methodName, this);
3878
4043
  }
3879
4044
  return;
3880
4045
  } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
@@ -3891,14 +4056,16 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3891
4056
  return;
3892
4057
  }
3893
4058
  const propFlags = members.find(([m]) => m === propName);
3894
- const isBooleanTarget = propFlags && propFlags[1][0] & MEMBER_FLAGS.Boolean;
4059
+ const propMemberFlags = propFlags ? propFlags[1][0] : 0;
4060
+ const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
4061
+ if (BUILD$1.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
3895
4062
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
3896
4063
  if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
3897
4064
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
3898
4065
  if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
3899
4066
  });
3900
4067
  };
3901
- Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
4068
+ Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
3902
4069
  const attrName = m[1] || propName;
3903
4070
  attrNameToPropName.set(attrName, propName);
3904
4071
  if (BUILD$1.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
@@ -3925,6 +4092,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3925
4092
  try {
3926
4093
  if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
3927
4094
  hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
4095
+ hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
3928
4096
  const bundleId = cmpMeta.$lazyBundleId$;
3929
4097
  if (BUILD$1.lazyLoad && bundleId) {
3930
4098
  const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
@@ -3933,7 +4101,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3933
4101
  Cstr = await CstrImport;
3934
4102
  endLoad();
3935
4103
  } else Cstr = CstrImport;
3936
- if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4104
+ if (!Cstr) {
4105
+ hostRef.$flags$ &= ~HOST_FLAGS.hasInitializedComponent;
4106
+ hostRef.$loadRetryCount$ = (hostRef.$loadRetryCount$ ?? 0) + 1;
4107
+ if (hostRef.$loadRetryCount$ < 3) hostRef.$flags$ |= HOST_FLAGS.hasFailedLoad;
4108
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4109
+ }
3937
4110
  if (BUILD$1.member && !Cstr.isProxied) {
3938
4111
  if (BUILD$1.propChangeCallback) {
3939
4112
  cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
@@ -3952,8 +4125,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3952
4125
  }
3953
4126
  if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
3954
4127
  endNewInstance();
3955
- if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) fireConnectedCallback(hostRef.$lazyInstance$, elm);
3956
- else hostRef.$deferredConnectedCallback$ = true;
4128
+ if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4129
+ if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4130
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4131
+ if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4132
+ } else queueMicrotask(() => {
4133
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4134
+ if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4135
+ });
3957
4136
  } else Cstr = elm.constructor;
3958
4137
  if (BUILD$1.style && Cstr && Cstr.style) {
3959
4138
  /**
@@ -4012,7 +4191,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4012
4191
  hostRef.$onRenderResolve$();
4013
4192
  hostRef.$onRenderResolve$ = void 0;
4014
4193
  }
4015
- if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$) hostRef.$onReadyResolve$(elm);
4194
+ if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4195
+ if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
4016
4196
  }
4017
4197
  };
4018
4198
  const fireConnectedCallback = (instance, elm) => {
@@ -4075,6 +4255,7 @@ const connectedCallback = (elm) => {
4075
4255
  } else {
4076
4256
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
4077
4257
  if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4258
+ else if (hostRef.$flags$ & HOST_FLAGS.hasFailedLoad) setTimeout(() => initializeComponent(elm, hostRef, cmpMeta), LAZY_LOAD_RETRY_INTERVAL_MS);
4078
4259
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
4079
4260
  }
4080
4261
  endConnected();
@@ -4104,6 +4285,7 @@ const disconnectedCallback = async (elm) => {
4104
4285
  hostRef.$signalCleanup$();
4105
4286
  hostRef.$signalCleanup$ = void 0;
4106
4287
  }
4288
+ if (BUILD$1.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
4107
4289
  if (!BUILD$1.lazyLoad) disconnectInstance(elm);
4108
4290
  else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
4109
4291
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
@@ -4151,7 +4333,6 @@ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
4151
4333
  };
4152
4334
  const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4153
4335
  const modulePath = hostElement.constructor.__stencil_module__;
4154
- console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
4155
4336
  if (!modulePath) {
4156
4337
  console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor - was this built with devMode?`);
4157
4338
  return;
@@ -4164,18 +4345,39 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4164
4345
  const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4165
4346
  if (!NewClass) return;
4166
4347
  const ctor = customElements.get(cmpMeta.$tagName$);
4167
- if (ctor) for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4168
- if (key === "constructor") continue;
4169
- Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4348
+ if (ctor) {
4349
+ for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4350
+ if (key === "constructor") continue;
4351
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4352
+ }
4353
+ const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4354
+ if (styleDesc) {
4355
+ Object.defineProperty(ctor, "style", styleDesc);
4356
+ const newStyle = NewClass.style;
4357
+ if (newStyle) {
4358
+ const scopeId = getScopeId(cmpMeta);
4359
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4360
+ console.log("[stencil-hmr] registerStyle", {
4361
+ tag: cmpMeta.$tagName$,
4362
+ scopeId,
4363
+ isShadow,
4364
+ cssLen: newStyle.length
4365
+ });
4366
+ registerStyle(scopeId, newStyle, isShadow);
4367
+ }
4368
+ }
4170
4369
  }
4370
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4171
4371
  document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4172
- if (BUILD$1.hostListener) {
4173
- const hostRef = getHostRef(el);
4174
- if (hostRef?.$rmListeners$) {
4175
- hostRef.$rmListeners$.map((rmListener) => rmListener());
4176
- hostRef.$rmListeners$ = void 0;
4177
- addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4178
- }
4372
+ const hostRef = getHostRef(el);
4373
+ if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
4374
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
4375
+ hostRef.$rmListeners$ = void 0;
4376
+ addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4377
+ }
4378
+ if (!isShadow && hostRef) {
4379
+ console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
4380
+ attachStyles(hostRef);
4179
4381
  }
4180
4382
  forceUpdate(el);
4181
4383
  });
@@ -4186,7 +4388,9 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4186
4388
  //#endregion
4187
4389
  //#region src/runtime/bootstrap-standalone.ts
4188
4390
  const defineCustomElement = (Cstr, compactMeta) => {
4189
- customElements.define(transformTag(compactMeta[1]), proxyCustomElement(Cstr, compactMeta));
4391
+ const tag = transformTag(compactMeta[1]);
4392
+ const proxied = proxyCustomElement(Cstr, compactMeta);
4393
+ if (!customElements.get(tag)) customElements.define(tag, proxied);
4190
4394
  };
4191
4395
  const proxyCustomElement = (Cstr, compactMeta) => {
4192
4396
  if (BUILD$1.profile && performance.mark && performance.getEntriesByName("st:app:start", "mark").length === 0) performance.mark("st:app:start");
@@ -4207,18 +4411,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4207
4411
  hmrStart(this, cmpMeta, hmrVersionId);
4208
4412
  };
4209
4413
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4210
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4211
- else {
4212
- if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4213
- if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4214
- patchSlotAppendChild(Cstr.prototype);
4215
- patchSlotAppend(Cstr.prototype);
4216
- patchSlotPrepend(Cstr.prototype);
4217
- patchSlotInsertAdjacentHTML(Cstr.prototype);
4218
- patchInsertBefore(Cstr.prototype);
4219
- patchSlotRemoveChild(Cstr.prototype);
4414
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4415
+ if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4416
+ else {
4417
+ if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4418
+ if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4419
+ patchSlotAppendChild(Cstr.prototype);
4420
+ patchSlotAppend(Cstr.prototype);
4421
+ patchSlotPrepend(Cstr.prototype);
4422
+ patchSlotInsertAdjacentHTML(Cstr.prototype);
4423
+ patchInsertBefore(Cstr.prototype);
4424
+ patchSlotRemoveChild(Cstr.prototype);
4425
+ }
4426
+ if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
4220
4427
  }
4221
- if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
4222
4428
  }
4223
4429
  if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
4224
4430
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
@@ -4231,19 +4437,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4231
4437
  componentOnReady() {
4232
4438
  return getHostRef(this)?.$onReadyPromise$;
4233
4439
  },
4234
- connectedCallback() {
4235
- if (!this.__hasHostListenerAttached) {
4236
- const hostRef = getHostRef(this);
4440
+ async connectedCallback() {
4441
+ const isFirstConnect = !this.__hasHostListenerAttached;
4442
+ let hostRef;
4443
+ if (isFirstConnect) {
4444
+ hostRef = getHostRef(this);
4237
4445
  if (!hostRef) return;
4238
4446
  addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4239
4447
  this.__hasHostListenerAttached = true;
4240
4448
  }
4241
4449
  connectedCallback(this);
4242
- if (originalConnectedCallback) originalConnectedCallback.call(this);
4450
+ if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4451
+ await awaitAncestorConnected(hostRef.$ancestorComponent$);
4452
+ if (!this.isConnected) return;
4453
+ }
4454
+ if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
4455
+ if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);
4243
4456
  },
4244
4457
  disconnectedCallback() {
4245
4458
  disconnectedCallback(this);
4246
- if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
4459
+ if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
4247
4460
  },
4248
4461
  __attachShadow() {
4249
4462
  const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
@@ -4297,8 +4510,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4297
4510
  const exclude = options.exclude || [];
4298
4511
  const _reg = options.registry ?? getRegistry();
4299
4512
  const head = win.document.head;
4300
- const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
4301
- const dataStyles = /* @__PURE__ */ win.document.createElement("style");
4513
+ const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
4514
+ const dataStyles = /*@__PURE__*/ win.document.createElement("style");
4302
4515
  const deferredConnectedCallbacks = [];
4303
4516
  let appLoadFallback;
4304
4517
  let isBootstrapping = true;
@@ -4366,8 +4579,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4366
4579
  *
4367
4580
  * Also remove the reference from `deferredConnectedCallbacks` array
4368
4581
  * otherwise removed instances won't get garbage collected.
4582
+ *
4583
+ * Use `nextTick` (microtask) rather than `plt.raf` since
4584
+ * `requestAnimationFrame` callbacks do not fire while `document.hidden`
4369
4585
  */
4370
- plt.raf(() => {
4586
+ nextTick(() => {
4371
4587
  const hostRef = getHostRef(this);
4372
4588
  if (!hostRef) return;
4373
4589
  const i = deferredConnectedCallbacks.findIndex((host) => host === this);
@@ -4380,18 +4596,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4380
4596
  }
4381
4597
  };
4382
4598
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(HostElement.prototype);
4383
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4384
- else {
4385
- if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4386
- if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4387
- patchSlotAppendChild(HostElement.prototype);
4388
- patchSlotAppend(HostElement.prototype);
4389
- patchSlotPrepend(HostElement.prototype);
4390
- patchSlotInsertAdjacentHTML(HostElement.prototype);
4391
- patchInsertBefore(HostElement.prototype);
4392
- patchSlotRemoveChild(HostElement.prototype);
4599
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4600
+ if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4601
+ else {
4602
+ if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4603
+ if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4604
+ patchSlotAppendChild(HostElement.prototype);
4605
+ patchSlotAppend(HostElement.prototype);
4606
+ patchSlotPrepend(HostElement.prototype);
4607
+ patchSlotInsertAdjacentHTML(HostElement.prototype);
4608
+ patchInsertBefore(HostElement.prototype);
4609
+ patchSlotRemoveChild(HostElement.prototype);
4610
+ }
4611
+ if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
4393
4612
  }
4394
- if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
4395
4613
  }
4396
4614
  if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
4397
4615
  if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
@@ -4437,9 +4655,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
4437
4655
  };
4438
4656
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
4439
4657
  try {
4440
- if (BUILD$1.lazyLoad) if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4441
- else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4442
- else hostRef.$hostElement$[methodName](ev);
4658
+ if (BUILD$1.lazyLoad) {
4659
+ if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4660
+ else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4661
+ } else hostRef.$hostElement$[methodName](ev);
4443
4662
  } catch (e) {
4444
4663
  consoleError(e, hostRef.$hostElement$);
4445
4664
  }
@@ -4452,6 +4671,86 @@ const getHostListenerTarget = (doc, elm, flags) => {
4452
4671
  };
4453
4672
  const hostListenerOpts = (flags) => (flags & LISTENER_FLAGS.Capture) !== 0;
4454
4673
  //#endregion
4674
+ //#region src/runtime/inject-side-effect-style.ts
4675
+ const styleSheets = /* @__PURE__ */ new Map();
4676
+ const knownRoots = /* @__PURE__ */ new Set();
4677
+ const adoptedRoots = /* @__PURE__ */ new WeakMap();
4678
+ const knownFontFaces = /* @__PURE__ */ new Set();
4679
+ const adopt = (root, sheet) => {
4680
+ let roots = adoptedRoots.get(sheet);
4681
+ if (!roots) {
4682
+ roots = /* @__PURE__ */ new WeakSet();
4683
+ adoptedRoots.set(sheet, roots);
4684
+ }
4685
+ if (!roots.has(root)) {
4686
+ roots.add(root);
4687
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
4688
+ }
4689
+ };
4690
+ /**
4691
+ * Registers a root (a shadow root, or `document`) to receive every side-effect CSS import
4692
+ * (a plain, non-component `import './foo.css'`), now and in future. Call in `connectedCallback`,
4693
+ * paired with `unregisterSideEffectStyleTarget` in `disconnectedCallback` so the registry doesn't
4694
+ * hold disconnected roots forever.
4695
+ * @param root the root to register
4696
+ */
4697
+ function registerSideEffectStyleTarget(root) {
4698
+ knownRoots.add(root);
4699
+ for (const sheet of styleSheets.values()) adopt(root, sheet);
4700
+ }
4701
+ /**
4702
+ * Removes a root registered via `registerSideEffectStyleTarget` - call in `disconnectedCallback`.
4703
+ * @param root the root to unregister
4704
+ */
4705
+ function unregisterSideEffectStyleTarget(root) {
4706
+ knownRoots.delete(root);
4707
+ }
4708
+ const FONT_FACE_RE = /@font-face\s*\{[^{}]*\}/g;
4709
+ /**
4710
+ * Splits `@font-face` rules out of a CSS text - exported standalone (from private
4711
+ * module state - usually 3rd party node_modules) exported for testing
4712
+ * @param cssText the CSS text to split
4713
+ * @returns the font-face rules joined together (`null` if there were none) and the remaining CSS
4714
+ */
4715
+ function splitFontFaces(cssText) {
4716
+ const fontFaces = cssText.match(FONT_FACE_RE);
4717
+ if (!fontFaces) return {
4718
+ fontFaceText: null,
4719
+ rest: cssText
4720
+ };
4721
+ return {
4722
+ fontFaceText: fontFaces.join("\n"),
4723
+ rest: cssText.replace(FONT_FACE_RE, "")
4724
+ };
4725
+ }
4726
+ /**
4727
+ * Applies plain (non-component) CSS text to every registered root - respects shadow DOM
4728
+ * encapsulation instead of always reaching for the top-level document. Not meant to be called
4729
+ * directly: this is what the compiler's CSS-to-ESM output calls for CSS with no Stencil `tag`
4730
+ * (i.e. not a component's own `styleUrl`), typically a third-party dependency's CSS import.
4731
+ *
4732
+ * `@font-face` rules are pulled out and adopted onto top-level `document` not per-root
4733
+ * (Chromium (https://issues.chromium.org/issues/41085401) per-root never loads).
4734
+ * @param cssText the CSS text to apply
4735
+ */
4736
+ function injectSideEffectStyle(cssText) {
4737
+ const { fontFaceText, rest } = splitFontFaces(cssText);
4738
+ if (fontFaceText && !knownFontFaces.has(fontFaceText)) {
4739
+ knownFontFaces.add(fontFaceText);
4740
+ const fontFaceSheet = new CSSStyleSheet();
4741
+ fontFaceSheet.replaceSync(fontFaceText);
4742
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, fontFaceSheet];
4743
+ }
4744
+ if (!rest.trim()) return;
4745
+ let sheet = styleSheets.get(rest);
4746
+ if (!sheet) {
4747
+ sheet = new CSSStyleSheet();
4748
+ sheet.replaceSync(rest);
4749
+ styleSheets.set(rest, sheet);
4750
+ }
4751
+ for (const root of knownRoots) adopt(root, sheet);
4752
+ }
4753
+ //#endregion
4455
4754
  //#region src/runtime/mixin.ts
4456
4755
  const baseClass = BUILD$1.lazyLoad ? class {} : globalThis.HTMLElement || class {};
4457
4756
  function Mixin(...mixins) {
@@ -4659,7 +4958,8 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
4659
4958
  const nodeName = parentNode?.nodeName;
4660
4959
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
4661
4960
  const textNodeId = `t.${childId}`;
4662
- insertBefore(parentNode, doc.createComment(textNodeId), childElm);
4961
+ const commentBeforeTextNode = doc.createComment(textNodeId);
4962
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
4663
4963
  }
4664
4964
  } else if (childElm.nodeType === NODE_TYPE.CommentNode) {
4665
4965
  if (childElm["s-sr"]) childElm.nodeValue = `s.${childId}.${childElm["s-sn"] || ""}`;
@@ -4694,22 +4994,19 @@ function proxyHostElement(elm, cstr) {
4694
4994
  const propValue = elm[memberName];
4695
4995
  let attrPropVal;
4696
4996
  const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
4697
- if (attrValue != null) if (cmpMeta.$deserializers$?.[memberName]) for (const deserializer of cmpMeta.$deserializers$[memberName]) {
4698
- const [[methodName]] = Object.entries(deserializer);
4699
- attrPropVal = cstr.prototype[methodName](attrValue, memberName);
4997
+ if (attrValue != null) {
4998
+ if (cmpMeta.$deserializers$?.[memberName]) for (const deserializer of cmpMeta.$deserializers$[memberName]) {
4999
+ const [[methodName]] = Object.entries(deserializer);
5000
+ attrPropVal = cstr.prototype[methodName](attrValue, memberName);
5001
+ }
5002
+ else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4700
5003
  }
4701
- else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4702
5004
  if (propValue !== void 0) {
4703
5005
  attrPropVal = propValue;
4704
5006
  delete elm[memberName];
4705
5007
  }
4706
- if (attrPropVal !== void 0) {
4707
- if (origSetter) {
4708
- origSetter.apply(elm, [attrPropVal]);
4709
- attrPropVal = origGetter ? origGetter.apply(elm) : attrPropVal;
4710
- }
4711
- hostRef?.$instanceValues$?.set(memberName, attrPropVal);
4712
- }
5008
+ const userSetter = !cstr.isProxied ? origSetter : void 0;
5009
+ if (attrPropVal !== void 0 && !userSetter) hostRef?.$instanceValues$?.set(memberName, attrPropVal);
4713
5010
  const getterSetterDescriptor = {
4714
5011
  get: function() {
4715
5012
  return getValue(this, memberName);
@@ -4723,8 +5020,26 @@ function proxyHostElement(elm, cstr) {
4723
5020
  Object.defineProperty(elm, memberName, getterSetterDescriptor);
4724
5021
  Object.defineProperty(elm, metaAttributeName, getterSetterDescriptor);
4725
5022
  hostRef.$fetchedCbList$.push(() => {
4726
- if (!hostRef?.$instanceValues$?.has(memberName)) setValue(elm, memberName, attrPropVal !== void 0 ? attrPropVal : hostRef.$lazyInstance$[memberName], cmpMeta);
4727
- Object.defineProperty(hostRef.$lazyInstance$, memberName, getterSetterDescriptor);
5023
+ if (userSetter && attrPropVal !== void 0) {
5024
+ userSetter.apply(hostRef.$lazyInstance$, [attrPropVal]);
5025
+ const processedValue = origGetter ? origGetter.apply(hostRef.$lazyInstance$) : attrPropVal;
5026
+ setValue(elm, memberName, processedValue, cmpMeta);
5027
+ } else if (!hostRef?.$instanceValues$?.has(memberName)) setValue(elm, memberName, attrPropVal !== void 0 ? attrPropVal : hostRef.$lazyInstance$[memberName], cmpMeta);
5028
+ if (userSetter) Object.defineProperty(hostRef.$lazyInstance$, memberName, {
5029
+ get: origGetter ? function() {
5030
+ return origGetter.call(this);
5031
+ } : function() {
5032
+ return getValue(this, memberName);
5033
+ },
5034
+ set: function(newValue) {
5035
+ userSetter.call(this, newValue);
5036
+ newValue = origGetter ? origGetter.call(this) : newValue;
5037
+ setValue(elm, memberName, newValue, cmpMeta);
5038
+ },
5039
+ configurable: true,
5040
+ enumerable: true
5041
+ });
5042
+ else Object.defineProperty(hostRef.$lazyInstance$, memberName, getterSetterDescriptor);
4728
5043
  });
4729
5044
  } else if (memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(elm, memberName, { value(...args) {
4730
5045
  const ref = getHostRef(this);
@@ -4904,7 +5219,7 @@ function shouldHydrate(elm) {
4904
5219
  if (parentNode == null) return true;
4905
5220
  return shouldHydrate(parentNode);
4906
5221
  }
4907
- const NO_HYDRATE_TAGS = new Set([
5222
+ const NO_HYDRATE_TAGS = /* @__PURE__ */ new Set([
4908
5223
  "CODE",
4909
5224
  "HEAD",
4910
5225
  "IFRAME",
@@ -4933,9 +5248,11 @@ function renderCatchError(opts, results, err) {
4933
5248
  const u = new URL(opts.url);
4934
5249
  if (u.pathname !== "/") diagnostic.header += ": " + u.pathname;
4935
5250
  } catch {}
4936
- if (err != null) if (err.stack != null) diagnostic.messageText = err.stack.toString();
4937
- else if (err.message != null) diagnostic.messageText = err.message.toString();
4938
- else diagnostic.messageText = err.toString();
5251
+ if (err != null) {
5252
+ if (err.stack != null) diagnostic.messageText = err.stack.toString();
5253
+ else if (err.message != null) diagnostic.messageText = err.message.toString();
5254
+ else diagnostic.messageText = err.toString();
5255
+ }
4939
5256
  results.diagnostics.push(diagnostic);
4940
5257
  }
4941
5258
  function printTag(elm) {
@@ -5046,7 +5363,7 @@ const writeTask = (cb) => {
5046
5363
  }
5047
5364
  });
5048
5365
  };
5049
- const resolved = /* @__PURE__ */ Promise.resolve();
5366
+ const resolved = /*@__PURE__*/ Promise.resolve();
5050
5367
  const nextTick = (cb) => resolved.then(cb);
5051
5368
  const defaultConsoleError = (e) => {
5052
5369
  if (e != null) console.error(e.stack || e.message || e);
@@ -5137,4 +5454,4 @@ const setScopedSsr = (opts) => {
5137
5454
  const needsScopedSSR = () => scopedSSR;
5138
5455
  let scopedSSR = false;
5139
5456
  //#endregion
5140
- export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, win, writeTask };
5457
+ export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, injectSideEffectStyle, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, registerSideEffectStyleTarget, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };