@stencil/core 5.0.0-alpha.8 → 5.0.0-beta.0

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 (50) hide show
  1. package/README.md +94 -0
  2. package/dist/app-data/index.d.ts +2 -0
  3. package/dist/{runtime/app-data → app-data}/index.js +5 -2
  4. package/dist/client-BRu0GtRn.mjs +2368 -0
  5. package/dist/compiler/index.d.mts +167 -3
  6. package/dist/compiler/index.mjs +3 -3
  7. package/dist/compiler/utils/index.d.mts +272 -2
  8. package/dist/compiler/utils/index.mjs +4 -3
  9. package/dist/{compiler-B3pUYg_P.mjs → compiler-NrvbUOX1.mjs} +2904 -1269
  10. package/dist/declarations/stencil-ext-modules.d.ts +5 -5
  11. package/dist/declarations/stencil-public-compiler.d.ts +208 -62
  12. package/dist/declarations/stencil-public-docs.d.ts +9 -0
  13. package/dist/declarations/stencil-public-runtime.d.ts +91 -6
  14. package/dist/fragment-Di1hWOC8.mjs +4 -0
  15. package/dist/{regular-expression-CFVJOTUh.mjs → helpers-Cpp3qc3u.mjs} +31 -15
  16. package/dist/index-BOrz3rbJ.d.mts +100 -0
  17. package/dist/{index-BuveMLxy.d.ts → index-DnISpqrd.d.ts} +150 -10
  18. package/dist/{index-CVhWFUM0.d.mts → index-RrQfiPWK.d.mts} +490 -841
  19. package/dist/index.d.mts +4 -0
  20. package/dist/index.mjs +91 -2
  21. package/dist/jsx-runtime.mjs +2 -1
  22. package/dist/{node-10UamZmn.mjs → node-75gQKkFz.mjs} +60 -58
  23. package/dist/{chunk-z9aeyW2b.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
  24. package/dist/runtime/client/lazy.js +483 -347
  25. package/dist/runtime/client/runtime.d.ts +150 -39
  26. package/dist/runtime/client/runtime.js +483 -347
  27. package/dist/runtime/index.d.ts +6 -32
  28. package/dist/runtime/index.js +482 -345
  29. package/dist/runtime/server/index.d.mts +81 -9
  30. package/dist/runtime/server/index.mjs +419 -193
  31. package/dist/runtime/server/runner.d.mts +3 -0
  32. package/dist/runtime/server/runner.mjs +321 -338
  33. package/dist/signals/index.d.ts +2 -0
  34. package/dist/signals/index.js +5 -2
  35. package/dist/sys/node/index.d.mts +1 -2
  36. package/dist/sys/node/index.mjs +1 -1
  37. package/dist/sys/node/worker.d.mts +1 -1
  38. package/dist/sys/node/worker.mjs +6 -3
  39. package/dist/testing/index.d.mts +4716 -105
  40. package/dist/testing/index.mjs +7744 -791
  41. package/dist/util-IKfWWLJo.mjs +724 -0
  42. package/dist/validation-DAdGTrys.mjs +791 -0
  43. package/package.json +33 -33
  44. package/dist/client-Dd-NB5Ei.mjs +0 -4833
  45. package/dist/index-ch-cf-bZ.d.mts +0 -205
  46. package/dist/runtime/app-data/index.d.ts +0 -2
  47. package/dist/validation-ByxKj8bC.mjs +0 -1458
  48. /package/{LICENSE.md → LICENSE} +0 -0
  49. /package/dist/{runtime/app-globals → app-globals}/index.d.ts +0 -0
  50. /package/dist/{runtime/app-globals → app-globals}/index.js +0 -0
@@ -1,5 +1,5 @@
1
- import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/runtime/app-data";
2
- import { globalScripts, globalStyles } from "@stencil/core/runtime/app-globals";
1
+ import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/app-data";
2
+ import { globalScripts, globalStyles } from "@stencil/core/app-globals";
3
3
  import { effect, effect as effect$1, signal } from "@preact/signals-core";
4
4
  const MEMBER_FLAGS = {
5
5
  String: 1,
@@ -43,8 +43,20 @@ const HOST_FLAGS = {
43
43
  isWatchReady: 128,
44
44
  isListenReady: 256,
45
45
  needsRerender: 512,
46
- devOnRender: 1024,
47
- devOnDidLoad: 2048
46
+ /**
47
+ * Set once this component's real (lazy-loaded) `connectedCallback` has fired for
48
+ * the first time. Lets a descendant skip creating/awaiting a connect-promise for
49
+ * an ancestor that's already connected. See {@link HostRef.$onFirstConnectResolve$}.
50
+ */
51
+ hasFiredConnected: 1024,
52
+ /**
53
+ * Set when a lazy component's dynamic `import()` fails to resolve a
54
+ * constructor. Distinct from `hasInitializedComponent` being unset, which
55
+ * is true while an initialization attempt is merely queued/in-flight.
56
+ */
57
+ hasFailedLoad: 2048,
58
+ devOnRender: 4096,
59
+ devOnDidLoad: 8192
48
60
  };
49
61
  const CF_scopedCssEncapsulation = 2;
50
62
  /**
@@ -129,7 +141,17 @@ const CMP_FLAGS = {
129
141
  * e.g. `encapsulation: { type: 'none', patches: ['all'] }`
130
142
  * Equivalent to the global `experimentalSlotFixes` config option.
131
143
  */
132
- patchAll: 32768
144
+ patchAll: 32768,
145
+ /**
146
+ * Determines if `clonable` is enabled for a component that uses the shadow DOM.
147
+ * e.g. `encapsulation: { type: 'shadow', clonable: true }` is set on the `@Component()` decorator
148
+ */
149
+ shadowClonable: 65536,
150
+ /**
151
+ * Determines if `serializable` is enabled for a component that uses the shadow DOM.
152
+ * e.g. `encapsulation: { type: 'shadow', serializable: true }` is set on the `@Component()` decorator
153
+ */
154
+ shadowSerializable: 1 << 17
133
155
  };
134
156
  /**
135
157
  * Namespaces
@@ -295,6 +317,10 @@ const DEFAULT_DOC_DATA = {
295
317
  */
296
318
  const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
297
319
  const XLINK_NS = "http://www.w3.org/1999/xlink";
320
+ /**
321
+ * Minimum delay, in milliseconds, before retrying a failed lazy component load.
322
+ */
323
+ const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
298
324
  const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
299
325
  "formAssociatedCallback",
300
326
  "formResetCallback",
@@ -314,6 +340,8 @@ function createShadowRoot(cmpMeta) {
314
340
  if (BUILD$1.shadowSlotAssignmentManual) {
315
341
  if (!!(cmpMeta.$flags$ & CMP_FLAGS.shadowSlotAssignmentManual)) opts.slotAssignment = "manual";
316
342
  }
343
+ if (BUILD$1.shadowClonable) opts.clonable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowClonable);
344
+ if (BUILD$1.shadowSerializable) opts.serializable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowSerializable);
317
345
  const shadowRoot = this.attachShadow(opts);
318
346
  if (BUILD$1.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
319
347
  if (globalStyleSheet === void 0) globalStyleSheet = null;
@@ -343,8 +371,10 @@ function createShadowRoot(cmpMeta) {
343
371
  const updateFallbackSlotVisibility = (elm) => {
344
372
  const childNodes = internalCall(elm, "childNodes");
345
373
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
346
- if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
347
- else slotNode.hidden = false;
374
+ if (slotNode.nodeType === NODE_TYPE.ElementNode && slotNode.tagName === "SLOT-FB") {
375
+ if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) slotNode.hidden = true;
376
+ else slotNode.hidden = false;
377
+ }
348
378
  });
