@stencil/core 5.0.0-alpha.27 → 5.0.0-alpha.29

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 (44) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/{client-CvcvHKz4.mjs → client-D1MsT-Rp.mjs} +373 -238
  3. package/dist/compiler/index.d.mts +2 -3
  4. package/dist/compiler/index.mjs +3 -3
  5. package/dist/compiler/utils/index.d.mts +272 -2
  6. package/dist/compiler/utils/index.mjs +4 -3
  7. package/dist/{compiler-D43Ied7R.mjs → compiler-BbS9TDF_.mjs} +1845 -1118
  8. package/dist/declarations/stencil-ext-modules.d.ts +5 -5
  9. package/dist/declarations/stencil-public-compiler.d.ts +108 -40
  10. package/dist/declarations/stencil-public-docs.d.ts +9 -0
  11. package/dist/declarations/stencil-public-runtime.d.ts +81 -6
  12. package/dist/fragment-Di1hWOC8.mjs +4 -0
  13. package/dist/{index-F3IidHM1.d.mts → index-BHj3EBl2.d.mts} +395 -312
  14. package/dist/{index-xAkMgLX_.d.ts → index-D2PAsXxx.d.ts} +133 -9
  15. package/dist/index-VK8okIiF.d.mts +108 -0
  16. package/dist/index.d.mts +4 -0
  17. package/dist/index.mjs +91 -2
  18. package/dist/jsx-runtime.mjs +2 -1
  19. package/dist/{node-DKVq_Ud0.mjs → node-BQR4L-TG.mjs} +60 -58
  20. package/dist/reactive-controller-BdCpSAQP.d.mts +13 -0
  21. package/dist/{regular-expression-CFVJOTUh.mjs → regular-expression-XqU5zmPp.mjs} +20 -3
  22. package/dist/{chunk-z9aeyW2b.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
  23. package/dist/runtime/client/lazy.js +411 -165
  24. package/dist/runtime/client/runtime.d.ts +136 -9
  25. package/dist/runtime/client/runtime.js +411 -165
  26. package/dist/runtime/index.d.ts +5 -3
  27. package/dist/runtime/index.js +410 -163
  28. package/dist/runtime/server/index.d.mts +80 -8
  29. package/dist/runtime/server/index.mjs +333 -158
  30. package/dist/runtime/server/runner.d.mts +3 -0
  31. package/dist/runtime/server/runner.mjs +232 -308
  32. package/dist/signals/index.d.ts +2 -0
  33. package/dist/sys/node/index.d.mts +1 -2
  34. package/dist/sys/node/index.mjs +1 -1
  35. package/dist/sys/node/worker.d.mts +1 -1
  36. package/dist/sys/node/worker.mjs +6 -3
  37. package/dist/testing/index.d.mts +4 -9
  38. package/dist/testing/index.mjs +74 -56
  39. package/dist/util-BIa-iHnt.mjs +724 -0
  40. package/dist/validation-Dd3g77T5.mjs +778 -0
  41. package/package.json +27 -27
  42. package/dist/index-3fu7WQs4.d.mts +0 -205
  43. package/dist/validation-ByxKj8bC.mjs +0 -1458
  44. /package/{LICENSE.md → LICENSE} +0 -0
@@ -144,8 +144,20 @@ const HOST_FLAGS = {
144
144
  isWatchReady: 128,
145
145
  isListenReady: 256,
146
146
  needsRerender: 512,
147
- devOnRender: 1024,
148
- devOnDidLoad: 2048
147
+ /**
148
+ * Set once this component's real (lazy-loaded) `connectedCallback` has fired for
149
+ * the first time. Lets a descendant skip creating/awaiting a connect-promise for
150
+ * an ancestor that's already connected. See {@link HostRef.$onFirstConnectResolve$}.
151
+ */
152
+ hasFiredConnected: 1024,
153
+ /**
154
+ * Set when a lazy component's dynamic `import()` fails to resolve a
155
+ * constructor. Distinct from `hasInitializedComponent` being unset, which
156
+ * is true while an initialization attempt is merely queued/in-flight.
157
+ */
158
+ hasFailedLoad: 2048,
159
+ devOnRender: 4096,
160
+ devOnDidLoad: 8192
149
161
  };
150
162
  const CF_scopedCssEncapsulation = 2;
151
163
  /**
@@ -377,8 +389,13 @@ const registerHost = (hostElement, cmpMeta) => {
377
389
  if (BUILD.asyncLoading) {
378
390
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
379
391
  hostElement["s-rp"] = hostRef.$onReadyPromise$;
392
+ if (!BUILD.lazyLoad) {
393
+ hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
394
+ hostElement["s-fc"] = hostRef.$onFirstConnectPromise$;
395
+ }
380
396
  if (!hostElement["s-p"]) hostElement["s-p"] = [];
381
397
  if (!hostElement["s-rc"]) hostElement["s-rc"] = [];
398
+ if (!hostElement["s-pc"]) hostElement["s-pc"] = [];
382
399
  }
383
400
  if (BUILD.lazyLoad) hostRef.$fetchedCbList$ = [];
384
401
  const ref = hostRef;
@@ -398,7 +415,12 @@ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
398
415
  const setErrorHandler = (handler) => customError = handler;
399
416
  //#endregion
400
417
  //#region src/client/client-load-module.ts
401
- const cmpModules = /* @__PURE__ */ new Map();
418
+ const cmpModules = /*@__PURE__*/ new Map();
419
+ /**
420
+ * Tracks how many times a dynamic `import()` for a given lazy bundle has failed.
421
+ * Used to cache bust the retry attempt in connected-callback.ts
422
+ */
423
+ const failedLoadAttempts = /*@__PURE__*/ new Map();
402
424
  /**
403
425
  * We need to separate out this prefix so that Esbuild doesn't try to resolve
404
426
  * the below, but instead retains a dynamic `import()` statement in the
@@ -429,13 +451,21 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
429
451
  } else if (!bundleId) return;
430
452
  const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
431
453
  if (module) return module[exportName];
454
+ const retryCount = failedLoadAttempts.get(bundleId) ?? 0;
455
+ const cacheBustParams = [retryCount > 0 ? `s-retry=${retryCount}` : "", BUILD.hotModuleReplacement && hmrVersionId ? `s-hmr=${hmrVersionId}` : ""].filter(Boolean).join("&");
432
456
  /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
433
- const entryFile = `${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? "?s-hmr=" + hmrVersionId : ""}`;
457
+ const entryFile = `${bundleId}.entry.js${cacheBustParams ? "?" + cacheBustParams : ""}`;
434
458
  const onLoad = (importedModule) => {
435
- if (!BUILD.hotModuleReplacement) cmpModules.set(bundleId, importedModule);
459
+ if (!BUILD.hotModuleReplacement) {
460
+ failedLoadAttempts.delete(bundleId);
461
+ cmpModules.set(bundleId, importedModule);
462
+ }
436
463
  return importedModule[exportName];
437
464
  };
438
- const onError = (e) => consoleError(e, hostRef.$hostElement$);
465
+ const onError = (e) => {
466
+ failedLoadAttempts.set(bundleId, retryCount + 1);
467
+ consoleError(e, hostRef.$hostElement$);
468
+ };
439
469
  if (lazyLoadBasePath) return import(
440
470
  /* @vite-ignore */
441
471
  /* webpackInclude: /\.entry\.js$/ */
@@ -453,7 +483,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
453
483
  };
