@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
@@ -50,8 +50,20 @@ const HOST_FLAGS = {
50
50
  isWatchReady: 128,
51
51
  isListenReady: 256,
52
52
  needsRerender: 512,
53
- devOnRender: 1024,
54
- devOnDidLoad: 2048
53
+ /**
54
+ * Set once this component's real (lazy-loaded) `connectedCallback` has fired for
55
+ * the first time. Lets a descendant skip creating/awaiting a connect-promise for
56
+ * an ancestor that's already connected. See {@link HostRef.$onFirstConnectResolve$}.
57
+ */
58
+ hasFiredConnected: 1024,
59
+ /**
60
+ * Set when a lazy component's dynamic `import()` fails to resolve a
61
+ * constructor. Distinct from `hasInitializedComponent` being unset, which
62
+ * is true while an initialization attempt is merely queued/in-flight.
63
+ */
64
+ hasFailedLoad: 2048,
65
+ devOnRender: 4096,
66
+ devOnDidLoad: 8192
55
67
  };
56
68
  const CF_scopedCssEncapsulation = 2;
57
69
  /**
@@ -270,8 +282,13 @@ const registerHost = (hostElement, cmpMeta) => {
270
282
  if (BUILD.asyncLoading) {
271
283
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
272
284
  hostElement["s-rp"] = hostRef.$onReadyPromise$;
285
+ if (!BUILD.lazyLoad) {
286
+ hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
287
+ hostElement["s-fc"] = hostRef.$onFirstConnectPromise$;
288
+ }
273
289
  if (!hostElement["s-p"]) hostElement["s-p"] = [];
274
290
  if (!hostElement["s-rc"]) hostElement["s-rc"] = [];
291
+ if (!hostElement["s-pc"]) hostElement["s-pc"] = [];
275
292
  }
276
293
  if (BUILD.lazyLoad) hostRef.$fetchedCbList$ = [];
277
294
  const ref = hostRef;
@@ -286,7 +303,12 @@ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
286
303
  const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
287
304
  //#endregion
288
305
  //#region src/client/client-load-module.ts
289
- const cmpModules = /* @__PURE__ */ new Map();
306
+ const cmpModules = /*@__PURE__*/ new Map();
307
+ /**
308
+ * Tracks how many times a dynamic `import()` for a given lazy bundle has failed.
309
+ * Used to cache bust the retry attempt in connected-callback.ts
310
+ */
311
+ const failedLoadAttempts = /*@__PURE__*/ new Map();
290
312
  /**
291
313
  * We need to separate out this prefix so that Esbuild doesn't try to resolve
292
314
  * the below, but instead retains a dynamic `import()` statement in the
@@ -313,13 +335,21 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
313
335
  } else if (!bundleId) return;
314
336
  const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
315
337
  if (module) return module[exportName];
338
+ const retryCount = failedLoadAttempts.get(bundleId) ?? 0;
339
+ const cacheBustParams = [retryCount > 0 ? `s-retry=${retryCount}` : "", BUILD.hotModuleReplacement && hmrVersionId ? `s-hmr=${hmrVersionId}` : ""].filter(Boolean).join("&");
316
340
  /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
317
- const entryFile = `${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? "?s-hmr=" + hmrVersionId : ""}`;
341
+ const entryFile = `${bundleId}.entry.js${cacheBustParams ? "?" + cacheBustParams : ""}`;
318
342
  const onLoad = (importedModule) => {
319
- if (!BUILD.hotModuleReplacement) cmpModules.set(bundleId, importedModule);
343
+ if (!BUILD.hotModuleReplacement) {
344
+ failedLoadAttempts.delete(bundleId);
345
+ cmpModules.set(bundleId, importedModule);
346
+ }
320
347
  return importedModule[exportName];
321
348
  };
322
- const onError = (e) => consoleError(e, hostRef.$hostElement$);
349
+ const onError = (e) => {
350
+ failedLoadAttempts.set(bundleId, retryCount + 1);
351
+ consoleError(e, hostRef.$hostElement$);
352
+ };
323
353
  return import(
324
354
  /* @vite-ignore */
325
355
  /* webpackInclude: /\.entry\.js$/ */
@@ -330,7 +360,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
330
360
  };
331
361
  //#endregion
332
362
  //#region src/client/client-style.ts
333
- const styles = /* @__PURE__ */ new Map();
363
+ const styles = /*@__PURE__*/ new Map();
334
364
  const modeResolutionChain = [];
335
365
  const needsScopedSSR = () => false;
336
366
  //#endregion
@@ -392,6 +422,10 @@ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
392
422
  */
393
423
  const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
394
424
  const XLINK_NS = "http://www.w3.org/1999/xlink";
425
+ /**
426
+ * Minimum delay, in milliseconds, before retrying a failed lazy component load.
427
+ */
428
+ const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
395
429
  const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
396
430
  "formAssociatedCallback",
397
431
  "formResetCallback",
@@ -411,7 +445,7 @@ const plt = {
411
445
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
412
446
  ce: (eventName, opts) => new CustomEvent(eventName, opts)
413
447
  };
