@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.
@@ -33,7 +33,7 @@ import "@rollup/pluginutils";
33
33
  import { createHash } from "crypto";
34
34
  import { afterAll, vi } from "vitest";
35
35
  //#region src/version.ts
36
- const version = "5.0.0-rc.1";
36
+ const version = "5.0.0-rc.11";
37
37
  const MEMBER_FLAGS = {
38
38
  String: 1,
39
39
  Number: 2,
@@ -93,7 +93,11 @@ const HOST_FLAGS = {
93
93
  * coming from the runtime's own reflection aren't applied back to the prop.
94
94
  */
95
95
  isReflecting: 16384,
96
- devOnRender: 4096,
96
+ /**
97
+ * Set by `forceUpdate()` so the next update renders even if `componentShouldUpdate` returns `false`.
98
+ */
99
+ isUpdateForced: 4096,
100
+ devOnRender: 32768,
97
101
  devOnDidLoad: 8192
98
102
  };
99
103
  const CF_scopedCssEncapsulation = 2;
@@ -1545,7 +1549,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
1545
1549
  return toReturn;
1546
1550
  }
1547
1551
  if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
1548
- return HostElementPrototype.__prepend(newChild);
1552
+ return HostElementPrototype.__prepend.call(this, newChild);
1549
1553
  });
1550
1554
  };
1551
1555
  };
@@ -2157,7 +2161,7 @@ const attachStyles = (hostRef) => {
2157
2161
  else if (BUILD.hydrateServerSide && BUILD.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
2158
2162
  else styleContainerNode = elm.getRootNode();
2159
2163
  const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
2160
- if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
2164
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
2161
2165
  elm["s-sc"] = scopeId;
2162
2166
  elm.classList.add(scopeId + "-h");
2163
2167
  }
@@ -2224,12 +2228,51 @@ const hydrateScopedToShadow = (cmpMetas) => {
2224
2228
  }
2225
2229
  };
2226
2230
  //#endregion
2227
- //#region src/runtime/signals-core.ts
2228
- const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
2229
- const effect = (fn, options) => getCore().effect(fn, options);
2230
- function signal(value, options) {
2231
- return getCore().signal(value, options);
2232
- }
2231
+ //#region src/runtime/parse-property-value.ts
2232
+ /**
2233
+ * Parse a new property value for a given property type.
2234
+ *
2235
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
2236
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
2237
+ * 1. `any`, the type given to `propValue` in the function signature
2238
+ * 2. the type stored from `propType`.
2239
+ *
2240
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
2241
+ *
2242
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
2243
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
2244
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
2245
+ * ```tsx
2246
+ * <my-cmp prop-val={0}></my-cmp>
2247
+ * ```
2248
+ *
2249
+ * HTML prop values on the other hand, will always a string
2250
+ *
2251
+ * @param propValue the new value to coerce to some type
2252
+ * @param propType the type of the prop, expressed as a binary number
2253
+ * @returns the parsed/coerced value
2254
+ */
2255
+ const parsePropertyValue = (propValue, propType) => {
2256
+ if (propValue != null && !isComplexType(propValue)) {
2257
+ /**
2258
+ * ensure this value is of the correct prop type
2259
+ */
2260
+ if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
2261
+ /**
2262
+ * force it to be a number
2263
+ */
2264
+ if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
2265
+ /**
2266
+ * could have been passed as a number or boolean but we still want it as a string
2267
+ */
2268
+ if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
2269
+ return propValue;
2270
+ }
2271
+ /**
2272
+ * not sure exactly what type we want so no need to change to a different type
2273
+ */
2274
+ return propValue;
2275
+ };
2233
2276
  const getRegistry = () => globalThis.customElements;