349
379
  let i = 0;
350
380
  for (i = 0; i < childNodes.length; i++) {
@@ -387,7 +417,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
387
417
  slottedNodes.push(childNode);
388
418
  if (typeof slotName !== "undefined") return slottedNodes;
389
419
  }
390
- slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
420
+ slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
391
421
  }
392
422
  return slottedNodes;
393
423
  }
@@ -418,7 +448,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
418
448
  if (nodeToRelocate.getAttribute("slot") === slotName) return true;
419
449
  return false;
420
450
  }
421
- if (nodeToRelocate["s-sn"] === slotName) return true;
451
+ if (typeof nodeToRelocate["s-sa"] === "string") return nodeToRelocate["s-sa"] === slotName;
422
452
  return slotName === "";
423
453
  };
424
454
  /**
@@ -467,8 +497,10 @@ function patchSlotNode(node) {
467
497
  const assignedFactory = (elementsOnly) => function(opts) {
468
498
  const toReturn = [];
469
499
  const slotName = this["s-sn"];
470
- if (opts?.flatten) if (BUILD$1.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
471
- else console.error("Flattening not supported for Stencil non-shadow slots");
500
+ if (opts?.flatten) {
501
+ if (BUILD$1.isDev) console.error("Flattening is not supported for Stencil non-shadow slots. You can use `.childNodes` for nested slot fallback content.");
502
+ else console.error("Flattening not supported for Stencil non-shadow slots");
503
+ }
472
504
  const parent = this["s-cr"].parentElement;
473
505
  (parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes)).forEach((n) => {
474
506
  if (slotName === getSlotName(n)) toReturn.push(n);
@@ -559,8 +591,10 @@ const patchCloneNode = (HostElementPrototype) => {
559
591
  for (; i < childNodes.length; i++) {
560
592
  slotted = childNodes[i]["s-nr"];
561
593
  nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i][privateField]);
562
- if (slotted) if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
563
- else clonedNode.appendChild(slotted.cloneNode(true));
594
+ if (slotted) {
595
+ if (clonedNode.__appendChild) clonedNode.__appendChild(slotted.cloneNode(true));
596
+ else clonedNode.appendChild(slotted.cloneNode(true));
597
+ }
564
598
  if (nonStencilNode) clonedNode.appendChild(childNodes[i].cloneNode(true));
565
599
  }
566
600
  }
@@ -763,11 +797,11 @@ const patchChildSlotNodes = (elm) => {
763
797
  } });
764
798
  patchHostOriginalAccessor("firstChild", elm);
765
799
  Object.defineProperty(elm, "firstChild", { get() {
766
- return this.childNodes[0];
800
+ return this.childNodes[0] || null;
767
801
  } });
768
802
  patchHostOriginalAccessor("lastChild", elm);
769
803
  Object.defineProperty(elm, "lastChild", { get() {
770
- return this.childNodes[this.childNodes.length - 1];
804
+ return this.childNodes[this.childNodes.length - 1] || null;
771
805
  } });
772
806
  patchHostOriginalAccessor("childNodes", elm);
773
807
  Object.defineProperty(elm, "childNodes", { get() {
@@ -813,7 +847,7 @@ const patchNextSibling = (node) => {
813
847
  Object.defineProperty(node, "nextSibling", { get: function() {
814
848
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
815
849
  const index = parentNodes?.indexOf(this);
816
- if (parentNodes && index > -1) return parentNodes[index + 1];
850
+ if (parentNodes && index > -1) return parentNodes[index + 1] || null;
817
851
  return this.__nextSibling;
818
852
  } });
819
853
  };
@@ -828,7 +862,7 @@ const patchNextElementSibling = (element) => {
828
862
  Object.defineProperty(element, "nextElementSibling", { get: function() {
829
863
  const parentEles = this["s-ol"]?.parentNode.children;
830
864
  const index = parentEles?.indexOf(this);
831
- if (parentEles && index > -1) return parentEles[index + 1];
865
+ if (parentEles && index > -1) return parentEles[index + 1] || null;
832
866
  return this.__nextElementSibling;
833
867
  } });
834
868
  };
@@ -843,7 +877,7 @@ const patchPreviousSibling = (node) => {
843
877
  Object.defineProperty(node, "previousSibling", { get: function() {
844
878
  const parentNodes = this["s-ol"]?.parentNode.childNodes;
845
879
  const index = parentNodes?.indexOf(this);
846
- if (parentNodes && index > -1) return parentNodes[index - 1];
880
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
847
881
  return this.__previousSibling;
848
882
  } });
849
883
  };
@@ -858,7 +892,7 @@ const patchPreviousElementSibling = (element) => {
858
892
  Object.defineProperty(element, "previousElementSibling", { get: function() {
859
893
  const parentNodes = this["s-ol"]?.parentNode.children;
860
894
  const index = parentNodes?.indexOf(this);
861
- if (parentNodes && index > -1) return parentNodes[index - 1];
895
+ if (parentNodes && index > -1) return parentNodes[index - 1] || null;
862
896
  return this.__previousElementSibling;
863
897
  } });
864
898
  };
@@ -1033,7 +1067,7 @@ function queryNonceMetaTagContent(doc) {
1033
1067
  }
1034
1068
  //#endregion
1035
1069
  //#region src/runtime/styles.ts
1036
- const rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1070
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
1037
1071
  /**
1038
1072
  * Get or initialize the set of applied style scope IDs for a container element.
1039
1073
  *
@@ -1123,37 +1157,41 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1123
1157
  /**
1124
1158
  * attach styles at the end of the head tag if we render scoped components
1125
1159
  */
1126
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) if (styleContainerNode.nodeName === "HEAD") {
1127
- /**
1128
- * if the page contains preconnect links, we want to insert the styles
1129
- * after the last preconnect link to ensure the styles are preloaded
1130
- */
1131
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1132
- const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1133
- styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1134
- } else if ("host" in styleContainerNode) {
1135
- /**
1136
- * If a scoped component is used within a shadow root and constructable stylesheets are
1137
- * not supported, we want to insert the styles at the beginning of the shadow root node.
1138
- *
1139
- * However, if there is already a style node in the shadow root, we just append
1140
- * the styles to the existing node.
1141
- *
1142
- * Note: order of how styles are applied is important. The new style node
1143
- * should be inserted before the existing style node.
1144
- *
1145
- * During HMR, create separate style elements for scoped components so they can be
1146
- * updated independently without affecting other components' styles.
1147
- */
1148
- const existingStyleContainer = styleContainerNode.querySelector("style");
1149
- if (existingStyleContainer && !BUILD$1.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1150
- else styleContainerNode.prepend(styleElm);
1151
- } else styleContainerNode.append(styleElm);
1160
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) {
1161
+ if (styleContainerNode.nodeName === "HEAD") {
1162
+ /**
1163
+ * if the page contains preconnect links, we want to insert the styles
1164
+ * after the last preconnect link to ensure the styles are preloaded
1165
+ */
1166
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1167
+ const referenceNode = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1168
+ styleContainerNode.insertBefore(styleElm, referenceNode?.parentNode === styleContainerNode ? referenceNode : null);
1169
+ } else if ("host" in styleContainerNode) {
1170
+ /**
1171
+ * If a scoped component is used within a shadow root and constructable stylesheets are
1172
+ * not supported, we want to insert the styles at the beginning of the shadow root node.
1173
+ *
1174
+ * However, if there is already a style node in the shadow root, we just append
1175
+ * the styles to the existing node.
1176
+ *
1177
+ * Note: order of how styles are applied is important. The new style node
1178
+ * should be inserted before the existing style node.
1179
+ *
1180
+ * During HMR, create separate style elements for scoped components so they can be
1181
+ * updated independently without affecting other components' styles.
1182
+ */
1183
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1184
+ if (existingStyleContainer && !BUILD$1.hotModuleReplacement) existingStyleContainer.textContent = style + existingStyleContainer.textContent;
1185
+ else styleContainerNode.prepend(styleElm);
1186
+ } else styleContainerNode.append(styleElm);
1187
+ }
1152
1188
  /**
1153
1189
  * attach styles at the beginning of a shadow root node if we render shadow components
1154
1190
  */