414
- const supportsListenerOptions = /* @__PURE__ */ (() => {
448
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
415
449
  let supported = false;
416
450
  try {
417
451
  win.document?.addEventListener("e", null, Object.defineProperty({}, "passive", { get() {
@@ -421,14 +455,14 @@ const supportsListenerOptions = /* @__PURE__ */ (() => {
421
455
  return supported;
422
456
  })();
423
457
  const promiseResolve = (v) => Promise.resolve(v);
424
- const supportsConstructableStylesheets = BUILD.constructableCSS ? /* @__PURE__ */ (() => {
458
+ const supportsConstructableStylesheets = BUILD.constructableCSS ? /*@__PURE__*/ (() => {
425
459
  try {
426
460
  if (!win.document.adoptedStyleSheets) return false;
427
461
  return typeof new CSSStyleSheet().replaceSync === "function";
428
462
  } catch {}
429
463
  return false;
430
464
  })() : false;
431
- const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /* @__PURE__ */ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
465
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /*@__PURE__*/ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
432
466
  //#endregion
433
467
  //#region src/client/client-task-queue.ts
434
468
  let queueCongestion = 0;
@@ -436,12 +470,13 @@ let queuePending = false;
436
470
  const queueDomReads = [];
437
471
  const queueDomWrites = [];
438
472
  const queueDomWritesLow = [];
473
+ const scheduleFlush = () => win.document?.hidden ? nextTick(flush) : plt.raf(flush);
439
474
  const queueTask = (queue, write) => (cb) => {
440
475
  queue.push(cb);
441
476
  if (!queuePending) {
442
477
  queuePending = true;
443
478
  if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush);
444
- else plt.raf(flush);
479
+ else scheduleFlush();
445
480
  }
446
481
  };
447
482
  const consume = (queue) => {
@@ -474,15 +509,15 @@ const flush = () => {
474
509
  queueDomWritesLow.push(...queueDomWrites);
475
510
  queueDomWrites.length = 0;
476
511
  }
477
- if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) plt.raf(flush);
512
+ if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) scheduleFlush();
478
513
  else queueCongestion = 0;
479
514
  } else {
480
515
  consume(queueDomWrites);
481
- if (queuePending = queueDomReads.length > 0) plt.raf(flush);
516
+ if (queuePending = queueDomReads.length > 0) scheduleFlush();
482
517
  }
483
518
  };
484
519
  const nextTick = (cb) => promiseResolve().then(cb);
485
- const writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
520
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
486
521
  //#endregion
487
522
  //#region src/runtime/asset-path.ts
488
523
  const getAssetPath = (path) => {
@@ -521,8 +556,10 @@ function createShadowRoot(cmpMeta) {
521
556
  const shadowRoot = this.attachShadow(opts);
522
557
  if (BUILD.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
523
558
  if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported("") ?? null;
524
- if (globalStyleSheet) if (supportsMutableAdoptedStyleSheets) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
525
- else shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
559
+ if (globalStyleSheet) {
560
+ if (supportsMutableAdoptedStyleSheets) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
561
+ else shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
562
+ }
526
563
  }
527
564
  //#endregion
528
565
  //#region src/runtime/slot-polyfill-utils.ts
@@ -542,8 +579,10 @@ function createShadowRoot(cmpMeta) {
542
579
  const updateFallbackSlotVisibility = (elm) => {
543
580
  const childNodes = internalCall(elm, "childNodes");
544
581
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
545
- if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
546
- else slotNode.hidden = false;
582
+ if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") {
583
+ if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
584
+ else slotNode.hidden = false;
585
+ }
547
586
  });
548
587
  let i = 0;
549
588
  for (i = 0; i < childNodes.length; i++) {
@@ -586,7 +625,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
586
625
  slottedNodes.push(childNode);
587
626
  if (typeof slotName !== "undefined") return slottedNodes;
588
627
  }
589
- slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
628
+ slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
590
629
  }
591
630
  return slottedNodes;
592
631
  }
@@ -617,7 +656,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
617
656
  if (nodeToRelocate.getAttribute("slot") === slotName) return true;
618
657
  return false;
619
658
  }
620
- if (nodeToRelocate["s-sn"] === slotName) return true;
659
+ if (typeof nodeToRelocate["s-sa"] === "string") return nodeToRelocate["s-sa"] === slotName;
621
660
  return slotName === "";
622
661
  };
623
662
  /**
@@ -666,8 +705,10 @@ function patchSlotNode(node) {
666
705
  const assignedFactory = (elementsOnly) => function(opts) {
667
706
  const toReturn = [];
668
707
  const slotName = this["s-sn"];
669
- 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.");
670
- else console.error("Flattening not supported for Stencil non-shadow slots");
708
+ if (opts?.flatten) {
709
+ if (BUILD.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
710
+ else console.error("Flattening not supported for Stencil non-shadow slots");
711
+ }
671
712
  const parent = this["s-cr"].parentElement;
672
713
  (parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
673
714
  if (slotName === getSlotName(n)) toReturn.push(n);
@@ -758,8 +799,10 @@ const patchCloneNode = (HostElementPrototype) => {
758
799
  for (; i < childNodes.length; i++) {
759
800
  slotted = childNodes[i]["s-nr"];
760
801
  nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
761
- if (slotted) if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
762
- else clonedNode.appendChild(slotted.cloneNode(true));
802
+ if (slotted) {
803
+ if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
804
+ else clonedNode.appendChild(slotted.cloneNode(true));
805
+ }
763
806
  if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
764
807
  }
765
808
  }
@@ -962,11 +1005,11 @@ const patchChildSlotNodes = (elm) => {
962
1005
  } });
963
1006
  patchHostOriginalAccessor("firstChild", elm);
964
1007
  Object.defineProperty(elm, "firstChild", { get() {
965
- return this.childNodes[0];
1008
+ return this.childNodes[0] || null;
966
1009
  } });
967
1010
  patchHostOriginalAccessor("lastChild", elm);
968
1011
  Object.defineProperty(elm, "lastChild", { get() {
969
- return this.childNodes[this.childNodes.length - 1];
1012
+ return this.childNodes[this.childNodes.length - 1] || null;
970
1013
  } });
971
1014
  patchHostOriginalAccessor("childNodes", elm);
972
1015
  Object.defineProperty(elm, "childNodes", { get() {
@@ -1012,7 +1055,7 @@ const patchNextSibling = (node) => {
1012
1055
  Object.defineProperty(node, "nextSibling", { get: function() {
1013
1056
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
1014
1057
  const index = parentNodes?.indexOf(this);
1015
- if (parentNodes && index > -1) return parentNodes[index + 1];
1058
+ if (parentNodes && index > -1) return parentNodes[index + 1] || null;
1016
1059
  return this.__nextSibling;
1017
1060
  } });
1018
1061
  };
@@ -1027,7 +1070,7 @@ const patchNextElementSibling = (element) => {
1027
1070
  Object.defineProperty(element, "nextElementSibling", { get: function() {
1028
1071
  const parentEles = this["s-ol"]?.parentNode.children;
1029
1072
  const index = parentEles?.indexOf(this);
1030
- if (parentEles && index > -1) return parentEles[index + 1];
1073
+ if (parentEles && index > -1) return parentEles[index + 1] || null;
1031
1074
  return this.__nextElementSibling;
1032
1075
  } });
1033
1076
  };
@@ -1042,7 +1085,7 @@ const patchPreviousSibling = (node) => {
1042
1085
  Object.defineProperty(node, "previousSibling", { get: function() {
1043
1086
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
1044
1087
  const index = parentNodes?.indexOf(this);
1045
- if (parentNodes && index > -1) return parentNodes[index - 1];
1088
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
1046
1089
  return this.__previousSibling;
1047
1090
  } });
1048
1091
  };
@@ -1057,7 +1100,7 @@ const patchPreviousElementSibling = (element) => {
1057
1100
  Object.defineProperty(element, "previousElementSibling", { get: function() {
1058
1101
  const parentNodes = this["s-ol"]?.parentNode.children;
1059
1102
  const index = parentNodes?.indexOf(this);
1060
- if (parentNodes && index > -1) return parentNodes[index - 1];
1103
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
1061
1104
  return this.__previousElementSibling;
1062
1105
  } });
1063
1106
  };
@@ -1232,7 +1275,7 @@ function queryNonceMetaTagContent(doc) {
1232
1275
  }
1233
1276
  //#endregion
1234
1277
  //#region src/runtime/styles.ts
1235
- const rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1278
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
1236
1279
  /**
1237
1280
  * Get or initialize the set of applied style scope IDs for a container element.
1238
1281
  *
@@ -1256,9 +1299,10 @@ const getAppliedStyles = (container) => {
1256
1299
  * @param prepend if true, add to beginning; if false, add to end
1257
1300
  */
1258
1301
  const adoptStylesheet = (container, sheet, prepend = false) => {
1259
- if (supportsMutableAdoptedStyleSheets) if (prepend) container.adoptedStyleSheets.unshift(sheet);
1260
- else container.adoptedStyleSheets.push(sheet);
1261
- else if (prepend) container.adoptedStyleSheets = [sheet, ...container.adoptedStyleSheets];
1302
+ if (supportsMutableAdoptedStyleSheets) {
1303
+ if (prepend) container.adoptedStyleSheets.unshift(sheet);
1304
+ else container.adoptedStyleSheets.push(sheet);
1305
+ } else if (prepend) container.adoptedStyleSheets = [sheet, ...container.adoptedStyleSheets];
1262
1306
  else container.adoptedStyleSheets = [...container.adoptedStyleSheets, sheet];
1263
1307
  };
1264
1308
  /**
@@ -1271,7 +1315,7 @@ const adoptStylesheet = (container, sheet, prepend = false) => {
1271
1315
  * @returns a new CSSStyleSheet for the correct window
1272
1316
  */
1273
1317
  const createStylesheetForWindow = (container, cssText) => {
1274
- const sheet = new (container.defaultView ?? container.ownerDocument?.defaultView ?? win).CSSStyleSheet();
1318
+ const sheet = new (container.defaultView ?? (container.ownerDocument?.defaultView) ?? win).CSSStyleSheet();
1275
1319
  sheet.replaceSync(cssText);
1276
1320
  return sheet;
1277
1321
  };
@@ -1342,41 +1386,46 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1342
1386
  /**
1343
1387
  * attach styles at the end of the head tag if we render scoped components
1344
1388
  */
1345
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) if (styleContainerNode.nodeName === "HEAD") {
1346
- /**
1347
- * if the page contains preconnect links, we want to insert the styles
1348
- * after the last preconnect link to ensure the styles are preloaded
1349
- */
1350
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1351
- const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1352
- styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1353
- } else if ("host" in styleContainerNode) if (supportsConstructableStylesheets) {
1354
- const stylesheet = createStylesheetForWindow(styleContainerNode, style);
1355
- adoptStylesheet(styleContainerNode, stylesheet, true);
1356
- } else {
1357
- /**
1358
- * If a scoped component is used within a shadow root and constructable stylesheets are
1359
- * not supported, we want to insert the styles at the beginning of the shadow root node.
1360
- *
1361
- * However, if there is already a style node in the shadow root, we just append
1362
- * the styles to the existing node.
1363
- *
1364
- * Note: order of how styles are applied is important. The new style node
1365
- * should be inserted before the existing style node.
1366
- *
1367
- * During HMR, create separate style elements for scoped components so they can be
1368
- * updated independently without affecting other components' styles.
1369
- */
1370
- const existingStyleContainer = styleContainerNode.querySelector("style");
1371
- if (existingStyleContainer && !BUILD.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1372
- else styleContainerNode.prepend(styleElm);
1389
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
1390
+ if (styleContainerNode.nodeName === "HEAD") {
1391
+ /**
1392
+ * if the page contains preconnect links, we want to insert the styles
1393
+ * after the last preconnect link to ensure the styles are preloaded
1394
+ */
1395
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1396
+ const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1397
+ styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1398
+ } else if ("host" in styleContainerNode) {
1399
+ if (supportsConstructableStylesheets) {
1400
+ const stylesheet = createStylesheetForWindow(styleContainerNode, style);
1401
+ adoptStylesheet(styleContainerNode, stylesheet, true);
1402
+ } else {
1403
+ /**
1404
+ * If a scoped component is used within a shadow root and constructable stylesheets are
1405
+ * not supported, we want to insert the styles at the beginning of the shadow root node.
1406
+ *
1407
+ * However, if there is already a style node in the shadow root, we just append
1408
+ * the styles to the existing node.
1409
+ *
1410
+ * Note: order of how styles are applied is important. The new style node
1411
+ * should be inserted before the existing style node.
1412
+ *
1413
+ * During HMR, create separate style elements for scoped components so they can be
1414
+ * updated independently without affecting other components' styles.
1415
+ */
1416
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1417
+ if (existingStyleContainer && !BUILD.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1418
+ else styleContainerNode.prepend(styleElm);
1419
+ }
1420
+ } else styleContainerNode.append(styleElm);
1373
1421
  }
1374
- else styleContainerNode.append(styleElm);
1375
1422
  /**
1376
1423
  * attach styles at the beginning of a shadow root node if we render shadow components
1377
1424
  */
1378
- if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1379
- else styleContainerNode.insertBefore(styleElm, null);
1425
+ if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
1426
+ if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1427
+ else styleContainerNode.insertBefore(styleElm, null);
1428
+ }
1380
1429
  if (appliedStyles) appliedStyles.add(scopeId);
1381
1430
  }
1382
1431
  } else if (BUILD.constructableCSS) {
@@ -1605,11 +1654,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1605
1654
  }
