@stencil/core 5.0.0-rc.1 → 5.0.0-rc.11

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.
@@ -161,7 +161,11 @@ const HOST_FLAGS = {
161
161
  * coming from the runtime's own reflection aren't applied back to the prop.
162
162
  */
163
163
  isReflecting: 16384,
164
- devOnRender: 4096,
164
+ /**
165
+ * Set by `forceUpdate()` so the next update renders even if `componentShouldUpdate` returns `false`.
166
+ */
167
+ isUpdateForced: 4096,
168
+ devOnRender: 32768,
165
169
  devOnDidLoad: 8192
166
170
  };
167
171
  const CF_scopedCssEncapsulation = 2;
@@ -707,7 +711,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
707
711
  return toReturn;
708
712
  }
709
713
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
710
- return HostElementPrototype.__prepend(newChild);
714
+ return HostElementPrototype.__prepend.call(this, newChild);
711
715
  });
712
716
  };
713
717
  };
@@ -1350,7 +1354,7 @@ const attachStyles = (hostRef) => {
1350
1354
  else if (BUILD$1.hydrateServerSide && BUILD$1.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
1351
1355
  else styleContainerNode = elm.getRootNode();
1352
1356
  const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
1353
- if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
1357
+ if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
1354
1358
  elm["s-sc"] = scopeId;
1355
1359
  elm.classList.add(scopeId + "-h");
1356
1360
  }
@@ -1444,12 +1448,51 @@ const isComplexType = (o) => {
1444
1448
  return o === "object" || o === "function";
1445
1449
  };
1446
1450
  //#endregion
1447
- //#region src/runtime/signals-core.ts
1448
- const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
1449
- const effect = (fn, options) => getCore().effect(fn, options);
1450
- function signal(value, options) {
1451
- return getCore().signal(value, options);
1452
- }
1451
+ //#region src/runtime/parse-property-value.ts
1452
+ /**
1453
+ * Parse a new property value for a given property type.
1454
+ *
1455
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1456
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1457
+ * 1. `any`, the type given to `propValue` in the function signature
1458
+ * 2. the type stored from `propType`.
1459
+ *
1460
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1461
+ *
1462
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1463
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1464
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1465
+ * ```tsx
1466
+ * <my-cmp prop-val={0}></my-cmp>
1467
+ * ```
1468
+ *
1469
+ * HTML prop values on the other hand, will always a string
1470
+ *
1471
+ * @param propValue the new value to coerce to some type
1472
+ * @param propType the type of the prop, expressed as a binary number
1473
+ * @returns the parsed/coerced value
1474
+ */
1475
+ const parsePropertyValue = (propValue, propType) => {
1476
+ if (propValue != null && !isComplexType(propValue)) {
1477
+ /**
1478
+ * ensure this value is of the correct prop type
1479
+ */
1480
+ if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
1481
+ /**
1482
+ * force it to be a number
1483
+ */
1484
+ if (BUILD$1.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
1485
+ /**
1486
+ * could have been passed as a number or boolean but we still want it as a string
1487
+ */
1488
+ if (BUILD$1.propString && propType & MEMBER_FLAGS.String) return String(propValue);
1489
+ return propValue;
1490
+ }
1491
+ /**
1492
+ * not sure exactly what type we want so no need to change to a different type
1493
+ */
1494
+ return propValue;
1495
+ };
1453
1496
  //#endregion
1454
1497
  //#region src/runtime/event-emitter.ts
1455
1498
  const createEvent = (ref, name, flags) => {
@@ -2507,24 +2550,24 @@ const markFirstConnected = (hostRef) => {
2507
2550
  hostRef.$onFirstConnectResolve$ = void 0;
2508
2551
  };
2509
2552
  /**
2510
- * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
2511
- * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
2512
- * `connectedCallback` paths so a component never connects before its nearest Stencil
2513
- * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
2514
- * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
2515
- * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
2516
- * autoloader, where the ancestor tag may not be defined yet.
2553
+ * Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
2554
+ * completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
2555
+ * and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
2556
+ * connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
2557
+ * a returned promise, so a component whose ancestor is already connected carries on
2558
+ * synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
2559
+ * the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
2560
+ * tag may not be defined yet.
2517
2561
  *
2518
2562
  * @param ancestorElm the nearest Stencil ancestor element
2519
2563
  * @param registry the registry the waiting component is defined in
2564
+ * @returns a promise to await, or `undefined` if there's nothing to wait for
2520
2565
  */
2521
- const awaitAncestorConnected = async (ancestorElm, registry) => {
2522
- let ancestorHostRef = getHostRef(ancestorElm);
2523
- if (!BUILD$1.lazyLoad && !ancestorHostRef) {
2524
- await registry.whenDefined(ancestorElm.tagName.toLowerCase());
2525
- ancestorHostRef = getHostRef(ancestorElm);
2526
- }
2527
- if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
2566
+ const whenAncestorConnected = (ancestorElm, registry) => {
2567
+ const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
2568
+ const ancestorHostRef = getHostRef(ancestorElm);
2569
+ if (!BUILD$1.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
2570
+ return pendingConnect(ancestorHostRef);
2528
2571
  };
2529
2572
  const attachToAncestor = (hostRef, ancestorComponent) => {
2530
2573
  if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
@@ -2535,6 +2578,17 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
2535
2578
  if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
2536
2579
  }
2537
2580
  };
2581
+ /**
2582
+ * Release the ancestor waiting on this component's update (registered by {@link attachToAncestor}).
2583
+ *
2584
+ * @param hostRef the component's host reference
2585
+ */
2586
+ const resolveAncestorWait = (hostRef) => {
2587
+ if (BUILD$1.asyncLoading && hostRef.$onRenderResolve$) {
2588
+ hostRef.$onRenderResolve$();
2589
+ hostRef.$onRenderResolve$ = void 0;
2590
+ }
2591
+ };
2538
2592
  const scheduleUpdate = (hostRef, isInitialLoad) => {
2539
2593
  if (BUILD$1.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
2540
2594
  if (BUILD$1.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
@@ -2544,10 +2598,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
2544
2598
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2545
2599
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2546
2600
  if (isInitialLoad) {
2547
- const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2548
- if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
2549
2601
  queueMicrotask(() => {
2550
- dispatch();
2602
+ const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
2603
+ if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
2604
+ else dispatch();
2551
2605
  });
2552
2606
  return;
2553
2607
  }
@@ -2600,8 +2654,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
2600
2654
  if (BUILD$1.updatable && hostRef.$queuedPropChanges$) {
2601
2655
  const changes = hostRef.$queuedPropChanges$;
2602
2656
  hostRef.$queuedPropChanges$ = void 0;
2603
- if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
2657
+ if (safeCall(instance, "componentShouldUpdate", changes, elm) === false && !(hostRef.$flags$ & HOST_FLAGS.isUpdateForced)) {
2604
2658
  hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2659
+ resolveAncestorWait(hostRef);
2605
2660
  return;
2606
2661
  }
2607
2662
  }
@@ -2727,7 +2782,10 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
2727
2782
  * method, so we can call the method immediately. If not, check before calling it.
2728
2783
  */
2729
2784
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
2730
- if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
2785
+ if (updatable) {
2786
+ hostRef.$flags$ &= ~(HOST_FLAGS.isQueuedForUpdate | HOST_FLAGS.isUpdateForced);
2787
+ hostRef.$queuedPropChanges$ = void 0;
2788
+ }
2731
2789
  if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
2732
2790
  if (BUILD$1.hasRenderFn || BUILD$1.reflect) {
2733
2791
  if (BUILD$1.vdomRender || BUILD$1.reflect) {
@@ -2778,10 +2836,7 @@ const postUpdateComponent = (hostRef) => {
2778
2836
  }
2779
2837
  if (BUILD$1.method && BUILD$1.lazyLoad) hostRef.$onInstanceResolve$(elm);
2780
2838
  if (BUILD$1.asyncLoading) {
2781
- if (hostRef.$onRenderResolve$) {
2782
- hostRef.$onRenderResolve$();
2783
- hostRef.$onRenderResolve$ = void 0;
2784
- }
2839
+ resolveAncestorWait(hostRef);
2785
2840
  if (hostRef.$flags$ & HOST_FLAGS.needsRerender) nextTick(() => scheduleUpdate(hostRef, false));
2786
2841
  hostRef.$flags$ &= ~(HOST_FLAGS.isWaitingForChildren | HOST_FLAGS.needsRerender);
2787
2842
  }
@@ -2790,7 +2845,10 @@ const forceUpdate = (ref) => {
2790
2845
  if (BUILD$1.updatable && (Build.isBrowser || Build.isTesting)) {
2791
2846
  const hostRef = getHostRef(ref);
2792
2847
  const isConnected = hostRef?.$hostElement$?.isConnected;
2793
- if (isConnected && (hostRef.$flags$ & (HOST_FLAGS.hasRendered | HOST_FLAGS.isQueuedForUpdate)) === HOST_FLAGS.hasRendered) scheduleUpdate(hostRef, false);
2848
+ if (isConnected && hostRef.$flags$ & HOST_FLAGS.hasRendered) {
2849
+ hostRef.$flags$ |= HOST_FLAGS.isUpdateForced;
2850
+ if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
2851
+ }
2794
2852
  return isConnected;
2795
2853
  }
2796
2854
  return false;
@@ -2850,6 +2908,121 @@ const serverSideConnected = (elm) => {
2850
2908
  }
2851
2909
  };
2852
2910
  //#endregion
2911
+ //#region src/runtime/set-value.ts
2912
+ /**
2913
+ * The value a reflected prop writes to its attribute: the serialized value if it has one.
2914
+ * @param hostRef the component's host ref
2915
+ * @param propName the prop
2916
+ * @param val the prop's value
2917
+ * @returns the value to reflect
2918
+ */
2919
+ const getReflectedValue = (hostRef, propName, val) => BUILD$1.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
2920
+ /**
2921
+ * Write a reflected prop's attribute as soon as the prop changes, like native elements do,
2922
+ * so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
2923
+ * @param hostRef the component's host ref
2924
+ * @param cmpMeta the component's runtime metadata
2925
+ * @param elm the host element
2926
+ * @param propName the prop that changed
2927
+ * @param oldAttrVal the previously reflected value
2928
+ * @param newAttrVal the value to reflect
2929
+ */
2930
+ const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
2931
+ if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
2932
+ const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
2933
+ if (!attrName) return;
2934
+ if (BUILD$1.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
2935
+ setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
2936
+ if (BUILD$1.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
2937
+ };
2938
+ const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
2939
+ const run = (inst) => {
2940
+ let attrVal = val;
2941
+ for (const serializer of cmpMeta.$serializers$[propName]) {
2942
+ const [[methodName]] = Object.entries(serializer);
2943
+ attrVal = inst[methodName](attrVal, propName);
2944
+ }
2945
+ hostRef.$serializerValues$.set(propName, attrVal);
2946
+ };
2947
+ if (instance) run(instance);
2948
+ else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
2949
+ };
2950
+ const getValue = (ref, propName) => {
2951
+ if (BUILD$1.signalBacking) {
2952
+ const sig = getHostRef(ref)?.$signalValues$?.get(propName);
2953
+ if (sig !== void 0) return sig.value;
2954
+ }
2955
+ return getHostRef(ref).$instanceValues$.get(propName);
2956
+ };
2957
+ const setValue = (ref, propName, newVal, cmpMeta) => {
2958
+ const hostRef = getHostRef(ref);
2959
+ if (BUILD$1.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
2960
+ if (BUILD$1.signalBacking) {
2961
+ const sig = hostRef?.$signalValues$?.get(propName);
2962
+ if (sig !== void 0) {
2963
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2964
+ if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
2965
+ const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
2966
+ applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
2967
+ }
2968
+ if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
2969
+ return;
2970
+ }
2971
+ }
2972
+ if (!hostRef) {
2973
+ if (BUILD$1.lazyLoad) throw new Error(BUILD$1.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
2974
+ return;
2975
+ }
2976
+ const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
2977
+ const oldVal = hostRef.$instanceValues$.get(propName);
2978
+ const flags = hostRef.$flags$;
2979
+ const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
2980
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2981
+ const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
2982
+ if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
2983
+ hostRef.$instanceValues$.set(propName, newVal);
2984
+ const oldAttrVal = BUILD$1.reflect && getReflectedValue(hostRef, propName, oldVal);
2985
+ if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
2986
+ if (BUILD$1.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
2987
+ if (BUILD$1.isDev) {
2988
+ if (hostRef.$flags$ & HOST_FLAGS.devOnRender) `${propName}`;
2989
+ else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) `${propName}`;
2990
+ }
2991
+ if (BUILD$1.propChangeCallback && cmpMeta.$watchers$) {
2992
+ const watchMethods = cmpMeta.$watchers$[propName];
2993
+ if (watchMethods) watchMethods.map((watcher) => {
2994
+ try {
2995
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
2996
+ if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
2997
+ if (BUILD$1.signalBacking && !hostRef.$signalValues$) return;
2998
+ if (!instance) hostRef.$fetchedCbList$.push(() => {
2999
+ hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
3000
+ });
3001
+ else instance[watchMethodName](newVal, oldVal, propName);
3002
+ }
3003
+ } catch (e) {
3004
+ consoleError(e, elm);
3005
+ }
3006
+ });
3007
+ }
3008
+ if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
3009
+ if (instance.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[propName] ||= {
3010
+ oldVal,
3011
+ newVal
3012
+ }).newVal = newVal;
3013
+ if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3014
+ }
3015
+ }
3016
+ };
3017
+ //#endregion
3018
+ //#region src/runtime/signals-core.ts
3019
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
3020
+ const effect = (fn, options) => getCore().effect(fn, options);
3021
+ const untracked = (fn) => getCore().untracked(fn);
3022
+ function signal(value, options) {
3023
+ return getCore().signal(value, options);
3024
+ }
3025
+ //#endregion
2853
3026
  //#region src/runtime/signals.ts
2854
3027
  const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
2855
3028
  /**
@@ -2883,17 +3056,22 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
2883
3056
  disposers.push(effect(() => {
2884
3057
  const newVal = sig.value;
2885
3058
  if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
2886
- if (instance?.componentShouldUpdate) {
2887
- const changes = hostRef.$queuedPropChanges$ ||= {};
2888
- changes[memberName] = {
2889
- newVal,
2890
- oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
2891
- };
2892
- }
3059
+ if (instance?.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[memberName] ||= {
3060
+ oldVal: prevScheduleVal,
3061
+ newVal
3062
+ }).newVal = newVal;
2893
3063
  if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
2894
3064
  }
2895
3065
  prevScheduleVal = newVal;
2896
3066
  }));
3067
+ if (BUILD$1.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
3068
+ let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
3069
+ disposers.push(effect(() => {
3070
+ const attrVal = getReflectedValue(hostRef, memberName, sig.value);
3071
+ untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
3072
+ prevAttrVal = attrVal;
3073
+ }));
3074
+ }
2897
3075
  if (BUILD$1.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
2898
3076
  const watchMethods = cmpMeta.$watchers$[memberName];
2899
3077
  let prevWatchVal = sig.peek();
@@ -2962,7 +3140,7 @@ const initializeEffects = (elm, hostRef) => {
2962
3140
  * Modified for Stencil's compiler and vdom
2963
3141
  */
2964
3142
  const h = (nodeName, vnodeData, ...children) => {
2965
- if (typeof nodeName === "string") nodeName = transformTag(nodeName);
3143
+ if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
2966
3144
  let child = null;
2967
3145
  let key = null;
2968
3146
  let slotName = null;
@@ -3138,7 +3316,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3138
3316
  let scopeId;
3139
3317
  if (BUILD$1.scoped) {
3140
3318
  const cmpMeta = hostRef.$cmpMeta$;
3141
- if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
3319
+ if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
3142
3320
  scopeId = hostElm["s-sc"];
3143
3321
  hostElm.classList.add(scopeId + "-h");
3144
3322
  } else if (hostElm["s-sc"]) delete hostElm["s-sc"];
@@ -3434,7 +3612,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
3434
3612
  if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
3435
3613
  do {
3436
3614
  const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
3437
- if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
3615
+ if ((slottedNode["getAttribute"] && slottedNode.getAttribute("s-sn")) === slotName || (sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
3438
3616
  slottedNode["s-sn"] = slotName;
3439
3617
  group.push({
3440
3618
  slot: slotNode,
@@ -3956,134 +4134,6 @@ const normalizeWatchers = (raw) => {
3956
4134
  return out;
3957
4135
  };
3958
4136
  //#endregion
3959
- //#region src/runtime/parse-property-value.ts
3960
- /**
3961
- * Parse a new property value for a given property type.
3962
- *
3963
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
3964
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
3965
- * 1. `any`, the type given to `propValue` in the function signature
3966
- * 2. the type stored from `propType`.
3967
- *
3968
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
3969
- *
3970
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
3971
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
3972
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
3973
- * ```tsx
3974
- * <my-cmp prop-val={0}></my-cmp>
3975
- * ```
3976
- *
3977
- * HTML prop values on the other hand, will always a string
3978
- *
3979
- * @param propValue the new value to coerce to some type
3980
- * @param propType the type of the prop, expressed as a binary number
3981
- * @returns the parsed/coerced value
3982
- */
3983
- const parsePropertyValue = (propValue, propType) => {
3984
- if (propValue != null && !isComplexType(propValue)) {
3985
- /**
3986
- * ensure this value is of the correct prop type
3987
- */
3988
- if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
3989
- /**
3990
- * force it to be a number
3991
- */
3992
- if (BUILD$1.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
3993
- /**
3994
- * could have been passed as a number or boolean but we still want it as a string
3995
- */
3996
- if (BUILD$1.propString && propType & MEMBER_FLAGS.String) return String(propValue);
3997
- return propValue;
3998
- }
3999
- /**
4000
- * not sure exactly what type we want so no need to change to a different type
4001
- */
4002
- return propValue;
4003
- };
4004
- //#endregion
4005
- //#region src/runtime/set-value.ts
4006
- const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
4007
- const run = (inst) => {
4008
- let attrVal = val;
4009
- for (const serializer of cmpMeta.$serializers$[propName]) {
4010
- const [[methodName]] = Object.entries(serializer);
4011
- attrVal = inst[methodName](attrVal, propName);
4012
- }
4013
- hostRef.$serializerValues$.set(propName, attrVal);
4014
- };
4015
- if (instance) run(instance);
4016
- else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
4017
- };
4018
- const getValue = (ref, propName) => {
4019
- if (BUILD$1.signalBacking) {
4020
- const sig = getHostRef(ref)?.$signalValues$?.get(propName);
4021
- if (sig !== void 0) return sig.value;
4022
- }
4023
- return getHostRef(ref).$instanceValues$.get(propName);
4024
- };
4025
- const setValue = (ref, propName, newVal, cmpMeta) => {
4026
- const hostRef = getHostRef(ref);
4027
- if (BUILD$1.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
4028
- if (BUILD$1.signalBacking) {
4029
- const sig = hostRef?.$signalValues$?.get(propName);
4030
- if (sig !== void 0) {
4031
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4032
- if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
4033
- const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
4034
- applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
4035
- }
4036
- if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
4037
- return;
4038
- }
4039
- }
4040
- if (!hostRef) {
4041
- if (BUILD$1.lazyLoad) throw new Error(BUILD$1.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
4042
- return;
4043
- }
4044
- const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
4045
- const oldVal = hostRef.$instanceValues$.get(propName);
4046
- const flags = hostRef.$flags$;
4047
- const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
4048
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4049
- const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
4050
- if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
4051
- hostRef.$instanceValues$.set(propName, newVal);
4052
- if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
4053
- if (BUILD$1.isDev) {
4054
- if (hostRef.$flags$ & HOST_FLAGS.devOnRender) `${propName}`;
4055
- else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) `${propName}`;
4056
- }
4057
- if (BUILD$1.propChangeCallback && cmpMeta.$watchers$) {
4058
- const watchMethods = cmpMeta.$watchers$[propName];
4059
- if (watchMethods) watchMethods.map((watcher) => {
4060
- try {
4061
- const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
4062
- if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
4063
- if (BUILD$1.signalBacking && !hostRef.$signalValues$) return;
4064
- if (!instance) hostRef.$fetchedCbList$.push(() => {
4065
- hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
4066
- });
4067
- else instance[watchMethodName](newVal, oldVal, propName);
4068
- }
4069
- } catch (e) {
4070
- consoleError(e, elm);
4071
- }
4072
- });
4073
- }
4074
- if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
4075
- if (instance.componentShouldUpdate) {
4076
- const changes = hostRef.$queuedPropChanges$ ||= {};
4077
- changes[propName] = {
4078
- newVal,
4079
- oldVal: changes[propName]?.oldVal ?? oldVal
4080
- };
4081
- }
4082
- if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
4083
- }
4084
- }
4085
- };
4086
- //#endregion
4087
4137
  //#region src/runtime/proxy-component.ts
4088
4138
  /**
4089
4139
  * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
@@ -4326,7 +4376,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4326
4376
  replayPendingSetterValues(hostRef, cmpMeta);
4327
4377
  }
4328
4378
  endNewInstance();
4329
- if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4379
+ if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) {
4380
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
4381
+ if (ancestorConnected) await ancestorConnected;
4382
+ }
4330
4383
  if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
4331
4384
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
4332
4385
  if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
@@ -4388,10 +4441,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4388
4441
  else schedule();
4389
4442
  } catch (e) {
4390
4443
  consoleError(e, elm);
4391
- if (BUILD$1.asyncLoading && hostRef.$onRenderResolve$) {
4392
- hostRef.$onRenderResolve$();
4393
- hostRef.$onRenderResolve$ = void 0;
4394
- }
4444
+ resolveAncestorWait(hostRef);
4395
4445
  if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
4396
4446
  if (BUILD$1.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
4397
4447
  }
@@ -4727,8 +4777,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4727
4777
  }
4728
4778
  connectedCallback(this);
4729
4779
  if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
4730
- await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
4731
- if (!this.isConnected) return;
4780
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
4781
+ if (ancestorConnected) {
4782
+ await ancestorConnected;
4783
+ if (!this.isConnected) return;
4784
+ }
4732
4785
  }
4733
4786
  if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
4734
4787
  if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);