1155
- if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1156
- else styleContainerNode.insertBefore(styleElm, null);
1191
+ if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
1192
+ if (isClosedShadowSSR) styleContainerNode.prepend(styleElm);
1193
+ else styleContainerNode.insertBefore(styleElm, null);
1194
+ }
1157
1195
  if (appliedStyles) appliedStyles.add(scopeId);
1158
1196
  }
1159
1197
  } else if (BUILD$1.constructableCSS) {
@@ -1245,7 +1283,12 @@ const hydrateScopedToShadow = () => {
1245
1283
  if (!win.document) return;
1246
1284
  const styleElements = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1247
1285
  let i = 0;
1248
- for (; i < styleElements.length; i++) registerStyle(styleElements[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styleElements[i].innerHTML), true);
1286
+ for (; i < styleElements.length; i++) {
1287
+ const scopeId = styleElements[i].getAttribute(HYDRATED_STYLE_ID);
1288
+ const existing = styles.get(scopeId);
1289
+ const allowCS = existing !== void 0 ? existing instanceof CSSStyleSheet : true;
1290
+ registerStyle(scopeId, convertScopedToShadow(styleElements[i].innerHTML), allowCS);
1291
+ }
1249
1292
  };
1250
1293
  //#endregion
1251
1294
  //#region src/utils/helpers.ts
@@ -1371,11 +1414,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1371
1414
  }
1372
1415
  } else if (BUILD$1.vdomStyle && memberName === "style") {
1373
1416
  if (BUILD$1.updatable) {
1374
- for (const prop in oldValue) if (!newValue || newValue[prop] == null) if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1375
- else elm.style[prop] = "";
1417
+ for (const prop in oldValue) if (!newValue || newValue[prop] == null) {
1418
+ if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.removeProperty(prop);
1419
+ else elm.style[prop] = "";
1420
+ }
1421
+ }
1422
+ for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) {
1423
+ if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1424
+ else elm.style[prop] = newValue[prop];
1376
1425
  }