1606
1655
  } else if (BUILD.vdomStyle && memberName === "style") {
1607
1656
  if (BUILD.updatable) {
1608
- for (const prop in oldValue) if (!newValue || newValue[prop] == null) if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1609
- else elm.style[prop] = "";
1657
+ for (const prop in oldValue) if (!newValue || newValue[prop] == null) {
1658
+ if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1659
+ else elm.style[prop] = "";
1660
+ }
1661
+ }
1662
+ for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) {
1663
+ if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1664
+ else elm.style[prop] = newValue[prop];
1610
1665
  }
1611
- for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1612
- else elm.style[prop] = newValue[prop];
1613
1666
  } else if (BUILD.vdomKey && memberName === "key") {} else if (BUILD.vdomRef && memberName === "ref") {
1614
1667
  if (newValue) queueRefAttachment(newValue, elm);
1615
1668
  } else if (BUILD.vdomListener && (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
@@ -1618,7 +1671,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1618
1671
  else memberName = ln[2] + memberName.slice(3);
1619
1672
  if (oldValue || newValue) {
1620
1673
  const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1621
- memberName = memberName.replace(/* @__PURE__ */ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1674
+ memberName = memberName.replace(/*@__PURE__*/ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1622
1675
  if (oldValue) plt.rel(elm, memberName, oldValue, capture);
1623
1676
  if (newValue) plt.ael(elm, memberName, newValue, capture);
1624
1677
  }
@@ -1657,8 +1710,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1657
1710
  if (!elm.tagName.includes("-")) {
1658
1711
  const n = newValue == null ? "" : newValue;
1659
1712
  if (memberName === "list") isProp = false;
1660
- else if (oldValue == null || elm[memberName] !== n) if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1661
- else elm.setAttribute(memberName, n);
1713
+ else if (oldValue == null || elm[memberName] !== n) {
1714
+ if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1715
+ else elm.setAttribute(memberName, n);
1716
+ }
1662
1717
  } else if (elm[memberName] !== newValue) elm[memberName] = newValue;
1663
1718
  } catch {}
1664
1719
  /**
@@ -1676,8 +1731,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1676
1731
  }
1677
1732
  }
1678
1733
  if (newValue == null || newValue === false) {
1679
- if (newValue !== false || elm.getAttribute(memberName) === "") if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1680
- else elm.removeAttribute(memberName);
1734
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
1735
+ if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1736
+ else elm.removeAttribute(memberName);
1737
+ }
1681
1738
  } else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
1682
1739
  newValue = newValue === true ? "" : newValue;
1683
1740
  if (BUILD.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -1808,6 +1865,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1808
1865
  }
1809
1866
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1810
1867
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
1868
+ if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
1811
1869
  if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
1812
1870
  } else {
1813
1871
  if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
@@ -2083,8 +2141,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
2083
2141
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
2084
2142
  newStartVnode = newCh[++newStartIdx];
2085
2143
  }
2086
- if (node) if (BUILD.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
2087
- else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
2144
+ if (node) {
2145
+ if (BUILD.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
2146
+ else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
2147
+ }
2088
2148
  }
2089
2149
  if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
2090
2150
  else if (BUILD.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
@@ -2171,6 +2231,30 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
2171
2231
  */
2172
2232
  const relocateNodes = [];
2173
2233
  /**
2234
+ * When a forwarded `<slot>` gets relocated, drag along any content already forwarded through it,
2235
+ * to wherever it just landed (or nowhere, to be hidden, if it didn't match anything).
2236
+ *
2237
+ * Runs as its own pass after {@link markSlotContentForRelocation} rather than inside it, so that
2238
+ * function's matching order - which hydration's node/comment ordering depends on - is untouched.
2239
+ */
2240
+ const carryContentWithRelocatedSlotRefs = () => {
2241
+ for (const relocateData of relocateNodes.slice()) {
2242
+ const marker = relocateData.$nodeToRelocate$;
2243
+ if (!marker["s-sr"]) continue;
2244
+ const carriedSiblings = getSlotChildSiblings(marker, marker["s-sn"] || "", false);
2245
+ for (const carriedSibling of carriedSiblings) {
2246
+ if (!carriedSibling["s-ol"]) continue;
2247
+ let siblingRelocateData = relocateNodes.find((r) => r.$nodeToRelocate$ === carriedSibling);
2248
+ if (!siblingRelocateData) {
2249
+ siblingRelocateData = { $nodeToRelocate$: carriedSibling };
2250
+ relocateNodes.push(siblingRelocateData);
2251
+ }
2252
+ siblingRelocateData.$slotRefNode$ = relocateData.$slotRefNode$;
2253
+ if (relocateData.$slotRefNode$) carriedSibling["s-sh"] = relocateData.$slotRefNode$["s-hn"];
2254
+ }
2255
+ }
2256
+ };
2257
+ /**
2174
2258
  * Mark the contents of a slot for relocation via adding references to them to
2175
2259
  * the {@link relocateNodes} data structure. The actual work of relocating them
2176
2260
  * will then be handled in {@link renderVdom}.
@@ -2369,6 +2453,7 @@ render() {
2369
2453
  plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
2370
2454
  if (checkSlotRelocate) {
2371
2455
  markSlotContentForRelocation(rootVnode.$elm$);
2456
+ carryContentWithRelocatedSlotRefs();
2372
2457
  for (const relocateData of relocateNodes) {
2373
2458
  const nodeToRelocate = relocateData.$nodeToRelocate$;
2374
2459
  if (!nodeToRelocate["s-ol"] && win.document) {
@@ -2428,7 +2513,7 @@ render() {
2428
2513
  }
2429
2514
  if (BUILD.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2430
2515
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2431
- for (const childNode of children) if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2516
+ for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2432
2517
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
2433
2518
  if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
2434
2519
  else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
@@ -2446,16 +2531,58 @@ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot
2446
2531
  const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
2447
2532
  //#endregion
2448
2533
  //#region src/runtime/update-component.ts
2534
+ /**
2535
+ * Get a promise that resolves once `hostRef`'s real `connectedCallback` has fired for the first time.
2536
+ *
2537
+ * @param hostRef the component's host reference
2538
+ * @returns a promise that resolves once the component's real `connectedCallback` has fired
2539
+ */
2540
+ const ensureFirstConnectPromise = (hostRef) => {
2541
+ if (!hostRef.$onFirstConnectPromise$) hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
2542
+ return hostRef.$onFirstConnectPromise$;
2543
+ };
2544
+ /**
2545
+ * Resolve `hostRef`'s first-connect promise and flag it connected. Called once this
2546
+ * component's real `connectedCallback` fires, plus from error/disconnect cleanup so a
2547
+ * component that never connects can't hang an ancestor or descendant forever.
2548
+ *
2549
+ * @param hostRef the component's host reference
2550
+ */
2551
+ const markFirstConnected = (hostRef) => {
2552
+ hostRef.$flags$ |= HOST_FLAGS.hasFiredConnected;
2553
+ hostRef.$onFirstConnectResolve$?.();
2554
+ hostRef.$onFirstConnectResolve$ = void 0;
2555
+ };
2556
+ /**
2557
+ * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
2558
+ * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
2559
+ * `connectedCallback` paths so a component never connects before its nearest Stencil
2560
+ * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
2561
+ * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
2562
+ * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
2563
+ * autoloader, where the ancestor tag may not be defined yet.
2564
+ *
2565
+ * @param ancestorElm the nearest Stencil ancestor element
2566
+ */
2567
+ const awaitAncestorConnected = async (ancestorElm) => {
2568
+ let ancestorHostRef = getHostRef(ancestorElm);
2569
+ if (!BUILD.lazyLoad && !ancestorHostRef) {
2570
+ await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
2571
+ ancestorHostRef = getHostRef(ancestorElm);
2572
+ }
2573
+ if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
2574
+ };
2449
2575
  const attachToAncestor = (hostRef, ancestorComponent) => {
2450
2576
  if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2451
2577
  const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
2452
2578
  ancestorComponent["s-p"].splice(index - 1, 1);
2453
2579
  r();
2454
2580
  }));
2581
+ if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
2455
2582
  }
