@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.
- package/dist/{client-BMtGBEQV.mjs → client-QadqfKfL.mjs} +32 -17
- package/dist/compiler/browser.d.ts +28 -5
- package/dist/compiler/browser.js +102 -19
- package/dist/compiler/index.d.mts +2 -2
- package/dist/compiler/index.mjs +2 -2
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/compiler/utils/index.mjs +3 -3
- package/dist/{compiler-C_Y38j4m.mjs → compiler-DlA2VsX7.mjs} +335 -130
- package/dist/declarations/stencil-public-compiler.d.ts +30 -7
- package/dist/{helpers-pTCZhNi0.mjs → helpers-k8xQHE77.mjs} +5 -1
- package/dist/{index-CFiy6MZ3.d.mts → index-BDAZsQzV.d.mts} +34 -7
- package/dist/{index-CViiWNQ9.d.mts → index-BS1JKKvz.d.mts} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-Bkq8vRnu.mjs → node-BR2GYgzY.mjs} +3 -3
- package/dist/runtime/client/lazy.js +231 -178
- package/dist/runtime/client/runtime.js +231 -178
- package/dist/runtime/index.js +231 -178
- package/dist/runtime/server/index.mjs +231 -178
- package/dist/runtime/server/runner.mjs +82 -7
- package/dist/sys/node/index.d.mts +1 -1
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.mjs +2 -2
- package/dist/testing/index.d.mts +5 -0
- package/dist/testing/index.mjs +228 -177
- package/dist/{util-CP6-333M.mjs → util-Cj2D3x_h.mjs} +1 -1
- package/dist/{validation-C1mr0klL.mjs → validation-GfBzquhJ.mjs} +2 -2
- package/package.json +4 -4
package/dist/runtime/index.js
CHANGED
|
@@ -144,7 +144,11 @@ const HOST_FLAGS = {
|
|
|
144
144
|
* coming from the runtime's own reflection aren't applied back to the prop.
|
|
145
145
|
*/
|
|
146
146
|
isReflecting: 16384,
|
|
147
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Set by `forceUpdate()` so the next update renders even if `componentShouldUpdate` returns `false`.
|
|
149
|
+
*/
|
|
150
|
+
isUpdateForced: 4096,
|
|
151
|
+
devOnRender: 32768,
|
|
148
152
|
devOnDidLoad: 8192
|
|
149
153
|
};
|
|
150
154
|
const CF_scopedCssEncapsulation = 2;
|
|
@@ -910,7 +914,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
910
914
|
return toReturn;
|
|
911
915
|
}
|
|
912
916
|
if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
|
|
913
|
-
return HostElementPrototype.__prepend(newChild);
|
|
917
|
+
return HostElementPrototype.__prepend.call(this, newChild);
|
|
914
918
|
});
|
|
915
919
|
};
|
|
916
920
|
};
|
|
@@ -1579,7 +1583,7 @@ const attachStyles = (hostRef) => {
|
|
|
1579
1583
|
else if (BUILD.hydrateServerSide && BUILD.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
|
|
1580
1584
|
else styleContainerNode = elm.getRootNode();
|
|
1581
1585
|
const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
|
|
1582
|
-
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
|
|
1586
|
+
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
|
|
1583
1587
|
elm["s-sc"] = scopeId;
|
|
1584
1588
|
elm.classList.add(scopeId + "-h");
|
|
1585
1589
|
}
|
|
@@ -1666,12 +1670,51 @@ const isComplexType = (o) => {
|
|
|
1666
1670
|
return o === "object" || o === "function";
|
|
1667
1671
|
};
|
|
1668
1672
|
//#endregion
|
|
1669
|
-
//#region src/runtime/
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1673
|
+
//#region src/runtime/parse-property-value.ts
|
|
1674
|
+
/**
|
|
1675
|
+
* Parse a new property value for a given property type.
|
|
1676
|
+
*
|
|
1677
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1678
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1679
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
1680
|
+
* 2. the type stored from `propType`.
|
|
1681
|
+
*
|
|
1682
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1683
|
+
*
|
|
1684
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1685
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1686
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1687
|
+
* ```tsx
|
|
1688
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
1689
|
+
* ```
|
|
1690
|
+
*
|
|
1691
|
+
* HTML prop values on the other hand, will always a string
|
|
1692
|
+
*
|
|
1693
|
+
* @param propValue the new value to coerce to some type
|
|
1694
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
1695
|
+
* @returns the parsed/coerced value
|
|
1696
|
+
*/
|
|
1697
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
1698
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
1699
|
+
/**
|
|
1700
|
+
* ensure this value is of the correct prop type
|
|
1701
|
+
*/
|
|
1702
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
1703
|
+
/**
|
|
1704
|
+
* force it to be a number
|
|
1705
|
+
*/
|
|
1706
|
+
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
1707
|
+
/**
|
|
1708
|
+
* could have been passed as a number or boolean but we still want it as a string
|
|
1709
|
+
*/
|
|
1710
|
+
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
1711
|
+
return propValue;
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* not sure exactly what type we want so no need to change to a different type
|
|
1715
|
+
*/
|
|
1716
|
+
return propValue;
|
|
1717
|
+
};
|
|
1675
1718
|
//#endregion
|
|
1676
1719
|
//#region src/runtime/event-emitter.ts
|
|
1677
1720
|
const createEvent = (ref, name, flags) => {
|
|
@@ -2735,24 +2778,24 @@ const markFirstConnected = (hostRef) => {
|
|
|
2735
2778
|
hostRef.$onFirstConnectResolve$ = void 0;
|
|
2736
2779
|
};
|
|
2737
2780
|
/**
|
|
2738
|
-
*
|
|
2739
|
-
* Shared by the lazy ({@link initializeComponent})
|
|
2740
|
-
* `connectedCallback` paths so a component never
|
|
2741
|
-
* ancestor, regardless of load order.
|
|
2742
|
-
*
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
2781
|
+
* Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
|
|
2782
|
+
* completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
|
|
2783
|
+
* and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
|
|
2784
|
+
* connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
|
|
2785
|
+
* a returned promise, so a component whose ancestor is already connected carries on
|
|
2786
|
+
* synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
|
|
2787
|
+
* the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
|
|
2788
|
+
* tag may not be defined yet.
|
|
2745
2789
|
*
|
|
2746
2790
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2747
2791
|
* @param registry the registry the waiting component is defined in
|
|
2792
|
+
* @returns a promise to await, or `undefined` if there's nothing to wait for
|
|
2748
2793
|
*/
|
|
2749
|
-
const
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
}
|
|
2755
|
-
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
2794
|
+
const whenAncestorConnected = (ancestorElm, registry) => {
|
|
2795
|
+
const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
|
|
2796
|
+
const ancestorHostRef = getHostRef(ancestorElm);
|
|
2797
|
+
if (!BUILD.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
|
|
2798
|
+
return pendingConnect(ancestorHostRef);
|
|
2756
2799
|
};
|
|
2757
2800
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
2758
2801
|
if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
@@ -2763,6 +2806,17 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
2763
2806
|
if (ancestorComponent["s-pc"]) ancestorComponent["s-pc"].push(ensureFirstConnectPromise(hostRef));
|
|
2764
2807
|
}
|
|
2765
2808
|
};
|
|
2809
|
+
/**
|
|
2810
|
+
* Release the ancestor waiting on this component's update (registered by {@link attachToAncestor}).
|
|
2811
|
+
*
|
|
2812
|
+
* @param hostRef the component's host reference
|
|
2813
|
+
*/
|
|
2814
|
+
const resolveAncestorWait = (hostRef) => {
|
|
2815
|
+
if (BUILD.asyncLoading && hostRef.$onRenderResolve$) {
|
|
2816
|
+
hostRef.$onRenderResolve$();
|
|
2817
|
+
hostRef.$onRenderResolve$ = void 0;
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2766
2820
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
2767
2821
|
if (BUILD.updatable) hostRef.$flags$ |= HOST_FLAGS.isQueuedForUpdate;
|
|
2768
2822
|
if (BUILD.asyncLoading && hostRef.$flags$ & HOST_FLAGS.isWaitingForChildren) {
|
|
@@ -2772,10 +2826,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
2772
2826
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
2773
2827
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
2774
2828
|
if (isInitialLoad) {
|
|
2775
|
-
const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2776
|
-
if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
|
|
2777
2829
|
queueMicrotask(() => {
|
|
2778
|
-
|
|
2830
|
+
const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2831
|
+
if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
|
|
2832
|
+
else dispatch();
|
|
2779
2833
|
});
|
|
2780
2834
|
return;
|
|
2781
2835
|
}
|
|
@@ -2828,8 +2882,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2828
2882
|
if (BUILD.updatable && hostRef.$queuedPropChanges$) {
|
|
2829
2883
|
const changes = hostRef.$queuedPropChanges$;
|
|
2830
2884
|
hostRef.$queuedPropChanges$ = void 0;
|
|
2831
|
-
if (safeCall(instance, "componentShouldUpdate", changes, elm) === false) {
|
|
2885
|
+
if (safeCall(instance, "componentShouldUpdate", changes, elm) === false && !(hostRef.$flags$ & HOST_FLAGS.isUpdateForced)) {
|
|
2832
2886
|
hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
|
|
2887
|
+
resolveAncestorWait(hostRef);
|
|
2833
2888
|
return;
|
|
2834
2889
|
}
|
|
2835
2890
|
}
|
|
@@ -2955,7 +3010,10 @@ const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
|
2955
3010
|
* method, so we can call the method immediately. If not, check before calling it.
|
|
2956
3011
|
*/
|
|
2957
3012
|
instance = allRenderFn ? instance.render() : instance.render && instance.render();
|
|
2958
|
-
if (updatable)
|
|
3013
|
+
if (updatable) {
|
|
3014
|
+
hostRef.$flags$ &= ~(HOST_FLAGS.isQueuedForUpdate | HOST_FLAGS.isUpdateForced);
|
|
3015
|
+
hostRef.$queuedPropChanges$ = void 0;
|
|
3016
|
+
}
|
|
2959
3017
|
if (updatable || lazyLoad) hostRef.$flags$ |= HOST_FLAGS.hasRendered;
|
|
2960
3018
|
if (BUILD.hasRenderFn || BUILD.reflect) {
|
|
2961
3019
|
if (BUILD.vdomRender || BUILD.reflect) {
|
|
@@ -3006,10 +3064,7 @@ const postUpdateComponent = (hostRef) => {
|
|
|
3006
3064
|
}
|
|
3007
3065
|
if (BUILD.method && BUILD.lazyLoad) hostRef.$onInstanceResolve$(elm);
|
|
3008
3066
|
if (BUILD.asyncLoading) {
|
|
3009
|
-
|
|
3010
|
-
hostRef.$onRenderResolve$();
|
|
3011
|
-
hostRef.$onRenderResolve$ = void 0;
|
|
3012
|
-
}
|
|
3067
|
+
resolveAncestorWait(hostRef);
|
|
3013
3068
|
if (hostRef.$flags$ & HOST_FLAGS.needsRerender) nextTick(() => scheduleUpdate(hostRef, false));
|
|
3014
3069
|
hostRef.$flags$ &= ~(HOST_FLAGS.isWaitingForChildren | HOST_FLAGS.needsRerender);
|
|
3015
3070
|
}
|
|
@@ -3018,7 +3073,10 @@ const forceUpdate = (ref) => {
|
|
|
3018
3073
|
if (BUILD.updatable && (Build.isBrowser || Build.isTesting)) {
|
|
3019
3074
|
const hostRef = getHostRef(ref);
|
|
3020
3075
|
const isConnected = hostRef?.$hostElement$?.isConnected;
|
|
3021
|
-
if (isConnected &&
|
|
3076
|
+
if (isConnected && hostRef.$flags$ & HOST_FLAGS.hasRendered) {
|
|
3077
|
+
hostRef.$flags$ |= HOST_FLAGS.isUpdateForced;
|
|
3078
|
+
if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3079
|
+
}
|
|
3022
3080
|
return isConnected;
|
|
3023
3081
|
}
|
|
3024
3082
|
return false;
|
|
@@ -3078,6 +3136,121 @@ const serverSideConnected = (elm) => {
|
|
|
3078
3136
|
}
|
|
3079
3137
|
};
|
|
3080
3138
|
//#endregion
|
|
3139
|
+
//#region src/runtime/set-value.ts
|
|
3140
|
+
/**
|
|
3141
|
+
* The value a reflected prop writes to its attribute: the serialized value if it has one.
|
|
3142
|
+
* @param hostRef the component's host ref
|
|
3143
|
+
* @param propName the prop
|
|
3144
|
+
* @param val the prop's value
|
|
3145
|
+
* @returns the value to reflect
|
|
3146
|
+
*/
|
|
3147
|
+
const getReflectedValue = (hostRef, propName, val) => BUILD.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
|
|
3148
|
+
/**
|
|
3149
|
+
* Write a reflected prop's attribute as soon as the prop changes, like native elements do,
|
|
3150
|
+
* so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
|
|
3151
|
+
* @param hostRef the component's host ref
|
|
3152
|
+
* @param cmpMeta the component's runtime metadata
|
|
3153
|
+
* @param elm the host element
|
|
3154
|
+
* @param propName the prop that changed
|
|
3155
|
+
* @param oldAttrVal the previously reflected value
|
|
3156
|
+
* @param newAttrVal the value to reflect
|
|
3157
|
+
*/
|
|
3158
|
+
const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
|
|
3159
|
+
if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
|
|
3160
|
+
const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
|
|
3161
|
+
if (!attrName) return;
|
|
3162
|
+
if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
3163
|
+
setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
|
|
3164
|
+
if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
3165
|
+
};
|
|
3166
|
+
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
3167
|
+
const run = (inst) => {
|
|
3168
|
+
let attrVal = val;
|
|
3169
|
+
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
3170
|
+
const [[methodName]] = Object.entries(serializer);
|
|
3171
|
+
attrVal = inst[methodName](attrVal, propName);
|
|
3172
|
+
}
|
|
3173
|
+
hostRef.$serializerValues$.set(propName, attrVal);
|
|
3174
|
+
};
|
|
3175
|
+
if (instance) run(instance);
|
|
3176
|
+
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
3177
|
+
};
|
|
3178
|
+
const getValue = (ref, propName) => {
|
|
3179
|
+
if (BUILD.signalBacking) {
|
|
3180
|
+
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
3181
|
+
if (sig !== void 0) return sig.value;
|
|
3182
|
+
}
|
|
3183
|
+
return getHostRef(ref).$instanceValues$.get(propName);
|
|
3184
|
+
};
|
|
3185
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
3186
|
+
const hostRef = getHostRef(ref);
|
|
3187
|
+
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
3188
|
+
if (BUILD.signalBacking) {
|
|
3189
|
+
const sig = hostRef?.$signalValues$?.get(propName);
|
|
3190
|
+
if (sig !== void 0) {
|
|
3191
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3192
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
3193
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3194
|
+
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
3195
|
+
}
|
|
3196
|
+
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
3197
|
+
return;
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
if (!hostRef) {
|
|
3201
|
+
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$}"`);
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3204
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3205
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
3206
|
+
const flags = hostRef.$flags$;
|
|
3207
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3208
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3209
|
+
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
3210
|
+
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
3211
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
3212
|
+
const oldAttrVal = BUILD.reflect && getReflectedValue(hostRef, propName, oldVal);
|
|
3213
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
3214
|
+
if (BUILD.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
|
|
3215
|
+
if (BUILD.isDev) {
|
|
3216
|
+
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);
|
|
3217
|
+
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);
|
|
3218
|
+
}
|
|
3219
|
+
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
3220
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
3221
|
+
if (watchMethods) watchMethods.map((watcher) => {
|
|
3222
|
+
try {
|
|
3223
|
+
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
3224
|
+
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
3225
|
+
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
3226
|
+
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
3227
|
+
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
3228
|
+
});
|
|
3229
|
+
else instance[watchMethodName](newVal, oldVal, propName);
|
|
3230
|
+
}
|
|
3231
|
+
} catch (e) {
|
|
3232
|
+
consoleError(e, elm);
|
|
3233
|
+
}
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3236
|
+
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
3237
|
+
if (instance.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[propName] ||= {
|
|
3238
|
+
oldVal,
|
|
3239
|
+
newVal
|
|
3240
|
+
}).newVal = newVal;
|
|
3241
|
+
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
};
|
|
3245
|
+
//#endregion
|
|
3246
|
+
//#region src/runtime/signals-core.ts
|
|
3247
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
3248
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
3249
|
+
const untracked = (fn) => getCore().untracked(fn);
|
|
3250
|
+
function signal(value, options) {
|
|
3251
|
+
return getCore().signal(value, options);
|
|
3252
|
+
}
|
|
3253
|
+
//#endregion
|
|
3081
3254
|
//#region src/runtime/signals.ts
|
|
3082
3255
|
const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
|
|
3083
3256
|
/**
|
|
@@ -3111,17 +3284,22 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3111
3284
|
disposers.push(effect(() => {
|
|
3112
3285
|
const newVal = sig.value;
|
|
3113
3286
|
if (hostRef.$flags$ & HOST_FLAGS.hasRendered) {
|
|
3114
|
-
if (instance?.componentShouldUpdate) {
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
oldVal: changes[memberName]?.oldVal ?? prevScheduleVal
|
|
3119
|
-
};
|
|
3120
|
-
}
|
|
3287
|
+
if (instance?.componentShouldUpdate) ((hostRef.$queuedPropChanges$ ||= {})[memberName] ||= {
|
|
3288
|
+
oldVal: prevScheduleVal,
|
|
3289
|
+
newVal
|
|
3290
|
+
}).newVal = newVal;
|
|
3121
3291
|
if (!(hostRef.$flags$ & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3122
3292
|
}
|
|
3123
3293
|
prevScheduleVal = newVal;
|
|
3124
3294
|
}));
|
|
3295
|
+
if (BUILD.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
|
|
3296
|
+
let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
|
|
3297
|
+
disposers.push(effect(() => {
|
|
3298
|
+
const attrVal = getReflectedValue(hostRef, memberName, sig.value);
|
|
3299
|
+
untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
|
|
3300
|
+
prevAttrVal = attrVal;
|
|
3301
|
+
}));
|
|
3302
|
+
}
|
|
3125
3303
|
if (BUILD.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
|
|
3126
3304
|
const watchMethods = cmpMeta.$watchers$[memberName];
|
|
3127
3305
|
let prevWatchVal = sig.peek();
|
|
@@ -3190,7 +3368,7 @@ const initializeEffects = (elm, hostRef) => {
|
|
|
3190
3368
|
* Modified for Stencil's compiler and vdom
|
|
3191
3369
|
*/
|
|
3192
3370
|
const h = (nodeName, vnodeData, ...children) => {
|
|
3193
|
-
if (typeof nodeName === "string") nodeName = transformTag(nodeName);
|
|
3371
|
+
if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
|
|
3194
3372
|
let child = null;
|
|
3195
3373
|
let key = null;
|
|
3196
3374
|
let slotName = null;
|
|
@@ -3368,7 +3546,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3368
3546
|
let scopeId;
|
|
3369
3547
|
if (BUILD.scoped) {
|
|
3370
3548
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
3371
|
-
if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
|
|
3549
|
+
if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
|
|
3372
3550
|
scopeId = hostElm["s-sc"];
|
|
3373
3551
|
hostElm.classList.add(scopeId + "-h");
|
|
3374
3552
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
@@ -3664,7 +3842,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
3664
3842
|
if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
|
|
3665
3843
|
do {
|
|
3666
3844
|
const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
|
|
3667
|
-
if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
|
|
3845
|
+
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)) {
|
|
3668
3846
|
slottedNode["s-sn"] = slotName;
|
|
3669
3847
|
group.push({
|
|
3670
3848
|
slot: slotNode,
|
|
@@ -4186,134 +4364,6 @@ const normalizeWatchers = (raw) => {
|
|
|
4186
4364
|
return out;
|
|
4187
4365
|
};
|
|
4188
4366
|
//#endregion
|
|
4189
|
-
//#region src/runtime/parse-property-value.ts
|
|
4190
|
-
/**
|
|
4191
|
-
* Parse a new property value for a given property type.
|
|
4192
|
-
*
|
|
4193
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
4194
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
4195
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
4196
|
-
* 2. the type stored from `propType`.
|
|
4197
|
-
*
|
|
4198
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
4199
|
-
*
|
|
4200
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
4201
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
4202
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
4203
|
-
* ```tsx
|
|
4204
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
4205
|
-
* ```
|
|
4206
|
-
*
|
|
4207
|
-
* HTML prop values on the other hand, will always a string
|
|
4208
|
-
*
|
|
4209
|
-
* @param propValue the new value to coerce to some type
|
|
4210
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
4211
|
-
* @returns the parsed/coerced value
|
|
4212
|
-
*/
|
|
4213
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
4214
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
4215
|
-
/**
|
|
4216
|
-
* ensure this value is of the correct prop type
|
|
4217
|
-
*/
|
|
4218
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4219
|
-
/**
|
|
4220
|
-
* force it to be a number
|
|
4221
|
-
*/
|
|
4222
|
-
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
4223
|
-
/**
|
|
4224
|
-
* could have been passed as a number or boolean but we still want it as a string
|
|
4225
|
-
*/
|
|
4226
|
-
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
4227
|
-
return propValue;
|
|
4228
|
-
}
|
|
4229
|
-
/**
|
|
4230
|
-
* not sure exactly what type we want so no need to change to a different type
|
|
4231
|
-
*/
|
|
4232
|
-
return propValue;
|
|
4233
|
-
};
|
|
4234
|
-
//#endregion
|
|
4235
|
-
//#region src/runtime/set-value.ts
|
|
4236
|
-
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
4237
|
-
const run = (inst) => {
|
|
4238
|
-
let attrVal = val;
|
|
4239
|
-
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
4240
|
-
const [[methodName]] = Object.entries(serializer);
|
|
4241
|
-
attrVal = inst[methodName](attrVal, propName);
|
|
4242
|
-
}
|
|
4243
|
-
hostRef.$serializerValues$.set(propName, attrVal);
|
|
4244
|
-
};
|
|
4245
|
-
if (instance) run(instance);
|
|
4246
|
-
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
4247
|
-
};
|
|
4248
|
-
const getValue = (ref, propName) => {
|
|
4249
|
-
if (BUILD.signalBacking) {
|
|
4250
|
-
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
4251
|
-
if (sig !== void 0) return sig.value;
|
|
4252
|
-
}
|
|
4253
|
-
return getHostRef(ref).$instanceValues$.get(propName);
|
|
4254
|
-
};
|
|
4255
|
-
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
4256
|
-
const hostRef = getHostRef(ref);
|
|
4257
|
-
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
4258
|
-
if (BUILD.signalBacking) {
|
|
4259
|
-
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4260
|
-
if (sig !== void 0) {
|
|
4261
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4262
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4263
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4264
|
-
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
4265
|
-
}
|
|
4266
|
-
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
4267
|
-
return;
|
|
4268
|
-
}
|
|
4269
|
-
}
|
|
4270
|
-
if (!hostRef) {
|
|
4271
|
-
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$}"`);
|
|
4272
|
-
return;
|
|
4273
|
-
}
|
|
4274
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4275
|
-
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4276
|
-
const flags = hostRef.$flags$;
|
|
4277
|
-
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4278
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4279
|
-
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4280
|
-
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4281
|
-
hostRef.$instanceValues$.set(propName, newVal);
|
|
4282
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
4283
|
-
if (BUILD.isDev) {
|
|
4284
|
-
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);
|
|
4285
|
-
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);
|
|
4286
|
-
}
|
|
4287
|
-
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
4288
|
-
const watchMethods = cmpMeta.$watchers$[propName];
|
|
4289
|
-
if (watchMethods) watchMethods.map((watcher) => {
|
|
4290
|
-
try {
|
|
4291
|
-
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4292
|
-
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
4293
|
-
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
4294
|
-
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
4295
|
-
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
4296
|
-
});
|
|
4297
|
-
else instance[watchMethodName](newVal, oldVal, propName);
|
|
4298
|
-
}
|
|
4299
|
-
} catch (e) {
|
|
4300
|
-
consoleError(e, elm);
|
|
4301
|
-
}
|
|
4302
|
-
});
|
|
4303
|
-
}
|
|
4304
|
-
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4305
|
-
if (instance.componentShouldUpdate) {
|
|
4306
|
-
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4307
|
-
changes[propName] = {
|
|
4308
|
-
newVal,
|
|
4309
|
-
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4310
|
-
};
|
|
4311
|
-
}
|
|
4312
|
-
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4313
|
-
}
|
|
4314
|
-
}
|
|
4315
|
-
};
|
|
4316
|
-
//#endregion
|
|
4317
4367
|
//#region src/runtime/proxy-component.ts
|
|
4318
4368
|
/**
|
|
4319
4369
|
* Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
|
|
@@ -4556,7 +4606,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4556
4606
|
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4557
4607
|
}
|
|
4558
4608
|
endNewInstance();
|
|
4559
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$)
|
|
4609
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) {
|
|
4610
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4611
|
+
if (ancestorConnected) await ancestorConnected;
|
|
4612
|
+
}
|
|
4560
4613
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4561
4614
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4562
4615
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4618,10 +4671,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4618
4671
|
else schedule();
|
|
4619
4672
|
} catch (e) {
|
|
4620
4673
|
consoleError(e, elm);
|
|
4621
|
-
|
|
4622
|
-
hostRef.$onRenderResolve$();
|
|
4623
|
-
hostRef.$onRenderResolve$ = void 0;
|
|
4624
|
-
}
|
|
4674
|
+
resolveAncestorWait(hostRef);
|
|
4625
4675
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
4626
4676
|
if (BUILD.asyncLoading && hostRef.$onReadyResolve$ && !(hostRef.$flags$ & HOST_FLAGS.hasFailedLoad)) hostRef.$onReadyResolve$(elm);
|
|
4627
4677
|
}
|
|
@@ -4957,8 +5007,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4957
5007
|
}
|
|
4958
5008
|
connectedCallback(this);
|
|
4959
5009
|
if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4960
|
-
|
|
4961
|
-
if (
|
|
5010
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
5011
|
+
if (ancestorConnected) {
|
|
5012
|
+
await ancestorConnected;
|
|
5013
|
+
if (!this.isConnected) return;
|
|
5014
|
+
}
|
|
4962
5015
|
}
|
|
4963
5016
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
4964
5017
|
if (BUILD.asyncLoading && hostRef) markFirstConnected(hostRef);
|