@stencil/core 5.0.0-rc.1 → 5.0.0-rc.10
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-DkvdNuPu.mjs} +9 -9
- package/dist/compiler/browser.d.ts +23 -5
- package/dist/compiler/browser.js +99 -17
- 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-C_Y38j4m.mjs → compiler-ChKFuRry.mjs} +326 -123
- package/dist/declarations/stencil-public-compiler.d.ts +25 -7
- package/dist/{index-CFiy6MZ3.d.mts → index-BxnfbT3a.d.mts} +25 -7
- package/dist/{index-CViiWNQ9.d.mts → index-xOwTL_5Z.d.mts} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-Bkq8vRnu.mjs → node-C59vQZNg.mjs} +1 -1
- package/dist/runtime/client/lazy.js +202 -159
- package/dist/runtime/client/runtime.js +202 -159
- package/dist/runtime/index.js +202 -159
- package/dist/runtime/server/index.mjs +202 -159
- 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.mjs +198 -158
- package/package.json +4 -4
package/dist/testing/index.mjs
CHANGED
|
@@ -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.
|
|
36
|
+
const version = "5.0.0-rc.10";
|
|
37
37
|
const MEMBER_FLAGS = {
|
|
38
38
|
String: 1,
|
|
39
39
|
Number: 2,
|
|
@@ -1545,7 +1545,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
1545
1545
|
return toReturn;
|
|
1546
1546
|
}
|
|
1547
1547
|
if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
|
|
1548
|
-
return HostElementPrototype.__prepend(newChild);
|
|
1548
|
+
return HostElementPrototype.__prepend.call(this, newChild);
|
|
1549
1549
|
});
|
|
1550
1550
|
};
|
|
1551
1551
|
};
|
|
@@ -2157,7 +2157,7 @@ const attachStyles = (hostRef) => {
|
|
|
2157
2157
|
else if (BUILD.hydrateServerSide && BUILD.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
|
|
2158
2158
|
else styleContainerNode = elm.getRootNode();
|
|
2159
2159
|
const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
|
|
2160
|
-
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
|
|
2160
|
+
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
|
|
2161
2161
|
elm["s-sc"] = scopeId;
|
|
2162
2162
|
elm.classList.add(scopeId + "-h");
|
|
2163
2163
|
}
|
|
@@ -2224,12 +2224,51 @@ const hydrateScopedToShadow = (cmpMetas) => {
|
|
|
2224
2224
|
}
|
|
2225
2225
|
};
|
|
2226
2226
|
//#endregion
|
|
2227
|
-
//#region src/runtime/
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2227
|
+
//#region src/runtime/parse-property-value.ts
|
|
2228
|
+
/**
|
|
2229
|
+
* Parse a new property value for a given property type.
|
|
2230
|
+
*
|
|
2231
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
2232
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
2233
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
2234
|
+
* 2. the type stored from `propType`.
|
|
2235
|
+
*
|
|
2236
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
2237
|
+
*
|
|
2238
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
2239
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
2240
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
2241
|
+
* ```tsx
|
|
2242
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
2243
|
+
* ```
|
|
2244
|
+
*
|
|
2245
|
+
* HTML prop values on the other hand, will always a string
|
|
2246
|
+
*
|
|
2247
|
+
* @param propValue the new value to coerce to some type
|
|
2248
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
2249
|
+
* @returns the parsed/coerced value
|
|
2250
|
+
*/
|
|
2251
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
2252
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
2253
|
+
/**
|
|
2254
|
+
* ensure this value is of the correct prop type
|
|
2255
|
+
*/
|
|
2256
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
2257
|
+
/**
|
|
2258
|
+
* force it to be a number
|
|
2259
|
+
*/
|
|
2260
|
+
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
2261
|
+
/**
|
|
2262
|
+
* could have been passed as a number or boolean but we still want it as a string
|
|
2263
|
+
*/
|
|
2264
|
+
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
2265
|
+
return propValue;
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* not sure exactly what type we want so no need to change to a different type
|
|
2269
|
+
*/
|
|
2270
|
+
return propValue;
|
|
2271
|
+
};
|
|
2233
2272
|
const getRegistry = () => globalThis.customElements;
|
|
2234
2273
|
/**
|
|
2235
2274
|
* @param elm a defined component host
|
|
@@ -3261,24 +3300,24 @@ const markFirstConnected = (hostRef) => {
|
|
|
3261
3300
|
hostRef.$onFirstConnectResolve$ = void 0;
|
|
3262
3301
|
};
|
|
3263
3302
|
/**
|
|
3264
|
-
*
|
|
3265
|
-
* Shared by the lazy ({@link initializeComponent})
|
|
3266
|
-
* `connectedCallback` paths so a component never
|
|
3267
|
-
* ancestor, regardless of load order.
|
|
3268
|
-
*
|
|
3269
|
-
*
|
|
3270
|
-
*
|
|
3303
|
+
* Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
|
|
3304
|
+
* completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
|
|
3305
|
+
* and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
|
|
3306
|
+
* connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
|
|
3307
|
+
* a returned promise, so a component whose ancestor is already connected carries on
|
|
3308
|
+
* synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
|
|
3309
|
+
* the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
|
|
3310
|
+
* tag may not be defined yet.
|
|
3271
3311
|
*
|
|
3272
3312
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
3273
3313
|
* @param registry the registry the waiting component is defined in
|
|
3314
|
+
* @returns a promise to await, or `undefined` if there's nothing to wait for
|
|
3274
3315
|
*/
|
|
3275
|
-
const
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
}
|
|
3281
|
-
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
3316
|
+
const whenAncestorConnected = (ancestorElm, registry) => {
|
|
3317
|
+
const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
|
|
3318
|
+
const ancestorHostRef = getHostRef(ancestorElm);
|
|
3319
|
+
if (!BUILD.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
|
|
3320
|
+
return pendingConnect(ancestorHostRef);
|
|
3282
3321
|
};
|
|
3283
3322
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
3284
3323
|
if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
@@ -3298,10 +3337,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
3298
3337
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
3299
3338
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
3300
3339
|
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
3340
|
queueMicrotask(() => {
|
|
3304
|
-
|
|
3341
|
+
const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
3342
|
+
if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
|
|
3343
|
+
else dispatch();
|
|
3305
3344
|
});
|
|
3306
3345
|
return;
|
|
3307
3346
|
}
|
|
@@ -3604,6 +3643,124 @@ const serverSideConnected = (elm) => {
|
|
|
3604
3643
|
}
|
|
3605
3644
|
};
|
|
3606
3645
|
//#endregion
|
|
3646
|
+
//#region src/runtime/set-value.ts
|
|
3647
|
+
/**
|
|
3648
|
+
* The value a reflected prop writes to its attribute: the serialized value if it has one.
|
|
3649
|
+
* @param hostRef the component's host ref
|
|
3650
|
+
* @param propName the prop
|
|
3651
|
+
* @param val the prop's value
|
|
3652
|
+
* @returns the value to reflect
|
|
3653
|
+
*/
|
|
3654
|
+
const getReflectedValue = (hostRef, propName, val) => BUILD.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
|
|
3655
|
+
/**
|
|
3656
|
+
* Write a reflected prop's attribute as soon as the prop changes, like native elements do,
|
|
3657
|
+
* so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
|
|
3658
|
+
* @param hostRef the component's host ref
|
|
3659
|
+
* @param cmpMeta the component's runtime metadata
|
|
3660
|
+
* @param elm the host element
|
|
3661
|
+
* @param propName the prop that changed
|
|
3662
|
+
* @param oldAttrVal the previously reflected value
|
|
3663
|
+
* @param newAttrVal the value to reflect
|
|
3664
|
+
*/
|
|
3665
|
+
const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
|
|
3666
|
+
if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
|
|
3667
|
+
const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
|
|
3668
|
+
if (!attrName) return;
|
|
3669
|
+
if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
3670
|
+
setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
|
|
3671
|
+
if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
3672
|
+
};
|
|
3673
|
+
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
3674
|
+
const run = (inst) => {
|
|
3675
|
+
let attrVal = val;
|
|
3676
|
+
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
3677
|
+
const [[methodName]] = Object.entries(serializer);
|
|
3678
|
+
attrVal = inst[methodName](attrVal, propName);
|
|
3679
|
+
}
|
|
3680
|
+
hostRef.$serializerValues$.set(propName, attrVal);
|
|
3681
|
+
};
|
|
3682
|
+
if (instance) run(instance);
|
|
3683
|
+
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
3684
|
+
};
|
|
3685
|
+
const getValue = (ref, propName) => {
|
|
3686
|
+
if (BUILD.signalBacking) {
|
|
3687
|
+
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
3688
|
+
if (sig !== void 0) return sig.value;
|
|
3689
|
+
}
|
|
3690
|
+
return getHostRef(ref).$instanceValues$.get(propName);
|
|
3691
|
+
};
|
|
3692
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
3693
|
+
const hostRef = getHostRef(ref);
|
|
3694
|
+
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
3695
|
+
if (BUILD.signalBacking) {
|
|
3696
|
+
const sig = hostRef?.$signalValues$?.get(propName);
|
|
3697
|
+
if (sig !== void 0) {
|
|
3698
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3699
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
3700
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3701
|
+
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
3702
|
+
}
|
|
3703
|
+
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
3704
|
+
return;
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
if (!hostRef) {
|
|
3708
|
+
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$}"`);
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
3711
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3712
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
3713
|
+
const flags = hostRef.$flags$;
|
|
3714
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3715
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3716
|
+
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
3717
|
+
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
3718
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
3719
|
+
const oldAttrVal = BUILD.reflect && getReflectedValue(hostRef, propName, oldVal);
|
|
3720
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
3721
|
+
if (BUILD.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
|
|
3722
|
+
if (BUILD.isDev) {
|
|
3723
|
+
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);
|
|
3724
|
+
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);
|
|
3725
|
+
}
|
|
3726
|
+
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
3727
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
3728
|
+
if (watchMethods) watchMethods.map((watcher) => {
|
|
3729
|
+
try {
|
|
3730
|
+
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
3731
|
+
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
3732
|
+
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
3733
|
+
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
3734
|
+
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
3735
|
+
});
|
|
3736
|
+
else instance[watchMethodName](newVal, oldVal, propName);
|
|
3737
|
+
}
|
|
3738
|
+
} catch (e) {
|
|
3739
|
+
consoleError(e, elm);
|
|
3740
|
+
}
|
|
3741
|
+
});
|
|
3742
|
+
}
|
|
3743
|
+
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
3744
|
+
if (instance.componentShouldUpdate) {
|
|
3745
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3746
|
+
changes[propName] = {
|
|
3747
|
+
newVal,
|
|
3748
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
3749
|
+
};
|
|
3750
|
+
}
|
|
3751
|
+
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
};
|
|
3755
|
+
//#endregion
|
|
3756
|
+
//#region src/runtime/signals-core.ts
|
|
3757
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
3758
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
3759
|
+
const untracked = (fn) => getCore().untracked(fn);
|
|
3760
|
+
function signal(value, options) {
|
|
3761
|
+
return getCore().signal(value, options);
|
|
3762
|
+
}
|
|
3763
|
+
//#endregion
|
|
3607
3764
|
//#region src/runtime/signals.ts
|
|
3608
3765
|
const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
|
|
3609
3766
|
/**
|
|
@@ -3648,6 +3805,14 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3648
3805
|
}
|
|
3649
3806
|
prevScheduleVal = newVal;
|
|
3650
3807
|
}));
|
|
3808
|
+
if (BUILD.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
|
|
3809
|
+
let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
|
|
3810
|
+
disposers.push(effect(() => {
|
|
3811
|
+
const attrVal = getReflectedValue(hostRef, memberName, sig.value);
|
|
3812
|
+
untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
|
|
3813
|
+
prevAttrVal = attrVal;
|
|
3814
|
+
}));
|
|
3815
|
+
}
|
|
3651
3816
|
if (BUILD.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
|
|
3652
3817
|
const watchMethods = cmpMeta.$watchers$[memberName];
|
|
3653
3818
|
let prevWatchVal = sig.peek();
|
|
@@ -3716,7 +3881,7 @@ const initializeEffects = (elm, hostRef) => {
|
|
|
3716
3881
|
* Modified for Stencil's compiler and vdom
|
|
3717
3882
|
*/
|
|
3718
3883
|
const h = (nodeName, vnodeData, ...children) => {
|
|
3719
|
-
if (typeof nodeName === "string") nodeName = transformTag(nodeName);
|
|
3884
|
+
if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
|
|
3720
3885
|
let child = null;
|
|
3721
3886
|
let key = null;
|
|
3722
3887
|
let slotName = null;
|
|
@@ -3894,7 +4059,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3894
4059
|
let scopeId;
|
|
3895
4060
|
if (BUILD.scoped) {
|
|
3896
4061
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
3897
|
-
if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
|
|
4062
|
+
if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
|
|
3898
4063
|
scopeId = hostElm["s-sc"];
|
|
3899
4064
|
hostElm.classList.add(scopeId + "-h");
|
|
3900
4065
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
@@ -4190,7 +4355,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
4190
4355
|
if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
|
|
4191
4356
|
do {
|
|
4192
4357
|
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)) {
|
|
4358
|
+
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
4359
|
slottedNode["s-sn"] = slotName;
|
|
4195
4360
|
group.push({
|
|
4196
4361
|
slot: slotNode,
|
|
@@ -4697,134 +4862,6 @@ const normalizeWatchers = (raw) => {
|
|
|
4697
4862
|
return out;
|
|
4698
4863
|
};
|
|
4699
4864
|
//#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
4865
|
//#region src/runtime/proxy-component.ts
|
|
4829
4866
|
/**
|
|
4830
4867
|
* Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
|
|
@@ -5067,7 +5104,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
5067
5104
|
replayPendingSetterValues(hostRef, cmpMeta);
|
|
5068
5105
|
}
|
|
5069
5106
|
endNewInstance();
|
|
5070
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$)
|
|
5107
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) {
|
|
5108
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
5109
|
+
if (ancestorConnected) await ancestorConnected;
|
|
5110
|
+
}
|
|
5071
5111
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
5072
5112
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
5073
5113
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/core",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.10",
|
|
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.
|
|
130
|
-
"@stencil/
|
|
131
|
-
"@stencil/
|
|
129
|
+
"@stencil/dev-server": "5.0.0-rc.10",
|
|
130
|
+
"@stencil/cli": "5.0.0-rc.10",
|
|
131
|
+
"@stencil/mock-doc": "5.0.0-rc.10"
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
134
|
"@ionic/prettier-config": "^4.0.0",
|