2234
2277
  /**
2235
2278
  * @param elm a defined component host
@@ -3261,24 +3304,24 @@ const markFirstConnected = (hostRef) => {
3261
3304
  hostRef.$onFirstConnectResolve$ = void 0;
3262
3305
  };
3263
3306
  /**
3264
- * Wait for `ancestorElm` to be defined and its real `connectedCallback` to have completed.
3265
- * Shared by the lazy ({@link initializeComponent}) and standalone (`bootstrap-standalone.ts`)
3266
- * `connectedCallback` paths so a component never connects before its nearest Stencil
3267
- * ancestor, regardless of load order. Both call sites already check `BUILD.asyncLoading` and
3268
- * that an ancestor exists before calling this. Lazy's proxy classes are always pre-defined,
3269
- * so the `whenDefined` wait is a no-op there - it only does real work for standalone's
3270
- * autoloader, where the ancestor tag may not be defined yet.
3307
+ * Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
3308
+ * completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
3309
+ * and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
3310
+ * connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
3311
+ * a returned promise, so a component whose ancestor is already connected carries on
3312
+ * synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
3313
+ * the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
3314
+ * tag may not be defined yet.
3271
3315
  *
3272
3316
  * @param ancestorElm the nearest Stencil ancestor element
3273
3317
  * @param registry the registry the waiting component is defined in
3318
+ * @returns a promise to await, or `undefined` if there's nothing to wait for
3274
3319
  */