1377
- for (const prop in newValue) if (!oldValue || newValue[prop] !== oldValue[prop]) if (!BUILD$1.hydrateServerSide && prop.includes("-")) elm.style.setProperty(prop, newValue[prop]);
1378
- else elm.style[prop] = newValue[prop];
1379
1426
  } else if (BUILD$1.vdomKey && memberName === "key") {} else if (BUILD$1.vdomRef && memberName === "ref") {
1380
1427
  if (newValue) queueRefAttachment(newValue, elm);
1381
1428
  } else if (BUILD$1.vdomListener && (BUILD$1.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
@@ -1384,11 +1431,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1384
1431
  else memberName = ln[2] + memberName.slice(3);
1385
1432
  if (oldValue || newValue) {
1386
1433
  const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1387
- memberName = memberName.replace(/* @__PURE__ */ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1434
+ memberName = memberName.replace(/*@__PURE__*/ new RegExp(CAPTURE_EVENT_SUFFIX + "$"), "");
1388
1435
  if (oldValue) plt.rel(elm, memberName, oldValue, capture);
1389
1436
  if (newValue) plt.ael(elm, memberName, newValue, capture);
1390
1437
  }
1391
- } else if (BUILD$1.vdomPropOrAttr && memberName[0] === "a" && memberName.startsWith("attr:")) {
1438
+ } else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "a" && memberName.startsWith("attr:")) {
1392
1439
  const propName = memberName.slice(5);
1393
1440
  let attrName;
1394
1441
  if (BUILD$1.member) {
@@ -1403,7 +1450,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1403
1450
  if (newValue !== false || elm.getAttribute(attrName) === "") elm.removeAttribute(attrName);
1404
1451
  } else elm.setAttribute(attrName, newValue === true ? "" : newValue);
1405
1452
  return;
1406
- } else if (BUILD$1.vdomPropOrAttr && memberName[0] === "p" && memberName.startsWith("prop:")) {
1453
+ } else if (BUILD$1.vdomPropOrAttrPrefix && memberName[0] === "p" && memberName.startsWith("prop:")) {
1407
1454
  const propName = memberName.slice(5);
1408
1455
  try {
1409
1456
  elm[propName] = newValue;
@@ -1423,8 +1470,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1423
1470
  if (!elm.tagName.includes("-")) {
1424
1471
  const n = newValue == null ? "" : newValue;
1425
1472
  if (memberName === "list") isProp = false;
1426
- else if (oldValue == null || elm[memberName] !== n) if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1427
- else elm.setAttribute(memberName, n);
1473
+ else if (oldValue == null || elm[memberName] !== n) {
1474
+ if (typeof elm.__lookupSetter__(memberName) === "function") elm[memberName] = n;
1475
+ else elm.setAttribute(memberName, n);
1476
+ }
1428
1477
  } else if (elm[memberName] !== newValue) elm[memberName] = newValue;
1429
1478
  } catch {}
1430
1479
  /**
@@ -1442,8 +1491,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1442
1491
  }
1443
1492
  }
1444
1493
  if (newValue == null || newValue === false) {
1445
- if (newValue !== false || elm.getAttribute(memberName) === "") if (BUILD$1.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1446
- else elm.removeAttribute(memberName);
1494
+ if (newValue !== false || elm.getAttribute(memberName) === "" || flags & VNODE_FLAGS.isHost && !isEnumeratedAttribute(memberName)) {
1495
+ if (BUILD$1.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
1496
+ else elm.removeAttribute(memberName);
1497
+ }
1447
1498
  } else if ((!isProp || flags & VNODE_FLAGS.isHost || isSvg) && !isComplex && elm.nodeType === NODE_TYPE.ElementNode) {
1448
1499
  newValue = newValue === true ? "" : newValue;
1449
1500
  if (BUILD$1.vdomXlink && xlink) elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -1451,6 +1502,18 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1451
1502
  }
1452
1503
  }
1453
1504
  };
1505
+ /**
1506
+ * Attribute names that are enumerated (tri-state true/false/unset) rather than
1507
+ * plain boolean-presence attributes. An explicit `"false"` string on one of
1508
+ * these is semantically different from the attribute being absent, so a
1509
+ * reflected `false` value must not clear a pre-existing literal value.
1510
+ */
1511
+ const ENUMERATED_ATTRIBUTES = /*@__PURE__*/ new Set([
1512
+ "draggable",
1513
+ "contenteditable",
1514
+ "spellcheck"
1515
+ ]);
1516
+ const isEnumeratedAttribute = (attrName) => ENUMERATED_ATTRIBUTES.has(attrName) || attrName.startsWith("aria-");
1454
1517
  const parseClassListRegex = /\s/;
1455
1518
  /**
1456
1519
  * Parsed a string of classnames into an array
@@ -1574,6 +1637,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1574
1637
  }
1575
1638
  } else if (BUILD$1.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1576
1639
  elm = newVNode.$elm$ = BUILD$1.isDebug || BUILD$1.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
1640
+ if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
1577
1641
  if (BUILD$1.vdomAttribute) updateElement(null, newVNode, isSvgMode);
1578
1642
  } else {
1579
1643
  if (BUILD$1.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
@@ -1849,8 +1913,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
1849
1913
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1850
1914
  newStartVnode = newCh[++newStartIdx];
1851
1915
  }
1852
- if (node) if (BUILD$1.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
1853
- else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1916
+ if (node) {
1917
+ if (BUILD$1.slotRelocation) insertBefore(referenceNode(oldStartVnode.$elm$).parentNode, node, referenceNode(oldStartVnode.$elm$));
1918
+ else insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1919
+ }
1854
1920
  }
1855
1921
  if (oldStartIdx > oldEndIdx) addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1856
1922
  else if (BUILD$1.updatable && newStartIdx > newEndIdx) removeVnodes(oldCh, oldStartIdx, oldEndIdx);
@@ -1937,6 +2003,30 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
1937
2003
  */
1938
2004
  const relocateNodes = [];
1939
2005
  /**
2006
+ * When a forwarded `<slot>` gets relocated, drag along any content already forwarded through it,
2007
+ * to wherever it just landed (or nowhere, to be hidden, if it didn't match anything).
2008
+ *
2009
+ * Runs as its own pass after {@link markSlotContentForRelocation} rather than inside it, so that
2010
+ * function's matching order - which hydration's node/comment ordering depends on - is untouched.
2011
+ */
2012
+ const carryContentWithRelocatedSlotRefs = () => {
2013
+ for (const relocateData of relocateNodes.slice()) {
2014
+ const marker = relocateData.$nodeToRelocate$;
2015
+ if (!marker["s-sr"]) continue;
2016
+ const carriedSiblings = getSlotChildSiblings(marker, marker["s-sn"] || "", false);
2017
+ for (const carriedSibling of carriedSiblings) {
2018
+ if (!carriedSibling["s-ol"]) continue;
2019
+ let siblingRelocateData = relocateNodes.find((r) => r.$nodeToRelocate$ === carriedSibling);
2020
+ if (!siblingRelocateData) {
2021
+ siblingRelocateData = { $nodeToRelocate$: carriedSibling };
2022
+ relocateNodes.push(siblingRelocateData);
2023
+ }
2024
+ siblingRelocateData.$slotRefNode$ = relocateData.$slotRefNode$;
2025
+ if (relocateData.$slotRefNode$) carriedSibling["s-sh"] = relocateData.$slotRefNode$["s-hn"];
2026
+ }
2027
+ }
2028
+ };
2029
+ /**
1940
2030
  * Mark the contents of a slot for relocation via adding references to them to
1941
2031
  * the {@link relocateNodes} data structure. The actual work of relocating them
1942
2032
  * will then be handled in {@link renderVdom}.
@@ -2041,7 +2131,7 @@ const insertBefore = (parent, newNode, reference, isInitialLoad) => {
2041
2131
  return newNode;
2042
2132
  }
2043
2133
  }
2044
- if (parent.__insertBefore) return parent.__insertBefore(newNode, reference);
2134
+ if (BUILD$1.slotRelocation && parent?.__insertBefore) return parent.__insertBefore(newNode, reference);
2045
2135
  else return parent?.insertBefore(newNode, reference);
2046
2136
  };
2047
2137
  /**
@@ -2135,6 +2225,7 @@ render() {
2135
2225
  plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
2136
2226
  if (checkSlotRelocate) {
2137
2227
  markSlotContentForRelocation(rootVnode.$elm$);
2228
+ carryContentWithRelocatedSlotRefs();
2138
2229
  for (const relocateData of relocateNodes) {
2139
2230
  const nodeToRelocate = relocateData.$nodeToRelocate$;
2140
2231
  if (!nodeToRelocate["s-ol"] && win.document) {
@@ -2194,7 +2285,7 @@ render() {
2194
2285
  }
2195
2286
  if (BUILD$1.slotRelocation && !useNativeShadowDom && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
2196
2287
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2197
- for (const childNode of children) if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2288
+ for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
2198
2289
  if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
2199
2290
  if (childNode.nodeType === NODE_TYPE.ElementNode) childNode.hidden = true;
2200
2291
  else if (childNode.nodeType === NODE_TYPE.TextNode && !!childNode.nodeValue.trim()) {
@@ -2212,16 +2303,58 @@ const slotReferenceDebugNode = (slotVNode) => win.document?.createComment(`<slot
2212
2303
  const originalLocationDebugNode = (nodeToRelocate) => win.document?.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`));
2213
2304
  //#endregion
2214
2305
  //#region src/runtime/update-component.ts
2306
+ /**
2307
+ * Get a promise that resolves once `hostRef`'s real `connectedCallback` has fired for the first time.
2308
+ *
2309
+ * @param hostRef the component's host reference
2310
+ * @returns a promise that resolves once the component's real `connectedCallback` has fired
2311
+ */
2312
+ const ensureFirstConnectPromise = (hostRef) => {
2313
+ if (!hostRef.$onFirstConnectPromise$) hostRef.$onFirstConnectPromise$ = new Promise((r) => hostRef.$onFirstConnectResolve$ = r);
2314
+ return hostRef.$onFirstConnectPromise$;
2315
+ };
2316
+ /**
2317
+ * Resolve `hostRef`'s first-connect promise and flag it connected. Called once this
2318
+ * component's real `connectedCallback` fires, plus from error/disconnect cleanup so a
2319
+ * component that never connects can't hang an ancestor or descendant forever.
2320
+ *
2321
+ * @param hostRef the component's host reference
2322
+ */
2323
+ const markFirstConnected = (hostRef) => {
2324
+ hostRef.$flags$ |= HOST_FLAGS.hasFiredConnected;
2325
+ hostRef.$onFirstConnectResolve$?.();
2326
+ hostRef.$onFirstConnectResolve$ = void 0;
2327
+ };
2328
+ /**
2329
+ * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
2330
+ * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
2331
+ * `connectedCallback` paths so a component never connects before its nearest Stencil
2332
+ * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
2333
+ * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
2334
+ * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
2335
+ * autoloader, where the ancestor tag may not be defined yet.
2336
+ *
2337
+ * @param ancestorElm the nearest Stencil ancestor element
2338
+ */
2339
+ const awaitAncestorConnected = async (ancestorElm) => {
2340
+ let ancestorHostRef = getHostRef(ancestorElm);
2341
+ if (!BUILD$1.lazyLoad && !ancestorHostRef) {
2342
+ await getRegistry().whenDefined(ancestorElm.tagName.toLowerCase());
2343
+ ancestorHostRef = getHostRef(ancestorElm);
2344
+ }
2345
+ if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
2346
+ };
2215
2347
  const attachToAncestor = (hostRef, ancestorComponent) => {
2216
2348
  if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2217
2349
  const index = ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = () => {
2218
2350
  ancestorComponent["s-p"].splice(index - 1, 1);
2219
2351
  r();
2220
2352
  }));
2353
+ if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
2221
2354
  }
2222
2355
  };