2456
2583
  };
2457
2584
  const scheduleUpdate = (hostRef, isInitialLoad) => {
2458
- if (BUILD.taskQueue && BUILD.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2585
+ if (BUILD.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2459
2586
  if (BUILD.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
2460
2587
  hostRef.$flags$ |= HOST_FLAGS.needsRerender;
2461
2588
  return;
@@ -2463,6 +2590,8 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2463
2590
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2464
2591
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2465
2592
  if (isInitialLoad) {
2593
+ const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2594
+ if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
2466
2595
  queueMicrotask(() => {
2467
2596
  dispatch();
2468
2597
  });
@@ -2502,10 +2631,6 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2502
2631
  let maybePromise;
2503
2632
  if (isInitialLoad) {
2504
2633
  if (BUILD.lazyLoad) {
2505
- if (BUILD.slotRelocation && hostRef.$deferredConnectedCallback$) {
2506
- hostRef.$deferredConnectedCallback$ = false;
2507
- safeCall(instance, "connectedCallback", void 0, elm);
2508
- }
2509
2634
  if (BUILD.hostListener) {
2510
2635
  hostRef.$flags$ |= HOST_FLAGS.isListenReady;
2511
2636
  if (hostRef.$queuedListeners$) {
@@ -2518,6 +2643,14 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2518
2643
  if (BUILD.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
2519
2644
  maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
2520
2645
  } else {
2646
+ if (BUILD.updatable && hostRef.$queuedPropChanges$) {
2647
+ const changes = hostRef.$queuedPropChanges$;
2648
+ hostRef.$queuedPropChanges$ = void 0;
2649
+ if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
2650
+ hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2651
+ return;
2652
+ }
2653
+ }
2521
2654
  if (BUILD.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
2522
2655
  maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
2523
2656
  }
@@ -2632,7 +2765,6 @@ let renderingRef = null;
2632
2765
  const callRender = (hostRef, instance, elm, isInitialLoad) => {
2633
2766
  const allRenderFn = !!BUILD.allRenderFn;
2634
2767
  const lazyLoad = !!BUILD.lazyLoad;
2635
- const taskQueue = !!BUILD.taskQueue;
2636
2768
  const updatable = !!BUILD.updatable;
2637
2769
  try {
2638
2770
  renderingRef = instance;
@@ -2641,14 +2773,17 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
2641
2773
  * method, so we can call the method immediately. If not, check before calling it.
2642
2774
  */
2643
2775
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
2644
- if (updatable && taskQueue) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2776
+ if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2645
2777
  if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
2646
- if (BUILD.hasRenderFn || BUILD.reflect) if (BUILD.vdomRender || BUILD.reflect) if (BUILD.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2647
- else renderVdom(hostRef, instance, isInitialLoad);
2648
- else {
2649
- const shadowRoot = elm.shadowRoot;
2650
- if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2651
- else elm.textContent = instance;
2778
+ if (BUILD.hasRenderFn || BUILD.reflect) {
2779
+ if (BUILD.vdomRender || BUILD.reflect) {
2780
+ if (BUILD.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2781
+ else renderVdom(hostRef, instance, isInitialLoad);
2782
+ } else {
2783
+ const shadowRoot = elm.shadowRoot;
2784
+ if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2785
+ else elm.textContent = instance;
2786
+ }
2652
2787
  }
2653
2788
  } catch (e) {
2654
2789
  consoleError(e, hostRef.$hostElement$);
@@ -2788,17 +2923,19 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2788
2923
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2789
2924
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
2790
2925
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
2791
- const sig = signal(hostRef.$instanceValues$.get(memberName));
2926
+ const initialVal = hostRef.$instanceValues$.get(memberName);
2927
+ const sig = signal(initialVal);
2792
2928
  hostRef.$signalValues$.set(memberName, sig);
2793
2929
  let prevScheduleVal = sig.peek();
2794
2930
  disposers.push(effect(() => {
2795
2931
  const newVal = sig.value;
2796
2932
  if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
2797
2933
  if (instance?.componentShouldUpdate) {
2798
- if (instance.componentShouldUpdate(newVal, prevScheduleVal, memberName) === false && !(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) {
2799
- prevScheduleVal = newVal;
2800
- return;
2801
- }
2934
+ const changes = hostRef.$queuedPropChanges$ ||= {};
2935
+ changes[memberName] = {
2936
+ newVal,
2937
+ oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
2938
+ };
2802
2939
  }
2803
2940
  if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
2804
2941
  }
@@ -2833,7 +2970,8 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2833
2970
  consoleError(e, elm);
2834
2971
  }
2835
2972
  }));
2836
- elm[STENCIL_SIGNALS_SYMBOL] = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
2973
+ const publicSignals = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
2974
+ elm[STENCIL_SIGNALS_SYMBOL] = publicSignals;
2837
2975
  hostRef.$signalCleanup$ = () => {
2838
2976
  disposers.forEach((d) => d());
2839
2977
  elm[STENCIL_SIGNALS_SYMBOL] = void 0;
@@ -2882,19 +3020,25 @@ const h = (nodeName, vnodeData, ...children) => {
2882
3020
  for (let i = 0; i < c.length; i++) {
2883
3021
  child = c[i];
2884
3022
  if (Array.isArray(child)) walk(child);
2885
- else if (child != null && typeof child !== "boolean") if (BUILD.vdomSignals && isSignalLike(child)) {
2886
- const sigVNode = newVNode(null, String(child.peek()));
2887
- sigVNode.$signal$ = child;
2888
- vNodeChildren.push(sigVNode);
2889
- lastSimple = false;
2890
- } else {
2891
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
2892
- else if (BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) consoleDevError(`vNode passed as children has unexpected type.
2893
- Make sure it's using the correct h() function.
2894
- Empty objects can also be the cause, look for JSX comments that became objects.`);
2895
- if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
2896
- else vNodeChildren.push(simple ? newVNode(null, child) : child);
2897
- lastSimple = simple;
3023
+ else if (child != null && typeof child !== "boolean") {
3024
+ if (BUILD.vdomSignals && isSignalLike(child)) {
3025
+ const sigVNode = newVNode(null, String(child.peek()));
3026
+ sigVNode.$signal$ = child;
3027
+ vNodeChildren.push(sigVNode);
3028
+ lastSimple = false;
3029
+ } else {
3030
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
3031
+ else if (typeof nodeName !== "function" && child.$flags$ === void 0) {
3032
+ if (BUILD.isDev) consoleDevError(`vNode passed as children has unexpected type.
3033
+ Make sure it's using the correct h() function.
3034
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
3035
+ else consoleError("Invalid vNode child");
3036
+ continue;
3037
+ }
3038
+ if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
3039
+ else vNodeChildren.push(simple ? newVNode(null, child) : child);
3040
+ lastSimple = simple;
3041
+ }
2898
3042
  }
2899
3043
  }
2900
3044
  };
@@ -3879,14 +4023,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
3879
4023
  /**
3880
4024
  * ensure this value is of the correct prop type
3881
4025
  */
3882
- if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
3883
- /**
3884
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
3885
- * (regardless of its value, even "false") should make the property true.
3886
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
3887
- */
3888
- if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
3889
- else return propValue === "false" ? false : propValue === "" || !!propValue;
4026
+ if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) {
4027
+ /**
4028
+ * For form-associated components, according to HTML spec, the presence of any boolean attribute
4029
+ * (regardless of its value, even "false") should make the property true.
4030
+ * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
4031
+ */
4032
+ if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
4033
+ else return propValue === "false" ? false : propValue === "" || !!propValue;
4034
+ }
3890
4035
  /**
3891
4036
  * force it to be a number
3892
4037
  */
@@ -3974,7 +4119,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3974
4119
  }
3975
4120
  if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
3976
4121
  if (instance.componentShouldUpdate) {
3977
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false && !(flags & HOST_FLAGS.isQueuedForUpdate)) return;
4122
+ const changes = hostRef.$queuedPropChanges$ ||= {};
4123
+ changes[propName] = {
4124
+ newVal,
4125
+ oldVal: changes[propName]?.oldVal ?? oldVal
4126
+ };
3978
4127
  }
3979
4128
  if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3980
4129
  }
@@ -4108,11 +4257,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4108
4257
  };
4109
4258
  for (const deserializer of cmpMeta.$deserializers$[propName]) {
4110
4259
  const [[methodName]] = Object.entries(deserializer);
4111
- if (BUILD.lazyLoad) if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
4112
- else hostRef.$fetchedCbList$.push(() => {
4113
- setVal(methodName, hostRef.$lazyInstance$);
4114
- });
4115
- else setVal(methodName, this);
4260
+ if (BUILD.lazyLoad) {
4261
+ if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
4262
+ else hostRef.$fetchedCbList$.push(() => {
4263
+ setVal(methodName, hostRef.$lazyInstance$);
4264
+ });
4265
+ } else setVal(methodName, this);
4116
4266
  }
4117
4267
  return;
4118
4268
  } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
@@ -4136,7 +4286,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4136
4286
  if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4137
4287
  });
4138
4288
  };
4139
- Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
4289
+ Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
4140
4290
  const attrName = m[1] || propName;
4141
4291
  attrNameToPropName.set(attrName, propName);
4142
4292
  if (BUILD.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
@@ -4163,6 +4313,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4163
4313
  try {
4164
4314
  if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
4165
4315
  hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
4316
+ hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
4166
4317
  const bundleId = cmpMeta.$lazyBundleId$;
4167
4318
  if (BUILD.lazyLoad && bundleId) {
4168
4319
  const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
@@ -4171,7 +4322,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4171
4322
  Cstr = await CstrImport;
4172
4323
  endLoad();
4173
4324
  } else Cstr = CstrImport;
4174
- if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4325
+ if (!Cstr) {
4326
+ hostRef.$flags$ &= ~HOST_FLAGS.hasInitializedComponent;
4327
+ hostRef.$loadRetryCount$ = (hostRef.$loadRetryCount$ ?? 0) + 1;
4328
+ if (hostRef.$loadRetryCount$ < 3) hostRef.$flags$ |= HOST_FLAGS.hasFailedLoad;
4329
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4330
+ }
4175
4331
  if (BUILD.member && !Cstr.isProxied) {
4176
4332
  if (BUILD.propChangeCallback) {
4177
4333
  cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
@@ -4190,8 +4346,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4190
4346
  }
4191
4347
  if (BUILD.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4192
4348
  endNewInstance();
4193
- if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4194
- else hostRef.$deferredConnectedCallback$ = true;
4349
+ if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4350
+ if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4351
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4352
+ if (BUILD.asyncLoading) markFirstConnected(hostRef);
4353
+ } else queueMicrotask(() => {
4354
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4355
+ if (BUILD.asyncLoading) markFirstConnected(hostRef);
4356
+ });
4195
4357
  } else Cstr = elm.constructor;
4196
4358
  if (BUILD.style && Cstr && Cstr.style) {
4197
4359
  /**
@@ -4250,7 +4412,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4250
4412
  hostRef.$onRenderResolve$();
4251
4413
  hostRef.$onRenderResolve$ = void 0;
4252
4414
  }
4253
- if (BUILD.asyncLoading && hostRef.$onReadyResolve$) hostRef.$onReadyResolve$(elm);
4415
+ if (BUILD.asyncLoading) markFirstConnected(hostRef);
4416
+ if (BUILD.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
4254
4417
  }
4255
4418
  };
4256
4419
  const fireConnectedCallback = (instance, elm) => {
@@ -4313,6 +4476,7 @@ const connectedCallback = (elm) => {
4313
4476
  } else {
4314
4477
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
4315
4478
  if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4479
+ else if (hostRef.$flags$ & HOST_FLAGS.hasFailedLoad) setTimeout(() => initializeComponent(elm, hostRef, cmpMeta), LAZY_LOAD_RETRY_INTERVAL_MS);
4316
4480
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
4317
4481
  }
4318
4482
  endConnected();
@@ -4342,6 +4506,7 @@ const disconnectedCallback = async (elm) => {
4342
4506
  hostRef.$signalCleanup$();
4343
4507
  hostRef.$signalCleanup$ = void 0;
4344
4508
  }
4509
+ if (BUILD.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
4345
4510
  if (!BUILD.lazyLoad) disconnectInstance(elm);
4346
4511
  else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
4347
4512
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
@@ -4467,18 +4632,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4467
4632
  hmrStart(this, cmpMeta, hmrVersionId);
4468
4633
  };
4469
4634
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4470
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4471
- else {
4472
- if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4473
- if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4474
- patchSlotAppendChild(Cstr.prototype);
4475
- patchSlotAppend(Cstr.prototype);
4476
- patchSlotPrepend(Cstr.prototype);
4477
- patchSlotInsertAdjacentHTML(Cstr.prototype);
4478
- patchInsertBefore(Cstr.prototype);
4479
- patchSlotRemoveChild(Cstr.prototype);
4635
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4636
+ if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4637
+ else {
4638
+ if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4639
+ if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4640
+ patchSlotAppendChild(Cstr.prototype);
4641
+ patchSlotAppend(Cstr.prototype);
4642
+ patchSlotPrepend(Cstr.prototype);
4643
+ patchSlotInsertAdjacentHTML(Cstr.prototype);
4644
+ patchInsertBefore(Cstr.prototype);
4645
+ patchSlotRemoveChild(Cstr.prototype);
4646
+ }
4647
+ if (BUILD.slotTextContent) patchTextContent(Cstr.prototype);
4480
4648
  }
4481
- if (BUILD.slotTextContent) patchTextContent(Cstr.prototype);
4482
4649
  }
4483
4650
  if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow();
4484
4651
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
@@ -4491,19 +4658,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4491
4658
  componentOnReady() {
4492
4659
  return getHostRef(this)?.$onReadyPromise$;
4493
4660
  },
4494
- connectedCallback() {
4495
- if (!this.__hasHostListenerAttached) {
4496
- const hostRef = getHostRef(this);
4661
+ async connectedCallback() {
4662
+ const isFirstConnect = !this.__hasHostListenerAttached;
4663
+ let hostRef;
4664
+ if (isFirstConnect) {
4665
+ hostRef = getHostRef(this);
4497
4666
  if (!hostRef) return;
4498
4667
  addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4499
4668
  this.__hasHostListenerAttached = true;
4500
4669
  }
4501
4670
  connectedCallback(this);
4502
- if (originalConnectedCallback) originalConnectedCallback.call(this);
4671
+ if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4672
+ await awaitAncestorConnected(hostRef.$ancestorComponent$);
4673
+ if (!this.isConnected) return;
4674
+ }
4675
+ if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
4676
+ if (BUILD.asyncLoading && hostRef) markFirstConnected(hostRef);
4503
4677
  },
4504
4678
  disconnectedCallback() {
4505
4679
  disconnectedCallback(this);
4506
- if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
4680
+ if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
4507
4681
  },
4508
4682
  __attachShadow() {
4509
4683
  const isClosed = BUILD.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
@@ -4557,8 +4731,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4557
4731
  const exclude = options.exclude || [];
4558
4732
  const _reg = options.registry ?? getRegistry();
4559
4733
  const head = win.document.head;
4560
- const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
4561
- const dataStyles = /* @__PURE__ */ win.document.createElement("style");
4734
+ const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
4735
+ const dataStyles = /*@__PURE__*/ win.document.createElement("style");
4562
4736
  const deferredConnectedCallbacks = [];
4563
4737
  let appLoadFallback;
4564
4738
  let isBootstrapping = true;
@@ -4626,8 +4800,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4626
4800
  *
4627
4801
  * Also remove the reference from `deferredConnectedCallbacks` array
4628
4802
  * otherwise removed instances won't get garbage collected.
4803
+ *
4804
+ * Use `nextTick` (microtask) rather than `plt.raf` since
4805
+ * `requestAnimationFrame` callbacks do not fire while `document.hidden`
4629
4806
  */
4630
- plt.raf(() => {
4807
+ nextTick(() => {
4631
4808
  const hostRef = getHostRef(this);
4632
4809
  if (!hostRef) return;
4633
4810
  const i = deferredConnectedCallbacks.findIndex((host) => host === this);
@@ -4640,18 +4817,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4640
4817
  }
4641
4818
  };
4642
4819
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(HostElement.prototype);
4643
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4644
- else {
4645
- if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4646
- if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4647
- patchSlotAppendChild(HostElement.prototype);
4648
- patchSlotAppend(HostElement.prototype);
4649
- patchSlotPrepend(HostElement.prototype);
4650
- patchSlotInsertAdjacentHTML(HostElement.prototype);
4651
- patchInsertBefore(HostElement.prototype);
4652
- patchSlotRemoveChild(HostElement.prototype);
4820
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4821
+ if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4822
+ else {
4823
+ if (BUILD.slotChildNodes || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4824
+ if (BUILD.slotDomMutations || BUILD.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4825
+ patchSlotAppendChild(HostElement.prototype);
4826
+ patchSlotAppend(HostElement.prototype);
4827
+ patchSlotPrepend(HostElement.prototype);
4828
+ patchSlotInsertAdjacentHTML(HostElement.prototype);
4829
+ patchInsertBefore(HostElement.prototype);
4830
+ patchSlotRemoveChild(HostElement.prototype);
4831
+ }
4832
+ if (BUILD.slotTextContent) patchTextContent(HostElement.prototype);
4653
4833
  }
4654
- if (BUILD.slotTextContent) patchTextContent(HostElement.prototype);
4655
4834
  }
4656
4835
  if (BUILD.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
4657
4836
  if (BUILD.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
@@ -4697,9 +4876,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
4697
4876
  };
4698
4877
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
4699
4878
  try {
4700
- if (BUILD.lazyLoad) if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4701
- else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4702
- else hostRef.$hostElement$[methodName](ev);
4879
+ if (BUILD.lazyLoad) {
4880
+ if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4881
+ else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4882
+ } else hostRef.$hostElement$[methodName](ev);
4703
4883
  } catch (e) {
4704
4884
  consoleError(e, hostRef.$hostElement$);
4705
4885
  }
@@ -4733,6 +4913,73 @@ const setNonce = (nonce) => plt.$nonce$ = nonce;
4733
4913
  //#region src/runtime/platform-options.ts
4734
4914
  const setPlatformOptions = (opts) => Object.assign(plt, opts);
4735
4915
  //#endregion
4916
+ //#region src/runtime/reactive-controller.ts
4917
+ const ReactiveControllerHost = (Base) => class ReactiveControllerHostMixin extends Base {
4918
+ controllers = /* @__PURE__ */ new Set();
4919
+ #connected = false;
4920
+ #updateCompleteResolvers = [];
4921
+ addController(controller) {
4922
+ this.controllers.add(controller);
4923
+ if (this.#connected) controller.hostConnected?.();
4924
+ }
4925
+ removeController(controller) {
4926
+ this.controllers.delete(controller);
4927
+ }
4928
+ requestUpdate() {
4929
+ forceUpdate(this);
4930
+ }
4931
+ get updateComplete() {
4932
+ return new Promise((resolve) => this.#updateCompleteResolvers.push(resolve));
4933
+ }
4934
+ connectedCallback() {
4935
+ super.connectedCallback?.();
4936
+ this.#connected = true;
4937
+ const el = getElement(this);
4938
+ if (el && el !== this) {
4939
+ el.addController = (controller) => this.addController(controller);
4940
+ el.removeController = (controller) => this.removeController(controller);
4941
+ el.requestUpdate = () => this.requestUpdate();
4942
+ Object.defineProperty(el, "updateComplete", {
4943
+ configurable: true,
4944
+ get: () => this.updateComplete
4945
+ });
4946
+ }
4947
+ this.controllers.forEach((c) => c.hostConnected?.());
4948
+ }
4949
+ disconnectedCallback() {
4950
+ super.disconnectedCallback?.();
4951
+ this.#connected = false;
4952
+ this.controllers.forEach((c) => c.hostDisconnected?.());
4953
+ }
4954
+ async componentWillLoad() {
4955
+ await super.componentWillLoad?.();
4956
+ await Promise.all([...this.controllers].map((c) => c.hostWillLoad?.()));
4957
+ }
4958
+ componentDidLoad() {
4959
+ super.componentDidLoad?.();
4960
+ this.controllers.forEach((c) => c.hostDidLoad?.());
4961
+ }
4962
+ async componentWillRender() {
4963
+ await super.componentWillRender?.();
4964
+ await Promise.all([...this.controllers].map((c) => c.hostWillRender?.()));
4965
+ }
4966
+ componentDidRender() {
4967
+ super.componentDidRender?.();
4968
+ this.controllers.forEach((c) => c.hostDidRender?.());
4969
+ const resolvers = this.#updateCompleteResolvers;
4970
+ this.#updateCompleteResolvers = [];
4971
+ resolvers.forEach((resolve) => resolve(true));
4972
+ }
4973
+ async componentWillUpdate() {
4974
+ await super.componentWillUpdate?.();
4975
+ await Promise.all([...this.controllers].map((c) => c.hostWillUpdate?.()));
4976
+ }
4977
+ componentDidUpdate() {
4978
+ super.componentDidUpdate?.();
4979
+ this.controllers.forEach((c) => c.hostDidUpdate?.());
4980
+ }
4981
+ };
4982
+ //#endregion
4736
4983
  //#region src/runtime/render.ts
4737
4984
  /**
4738
4985
  * A WeakMap to persist HostRef objects across multiple render() calls to the
@@ -4819,4 +5066,4 @@ function hasKeys(obj) {
4819
5066
  return false;
4820
5067
  }
4821
5068
  //#endregion
4822
- export { Fragment, HYDRATED_STYLE_ID, Host, Mixin, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, jsx, jsxDEV, jsxs, normalizeWatchers, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, render, setAssetPath, setMode, setNonce, setPlatformOptions, setRegistry, setTagTransformer, setValue, transformTag };
5069
+ export { Fragment, HYDRATED_STYLE_ID, Host, Mixin, ReactiveControllerHost, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, jsx, jsxDEV, jsxs, normalizeWatchers, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, render, setAssetPath, setMode, setNonce, setPlatformOptions, setRegistry, setTagTransformer, setValue, transformTag };