3275
- const awaitAncestorConnected = async (ancestorElm, registry) => {
3276
- let ancestorHostRef = getHostRef(ancestorElm);
3277
- if (!BUILD.lazyLoad && !ancestorHostRef) {
3278
- await registry.whenDefined(ancestorElm.tagName.toLowerCase());
3279
- ancestorHostRef = getHostRef(ancestorElm);
3280
- }
3281
- if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
3320
+ const whenAncestorConnected = (ancestorElm, registry) => {
3321
+ const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
3322
+ const ancestorHostRef = getHostRef(ancestorElm);
3323
+ if (!BUILD.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
3324
+ return pendingConnect(ancestorHostRef);
3282
3325
  };
3283
3326
  const attachToAncestor = (hostRef, ancestorComponent) => {
3284
3327
  if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
@@ -3289,6 +3332,17 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
3289
3332
  if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
3290
3333
  }
3291
3334
  };
3335
+ /**
3336
+ * Release the ancestor waiting on this component's update (registered by {@link attachToAncestor}).
3337
+ *
3338
+ * @param hostRef the component's host reference
3339
+ */
3340
+ const resolveAncestorWait = (hostRef) => {
3341
+ if (BUILD.asyncLoading && hostRef.$onRenderResolve$) {
3342
+ hostRef.$onRenderResolve$();
3343
+ hostRef.$onRenderResolve$ = void 0;
3344
+ }
3345
+ };
3292
3346
  const scheduleUpdate = (hostRef, isInitialLoad) => {
3293
3347
  if (BUILD.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
3294
3348
  if (BUILD.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
@@ -3298,10 +3352,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
3298
3352
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
3299
3353
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
3300
3354
  if (isInitialLoad) {
3301
- const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
3302
- if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
3303
3355
  queueMicrotask(() => {
3304
- dispatch();
3356
+ const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
3357
+ if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
3358
+ else dispatch();
3305
3359
  });
3306
3360
  return;
3307
3361
  }
@@ -3354,8 +3408,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
3354
3408
  if (BUILD.updatable && hostRef.$queuedPropChanges$) {
3355
3409
  const changes = hostRef.$queuedPropChanges$;
3356
3410
  hostRef.$queuedPropChanges$ = void 0;
3357
- if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
3411
+ if (safeCall(instance, "componentShouldUpdate", changes, elm) === false && !(hostRef.$flags$ & HOST_FLAGS.isUpdateForced)) {
3358
3412
  hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
3413
+ resolveAncestorWait(hostRef);
3359
3414
  return;
3360
3415
  }
3361
3416
  }
@@ -3481,7 +3536,10 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
3481
3536
  * method, so we can call the method immediately. If not, check before calling it.
3482
3537
  */
3483
3538
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
3484
- if (updatable) hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
3539
+ if (updatable) {
3540
+ hostRef.$flags$ &= ~(HOST_FLAGS.isQueuedForUpdate | HOST_FLAGS.isUpdateForced);
3541
+ hostRef.$queuedPropChanges$ = void 0;
3542
+ }
3485
3543
  if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
3486
3544
  if (BUILD.hasRenderFn || BUILD.reflect) {
3487
3545
  if (BUILD.vdomRender || BUILD.reflect) {
@@ -3532,10 +3590,7 @@ const postUpdateComponent = (hostRef) => {
3532
3590
  }
3533
3591
  if (BUILD.method && BUILD.lazyLoad) hostRef.$onInstanceResolve$(elm);
3534
3592
  if (BUILD.asyncLoading) {
3535
- if (hostRef.$onRenderResolve$) {
3536
- hostRef.$onRenderResolve$();
3537
- hostRef.$onRenderResolve$ = void 0;
3538
- }
3593
+ resolveAncestorWait(hostRef);
3539
3594
  if (hostRef.$flags$ & HOST_FLAGS.needsRerender) nextTick(() => scheduleUpdate(hostRef, false));
3540
3595
  hostRef.$flags$ &= ~(HOST_FLAGS.isWaitingForChildren | HOST_FLAGS.needsRerender);
3541
3596
  }
@@ -3544,7 +3599,10 @@ const forceUpdate = (ref) => {
3544
3599
  if (BUILD.updatable && (Build.isBrowser || Build.isTesting)) {
3545
3600
  const hostRef = getHostRef(ref);
3546
3601
  const isConnected = hostRef?.$hostElement$?.isConnected;
3547
- if (isConnected && (hostRef.$flags$ & (HOST_FLAGS.hasRendered | HOST_FLAGS.isQueuedForUpdate)) === HOST_FLAGS.hasRendered) scheduleUpdate(hostRef, false);
3602
+ if (isConnected && hostRef.$flags$ & HOST_FLAGS.hasRendered) {
3603
+ hostRef.$flags$ |= HOST_FLAGS.isUpdateForced;
3604
+ if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3605
+ }
3548
3606
  return isConnected;
3549
3607
  }
3550
3608
  return false;
@@ -3604,6 +3662,121 @@ const serverSideConnected = (elm) => {
3604
3662
  }
3605
3663
  };
3606
3664
  //#endregion
3665
+ //#region src/runtime/set-value.ts
3666
+ /**
3667
+ * The value a reflected prop writes to its attribute: the serialized value if it has one.
3668
+ * @param hostRef the component's host ref
3669
+ * @param propName the prop
3670
+ * @param val the prop's value
3671
+ * @returns the value to reflect
3672
+ */
3673
+ const getReflectedValue = (hostRef, propName, val) => BUILD.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
3674
+ /**
3675
+ * Write a reflected prop's attribute as soon as the prop changes, like native elements do,
3676
+ * so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
3677
+ * @param hostRef the component's host ref
3678
+ * @param cmpMeta the component's runtime metadata
3679
+ * @param elm the host element
3680
+ * @param propName the prop that changed
3681
+ * @param oldAttrVal the previously reflected value
3682
+ * @param newAttrVal the value to reflect
3683
+ */
3684
+ const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
3685
+ if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
3686
+ const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
3687
+ if (!attrName) return;
3688
+ if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
3689
+ setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
3690
+ if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
3691
+ };
3692
+ const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
3693
+ const run = (inst) => {
3694
+ let attrVal = val;
3695
+ for (const serializer of cmpMeta.$serializers$[propName]) {
3696
+ const [[methodName]] = Object.entries(serializer);
3697
+ attrVal = inst[methodName](attrVal, propName);
3698
+ }
3699
+ hostRef.$serializerValues$.set(propName, attrVal);
3700
+ };
3701
+ if (instance) run(instance);
3702
+ else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
3703
+ };
3704
+ const getValue = (ref, propName) => {
3705
+ if (BUILD.signalBacking) {
3706
+ const sig = getHostRef(ref)?.$signalValues$?.get(propName);
3707
+ if (sig !== void 0) return sig.value;
3708
+ }
3709
+ return getHostRef(ref).$instanceValues$.get(propName);
3710
+ };
3711
+ const setValue = (ref, propName, newVal, cmpMeta) => {
3712
+ const hostRef = getHostRef(ref);
3713
+ if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
3714
+ if (BUILD.signalBacking) {
3715
+ const sig = hostRef?.$signalValues$?.get(propName);
3716
+ if (sig !== void 0) {
3717
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3718
+ if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
3719
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
3720
+ applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
3721
+ }
3722
+ if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
3723
+ return;
3724
+ }
3725
+ }
3726
+ if (!hostRef) {
3727
+ if (BUILD.lazyLoad) throw new Error(BUILD.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$}"`);
3728
+ return;
3729
+ }
3730
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
3731
+ const oldVal = hostRef.$instanceValues$.get(propName);
3732
+ const flags = hostRef.$flags$;
3733
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3734
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3735
+ const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
3736
+ if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
3737
+ hostRef.$instanceValues$.set(propName, newVal);
3738
+ const oldAttrVal = BUILD.reflect && getReflectedValue(hostRef, propName, oldVal);
3739
+ if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
3740
+ if (BUILD.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
3741
+ if (BUILD.isDev) {
3742
+ if (hostRef.$flags$ & HOST_FLAGS.devOnRender) consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
3743
+ else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
3744
+ }
3745
+ if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
3746
+ const watchMethods = cmpMeta.$watchers$[propName];
3747
+ if (watchMethods) watchMethods.map((watcher) => {
3748
+ try {
3749
+ const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
3750
+ if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
3751
+ if (BUILD.signalBacking && !hostRef.$signalValues$) return;
3752
+ if (!instance) hostRef.$fetchedCbList$.push(() => {
3753
+ hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
3754
+ });
3755
+ else instance[watchMethodName](newVal, oldVal, propName);
3756
+ }
3757
+ } catch (e) {
3758
+ consoleError(e, elm);
3759
+ }
3760
+ });
3761
+ }
3762
+ if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
3763
+ if (instance.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[propName] ||= {
3764
+ oldVal,
3765
+ newVal
3766
+ }).newVal = newVal;
3767
+ if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3768
+ }
3769
+ }
3770
+ };
3771
+ //#endregion
3772
+ //#region src/runtime/signals-core.ts
3773
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
3774
+ const effect = (fn, options) => getCore().effect(fn, options);
3775
+ const untracked = (fn) => getCore().untracked(fn);
3776
+ function signal(value, options) {
3777
+ return getCore().signal(value, options);
3778
+ }
3779
+ //#endregion
3607
3780
  //#region src/runtime/signals.ts