454
484
  //#endregion
455
485
  //#region src/client/client-style.ts
456
- const styles = /* @__PURE__ */ new Map();
486
+ const styles = /*@__PURE__*/ new Map();
457
487
  const modeResolutionChain = [];
458
488
  const setScopedSsr = (_opts) => {};
459
489
  const needsScopedSSR = () => false;
@@ -516,6 +546,10 @@ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
516
546
  */
517
547
  const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
518
548
  const XLINK_NS = "http://www.w3.org/1999/xlink";
549
+ /**
550
+ * Minimum delay, in milliseconds, before retrying a failed lazy component load.
551
+ */
552
+ const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
519
553
  const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
520
554
  "formAssociatedCallback",
521
555
  "formResetCallback",
@@ -538,7 +572,7 @@ const plt = {
538
572
  const setPlatformHelpers = (helpers) => {
539
573
  Object.assign(plt, helpers);
540
574
  };
541
- const supportsListenerOptions = /* @__PURE__ */ (() => {
575
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
542
576
  let supported = false;
543
577
  try {
544
578
  win.document?.addEventListener("e", null, Object.defineProperty({}, "passive", { get() {
@@ -548,14 +582,14 @@ const supportsListenerOptions = /* @__PURE__ */ (() => {
548
582
  return supported;
549
583
  })();
550
584
  const promiseResolve = (v) => Promise.resolve(v);
551
- const supportsConstructableStylesheets = BUILD.constructableCSS ? /* @__PURE__ */ (() => {
585
+ const supportsConstructableStylesheets = BUILD.constructableCSS ? /*@__PURE__*/ (() => {
552
586
  try {
553
587
  if (!win.document.adoptedStyleSheets) return false;
554
588
  return typeof new CSSStyleSheet().replaceSync === "function";
555
589
  } catch {}
556
590
  return false;
557
591
  })() : false;
558
- const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /* @__PURE__ */ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
592
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /*@__PURE__*/ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
559
593
  //#endregion
560
594
  //#region src/client/client-task-queue.ts
561
595
  let queueCongestion = 0;
@@ -563,12 +597,13 @@ let queuePending = false;
563
597
  const queueDomReads = [];
564
598
  const queueDomWrites = [];
565
599
  const queueDomWritesLow = [];
600
+ const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
566
601
  const queueTask = (queue, write) => (cb) => {
567
602
  queue.push(cb);
568
603
  if (!queuePending) {
569
604
  queuePending = true;
570
605
  if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush);
571
- else plt.raf(flush);
606
+ else scheduleFlush();
572
607
  }
573
608
  };
574
609
  const consume = (queue) => {
@@ -601,16 +636,16 @@ const flush = () => {
601
636
  queueDomWritesLow.push(...queueDomWrites);
602
637
  queueDomWrites.length = 0;
603
638
  }
604
- if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) plt.raf(flush);
639
+ if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) scheduleFlush();
605
640
  else queueCongestion = 0;
606
641
  } else {
607
642
  consume(queueDomWrites);
608
- if (queuePending = queueDomReads.length > 0) plt.raf(flush);
643
+ if (queuePending = queueDomReads.length > 0) scheduleFlush();
609
644
  }
610
645
  };
611
646
  const nextTick = (cb) => promiseResolve().then(cb);
612
- const readTask = /* @__PURE__ */ queueTask(queueDomReads, false);
613
- const writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
647
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
648
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
614
649
  //#endregion
615
650
  //#region src/runtime/asset-path.ts
616
651
  const getAssetPath = (path) => {
@@ -650,9 +685,10 @@ function createShadowRoot(cmpMeta) {
650
685
  const shadowRoot = this.attachShadow(opts);
651
686
  if (BUILD.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
652
687
  if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported(globalStyles) ?? null;
653
- if (globalStyleSheet) if (supportsMutableAdoptedStyleSheets) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
654
- else shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
655
- else if (globalStyles && !supportsConstructableStylesheets) {
688
+ if (globalStyleSheet) {
689
+ if (supportsMutableAdoptedStyleSheets) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
690
+ else shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
691
+ } else if (globalStyles && !supportsConstructableStylesheets) {
656
692
  const styleElm = document.createElement("style");
657
693
  styleElm.innerHTML = globalStyles;
658
694
  if (BUILD.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, GLOBAL_STYLE_ID);
@@ -677,8 +713,10 @@ function createShadowRoot(cmpMeta) {
677
713
  const updateFallbackSlotVisibility = (elm) => {
678
714
  const childNodes = internalCall(elm, "childNodes");
679
715
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
680
- if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
681
- else slotNode.hidden = false;
716
+ if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") {
717
+ if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
718
+ else slotNode.hidden = false;
719
+ }
682
720
  });
683
721
  let i = 0;
684
722
  for (i = 0; i < childNodes.length; i++) {
@@ -721,7 +759,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
721
759
  slottedNodes.push(childNode);
722
760
  if (typeof slotName !== "undefined") return slottedNodes;
723
761
  }
724
- slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
762
+ slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
725
763
  }
726
764
  return slottedNodes;
727
765
  }
@@ -752,7 +790,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
752
790
  if (nodeToRelocate.getAttribute("slot") === slotName) return true;
753
791
  return false;
754
792
  }
755
- if (nodeToRelocate["s-sn"] === slotName) return true;
793
+ if (typeof nodeToRelocate["s-sa"] === "string") return nodeToRelocate["s-sa"] === slotName;
756
794
  return slotName === "";
757
795
  };
758
796
  /**
@@ -801,8 +839,10 @@ function patchSlotNode(node) {
801
839
  const assignedFactory = (elementsOnly) => function(opts) {
802
840
  const toReturn = [];
803
841
  const slotName = this["s-sn"];
804
- if (opts?.flatten) if (BUILD.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
805
- else console.error("Flattening not supported for Stencil non-shadow slots");
842
+ if (opts?.flatten) {
843
+ if (BUILD.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
844
+ else console.error("Flattening not supported for Stencil non-shadow slots");
845
+ }
806
846
  const parent = this["s-cr"].parentElement;
807
847
  (parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
808
848
  if (slotName === getSlotName(n)) toReturn.push(n);
@@ -893,8 +933,10 @@ const patchCloneNode = (HostElementPrototype) => {
893
933
  for (; i < childNodes.length; i++) {
894
934
  slotted = childNodes[i]["s-nr"];
895
935
  nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
896
- if (slotted) if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
897
- else clonedNode.appendChild(slotted.cloneNode(true));
936
+ if (slotted) {
937
+ if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
938
+ else clonedNode.appendChild(slotted.cloneNode(true));
939
+ }
898
940
  if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
899
941
  }
900
942
  }
@@ -1097,11 +1139,11 @@ const patchChildSlotNodes = (elm) => {
1097
1139
  } });
1098
1140
  patchHostOriginalAccessor("firstChild", elm);
1099
1141
  Object.defineProperty(elm, "firstChild", { get() {
1100
- return this.childNodes[0];
1142
+ return this.childNodes[0] || null;
1101
1143
  } });
1102
1144
  patchHostOriginalAccessor("lastChild", elm);
1103
1145
  Object.defineProperty(elm, "lastChild", { get() {
1104
- return this.childNodes[this.childNodes.length - 1];
1146
+ return this.childNodes[this.childNodes.length - 1] || null;
1105
1147
  } });
1106
1148
  patchHostOriginalAccessor("childNodes", elm);
1107
1149
  Object.defineProperty(elm, "childNodes", { get() {
@@ -1147,7 +1189,7 @@ const patchNextSibling = (node) => {
1147
1189
  Object.defineProperty(node, "nextSibling", { get: function() {
1148
1190
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
1149
1191
  const index = parentNodes?.indexOf(this);
1150
- if (parentNodes && index > -1) return parentNodes[index + 1];
1192
+ if (parentNodes && index > -1) return parentNodes[index + 1] || null;
1151
1193
  return this.__nextSibling;
1152
1194
  } });
1153
1195
  };
@@ -1162,7 +1204,7 @@ const patchNextElementSibling = (element) => {
1162
1204
  Object.defineProperty(element, "nextElementSibling", { get: function() {
1163
1205
  const parentEles = this["s-ol"]?.parentNode.children;
1164
1206
  const index = parentEles?.indexOf(this);
1165
- if (parentEles && index > -1) return parentEles[index + 1];
1207
+ if (parentEles && index > -1) return parentEles[index + 1] || null;
1166
1208
  return this.__nextElementSibling;
1167
1209
  } });
1168
1210
  };
@@ -1177,7 +1219,7 @@ const patchPreviousSibling = (node) => {
1177
1219
  Object.defineProperty(node, "previousSibling", { get: function() {
1178
1220
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
1179
1221
  const index = parentNodes?.indexOf(this);
1180
- if (parentNodes && index > -1) return parentNodes[index - 1];
1222
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
1181
1223
  return this.__previousSibling;
1182
1224
  } });
1183
1225
  };
@@ -1192,7 +1234,7 @@ const patchPreviousElementSibling = (element) => {
1192
1234
  Object.defineProperty(element, "previousElementSibling", { get: function() {
1193
1235
  const parentNodes = this["s-ol"]?.parentNode.children;
1194
1236
  const index = parentNodes?.indexOf(this);
1195
- if (parentNodes && index > -1) return parentNodes[index - 1];
1237
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
1196
1238
  return this.__previousElementSibling;
1197
1239
  } });
1198
1240
  };
@@ -1367,7 +1409,7 @@ function queryNonceMetaTagContent(doc) {
1367
1409
  }
1368
1410
  //#endregion
1369
1411
  //#region src/runtime/styles.ts
1370
- const rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1412
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
1371
1413
  /**
1372
1414
  * Get or initialize the set of applied style scope IDs for a container element.
1373
1415
  *
@@ -1391,9 +1433,10 @@ const getAppliedStyles = (container) => {
1391
1433
  * @param prepend if true, add to beginning; if false, add to end
1392
1434
  */
1393
1435
  const adoptStylesheet = (container, sheet, prepend = false) => {
1394
- if (supportsMutableAdoptedStyleSheets) if (prepend) container.adoptedStyleSheets.unshift(sheet);
1395
- else container.adoptedStyleSheets.push(sheet);
1396
- else if (prepend) container.adoptedStyleSheets = [sheet, ...container.adoptedStyleSheets];
1436
+ if (supportsMutableAdoptedStyleSheets) {
1437
+ if (prepend) container.adoptedStyleSheets.unshift(sheet);
1438
+ else container.adoptedStyleSheets.push(sheet);
1439
+ } else if (prepend) container.adoptedStyleSheets = [sheet, ...container.adoptedStyleSheets];
1397
1440
  else container.adoptedStyleSheets = [...container.adoptedStyleSheets, sheet];
1398
1441
  };
1399
1442
  /**
@@ -1406,7 +1449,7 @@ const adoptStylesheet = (container, sheet, prepend = false) => {
1406
1449
  * @returns a new CSSStyleSheet for the correct window
1407
1450
  */
1408
1451
  const createStylesheetForWindow = (container, cssText) => {
1409
- const sheet = new (container.defaultView ?? container.ownerDocument?.defaultView ?? win).CSSStyleSheet();
1452
+ const sheet = new (container.defaultView ?? (container.ownerDocument?.defaultView) ?? win).CSSStyleSheet();
1410
1453
  sheet.replaceSync(cssText);
1411
1454
  return sheet;
1412
1455
  };
@@ -1477,41 +1520,46 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1477
1520
  /**
1478
1521
  * attach styles at the end of the head tag if we render scoped components
1479
1522
  */
1480
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) if (styleContainerNode.nodeName === "HEAD") {
1481
- /**
1482
- * if the page contains preconnect links, we want to insert the styles
1483
- * after the last preconnect link to ensure the styles are preloaded
1484
- */
1485
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1486
- const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1487
- styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1488
- } else if ("host" in styleContainerNode) if (supportsConstructableStylesheets) {
1489
- const stylesheet = createStylesheetForWindow(styleContainerNode, style);
1490
- adoptStylesheet(styleContainerNode, stylesheet, true);
1491
- } else {
1492
- /**
1493
- * If a scoped component is used within a shadow root and constructable stylesheets are
1494
- * not supported, we want to insert the styles at the beginning of the shadow root node.
1495
- *
1496
- * However, if there is already a style node in the shadow root, we just append
1497
- * the styles to the existing node.
1498
- *
1499
- * Note: order of how styles are applied is important. The new style node
1500
- * should be inserted before the existing style node.
1501
- *
1502
- * During HMR, create separate style elements for scoped components so they can be
1503
- * updated independently without affecting other components' styles.
1504
- */
1505
- const existingStyleContainer = styleContainerNode.querySelector("style");
1506
- if (existingStyleContainer && !BUILD.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1507
- else styleContainerNode.prepend(styleElm);
1523
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
1524
+ if (styleContainerNode.nodeName === "HEAD") {
1525
+ /**
1526
+ * if the page contains preconnect links, we want to insert the styles
1527
+ * after the last preconnect link to ensure the styles are preloaded
1528
+ */
1529
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1530
+ const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1531
+ styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1532
+ } else if ("host" in styleContainerNode) {
1533
+ if (supportsConstructableStylesheets) {
1534
+ const stylesheet = createStylesheetForWindow(styleContainerNode, style);
1535
+ adoptStylesheet(styleContainerNode, stylesheet, true);
1536
+ } else {
1537
+ /**
1538
+ * If a scoped component is used within a shadow root and constructable stylesheets are
1539
+ * not supported, we want to insert the styles at the beginning of the shadow root node.
1540
+ *
1541
+ * However, if there is already a style node in the shadow root, we just append
1542
+ * the styles to the existing node.
1543
+ *
1544
+ * Note: order of how styles are applied is important. The new style node
1545
+ * should be inserted before the existing style node.
1546
+ *
1547
+ * During HMR, create separate style elements for scoped components so they can be
1548
+ * updated independently without affecting other components' styles.
1549
+ */
1550
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1551
+ if (existingStyleContainer && !BUILD.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1552
+ else styleContainerNode.prepend(styleElm);
1553
+ }
1554
+ } else styleContainerNode.append(styleElm);
1508
1555
  }
1509
- else styleContainerNode.append(styleElm);
1510
1556
  /**
1511
1557
  * attach styles at the beginning of a shadow root node if we render shadow components
1512
1558
  */
1513
- if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1514
- else styleContainerNode.insertBefore(styleElm, null);
1559
+ if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
1560
+ if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1561
+ else styleContainerNode.insertBefore(styleElm, null);
1562
+ }
1515
1563
  if (appliedStyles) appliedStyles.add(scopeId);
1516
1564
  }
1517
1565
  } else if (BUILD.constructableCSS) {
@@ -1740,11 +1788,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1740
1788
  }
1741
1789
  } else if (BUILD.vdomStyle && memberName === "style") {
1742
1790
  if (BUILD.updatable) {
1743
- for (const prop in oldValue) if (!newValue || newValue[prop] == null) if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1744
- else elm.style[prop] = "";
1791
+ for (const prop in oldValue) if (!newValue || newValue[prop] == null) {
1792
+ if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1793
+ else elm.style[prop] = "";
1794
+ }
1795
+ }
1796
+ for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) {
1797
+ if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1798
+ else elm.style[prop] = newValue[prop];
1745
1799
  }
1746
- for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1747
- else elm.style[prop] = newValue[prop];
1748
1800
  } else if (BUILD.vdomKey && memberName === "key") {} else if (BUILD.vdomRef && memberName === "ref") {
1749
1801
  if (newValue) queueRefAttachment(newValue, elm);
1750
1802
  } else if (BUILD.vdomListener && (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
@@ -1753,7 +1805,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1753
1805
  else memberName = ln[2] + memberName.slice(3);
1754
1806
  if (oldValue || newValue) {
1755
1807
  const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1756
- memberName = memberName.replace(/* @__PURE__ */ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1808
+ memberName = memberName.replace(/*@__PURE__*/ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1757
1809
  if (oldValue) plt.rel(elm, memberName, oldValue, capture);
1758
1810
  if (newValue) plt.ael(elm, memberName, newValue, capture);
1759
1811
  }
@@ -1792,8 +1844,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1792
1844
  if (!elm.tagName.includes("-")) {
1793
1845
  const n = newValue == null ? "" : newValue;
1794
1846
  if (memberName === "list") isProp = false;
1795
- else if (oldValue == null || elm[memberName] !== n) if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1796
- else elm.setAttribute(memberName, n);
1847
+ else if (oldValue == null || elm[memberName] !== n) {
1848
+ if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1849
+ else elm.setAttribute(memberName, n);
1850
+ }
1797
1851
  } else if (elm[memberName] !== newValue) elm[memberName] = newValue;
1798
1852
  } catch {}
1799
1853
  /**
@@ -1811,8 +1865,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1811
1865
  }
1812
1866
  }
1813
1867
  if (newValue == null || newValue === false) {
1814
- if (newValue !== false || elm.getAttribute(memberName) === "") if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1815
- else elm.removeAttribute(memberName);
1868
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
1869
+ if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1870
+ else elm.removeAttribute(memberName);
1871
+ }
1816
1872
  } else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
1817
1873
  newValue = newValue === true ? "" : newValue;
1818
1874
  if (BUILD.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -1943,6 +1999,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1943
1999
  }
1944
2000
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1945
2001
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
2002
+ if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
1946
2003
  if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
1947
2004
  } else {
1948
2005
  if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
@@ -2218,8 +2275,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
2218
2275
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
2219
2276
  newStartVnode = newCh[++newStartIdx];
2220
2277
  }
2221
- if (node) if (BUILD.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
2222
- else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
2278
+ if (node) {
2279
+ if (BUILD.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
2280
+ else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
2281
+ }
2223
2282
  }
2224
2283
  if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
2225
2284
  else if (BUILD.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
@@ -2306,6 +2365,30 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
2306
2365
  */
2307
2366
  const relocateNodes = [];
2308
2367
  /**
2368
+ * When a forwarded `<slot>` gets relocated, drag along any content already forwarded through it,
2369
+ * to wherever it just landed (or nowhere, to be hidden, if it didn't match anything).
2370
+ *
2371
+ * Runs as its own pass after {@link markSlotContentForRelocation} rather than inside it, so that
2372
+ * function's matching order - which hydration's node/comment ordering depends on - is untouched.
2373
+ */
2374
+ const carryContentWithRelocatedSlotRefs = () => {
2375
+ for (const relocateData of relocateNodes.slice()) {
2376
+ const marker = relocateData.$nodeToRelocate$;
2377
+ if (!marker["s-sr"]) continue;
2378
+ const carriedSiblings = getSlotChildSiblings(marker, marker["s-sn"] || "", false);
2379
+ for (const carriedSibling of carriedSiblings) {
2380
+ if (!carriedSibling["s-ol"]) continue;
2381
+ let siblingRelocateData = relocateNodes.find((r) => r.$nodeToRelocate$ === carriedSibling);
2382
+ if (!siblingRelocateData) {
2383
+ siblingRelocateData = { $nodeToRelocate$: carriedSibling };
2384
+ relocateNodes.push(siblingRelocateData);
2385
+ }
2386
+ siblingRelocateData.$slotRefNode$ = relocateData.$slotRefNode$;
2387
+ if (relocateData.$slotRefNode$) carriedSibling["s-sh"] = relocateData.$slotRefNode$["s-hn"];
2388
+ }
2389
+ }
2390
+ };
2391
+ /**
2309
2392
  * Mark the contents of a slot for relocation via adding references to them to
2310
2393
  * the {@link relocateNodes} data structure. The actual work of relocating them
2311
2394
  * will then be handled in {@link renderVdom}.
@@ -2504,6 +2587,7 @@ render() {
2504
2587
  plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
2505
2588
  if (checkSlotRelocate) {
2506
2589
  markSlotContentForRelocation(rootVnode.$elm$);
2590
+ carryContentWithRelocatedSlotRefs();
2507
2591
  for (const relocateData of relocateNodes) {
2508
2592
  const nodeToRelocate = relocateData.$nodeToRelocate$;
2509
2593
  if (!nodeToRelocate["s-ol"] && win.document) {
@@ -2563,7 +2647,7 @@ render() {
2563
2647
  }
2564
2648
  if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2565
2649
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2566
- for (const childNode of children) if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2650
+ for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2567
2651
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
2568
2652
  if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
2569
2653
  else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
@@ -2581,16 +2665,58 @@ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot
2581
2665
  const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
2582
2666
  //#endregion
2583
2667
  //#region src/runtime/update-component.ts
2668
+ /**
2669
+ * Get a promise that resolves once `hostRef`'s real `connectedCallback` has fired for the first time.
2670
+ *
2671
+ * @param hostRef the component's host reference
2672
+ * @returns a promise that resolves once the component's real `connectedCallback` has fired
2673
+ */
2674
+ const ensureFirstConnectPromise = (hostRef) => {
2675
+ if (!hostRef.$onFirstConnectPromise$) hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
2676
+ return hostRef.$onFirstConnectPromise$;
2677
+ };
2678
+ /**
2679
+ * Resolve `hostRef`'s first-connect promise and flag it connected. Called once this
2680
+ * component's real `connectedCallback` fires, plus from error/disconnect cleanup so a
2681
+ * component that never connects can't hang an ancestor or descendant forever.
2682
+ *
2683
+ * @param hostRef the component's host reference
2684
+ */
2685
+ const markFirstConnected = (hostRef) => {
2686
+ hostRef.$flags$ |= HOST_FLAGS.hasFiredConnected;
2687
+ hostRef.$onFirstConnectResolve$?.();
2688
+ hostRef.$onFirstConnectResolve$ = void 0;
2689
+ };
2690
+ /**
2691
+ * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
2692
+ * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
2693
+ * `connectedCallback` paths so a component never connects before its nearest Stencil
2694
+ * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
2695
+ * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
2696
+ * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
2697
+ * autoloader, where the ancestor tag may not be defined yet.
2698
+ *
2699
+ * @param ancestorElm the nearest Stencil ancestor element
2700
+ */
2701
+ const awaitAncestorConnected = async (ancestorElm) => {
2702
+ let ancestorHostRef = getHostRef(ancestorElm);
2703
+ if (!BUILD.lazyLoad && !ancestorHostRef) {
2704
+ await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
2705
+ ancestorHostRef = getHostRef(ancestorElm);
2706
+ }
2707
+ if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
2708
+ };
2584
2709
  const attachToAncestor = (hostRef, ancestorComponent) => {
2585
2710
  if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2586
2711
  const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
2587
2712
  ancestorComponent["s-p"].splice(index - 1, 1);
2588
2713
  r();
2589
2714
  }));
2715
+ if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
2590
2716
  }
2591
2717
  };
2592
2718
  const scheduleUpdate = (hostRef, isInitialLoad) => {
2593
- if (BUILD.taskQueue && BUILD.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2719
+ if (BUILD.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2594
2720
  if (BUILD.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
2595
2721
  hostRef.$flags$ |= HOST_FLAGS.needsRerender;
2596
2722
  return;
@@ -2598,6 +2724,8 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2598
2724
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2599
2725
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2600
2726
  if (isInitialLoad) {
2727
+ const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2728
+ if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
2601
2729
  queueMicrotask(() => {
2602
2730
  dispatch();
2603
2731
  });
@@ -2637,10 +2765,6 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2637
2765
  let maybePromise;
2638
2766
  if (isInitialLoad) {
2639
2767
  if (BUILD.lazyLoad) {
2640
- if (BUILD.slotRelocation && hostRef.$deferredConnectedCallback$) {
2641
- hostRef.$deferredConnectedCallback$ = false;
2642
- safeCall(instance, "connectedCallback", void 0, elm);
2643
- }
2644
2768
  if (BUILD.hostListener) {
2645
2769
  hostRef.$flags$ |= HOST_FLAGS.isListenReady;
2646
2770
  if (hostRef.$queuedListeners$) {
@@ -2653,6 +2777,14 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2653
2777
  if (BUILD.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
2654
2778
  maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
2655
2779
  } else {
2780
+ if (BUILD.updatable && hostRef.$queuedPropChanges$) {
2781
+ const changes = hostRef.$queuedPropChanges$;
2782
+ hostRef.$queuedPropChanges$ = void 0;
2783
+ if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
2784
+ hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2785
+ return;
2786
+ }
2787
+ }
2656
2788
  if (BUILD.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
2657
2789
  maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
2658
2790
  }
@@ -2767,7 +2899,6 @@ let renderingRef = null;
2767
2899
  const callRender = (hostRef, instance, elm, isInitialLoad) => {
2768
2900
  const allRenderFn = !!BUILD.allRenderFn;
2769
2901
  const lazyLoad = !!BUILD.lazyLoad;
2770
- const taskQueue = !!BUILD.taskQueue;
2771
2902
  const updatable = !!BUILD.updatable;
2772
2903
  try {
2773
2904
  renderingRef = instance;
@@ -2776,14 +2907,17 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
2776
2907
  * method, so we can call the method immediately. If not, check before calling it.
2777
2908
  */
2778
2909
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
2779
- if (updatable && taskQueue) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2910
+ if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2780
2911
  if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
2781
- if (BUILD.hasRenderFn || BUILD.reflect) if (BUILD.vdomRender || BUILD.reflect) if (BUILD.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2782
- else renderVdom(hostRef, instance, isInitialLoad);
2783
- else {
2784
- const shadowRoot = elm.shadowRoot;
2785
- if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2786
- else elm.textContent = instance;
2912
+ if (BUILD.hasRenderFn || BUILD.reflect) {
2913
+ if (BUILD.vdomRender || BUILD.reflect) {
2914
+ if (BUILD.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2915
+ else renderVdom(hostRef, instance, isInitialLoad);
2916
+ } else {
2917
+ const shadowRoot = elm.shadowRoot;
2918
+ if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2919
+ else elm.textContent = instance;
2920
+ }
2787
2921
  }
2788
2922
  } catch (e) {
2789
2923
  consoleError(e, hostRef.$hostElement$);
@@ -2923,17 +3057,19 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2923
3057
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2924
3058
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
2925
3059
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
2926
- const sig = signal(hostRef.$instanceValues$.get(memberName));
3060
+ const initialVal = hostRef.$instanceValues$.get(memberName);
3061
+ const sig = signal(initialVal);
2927
3062
  hostRef.$signalValues$.set(memberName, sig);
2928
3063
  let prevScheduleVal = sig.peek();
2929
3064
  disposers.push(effect(() => {
2930
3065
  const newVal = sig.value;
2931
3066
  if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
2932
3067
  if (instance?.componentShouldUpdate) {
2933
- if (instance.componentShouldUpdate(newVal, prevScheduleVal, memberName) === false && !(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) {
2934
- prevScheduleVal = newVal;
2935
- return;
2936
- }
3068
+ const changes = hostRef.$queuedPropChanges$ ||= {};
3069
+ changes[memberName] = {
3070
+ newVal,
3071
+ oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
3072
+ };
2937
3073
  }
2938
3074
  if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
2939
3075
  }
@@ -2968,7 +3104,8 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2968
3104
  consoleError(e, elm);
2969
3105
  }
2970
3106
  }));
2971
- elm[STENCIL_SIGNALS_SYMBOL] = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
3107
+ const publicSignals = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
3108
+ elm[STENCIL_SIGNALS_SYMBOL] = publicSignals;
2972
3109
  hostRef.$signalCleanup$ = () => {
2973
3110
  disposers.forEach((d) => d());
2974
3111
  elm[STENCIL_SIGNALS_SYMBOL] = void 0;
@@ -3017,19 +3154,25 @@ const h = (nodeName, vnodeData, ...children) => {
3017
3154
  for (let i = 0; i < c.length; i++) {
3018
3155
  child = c[i];
3019
3156
  if (Array.isArray(child)) walk(child);
3020
- else if (child != null && typeof child !== "boolean") if (BUILD.vdomSignals && isSignalLike(child)) {
3021
- const sigVNode = newVNode(null, String(child.peek()));
3022
- sigVNode.$signal$ = child;
3023
- vNodeChildren.push(sigVNode);
3024
- lastSimple = false;
3025
- } else {
3026
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
3027
- else if (BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) consoleDevError(`vNode passed as children has unexpected type.
3028
- Make sure it's using the correct h() function.
3029
- Empty objects can also be the cause, look for JSX comments that became objects.`);
3030
- if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
3031
- else vNodeChildren.push(simple ? newVNode(null, child) : child);
3032
- lastSimple = simple;
3157
+ else if (child != null && typeof child !== "boolean") {
3158
+ if (BUILD.vdomSignals && isSignalLike(child)) {
3159
+ const sigVNode = newVNode(null, String(child.peek()));
3160
+ sigVNode.$signal$ = child;
3161
+ vNodeChildren.push(sigVNode);
3162
+ lastSimple = false;
3163
+ } else {
3164
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
3165
+ else if (typeof nodeName !== "function" && child.$flags$ === void 0) {
3166
+ if (BUILD.isDev) consoleDevError(`vNode passed as children has unexpected type.
3167
+ Make sure it's using the correct h() function.
3168
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
3169
+ else consoleError("Invalid vNode child");
3170
+ continue;
3171
+ }
3172
+ if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
3173
+ else vNodeChildren.push(simple ? newVNode(null, child) : child);
3174
+ lastSimple = simple;
3175
+ }
3033
3176
  }
3034
3177
  }
3035
3178
  };
@@ -4014,14 +4157,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
4014
4157
  /**
4015
4158
  * ensure this value is of the correct prop type
4016
4159
  */
4017
- if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
4018
- /**
4019
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
4020
- * (regardless of its value, even "false") should make the property true.
4021
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
4022
- */
4023
- if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
4024
- else return propValue === "false" ? false : propValue === "" || !!propValue;
4160
+ if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) {
4161
+ /**
4162
+ * For form-associated components, according to HTML spec, the presence of any boolean attribute
4163
+ * (regardless of its value, even "false") should make the property true.
4164
+ * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
4165
+ */
4166
+ if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
4167
+ else return propValue === "false" ? false : propValue === "" || !!propValue;
4168
+ }
4025
4169
  /**
4026
4170
  * force it to be a number
4027
4171
  */
@@ -4109,7 +4253,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4109
4253
  }
4110
4254
  if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
4111
4255
  if (instance.componentShouldUpdate) {
4112
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false && !(flags & HOST_FLAGS.isQueuedForUpdate)) return;
4256
+ const changes = hostRef.$queuedPropChanges$ ||= {};
4257
+ changes[propName] = {
4258
+ newVal,
4259
+ oldVal: changes[propName]?.oldVal ?? oldVal
4260
+ };
4113
4261
  }
4114
4262
  if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
4115
4263
  }
@@ -4243,11 +4391,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4243
4391
  };
4244
4392
  for (const deserializer of cmpMeta.$deserializers$[propName]) {
4245
4393
  const [[methodName]] = Object.entries(deserializer);
4246
- if (BUILD.lazyLoad) if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
4247
- else hostRef.$fetchedCbList$.push(() => {
4248
- setVal(methodName, hostRef.$lazyInstance$);
4249
- });
4250
- else setVal(methodName, this);
4394
+ if (BUILD.lazyLoad) {
4395
+ if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
4396
+ else hostRef.$fetchedCbList$.push(() => {
4397
+ setVal(methodName, hostRef.$lazyInstance$);
4398
+ });
4399
+ } else setVal(methodName, this);
4251
4400
  }
4252
4401
  return;
4253
4402
  } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
@@ -4271,7 +4420,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4271
4420
  if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4272
4421
  });
4273
4422
  };
4274
- Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
4423
+ Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
4275
4424
  const attrName = m[1] || propName;
4276
4425
  attrNameToPropName.set(attrName, propName);
4277
4426
  if (BUILD.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
@@ -4298,6 +4447,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4298
4447
  try {
4299
4448
  if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
4300
4449
  hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
4450
+ hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
4301
4451
  const bundleId = cmpMeta.$lazyBundleId$;
4302
4452
  if (BUILD.lazyLoad && bundleId) {
4303
4453
  const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
@@ -4306,7 +4456,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4306
4456
  Cstr = await CstrImport;
4307
4457
  endLoad();
4308
4458
  } else Cstr = CstrImport;
4309
- if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4459
+ if (!Cstr) {
4460
+ hostRef.$flags$ &= ~HOST_FLAGS.hasInitializedComponent;
4461
+ hostRef.$loadRetryCount$ = (hostRef.$loadRetryCount$ ?? 0) + 1;
4462
+ if (hostRef.$loadRetryCount$ < 3) hostRef.$flags$ |= HOST_FLAGS.hasFailedLoad;
4463
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4464
+ }
4310
4465
  if (BUILD.member && !Cstr.isProxied) {
4311
4466
  if (BUILD.propChangeCallback) {
4312
4467
  cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
@@ -4325,8 +4480,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4325
4480
  }
4326
4481
  if (BUILD.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4327
4482
  endNewInstance();
4328
- if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4329
- else hostRef.$deferredConnectedCallback$ = true;
4483
+ if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4484
+ if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4485
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4486
+ if (BUILD.asyncLoading) markFirstConnected(hostRef);
4487
+ } else queueMicrotask(() => {
4488
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4489
+ if (BUILD.asyncLoading) markFirstConnected(hostRef);
4490
+ });
4330
4491
  } else Cstr = elm.constructor;
4331
4492
  if (BUILD.style && Cstr && Cstr.style) {
4332
4493
  /**
@@ -4385,7 +4546,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4385
4546
  hostRef.$onRenderResolve$();
4386
4547
  hostRef.$onRenderResolve$ = void 0;
4387
4548
  }
4388
- if (BUILD.asyncLoading && hostRef.$onReadyResolve$) hostRef.$onReadyResolve$(elm);
4549
+ if (BUILD.asyncLoading) markFirstConnected(hostRef);
4550
+ if (BUILD.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
4389
4551
  }
4390
4552
  };
4391
4553
  const fireConnectedCallback = (instance, elm) => {
@@ -4448,6 +4610,7 @@ const connectedCallback = (elm) => {
4448
4610
  } else {
4449
4611
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
4450
4612
  if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4613
+ else if (hostRef.$flags$ & HOST_FLAGS.hasFailedLoad) setTimeout(() => initializeComponent(elm, hostRef, cmpMeta), LAZY_LOAD_RETRY_INTERVAL_MS);
4451
4614
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
4452
4615
  }
4453
4616
  endConnected();
@@ -4477,6 +4640,7 @@ const disconnectedCallback = async (elm) => {
4477
4640
  hostRef.$signalCleanup$();
4478
4641
  hostRef.$signalCleanup$ = void 0;
4479
4642
  }
4643
+ if (BUILD.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
4480
4644
  if (!BUILD.lazyLoad) disconnectInstance(elm);
4481
4645
  else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
4482
4646
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
@@ -4602,18 +4766,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4602
4766
  hmrStart(this, cmpMeta, hmrVersionId);
4603
4767
  };
4604
4768
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4605
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4606
- else {
4607
- if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4608
- if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4609
- patchSlotAppendChild(Cstr.prototype);
4610
- patchSlotAppend(Cstr.prototype);
4611
- patchSlotPrepend(Cstr.prototype);
4612
- patchSlotInsertAdjacentHTML(Cstr.prototype);
4613
- patchInsertBefore(Cstr.prototype);
4614
- patchSlotRemoveChild(Cstr.prototype);
4769
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4770
+ if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4771
+ else {
4772
+ if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4773
+ if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4774
+ patchSlotAppendChild(Cstr.prototype);
4775
+ patchSlotAppend(Cstr.prototype);
4776
+ patchSlotPrepend(Cstr.prototype);
4777
+ patchSlotInsertAdjacentHTML(Cstr.prototype);
4778
+ patchInsertBefore(Cstr.prototype);
4779
+ patchSlotRemoveChild(Cstr.prototype);
4780
+ }
4781
+ if (BUILD.slotTextContent) patchTextContent(Cstr.prototype);
4615
4782
  }
4616
- if (BUILD.slotTextContent) patchTextContent(Cstr.prototype);
4617
4783
  }
4618
4784
  if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow();
4619
4785
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
@@ -4626,19 +4792,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4626
4792
  componentOnReady() {
4627
4793
  return getHostRef(this)?.$onReadyPromise$;
4628
4794
  },
4629
- connectedCallback() {
4630
- if (!this.__hasHostListenerAttached) {
4631
- const hostRef = getHostRef(this);
4795
+ async connectedCallback() {
4796
+ const isFirstConnect = !this.__hasHostListenerAttached;
4797
+ let hostRef;
4798
+ if (isFirstConnect) {
4799
+ hostRef = getHostRef(this);
4632
4800
  if (!hostRef) return;
4633
4801
  addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4634
4802
  this.__hasHostListenerAttached = true;
4635
4803
  }
4636
4804
  connectedCallback(this);
4637
- if (originalConnectedCallback) originalConnectedCallback.call(this);
4805
+ if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4806
+ await awaitAncestorConnected(hostRef.$ancestorComponent$);
4807
+ if (!this.isConnected) return;
4808
+ }
4809
+ if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
4810
+ if (BUILD.asyncLoading && hostRef) markFirstConnected(hostRef);
4638
4811
  },
4639
4812
  disconnectedCallback() {
4640
4813
  disconnectedCallback(this);
4641
- if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
4814
+ if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
4642
4815
  },
4643
4816
  __attachShadow() {
4644
4817
  const isClosed = BUILD.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
@@ -4692,8 +4865,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4692
4865
  const exclude = options.exclude || [];
4693
4866
  const _reg = options.registry ?? getRegistry();
4694
4867
  const head = win.document.head;
4695
- const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
4696
- const dataStyles = /* @__PURE__ */ win.document.createElement("style");
4868
+ const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
4869
+ const dataStyles = /*@__PURE__*/ win.document.createElement("style");
4697
4870
  const deferredConnectedCallbacks = [];
4698
4871
  let appLoadFallback;
4699
4872
  let isBootstrapping = true;
@@ -4761,8 +4934,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4761
4934
  *
4762
4935
  * Also remove the reference from `deferredConnectedCallbacks` array
4763
4936
  * otherwise removed instances won't get garbage collected.
4937
+ *
4938
+ * Use `nextTick` (microtask) rather than `plt.raf` since
4939
+ * `requestAnimationFrame` callbacks do not fire while `document.hidden`
4764
4940
  */
4765
- plt.raf(() => {
4941
+ nextTick(() => {
4766
4942
  const hostRef = getHostRef(this);
4767
4943
  if (!hostRef) return;
4768
4944
  const i = deferredConnectedCallbacks.findIndex((host) => host === this);
@@ -4775,18 +4951,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4775
4951
  }
4776
4952
  };
4777
4953
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(HostElement.prototype);
4778
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4779
- else {
4780
- if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4781
- if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4782
- patchSlotAppendChild(HostElement.prototype);
4783
- patchSlotAppend(HostElement.prototype);
4784
- patchSlotPrepend(HostElement.prototype);
4785
- patchSlotInsertAdjacentHTML(HostElement.prototype);
4786
- patchInsertBefore(HostElement.prototype);
4787
- patchSlotRemoveChild(HostElement.prototype);
4954
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4955
+ if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4956
+ else {
4957
+ if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4958
+ if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4959
+ patchSlotAppendChild(HostElement.prototype);
4960
+ patchSlotAppend(HostElement.prototype);
4961
+ patchSlotPrepend(HostElement.prototype);
4962
+ patchSlotInsertAdjacentHTML(HostElement.prototype);
4963
+ patchInsertBefore(HostElement.prototype);
4964
+ patchSlotRemoveChild(HostElement.prototype);
4965
+ }
4966
+ if (BUILD.slotTextContent) patchTextContent(HostElement.prototype);
4788
4967
  }
4789
- if (BUILD.slotTextContent) patchTextContent(HostElement.prototype);
4790
4968
  }
4791
4969
  if (BUILD.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
4792
4970
  if (BUILD.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
@@ -4832,9 +5010,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
4832
5010
  };
4833
5011
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
4834
5012
  try {
4835
- if (BUILD.lazyLoad) if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4836
- else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4837
- else hostRef.$hostElement$[methodName](ev);
5013
+ if (BUILD.lazyLoad) {
5014
+ if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
5015
+ else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
5016
+ } else hostRef.$hostElement$[methodName](ev);
4838
5017
  } catch (e) {
4839
5018
  consoleError(e, hostRef.$hostElement$);
4840
5019
  }
@@ -4868,6 +5047,73 @@ const setNonce = (nonce) => plt.$nonce$ = nonce;
4868
5047
  //#region src/runtime/platform-options.ts
4869
5048
  const setPlatformOptions = (opts) => Object.assign(plt, opts);
4870
5049
  //#endregion
5050
+ //#region src/runtime/reactive-controller.ts
5051
+ const ReactiveControllerHost = (Base) => class ReactiveControllerHostMixin extends Base {
5052
+ controllers = /* @__PURE__ */ new Set();
5053
+ #connected = false;
5054
+ #updateCompleteResolvers = [];
5055
+ addController(controller) {
5056
+ this.controllers.add(controller);
5057
+ if (this.#connected) controller.hostConnected?.();
5058
+ }
5059
+ removeController(controller) {
5060
+ this.controllers.delete(controller);
5061
+ }
5062
+ requestUpdate() {
5063
+ forceUpdate(this);
5064
+ }
5065
+ get updateComplete() {
5066
+ return new Promise((resolve) => this.#updateCompleteResolvers.push(resolve));
5067
+ }
5068
+ connectedCallback() {
5069
+ super.connectedCallback?.();
5070
+ this.#connected = true;
5071
+ const el = getElement(this);
5072
+ if (el && el !== this) {
5073
+ el.addController = (controller) => this.addController(controller);
5074
+ el.removeController = (controller) => this.removeController(controller);
5075
+ el.requestUpdate = () => this.requestUpdate();
5076
+ Object.defineProperty(el, "updateComplete", {
5077
+ configurable: true,
5078
+ get: () => this.updateComplete
5079
+ });
5080
+ }
5081
+ this.controllers.forEach((c) => c.hostConnected?.());
5082
+ }
5083
+ disconnectedCallback() {
5084
+ super.disconnectedCallback?.();
5085
+ this.#connected = false;
5086
+ this.controllers.forEach((c) => c.hostDisconnected?.());
5087
+ }
5088
+ async componentWillLoad() {
5089
+ await super.componentWillLoad?.();
5090
+ await Promise.all([...this.controllers].map((c) => c.hostWillLoad?.()));
5091
+ }
5092
+ componentDidLoad() {
5093
+ super.componentDidLoad?.();
5094
+ this.controllers.forEach((c) => c.hostDidLoad?.());
5095
+ }
5096
+ async componentWillRender() {
5097
+ await super.componentWillRender?.();
5098
+ await Promise.all([...this.controllers].map((c) => c.hostWillRender?.()));
5099
+ }
5100
+ componentDidRender() {
5101
+ super.componentDidRender?.();
5102
+ this.controllers.forEach((c) => c.hostDidRender?.());
5103
+ const resolvers = this.#updateCompleteResolvers;
5104
+ this.#updateCompleteResolvers = [];
5105
+ resolvers.forEach((resolve) => resolve(true));
5106
+ }
5107
+ async componentWillUpdate() {
5108
+ await super.componentWillUpdate?.();
5109
+ await Promise.all([...this.controllers].map((c) => c.hostWillUpdate?.()));
5110
+ }
5111
+ componentDidUpdate() {
5112
+ super.componentDidUpdate?.();
5113
+ this.controllers.forEach((c) => c.hostDidUpdate?.());
5114
+ }
5115
+ };
5116
+ //#endregion
4871
5117
  //#region src/runtime/render.ts
4872
5118
  /**
4873
5119
  * A WeakMap to persist HostRef objects across multiple render() calls to the
@@ -4954,4 +5200,4 @@ function hasKeys(obj) {
4954
5200
  return false;
4955
5201
  }
4956
5202
  //#endregion
4957
- export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, win, writeTask };
5203
+ export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, win, writeTask };