2223
2356
  const scheduleUpdate = (hostRef, isInitialLoad) => {
2224
- if (BUILD$1.taskQueue && BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2357
+ if (BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2225
2358
  if (BUILD$1.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
2226
2359
  hostRef.$flags$ |= HOST_FLAGS.needsRerender;
2227
2360
  return;
@@ -2229,6 +2362,8 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2229
2362
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2230
2363
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2231
2364
  if (isInitialLoad) {
2365
+ const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2366
+ if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
2232
2367
  queueMicrotask(() => {
2233
2368
  dispatch();
2234
2369
  });
@@ -2268,10 +2403,6 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2268
2403
  let maybePromise;
2269
2404
  if (isInitialLoad) {
2270
2405
  if (BUILD$1.lazyLoad) {
2271
- if (BUILD$1.slotRelocation && hostRef.$deferredConnectedCallback$) {
2272
- hostRef.$deferredConnectedCallback$ = false;
2273
- safeCall(instance, "connectedCallback", void 0, elm);
2274
- }
2275
2406
  if (BUILD$1.hostListener) {
2276
2407
  hostRef.$flags$ |= HOST_FLAGS.isListenReady;
2277
2408
  if (hostRef.$queuedListeners$) {
@@ -2284,6 +2415,14 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2284
2415
  if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillLoad");
2285
2416
  maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
2286
2417
  } else {
2418
+ if (BUILD$1.updatable && hostRef.$queuedPropChanges$) {
2419
+ const changes = hostRef.$queuedPropChanges$;
2420
+ hostRef.$queuedPropChanges$ = void 0;
2421
+ if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
2422
+ hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2423
+ return;
2424
+ }
2425
+ }
2287
2426
  if (BUILD$1.lifecycleDOMEvents) emitLifecycleEvent(elm, "componentWillUpdate");
2288
2427
  maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
2289
2428
  }
@@ -2398,7 +2537,6 @@ let renderingRef = null;
2398
2537
  const callRender = (hostRef, instance, elm, isInitialLoad) => {
2399
2538
  const allRenderFn = !!BUILD$1.allRenderFn;
2400
2539
  const lazyLoad = !!BUILD$1.lazyLoad;
2401
- const taskQueue = !!BUILD$1.taskQueue;
2402
2540
  const updatable = !!BUILD$1.updatable;
2403
2541
  try {
2404
2542
  renderingRef = instance;
@@ -2407,14 +2545,17 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
2407
2545
  * method, so we can call the method immediately. If not, check before calling it.
2408
2546
  */
2409
2547
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
2410
- if (updatable && taskQueue) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2548
+ if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2411
2549
  if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
2412
- if (BUILD$1.hasRenderFn || BUILD$1.reflect) if (BUILD$1.vdomRender || BUILD$1.reflect) if (BUILD$1.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2413
- else renderVdom(hostRef, instance, isInitialLoad);
2414
- else {
2415
- const shadowRoot = elm.shadowRoot;
2416
- if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2417
- else elm.textContent = instance;
2550
+ if (BUILD$1.hasRenderFn || BUILD$1.reflect) {
2551
+ if (BUILD$1.vdomRender || BUILD$1.reflect) {
2552
+ if (BUILD$1.hydrateServerSide) return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2553
+ else renderVdom(hostRef, instance, isInitialLoad);
2554
+ } else {
2555
+ const shadowRoot = elm.shadowRoot;
2556
+ if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.shadowDomEncapsulation) shadowRoot.textContent = instance;
2557
+ else elm.textContent = instance;
2558
+ }
2418
2559
  }
2419
2560
  } catch (e) {
2420
2561
  consoleError(e, hostRef.$hostElement$);
@@ -2554,17 +2695,19 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2554
2695
  const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
2555
2696
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
2556
2697
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
2557
- const sig = signal(hostRef.$instanceValues$.get(memberName));
2698
+ const initialVal = hostRef.$instanceValues$.get(memberName);
2699
+ const sig = signal(initialVal);
2558
2700
  hostRef.$signalValues$.set(memberName, sig);
2559
2701
  let prevScheduleVal = sig.peek();
2560
2702
  disposers.push(effect(() => {
2561
2703
  const newVal = sig.value;
2562
2704
  if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
2563
2705
  if (instance?.componentShouldUpdate) {
2564
- if (instance.componentShouldUpdate(newVal, prevScheduleVal, memberName) === false && !(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) {
2565
- prevScheduleVal = newVal;
2566
- return;
2567
- }
2706
+ const changes = hostRef.$queuedPropChanges$ ||= {};
2707
+ changes[memberName] = {
2708
+ newVal,
2709
+ oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
2710
+ };
2568
2711
  }
2569
2712
  if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
2570
2713
  }
@@ -2599,7 +2742,8 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2599
2742
  consoleError(e, elm);
2600
2743
  }
2601
2744
  }));
2602
- elm[STENCIL_SIGNALS_SYMBOL] = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
2745
+ const publicSignals = new Map([...hostRef.$signalValues$].filter(([k]) => (cmpMeta.$members$?.[k]?.[0] ?? 0) & MEMBER_FLAGS.Prop));
2746
+ elm[STENCIL_SIGNALS_SYMBOL] = publicSignals;
2603
2747
  hostRef.$signalCleanup$ = () => {
2604
2748
  disposers.forEach((d) => d());
2605
2749
  elm[STENCIL_SIGNALS_SYMBOL] = void 0;
@@ -2648,22 +2792,28 @@ const h = (nodeName, vnodeData, ...children) => {
2648
2792
  for (let i = 0; i < c.length; i++) {
2649
2793
  child = c[i];
2650
2794
  if (Array.isArray(child)) walk(child);
2651
- else if (child != null && typeof child !== "boolean") if (BUILD$1.vdomSignals && isSignalLike(child)) {
2652
- const sigVNode = newVNode(null, String(child.peek()));
2653
- sigVNode.$signal$ = child;
2654
- vNodeChildren.push(sigVNode);
2655
- lastSimple = false;
2656
- } else {
2657
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
2658
- else if (BUILD$1.isDev && typeof nodeName !== "function" && child.$flags$ === void 0);
2659
- if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
2660
- else vNodeChildren.push(simple ? newVNode(null, child) : child);
2661
- lastSimple = simple;
2795
+ else if (child != null && typeof child !== "boolean") {
2796
+ if (BUILD$1.vdomSignals && isSignalLike(child)) {
2797
+ const sigVNode = newVNode(null, String(child.peek()));
2798
+ sigVNode.$signal$ = child;
2799
+ vNodeChildren.push(sigVNode);
2800
+ lastSimple = false;
2801
+ } else {
2802
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) child = String(child);
2803
+ else if (typeof nodeName !== "function" && child.$flags$ === void 0) {
2804
+ if (BUILD$1.isDev);
2805
+ else consoleError("Invalid vNode child");
2806
+ continue;
2807
+ }
2808
+ if (simple && lastSimple) vNodeChildren[vNodeChildren.length - 1].$text$ += child;
2809
+ else vNodeChildren.push(simple ? newVNode(null, child) : child);
2810
+ lastSimple = simple;
2811
+ }
2662
2812
  }
2663
2813
  }
2664
2814
  };
2665
2815
  walk(children);
2666
- if (vnodeData) {
2816
+ if (vnodeData && typeof vnodeData === "object") {
2667
2817
  if (BUILD$1.isDev && nodeName === "input") validateInputProperties(vnodeData);
2668
2818
  if (BUILD$1.vdomKey && vnodeData.key) key = vnodeData.key;
2669
2819
  if (BUILD$1.slotRelocation && vnodeData.name) slotName = vnodeData.name;
@@ -2762,7 +2912,7 @@ const convertToPrivate = (node) => {
2762
2912
  /**
2763
2913
  * Validates the ordering of attributes on an input element
2764
2914
  *
2765
- * @param inputElm the element to validate
2915
+ * @param inputElm the vnode data (JSX props) for the element to validate
2766
2916
  */
2767
2917
  const validateInputProperties = (inputElm) => {
2768
2918
  const props = Object.keys(inputElm);
@@ -3641,14 +3791,15 @@ const parsePropertyValue = (propValue, propType, isFormAssociated) => {
3641
3791
  /**
3642
3792
  * ensure this value is of the correct prop type
3643
3793
  */
3644
- if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
3645
- /**
3646
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
3647
- * (regardless of its value, even "false") should make the property true.
3648
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
3649
- */
3650
- if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
3651
- else return propValue === "false" ? false : propValue === "" || !!propValue;
3794
+ if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) {
3795
+ /**
3796
+ * For form-associated components, according to HTML spec, the presence of any boolean attribute
3797
+ * (regardless of its value, even "false") should make the property true.
3798
+ * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
3799
+ */
3800
+ if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
3801
+ else return propValue === "false" ? false : propValue === "" || !!propValue;
3802
+ }
3652
3803
  /**
3653
3804
  * force it to be a number
3654
3805
  */
@@ -3736,7 +3887,11 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3736
3887
  }
3737
3888
  if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
3738
3889
  if (instance.componentShouldUpdate) {
3739
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false && !(flags & HOST_FLAGS.isQueuedForUpdate)) return;
3890
+ const changes = hostRef.$queuedPropChanges$ ||= {};
3891
+ changes[propName] = {
3892
+ newVal,
3893
+ oldVal: changes[propName]?.oldVal ?? oldVal
3894
+ };
3740
3895
  }
3741
3896
  if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3742
3897
  }
@@ -3870,11 +4025,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3870
4025
  };
3871
4026
  for (const deserializer of cmpMeta.$deserializers$[propName]) {
3872
4027
  const [[methodName]] = Object.entries(deserializer);
3873
- if (BUILD$1.lazyLoad) if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
3874
- else hostRef.$fetchedCbList$.push(() => {
3875
- setVal(methodName, hostRef.$lazyInstance$);
3876
- });
3877
- else setVal(methodName, this);
4028
+ if (BUILD$1.lazyLoad) {
4029
+ if (hostRef.$lazyInstance$) setVal(methodName, hostRef.$lazyInstance$);
4030
+ else hostRef.$fetchedCbList$.push(() => {
4031
+ setVal(methodName, hostRef.$lazyInstance$);
4032
+ });
4033
+ } else setVal(methodName, this);
3878
4034
  }
3879
4035
  return;
3880
4036
  } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) return;
@@ -3898,7 +4054,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3898
4054
  if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
3899
4055
  });
3900
4056
  };
3901
- Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
4057
+ Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
3902
4058
  const attrName = m[1] || propName;
3903
4059
  attrNameToPropName.set(attrName, propName);
3904
4060
  if (BUILD$1.reflect && m[0] & MEMBER_FLAGS.ReflectAttr) cmpMeta.$attrsToReflect$?.push([propName, attrName]);
@@ -3925,6 +4081,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3925
4081
  try {
3926
4082
  if ((hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
3927
4083
  hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;
4084
+ hostRef.$flags$ &= ~HOST_FLAGS.hasFailedLoad;
3928
4085
  const bundleId = cmpMeta.$lazyBundleId$;
3929
4086
  if (BUILD$1.lazyLoad && bundleId) {
3930
4087
  const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
@@ -3933,7 +4090,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3933
4090
  Cstr = await CstrImport;
3934
4091
  endLoad();
3935
4092
  } else Cstr = CstrImport;
3936
- if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4093
+ if (!Cstr) {
4094
+ hostRef.$flags$ &= ~HOST_FLAGS.hasInitializedComponent;
4095
+ hostRef.$loadRetryCount$ = (hostRef.$loadRetryCount$ ?? 0) + 1;
4096
+ if (hostRef.$loadRetryCount$ < 3) hostRef.$flags$ |= HOST_FLAGS.hasFailedLoad;
4097
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4098
+ }
3937
4099
  if (BUILD$1.member && !Cstr.isProxied) {
3938
4100
  if (BUILD$1.propChangeCallback) {
3939
4101
  cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
@@ -3952,8 +4114,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3952
4114
  }
3953
4115
  if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
3954
4116
  endNewInstance();
3955
- if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) fireConnectedCallback(hostRef.$lazyInstance$, elm);
3956
- else hostRef.$deferredConnectedCallback$ = true;
4117
+ if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4118
+ if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4119
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4120
+ if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4121
+ } else queueMicrotask(() => {
4122
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
4123
+ if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4124
+ });
3957
4125
  } else Cstr = elm.constructor;
3958
4126
  if (BUILD$1.style && Cstr && Cstr.style) {
3959
4127
  /**
@@ -4012,7 +4180,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4012
4180
  hostRef.$onRenderResolve$();
4013
4181
  hostRef.$onRenderResolve$ = void 0;
4014
4182
  }
4015
- if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$) hostRef.$onReadyResolve$(elm);
4183
+ if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4184
+ if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
4016
4185
  }
4017
4186
  };
4018
4187
  const fireConnectedCallback = (instance, elm) => {
@@ -4075,6 +4244,7 @@ const connectedCallback = (elm) => {
4075
4244
  } else {
4076
4245
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
4077
4246
  if (hostRef?.$lazyInstance$) fireConnectedCallback(hostRef.$lazyInstance$, elm);
4247
+ else if (hostRef.$flags$ & HOST_FLAGS.hasFailedLoad) setTimeout(() => initializeComponent(elm, hostRef, cmpMeta), LAZY_LOAD_RETRY_INTERVAL_MS);
4078
4248
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
4079
4249
  }
4080
4250
  endConnected();
@@ -4104,6 +4274,7 @@ const disconnectedCallback = async (elm) => {
4104
4274
  hostRef.$signalCleanup$();
4105
4275
  hostRef.$signalCleanup$ = void 0;
4106
4276
  }
4277
+ if (BUILD$1.asyncLoading && hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) markFirstConnected(hostRef);
4107
4278
  if (!BUILD$1.lazyLoad) disconnectInstance(elm);
4108
4279
  else if (hostRef?.$lazyInstance$) disconnectInstance(hostRef.$lazyInstance$, elm);
4109
4280
  else if (hostRef?.$onReadyPromise$) hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
@@ -4151,7 +4322,6 @@ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
4151
4322
  };
4152
4323
  const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4153
4324
  const modulePath = hostElement.constructor.__stencil_module__;
4154
- console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
4155
4325
  if (!modulePath) {
4156
4326
  console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor - was this built with devMode?`);
4157
4327
  return;
@@ -4164,18 +4334,39 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4164
4334
  const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4165
4335
  if (!NewClass) return;
4166
4336
  const ctor = customElements.get(cmpMeta.$tagName$);
4167
- if (ctor) for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4168
- if (key === "constructor") continue;
4169
- Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4337
+ if (ctor) {
4338
+ for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4339
+ if (key === "constructor") continue;
4340
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4341
+ }
4342
+ const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4343
+ if (styleDesc) {
4344
+ Object.defineProperty(ctor, "style", styleDesc);
4345
+ const newStyle = NewClass.style;
4346
+ if (newStyle) {
4347
+ const scopeId = getScopeId(cmpMeta);
4348
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4349
+ console.log("[stencil-hmr] registerStyle", {
4350
+ tag: cmpMeta.$tagName$,
4351
+ scopeId,
4352
+ isShadow,
4353
+ cssLen: newStyle.length
4354
+ });
4355
+ registerStyle(scopeId, newStyle, isShadow);
4356
+ }
4357
+ }
4170
4358
  }
4359
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4171
4360
  document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4172
- if (BUILD$1.hostListener) {
4173
- const hostRef = getHostRef(el);
4174
- if (hostRef?.$rmListeners$) {
4175
- hostRef.$rmListeners$.map((rmListener) => rmListener());
4176
- hostRef.$rmListeners$ = void 0;
4177
- addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4178
- }
4361
+ const hostRef = getHostRef(el);
4362
+ if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
4363
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
4364
+ hostRef.$rmListeners$ = void 0;
4365
+ addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4366
+ }
4367
+ if (!isShadow && hostRef) {
4368
+ console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
4369
+ attachStyles(hostRef);
4179
4370
  }
4180
4371
  forceUpdate(el);
4181
4372
  });
@@ -4186,7 +4377,9 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4186
4377
  //#endregion
4187
4378
  //#region src/runtime/bootstrap-standalone.ts
4188
4379
  const defineCustomElement = (Cstr, compactMeta) => {
4189
- customElements.define(transformTag(compactMeta[1]), proxyCustomElement(Cstr, compactMeta));
4380
+ const tag = transformTag(compactMeta[1]);
4381
+ const proxied = proxyCustomElement(Cstr, compactMeta);
4382
+ if (!customElements.get(tag)) customElements.define(tag, proxied);
4190
4383
  };
4191
4384
  const proxyCustomElement = (Cstr, compactMeta) => {
4192
4385
  if (BUILD$1.profile && performance.mark && performance.getEntriesByName("st:app:start", "mark").length === 0) performance.mark("st:app:start");
@@ -4207,18 +4400,20 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4207
4400
  hmrStart(this, cmpMeta, hmrVersionId);
4208
4401
  };
4209
4402
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4210
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4211
- else {
4212
- if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4213
- if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4214
- patchSlotAppendChild(Cstr.prototype);
4215
- patchSlotAppend(Cstr.prototype);
4216
- patchSlotPrepend(Cstr.prototype);
4217
- patchSlotInsertAdjacentHTML(Cstr.prototype);
4218
- patchInsertBefore(Cstr.prototype);
4219
- patchSlotRemoveChild(Cstr.prototype);
4403
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4404
+ if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
4405
+ else {
4406
+ if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
4407
+ if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4408
+ patchSlotAppendChild(Cstr.prototype);
4409
+ patchSlotAppend(Cstr.prototype);
4410
+ patchSlotPrepend(Cstr.prototype);
4411
+ patchSlotInsertAdjacentHTML(Cstr.prototype);
4412
+ patchInsertBefore(Cstr.prototype);
4413
+ patchSlotRemoveChild(Cstr.prototype);
4414
+ }
4415
+ if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
4220
4416
  }
4221
- if (BUILD$1.slotTextContent) patchTextContent(Cstr.prototype);
4222
4417
  }
4223
4418
  if (BUILD$1.hydrateClientSide && BUILD$1.shadowDom) hydrateScopedToShadow();
4224
4419
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
@@ -4231,19 +4426,26 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4231
4426
  componentOnReady() {
4232
4427
  return getHostRef(this)?.$onReadyPromise$;
4233
4428
  },
4234
- connectedCallback() {
4235
- if (!this.__hasHostListenerAttached) {
4236
- const hostRef = getHostRef(this);
4429
+ async connectedCallback() {
4430
+ const isFirstConnect = !this.__hasHostListenerAttached;
4431
+ let hostRef;
4432
+ if (isFirstConnect) {
4433
+ hostRef = getHostRef(this);
4237
4434
  if (!hostRef) return;
4238
4435
  addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
4239
4436
  this.__hasHostListenerAttached = true;
4240
4437
  }
4241
4438
  connectedCallback(this);
4242
- if (originalConnectedCallback) originalConnectedCallback.call(this);
4439
+ if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4440
+ await awaitAncestorConnected(hostRef.$ancestorComponent$);
4441
+ if (!this.isConnected) return;
4442
+ }
4443
+ if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
4444
+ if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);
4243
4445
  },
4244
4446
  disconnectedCallback() {
4245
4447
  disconnectedCallback(this);
4246
- if (originalDisconnectedCallback) originalDisconnectedCallback.call(this);
4448
+ if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
4247
4449
  },
4248
4450
  __attachShadow() {
4249
4451
  const isClosed = BUILD$1.shadowModeClosed && !!(cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed);
@@ -4297,8 +4499,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4297
4499
  const exclude = options.exclude || [];
4298
4500
  const _reg = options.registry ?? getRegistry();
4299
4501
  const head = win.document.head;
4300
- const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
4301
- const dataStyles = /* @__PURE__ */ win.document.createElement("style");
4502
+ const metaCharset = /*@__PURE__*/ head.querySelector("meta[charset]");
4503
+ const dataStyles = /*@__PURE__*/ win.document.createElement("style");
4302
4504
  const deferredConnectedCallbacks = [];
4303
4505
  let appLoadFallback;
4304
4506
  let isBootstrapping = true;
@@ -4366,8 +4568,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4366
4568
  *
4367
4569
  * Also remove the reference from `deferredConnectedCallbacks` array
4368
4570
  * otherwise removed instances won't get garbage collected.
4571
+ *
4572
+ * Use `nextTick` (microtask) rather than `plt.raf` since
4573
+ * `requestAnimationFrame` callbacks do not fire while `document.hidden`
4369
4574
  */
4370
- plt.raf(() => {
4575
+ nextTick(() => {
4371
4576
  const hostRef = getHostRef(this);
4372
4577
  if (!hostRef) return;
4373
4578
  const i = deferredConnectedCallbacks.findIndex((host) => host === this);
@@ -4380,18 +4585,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4380
4585
  }
4381
4586
  };
4382
4587
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(HostElement.prototype);
4383
- if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4384
- else {
4385
- if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4386
- if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4387
- patchSlotAppendChild(HostElement.prototype);
4388
- patchSlotAppend(HostElement.prototype);
4389
- patchSlotPrepend(HostElement.prototype);
4390
- patchSlotInsertAdjacentHTML(HostElement.prototype);
4391
- patchInsertBefore(HostElement.prototype);
4392
- patchSlotRemoveChild(HostElement.prototype);
4588
+ if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4589
+ if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(HostElement.prototype);
4590
+ else {
4591
+ if (BUILD$1.slotChildNodes || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(HostElement.prototype);
4592
+ if (BUILD$1.slotDomMutations || BUILD$1.patchInsert && cmpMeta.$flags$ & CMP_FLAGS.patchInsert) {
4593
+ patchSlotAppendChild(HostElement.prototype);
4594
+ patchSlotAppend(HostElement.prototype);
4595
+ patchSlotPrepend(HostElement.prototype);
4596
+ patchSlotInsertAdjacentHTML(HostElement.prototype);
4597
+ patchInsertBefore(HostElement.prototype);
4598
+ patchSlotRemoveChild(HostElement.prototype);
4599
+ }
4600
+ if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
4393
4601
  }
4394
- if (BUILD$1.slotTextContent) patchTextContent(HostElement.prototype);
4395
4602
  }
4396
4603
  if (BUILD$1.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
4397
4604
  if (BUILD$1.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
@@ -4437,9 +4644,10 @@ const addHostEventListeners = (elm, hostRef, listeners) => {
4437
4644
  };
4438
4645
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
4439
4646
  try {
4440
- if (BUILD$1.lazyLoad) if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4441
- else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4442
- else hostRef.$hostElement$[methodName](ev);
4647
+ if (BUILD$1.lazyLoad) {
4648
+ if (hostRef.$flags$ & HOST_FLAGS.isListenReady) hostRef.$lazyInstance$?.[methodName](ev);
4649
+ else (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
4650
+ } else hostRef.$hostElement$[methodName](ev);
4443
4651
  } catch (e) {
4444
4652
  consoleError(e, hostRef.$hostElement$);
4445
4653
  }
@@ -4503,6 +4711,20 @@ function hasKeys(obj) {
4503
4711
  return false;
4504
4712
  }
4505
4713
  //#endregion
4714
+ //#region src/server/platform/h-async.ts
4715
+ const hAsync = (nodeName, vnodeData, ...children) => {
4716
+ if (Array.isArray(children) && children.length > 0) {
4717
+ const flatChildren = children.flat(Infinity);
4718
+ if (flatChildren.some((child) => child instanceof Promise)) return Promise.all(flatChildren).then((resolvedChildren) => {
4719
+ return h(nodeName, vnodeData, ...resolvedChildren);
4720
+ }).catch((err) => {
4721
+ return h(nodeName, vnodeData);
4722
+ });
4723
+ return h(nodeName, vnodeData, ...flatChildren);
4724
+ }
4725
+ return h(nodeName, vnodeData);
4726
+ };
4727
+ //#endregion
4506
4728
  //#region src/runtime/vdom/vdom-annotations.ts
4507
4729
  /**
4508
4730
  * Updates the DOM generated on the server with annotations such as node attributes and
@@ -4645,7 +4867,8 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
4645
4867
  const nodeName = parentNode?.nodeName;
4646
4868
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
4647
4869
  const textNodeId = `t.${childId}`;
4648
- insertBefore(parentNode, doc.createComment(textNodeId), childElm);
4870
+ const commentBeforeTextNode = doc.createComment(textNodeId);
4871
+ insertBefore(parentNode, commentBeforeTextNode, childElm);
4649
4872
  }
4650
4873
  } else if (childElm.nodeType === NODE_TYPE.CommentNode) {
4651
4874
  if (childElm["s-sr"]) childElm.nodeValue = `s.${childId}.${childElm["s-sn"] || ""}`;
@@ -4658,20 +4881,6 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
4658
4881
  }
4659
4882
  };
4660
4883
  //#endregion
4661
- //#region src/server/platform/h-async.ts
4662
- const hAsync = (nodeName, vnodeData, ...children) => {
4663
- if (Array.isArray(children) && children.length > 0) {
4664
- const flatChildren = children.flat(Infinity);
4665
- if (flatChildren.some((child) => child instanceof Promise)) return Promise.all(flatChildren).then((resolvedChildren) => {
4666
- return h(nodeName, vnodeData, ...resolvedChildren);
4667
- }).catch((err) => {
4668
- return h(nodeName, vnodeData);
4669
- });
4670
- return h(nodeName, vnodeData, ...flatChildren);
4671
- }
4672
- return h(nodeName, vnodeData);
4673
- };
4674
- //#endregion
4675
4884
  //#region src/server/platform/proxy-host-element.ts
4676
4885
  function proxyHostElement(elm, cstr) {
4677
4886
  const cmpMeta = cstr.cmpMeta;
@@ -4694,22 +4903,19 @@ function proxyHostElement(elm, cstr) {
4694
4903
  const propValue = elm[memberName];
4695
4904
  let attrPropVal;
4696
4905
  const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
4697
- if (attrValue != null) if (cmpMeta.$deserializers$?.[memberName]) for (const deserializer of cmpMeta.$deserializers$[memberName]) {
4698
- const [[methodName]] = Object.entries(deserializer);
4699
- attrPropVal = cstr.prototype[methodName](attrValue, memberName);
4906
+ if (attrValue != null) {
4907
+ if (cmpMeta.$deserializers$?.[memberName]) for (const deserializer of cmpMeta.$deserializers$[memberName]) {
4908
+ const [[methodName]] = Object.entries(deserializer);
4909
+ attrPropVal = cstr.prototype[methodName](attrValue, memberName);
4910
+ }
4911
+ else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4700
4912
  }
4701
- else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4702
4913
  if (propValue !== void 0) {
4703
4914
  attrPropVal = propValue;
4704
4915
  delete elm[memberName];
4705
4916
  }
4706
- if (attrPropVal !== void 0) {
4707
- if (origSetter) {
4708
- origSetter.apply(elm, [attrPropVal]);
4709
- attrPropVal = origGetter ? origGetter.apply(elm) : attrPropVal;
4710
- }
4711
- hostRef?.$instanceValues$?.set(memberName, attrPropVal);
4712
- }
4917
+ const userSetter = !cstr.isProxied ? origSetter : void 0;
4918
+ if (attrPropVal !== void 0 && !userSetter) hostRef?.$instanceValues$?.set(memberName, attrPropVal);
4713
4919
  const getterSetterDescriptor = {
4714
4920
  get: function() {
4715
4921
  return getValue(this, memberName);
@@ -4723,8 +4929,26 @@ function proxyHostElement(elm, cstr) {
4723
4929
  Object.defineProperty(elm, memberName, getterSetterDescriptor);
4724
4930
  Object.defineProperty(elm, metaAttributeName, getterSetterDescriptor);
4725
4931
  hostRef.$fetchedCbList$.push(() => {
4726
- if (!hostRef?.$instanceValues$?.has(memberName)) setValue(elm, memberName, attrPropVal !== void 0 ? attrPropVal : hostRef.$lazyInstance$[memberName], cmpMeta);
4727
- Object.defineProperty(hostRef.$lazyInstance$, memberName, getterSetterDescriptor);
4932
+ if (userSetter && attrPropVal !== void 0) {
4933
+ userSetter.apply(hostRef.$lazyInstance$, [attrPropVal]);
4934
+ const processedValue = origGetter ? origGetter.apply(hostRef.$lazyInstance$) : attrPropVal;
4935
+ setValue(elm, memberName, processedValue, cmpMeta);
4936
+ } else if (!hostRef?.$instanceValues$?.has(memberName)) setValue(elm, memberName, attrPropVal !== void 0 ? attrPropVal : hostRef.$lazyInstance$[memberName], cmpMeta);
4937
+ if (userSetter) Object.defineProperty(hostRef.$lazyInstance$, memberName, {
4938
+ get: origGetter ? function() {
4939
+ return origGetter.call(this);
4940
+ } : function() {
4941
+ return getValue(this, memberName);
4942
+ },
4943
+ set: function(newValue) {
4944
+ userSetter.call(this, newValue);
4945
+ newValue = origGetter ? origGetter.call(this) : newValue;
4946
+ setValue(elm, memberName, newValue, cmpMeta);
4947
+ },
4948
+ configurable: true,
4949
+ enumerable: true
4950
+ });
4951
+ else Object.defineProperty(hostRef.$lazyInstance$, memberName, getterSetterDescriptor);
4728
4952
  });
4729
4953
  } else if (memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(elm, memberName, { value(...args) {
4730
4954
  const ref = getHostRef(this);
@@ -4904,7 +5128,7 @@ function shouldHydrate(elm) {
4904
5128
  if (parentNode == null) return true;
4905
5129
  return shouldHydrate(parentNode);
4906
5130
  }
4907
- const NO_HYDRATE_TAGS = new Set([
5131
+ const NO_HYDRATE_TAGS = /* @__PURE__ */ new Set([
4908
5132
  "CODE",
4909
5133
  "HEAD",
4910
5134
  "IFRAME",
@@ -4933,9 +5157,11 @@ function renderCatchError(opts, results, err) {
4933
5157
  const u = new URL(opts.url);
4934
5158
  if (u.pathname !== "/") diagnostic.header += ": " + u.pathname;
4935
5159
  } catch {}
4936
- if (err != null) if (err.stack != null) diagnostic.messageText = err.stack.toString();
4937
- else if (err.message != null) diagnostic.messageText = err.message.toString();
4938
- else diagnostic.messageText = err.toString();
5160
+ if (err != null) {
5161
+ if (err.stack != null) diagnostic.messageText = err.stack.toString();
5162
+ else if (err.message != null) diagnostic.messageText = err.message.toString();
5163
+ else diagnostic.messageText = err.toString();
5164
+ }
4939
5165
  results.diagnostics.push(diagnostic);
4940
5166
  }
4941
5167
  function printTag(elm) {
@@ -5046,7 +5272,7 @@ const writeTask = (cb) => {
5046
5272
  }
5047
5273
  });
5048
5274
  };
5049
- const resolved = /* @__PURE__ */ Promise.resolve();
5275
+ const resolved = /*@__PURE__*/ Promise.resolve();
5050
5276
  const nextTick = (cb) => resolved.then(cb);
5051
5277
  const defaultConsoleError = (e) => {
5052
5278
  if (e != null) console.error(e.stack || e.message || e);