3608
3781
  const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
3609
3782
  /**
@@ -3637,17 +3810,22 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
3637
3810
  disposers.push(effect(() => {
3638
3811
  const newVal = sig.value;
3639
3812
  if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
3640
- if (instance?.componentShouldUpdate) {
3641
- const changes = hostRef.$queuedPropChanges$ ||= {};
3642
- changes[memberName] = {
3643
- newVal,
3644
- oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
3645
- };
3646
- }
3813
+ if (instance?.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[memberName] ||= {
3814
+ oldVal: prevScheduleVal,
3815
+ newVal
3816
+ }).newVal = newVal;
3647
3817
  if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
3648
3818
  }
3649
3819
  prevScheduleVal = newVal;
3650
3820
  }));
3821
+ if (BUILD.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
3822
+ let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
3823
+ disposers.push(effect(() => {
3824
+ const attrVal = getReflectedValue(hostRef, memberName, sig.value);
3825
+ untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
3826
+ prevAttrVal = attrVal;
3827
+ }));
3828
+ }
3651
3829
  if (BUILD.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
3652
3830
  const watchMethods = cmpMeta.$watchers$[memberName];
3653
3831
  let prevWatchVal = sig.peek();
@@ -3716,7 +3894,7 @@ const initializeEffects = (elm, hostRef) => {
3716
3894
  * Modified for Stencil's compiler and vdom
3717
3895
  */
3718
3896
  const h = (nodeName, vnodeData, ...children) => {
3719
- if (typeof nodeName === "string") nodeName = transformTag(nodeName);
3897
+ if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
3720
3898
  let child = null;
3721
3899
  let key = null;
3722
3900
  let slotName = null;
@@ -3894,7 +4072,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
3894
4072
  let scopeId;
3895
4073
  if (BUILD.scoped) {
3896
4074
  const cmpMeta = hostRef.$cmpMeta$;
3897
- if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
4075
+ if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
3898
4076
  scopeId = hostElm["s-sc"];
3899
4077
  hostElm.classList.add(scopeId + "-h");
3900
4078
  } else if (hostElm["s-sc"]) delete hostElm["s-sc"];
@@ -4190,7 +4368,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
4190
4368
  if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
4191
4369
  do {
4192
4370
  const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
4193
- if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
4371
+ 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)) {
4194
4372
  slottedNode["s-sn"] = slotName;
4195
4373
  group.push({
4196
4374
  slot: slotNode,
@@ -4697,134 +4875,6 @@ const normalizeWatchers = (raw) => {
4697
4875
  return out;
4698
4876
  };
4699
4877
  //#endregion
4700
- //#region src/runtime/parse-property-value.ts
4701
- /**
4702
- * Parse a new property value for a given property type.
4703
- *
4704
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
4705
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
4706
- * 1. `any`, the type given to `propValue` in the function signature
4707
- * 2. the type stored from `propType`.
4708
- *
4709
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
4710
- *
4711
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
4712
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
4713
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
4714
- * ```tsx
4715
- * <my-cmp prop-val={0}></my-cmp>
4716
- * ```
4717
- *
4718
- * HTML prop values on the other hand, will always a string
4719
- *
4720
- * @param propValue the new value to coerce to some type
4721
- * @param propType the type of the prop, expressed as a binary number
4722
- * @returns the parsed/coerced value
4723
- */
4724
- const parsePropertyValue = (propValue, propType) => {
4725
- if (propValue != null && !isComplexType(propValue)) {
4726
- /**
4727
- * ensure this value is of the correct prop type
4728
- */
4729
- if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
4730
- /**
4731
- * force it to be a number
4732
- */
4733
- if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
4734
- /**
4735
- * could have been passed as a number or boolean but we still want it as a string
4736
- */
4737
- if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
4738
- return propValue;
4739
- }
4740
- /**
4741
- * not sure exactly what type we want so no need to change to a different type
4742
- */
4743
- return propValue;
4744
- };
4745
- //#endregion
4746
- //#region src/runtime/set-value.ts
4747
- const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
4748
- const run = (inst) => {
4749
- let attrVal = val;
4750
- for (const serializer of cmpMeta.$serializers$[propName]) {
4751
- const [[methodName]] = Object.entries(serializer);
4752
- attrVal = inst[methodName](attrVal, propName);
4753
- }
4754
- hostRef.$serializerValues$.set(propName, attrVal);
4755
- };
4756
- if (instance) run(instance);
4757
- else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
4758
- };
4759
- const getValue = (ref, propName) => {
4760
- if (BUILD.signalBacking) {
4761
- const sig = getHostRef(ref)?.$signalValues$?.get(propName);
4762
- if (sig !== void 0) return sig.value;
4763
- }
4764
- return getHostRef(ref).$instanceValues$.get(propName);
4765
- };
4766
- const setValue = (ref, propName, newVal, cmpMeta) => {
4767
- const hostRef = getHostRef(ref);
4768
- if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
4769
- if (BUILD.signalBacking) {
4770
- const sig = hostRef?.$signalValues$?.get(propName);
4771
- if (sig !== void 0) {
4772
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4773
- if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
4774
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
4775
- applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
4776
- }
4777
- if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
4778
- return;
4779
- }
4780
- }
4781
- if (!hostRef) {
4782
- if (BUILD.lazyLoad) throw new Error(BUILD.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$}"`);
4783
- return;
4784
- }
4785
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
4786
- const oldVal = hostRef.$instanceValues$.get(propName);
4787
- const flags = hostRef.$flags$;
4788
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
4789
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
4790
- const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
4791
- if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
4792
- hostRef.$instanceValues$.set(propName, newVal);
4793
- if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
4794
- if (BUILD.isDev) {
4795
- if (hostRef.$flags$ & HOST_FLAGS.devOnRender) consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
4796
- else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
4797
- }
4798
- if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
4799
- const watchMethods = cmpMeta.$watchers$[propName];
4800
- if (watchMethods) watchMethods.map((watcher) => {
4801
- try {
4802
- const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
4803
- if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
4804
- if (BUILD.signalBacking && !hostRef.$signalValues$) return;
4805
- if (!instance) hostRef.$fetchedCbList$.push(() => {
4806
- hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
4807
- });
4808
- else instance[watchMethodName](newVal, oldVal, propName);
4809
- }
4810
- } catch (e) {
4811
- consoleError(e, elm);
4812
- }
4813
- });
4814
- }
4815
- if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
4816
- if (instance.componentShouldUpdate) {
4817
- const changes = hostRef.$queuedPropChanges$ ||= {};
4818
- changes[propName] = {
4819
- newVal,
4820
- oldVal: changes[propName]?.oldVal ?? oldVal
4821
- };
4822
- }
4823
- if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
4824
- }
4825
- }
4826
- };
4827
- //#endregion
4828
4878
  //#region src/runtime/proxy-component.ts
4829
4879
  /**
4830
4880
  * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
@@ -5067,7 +5117,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
5067
5117
  replayPendingSetterValues(hostRef, cmpMeta);
5068
5118
  }
5069
5119
  endNewInstance();
5070
- if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
5120
+ if (BUILD.asyncLoading && hostRef.$ancestorComponent$) {
5121
+ const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
5122
+ if (ancestorConnected) await ancestorConnected;
5123
+ }
5071
5124
  if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
5072
5125
  fireConnectedCallback(hostRef.$lazyInstance$, elm);
5073
5126
  if (BUILD.asyncLoading) markFirstConnected(hostRef);
@@ -5129,10 +5182,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
5129
5182
  else schedule();
5130
5183
  } catch (e) {
5131
5184
  consoleError(e, elm);
5132
- if (BUILD.asyncLoading && hostRef.$onRenderResolve$) {
5133
- hostRef.$onRenderResolve$();
5134
- hostRef.$onRenderResolve$ = void 0;
5135
- }
5185
+ resolveAncestorWait(hostRef);
5136
5186
  if (BUILD.asyncLoading) markFirstConnected(hostRef);
5137
5187
  if (BUILD.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
5138
5188
  }
@@ -7955,6 +8005,7 @@ const mockComponentMeta = (overrides = {}) => ({
7955
8005
  internal: false,
7956
8006
  isCollectionDependency: false,
7957
8007
  isPlain: false,
8008
+ isCssOnly: false,
7958
8009
  isUpdateable: false,
7959
8010
  jsFilePath: "/some/stubbed/path/my-component.js",
7960
8011
  listeners: [],
@@ -1,4 +1,4 @@
1
- import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, F as DOCS_README, I as DOCS_VSCODE, J as STANDALONE, M as DOCS_CUSTOM, N as DOCS_CUSTOM_ELEMENTS_MANIFEST, O as CUSTOM, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, S as ASSETS, U as LOADER_BUNDLE, Y as STATS, f as isString, g as sortBy, j as DOCS_AGENT_SKILL, n as escapeWithPattern, q as SSR_WASM, r as flatOne, t as dashToPascalCase, v as toDashCase, w as COLLECTION, z as GLOBAL_STYLE } from "./helpers-pTCZhNi0.mjs";
1
+ import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, F as DOCS_README, I as DOCS_VSCODE, J as STANDALONE, M as DOCS_CUSTOM, N as DOCS_CUSTOM_ELEMENTS_MANIFEST, O as CUSTOM, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, S as ASSETS, U as LOADER_BUNDLE, Y as STATS, f as isString, g as sortBy, j as DOCS_AGENT_SKILL, n as escapeWithPattern, q as SSR_WASM, r as flatOne, t as dashToPascalCase, v as toDashCase, w as COLLECTION, z as GLOBAL_STYLE } from "./helpers-k8xQHE77.mjs";
2
2
  import nodePath, { basename, dirname, relative } from "node:path";
3
3
  import picomatch from "picomatch";
4
4
  //#region src/utils/is-glob.ts
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import { C as CMP_FLAGS, H as LISTENER_FLAGS, W as MEMBER_FLAGS, et as WATCH_FLAGS, f as isString, l as isIterable, y as toTitleCase } from "./helpers-pTCZhNi0.mjs";
3
- import { $ as buildWarn, J as relative$1, Y as resolve$1, q as normalizePath } from "./util-CP6-333M.mjs";
2
+ import { C as CMP_FLAGS, H as LISTENER_FLAGS, W as MEMBER_FLAGS, et as WATCH_FLAGS, f as isString, l as isIterable, y as toTitleCase } from "./helpers-k8xQHE77.mjs";
3
+ import { $ as buildWarn, J as relative$1, Y as resolve$1, q as normalizePath } from "./util-Cj2D3x_h.mjs";
4
4
  import nodePath from "node:path";
5
5
  //#region src/utils/regular-expression.ts
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.0-rc.11",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -126,9 +126,9 @@
126
126
  "terser": "^5.50.0",
127
127
  "tinyglobby": "^0.2.17",
128
128
  "typescript": ">5.0.0 <7.0.0",
129
- "@stencil/dev-server": "5.0.0-rc.1",
130
- "@stencil/mock-doc": "5.0.0-rc.1",
131
- "@stencil/cli": "5.0.0-rc.1"
129
+ "@stencil/cli": "5.0.0-rc.11",
130
+ "@stencil/dev-server": "5.0.0-rc.11",
131
+ "@stencil/mock-doc": "5.0.0-rc.11"
132
132
  },
133
133
  "devDependencies": {
134
134
  "@ionic/prettier-config": "^4.0.0",