@stencil/core 5.0.0-rc.0 → 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-ClM4H9-P.mjs → client-DkvdNuPu.mjs} +12 -10
- 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/utils/index.mjs +3 -3
- package/dist/{compiler-DFanjq9z.mjs → compiler-ChKFuRry.mjs} +329 -126
- package/dist/declarations/stencil-public-compiler.d.ts +25 -7
- package/dist/{helpers-Cpp3qc3u.mjs → helpers-pTCZhNi0.mjs} +5 -0
- package/dist/{index-DvfFOkiJ.d.mts → index-BxnfbT3a.d.mts} +30 -7
- package/dist/{index-aBMJC5F9.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-DJP8JuAS.mjs → node-C59vQZNg.mjs} +3 -3
- package/dist/runtime/client/lazy.js +211 -161
- package/dist/runtime/client/runtime.js +211 -161
- package/dist/runtime/index.js +211 -161
- package/dist/runtime/server/index.mjs +211 -161
- 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 +207 -160
- package/dist/{util-C-H1H84W.mjs → util-CP6-333M.mjs} +1 -1
- package/dist/{validation-ByYYKvnS.mjs → validation-C1mr0klL.mjs} +2 -2
- package/package.json +4 -4
|
@@ -233,6 +233,11 @@ const HOST_FLAGS = {
|
|
|
233
233
|
* is true while an initialization attempt is merely queued/in-flight.
|
|
234
234
|
*/
|
|
235
235
|
hasFailedLoad: 2048,
|
|
236
|
+
/**
|
|
237
|
+
* Set while `renderVdom` patches the host, so writes of a serialized reflected value
|
|
238
|
+
* coming from the runtime's own reflection aren't applied back to the prop.
|
|
239
|
+
*/
|
|
240
|
+
isReflecting: 16384,
|
|
236
241
|
devOnRender: 4096,
|
|
237
242
|
devOnDidLoad: 8192
|
|
238
243
|
};
|
|
@@ -1039,7 +1044,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
1039
1044
|
return toReturn;
|
|
1040
1045
|
}
|
|
1041
1046
|
if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
|
|
1042
|
-
return HostElementPrototype.__prepend(newChild);
|
|
1047
|
+
return HostElementPrototype.__prepend.call(this, newChild);
|
|
1043
1048
|
});
|
|
1044
1049
|
};
|
|
1045
1050
|
};
|
|
@@ -1708,7 +1713,7 @@ const attachStyles = (hostRef) => {
|
|
|
1708
1713
|
else if (BUILD.hydrateServerSide && BUILD.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
|
|
1709
1714
|
else styleContainerNode = elm.getRootNode();
|
|
1710
1715
|
const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
|
|
1711
|
-
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
|
|
1716
|
+
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
|
|
1712
1717
|
elm["s-sc"] = scopeId;
|
|
1713
1718
|
elm.classList.add(scopeId + "-h");
|
|
1714
1719
|
}
|
|
@@ -1795,12 +1800,51 @@ const isComplexType = (o) => {
|
|
|
1795
1800
|
return o === "object" || o === "function";
|
|
1796
1801
|
};
|
|
1797
1802
|
//#endregion
|
|
1798
|
-
//#region src/runtime/
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1803
|
+
//#region src/runtime/parse-property-value.ts
|
|
1804
|
+
/**
|
|
1805
|
+
* Parse a new property value for a given property type.
|
|
1806
|
+
*
|
|
1807
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1808
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1809
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
1810
|
+
* 2. the type stored from `propType`.
|
|
1811
|
+
*
|
|
1812
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1813
|
+
*
|
|
1814
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1815
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1816
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1817
|
+
* ```tsx
|
|
1818
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
1819
|
+
* ```
|
|
1820
|
+
*
|
|
1821
|
+
* HTML prop values on the other hand, will always a string
|
|
1822
|
+
*
|
|
1823
|
+
* @param propValue the new value to coerce to some type
|
|
1824
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
1825
|
+
* @returns the parsed/coerced value
|
|
1826
|
+
*/
|
|
1827
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
1828
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
1829
|
+
/**
|
|
1830
|
+
* ensure this value is of the correct prop type
|
|
1831
|
+
*/
|
|
1832
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
1833
|
+
/**
|
|
1834
|
+
* force it to be a number
|
|
1835
|
+
*/
|
|
1836
|
+
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
1837
|
+
/**
|
|
1838
|
+
* could have been passed as a number or boolean but we still want it as a string
|
|
1839
|
+
*/
|
|
1840
|
+
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
1841
|
+
return propValue;
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* not sure exactly what type we want so no need to change to a different type
|
|
1845
|
+
*/
|
|
1846
|
+
return propValue;
|
|
1847
|
+
};
|
|
1804
1848
|
//#endregion
|
|
1805
1849
|
//#region src/runtime/event-emitter.ts
|
|
1806
1850
|
const createEvent = (ref, name, flags) => {
|
|
@@ -2751,7 +2795,9 @@ render() {
|
|
|
2751
2795
|
checkSlotFallbackVisibility = false;
|
|
2752
2796
|
checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
|
|
2753
2797
|
}
|
|
2798
|
+
if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
2754
2799
|
patch(oldVNode, rootVnode, isInitialLoad);
|
|
2800
|
+
if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
2755
2801
|
if (BUILD.slotRelocation) {
|
|
2756
2802
|
plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
|
|
2757
2803
|
if (checkSlotRelocate) {
|
|
@@ -2862,24 +2908,24 @@ const markFirstConnected = (hostRef) => {
|
|
|
2862
2908
|
hostRef.$onFirstConnectResolve$ = void 0;
|
|
2863
2909
|
};
|
|
2864
2910
|
/**
|
|
2865
|
-
*
|
|
2866
|
-
* Shared by the lazy ({@link initializeComponent})
|
|
2867
|
-
* `connectedCallback` paths so a component never
|
|
2868
|
-
* ancestor, regardless of load order.
|
|
2869
|
-
*
|
|
2870
|
-
*
|
|
2871
|
-
*
|
|
2911
|
+
* Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
|
|
2912
|
+
* completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
|
|
2913
|
+
* and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
|
|
2914
|
+
* connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
|
|
2915
|
+
* a returned promise, so a component whose ancestor is already connected carries on
|
|
2916
|
+
* synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
|
|
2917
|
+
* the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
|
|
2918
|
+
* tag may not be defined yet.
|
|
2872
2919
|
*
|
|
2873
2920
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2874
2921
|
* @param registry the registry the waiting component is defined in
|
|
2922
|
+
* @returns a promise to await, or `undefined` if there's nothing to wait for
|
|
2875
2923
|
*/
|
|
2876
|
-
const
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
}
|
|
2882
|
-
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
2924
|
+
const whenAncestorConnected = (ancestorElm, registry) => {
|
|
2925
|
+
const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
|
|
2926
|
+
const ancestorHostRef = getHostRef(ancestorElm);
|
|
2927
|
+
if (!BUILD.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
|
|
2928
|
+
return pendingConnect(ancestorHostRef);
|
|
2883
2929
|
};
|
|
2884
2930
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
2885
2931
|
if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
@@ -2899,10 +2945,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
2899
2945
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
2900
2946
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
2901
2947
|
if (isInitialLoad) {
|
|
2902
|
-
const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2903
|
-
if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
|
|
2904
2948
|
queueMicrotask(() => {
|
|
2905
|
-
|
|
2949
|
+
const pendingConnects = BUILD.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2950
|
+
if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
|
|
2951
|
+
else dispatch();
|
|
2906
2952
|
});
|
|
2907
2953
|
return;
|
|
2908
2954
|
}
|
|
@@ -3205,6 +3251,124 @@ const serverSideConnected = (elm) => {
|
|
|
3205
3251
|
}
|
|
3206
3252
|
};
|
|
3207
3253
|
//#endregion
|
|
3254
|
+
//#region src/runtime/set-value.ts
|
|
3255
|
+
/**
|
|
3256
|
+
* The value a reflected prop writes to its attribute: the serialized value if it has one.
|
|
3257
|
+
* @param hostRef the component's host ref
|
|
3258
|
+
* @param propName the prop
|
|
3259
|
+
* @param val the prop's value
|
|
3260
|
+
* @returns the value to reflect
|
|
3261
|
+
*/
|
|
3262
|
+
const getReflectedValue = (hostRef, propName, val) => BUILD.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
|
|
3263
|
+
/**
|
|
3264
|
+
* Write a reflected prop's attribute as soon as the prop changes, like native elements do,
|
|
3265
|
+
* so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
|
|
3266
|
+
* @param hostRef the component's host ref
|
|
3267
|
+
* @param cmpMeta the component's runtime metadata
|
|
3268
|
+
* @param elm the host element
|
|
3269
|
+
* @param propName the prop that changed
|
|
3270
|
+
* @param oldAttrVal the previously reflected value
|
|
3271
|
+
* @param newAttrVal the value to reflect
|
|
3272
|
+
*/
|
|
3273
|
+
const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
|
|
3274
|
+
if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
|
|
3275
|
+
const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
|
|
3276
|
+
if (!attrName) return;
|
|
3277
|
+
if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
3278
|
+
setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
|
|
3279
|
+
if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
3280
|
+
};
|
|
3281
|
+
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
3282
|
+
const run = (inst) => {
|
|
3283
|
+
let attrVal = val;
|
|
3284
|
+
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
3285
|
+
const [[methodName]] = Object.entries(serializer);
|
|
3286
|
+
attrVal = inst[methodName](attrVal, propName);
|
|
3287
|
+
}
|
|
3288
|
+
hostRef.$serializerValues$.set(propName, attrVal);
|
|
3289
|
+
};
|
|
3290
|
+
if (instance) run(instance);
|
|
3291
|
+
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
3292
|
+
};
|
|
3293
|
+
const getValue = (ref, propName) => {
|
|
3294
|
+
if (BUILD.signalBacking) {
|
|
3295
|
+
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
3296
|
+
if (sig !== void 0) return sig.value;
|
|
3297
|
+
}
|
|
3298
|
+
return getHostRef(ref).$instanceValues$.get(propName);
|
|
3299
|
+
};
|
|
3300
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
3301
|
+
const hostRef = getHostRef(ref);
|
|
3302
|
+
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
3303
|
+
if (BUILD.signalBacking) {
|
|
3304
|
+
const sig = hostRef?.$signalValues$?.get(propName);
|
|
3305
|
+
if (sig !== void 0) {
|
|
3306
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3307
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
3308
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3309
|
+
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
3310
|
+
}
|
|
3311
|
+
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
if (!hostRef) {
|
|
3316
|
+
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$}"`);
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3320
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
3321
|
+
const flags = hostRef.$flags$;
|
|
3322
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3323
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3324
|
+
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
3325
|
+
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
3326
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
3327
|
+
const oldAttrVal = BUILD.reflect && getReflectedValue(hostRef, propName, oldVal);
|
|
3328
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
3329
|
+
if (BUILD.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
|
|
3330
|
+
if (BUILD.isDev) {
|
|
3331
|
+
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);
|
|
3332
|
+
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);
|
|
3333
|
+
}
|
|
3334
|
+
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
3335
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
3336
|
+
if (watchMethods) watchMethods.map((watcher) => {
|
|
3337
|
+
try {
|
|
3338
|
+
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
3339
|
+
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
3340
|
+
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
3341
|
+
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
3342
|
+
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
3343
|
+
});
|
|
3344
|
+
else instance[watchMethodName](newVal, oldVal, propName);
|
|
3345
|
+
}
|
|
3346
|
+
} catch (e) {
|
|
3347
|
+
consoleError(e, elm);
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
3352
|
+
if (instance.componentShouldUpdate) {
|
|
3353
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3354
|
+
changes[propName] = {
|
|
3355
|
+
newVal,
|
|
3356
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
3357
|
+
};
|
|
3358
|
+
}
|
|
3359
|
+
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
//#endregion
|
|
3364
|
+
//#region src/runtime/signals-core.ts
|
|
3365
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
3366
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
3367
|
+
const untracked = (fn) => getCore().untracked(fn);
|
|
3368
|
+
function signal(value, options) {
|
|
3369
|
+
return getCore().signal(value, options);
|
|
3370
|
+
}
|
|
3371
|
+
//#endregion
|
|
3208
3372
|
//#region src/runtime/signals.ts
|
|
3209
3373
|
const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
|
|
3210
3374
|
/**
|
|
@@ -3249,6 +3413,14 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3249
3413
|
}
|
|
3250
3414
|
prevScheduleVal = newVal;
|
|
3251
3415
|
}));
|
|
3416
|
+
if (BUILD.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
|
|
3417
|
+
let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
|
|
3418
|
+
disposers.push(effect(() => {
|
|
3419
|
+
const attrVal = getReflectedValue(hostRef, memberName, sig.value);
|
|
3420
|
+
untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
|
|
3421
|
+
prevAttrVal = attrVal;
|
|
3422
|
+
}));
|
|
3423
|
+
}
|
|
3252
3424
|
if (BUILD.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
|
|
3253
3425
|
const watchMethods = cmpMeta.$watchers$[memberName];
|
|
3254
3426
|
let prevWatchVal = sig.peek();
|
|
@@ -3317,7 +3489,7 @@ const initializeEffects = (elm, hostRef) => {
|
|
|
3317
3489
|
* Modified for Stencil's compiler and vdom
|
|
3318
3490
|
*/
|
|
3319
3491
|
const h = (nodeName, vnodeData, ...children) => {
|
|
3320
|
-
if (typeof nodeName === "string") nodeName = transformTag(nodeName);
|
|
3492
|
+
if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
|
|
3321
3493
|
let child = null;
|
|
3322
3494
|
let key = null;
|
|
3323
3495
|
let slotName = null;
|
|
@@ -3495,7 +3667,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3495
3667
|
let scopeId;
|
|
3496
3668
|
if (BUILD.scoped) {
|
|
3497
3669
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
3498
|
-
if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
|
|
3670
|
+
if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
|
|
3499
3671
|
scopeId = hostElm["s-sc"];
|
|
3500
3672
|
hostElm.classList.add(scopeId + "-h");
|
|
3501
3673
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
@@ -3791,7 +3963,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
3791
3963
|
if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
|
|
3792
3964
|
do {
|
|
3793
3965
|
const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
|
|
3794
|
-
if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
|
|
3966
|
+
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)) {
|
|
3795
3967
|
slottedNode["s-sn"] = slotName;
|
|
3796
3968
|
group.push({
|
|
3797
3969
|
slot: slotNode,
|
|
@@ -4313,134 +4485,6 @@ const normalizeWatchers = (raw) => {
|
|
|
4313
4485
|
return out;
|
|
4314
4486
|
};
|
|
4315
4487
|
//#endregion
|
|
4316
|
-
//#region src/runtime/parse-property-value.ts
|
|
4317
|
-
/**
|
|
4318
|
-
* Parse a new property value for a given property type.
|
|
4319
|
-
*
|
|
4320
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
4321
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
4322
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
4323
|
-
* 2. the type stored from `propType`.
|
|
4324
|
-
*
|
|
4325
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
4326
|
-
*
|
|
4327
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
4328
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
4329
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
4330
|
-
* ```tsx
|
|
4331
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
4332
|
-
* ```
|
|
4333
|
-
*
|
|
4334
|
-
* HTML prop values on the other hand, will always a string
|
|
4335
|
-
*
|
|
4336
|
-
* @param propValue the new value to coerce to some type
|
|
4337
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
4338
|
-
* @returns the parsed/coerced value
|
|
4339
|
-
*/
|
|
4340
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
4341
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
4342
|
-
/**
|
|
4343
|
-
* ensure this value is of the correct prop type
|
|
4344
|
-
*/
|
|
4345
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4346
|
-
/**
|
|
4347
|
-
* force it to be a number
|
|
4348
|
-
*/
|
|
4349
|
-
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
4350
|
-
/**
|
|
4351
|
-
* could have been passed as a number or boolean but we still want it as a string
|
|
4352
|
-
*/
|
|
4353
|
-
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
4354
|
-
return propValue;
|
|
4355
|
-
}
|
|
4356
|
-
/**
|
|
4357
|
-
* not sure exactly what type we want so no need to change to a different type
|
|
4358
|
-
*/
|
|
4359
|
-
return propValue;
|
|
4360
|
-
};
|
|
4361
|
-
//#endregion
|
|
4362
|
-
//#region src/runtime/set-value.ts
|
|
4363
|
-
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
4364
|
-
const run = (inst) => {
|
|
4365
|
-
let attrVal = val;
|
|
4366
|
-
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
4367
|
-
const [[methodName]] = Object.entries(serializer);
|
|
4368
|
-
attrVal = inst[methodName](attrVal, propName);
|
|
4369
|
-
}
|
|
4370
|
-
hostRef.$serializerValues$.set(propName, attrVal);
|
|
4371
|
-
};
|
|
4372
|
-
if (instance) run(instance);
|
|
4373
|
-
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
4374
|
-
};
|
|
4375
|
-
const getValue = (ref, propName) => {
|
|
4376
|
-
if (BUILD.signalBacking) {
|
|
4377
|
-
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
4378
|
-
if (sig !== void 0) return sig.value;
|
|
4379
|
-
}
|
|
4380
|
-
return getHostRef(ref).$instanceValues$.get(propName);
|
|
4381
|
-
};
|
|
4382
|
-
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
4383
|
-
const hostRef = getHostRef(ref);
|
|
4384
|
-
if (BUILD.signalBacking) {
|
|
4385
|
-
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4386
|
-
if (sig !== void 0) {
|
|
4387
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4388
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4389
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4390
|
-
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
4391
|
-
}
|
|
4392
|
-
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
4393
|
-
return;
|
|
4394
|
-
}
|
|
4395
|
-
}
|
|
4396
|
-
if (!hostRef) {
|
|
4397
|
-
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$}"`);
|
|
4398
|
-
return;
|
|
4399
|
-
}
|
|
4400
|
-
if (BUILD.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
4401
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4402
|
-
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4403
|
-
const flags = hostRef.$flags$;
|
|
4404
|
-
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4405
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4406
|
-
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4407
|
-
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4408
|
-
hostRef.$instanceValues$.set(propName, newVal);
|
|
4409
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
4410
|
-
if (BUILD.isDev) {
|
|
4411
|
-
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);
|
|
4412
|
-
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);
|
|
4413
|
-
}
|
|
4414
|
-
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
4415
|
-
const watchMethods = cmpMeta.$watchers$[propName];
|
|
4416
|
-
if (watchMethods) watchMethods.map((watcher) => {
|
|
4417
|
-
try {
|
|
4418
|
-
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4419
|
-
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
4420
|
-
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
4421
|
-
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
4422
|
-
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
4423
|
-
});
|
|
4424
|
-
else instance[watchMethodName](newVal, oldVal, propName);
|
|
4425
|
-
}
|
|
4426
|
-
} catch (e) {
|
|
4427
|
-
consoleError(e, elm);
|
|
4428
|
-
}
|
|
4429
|
-
});
|
|
4430
|
-
}
|
|
4431
|
-
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4432
|
-
if (instance.componentShouldUpdate) {
|
|
4433
|
-
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4434
|
-
changes[propName] = {
|
|
4435
|
-
newVal,
|
|
4436
|
-
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4437
|
-
};
|
|
4438
|
-
}
|
|
4439
|
-
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4440
|
-
}
|
|
4441
|
-
}
|
|
4442
|
-
};
|
|
4443
|
-
//#endregion
|
|
4444
4488
|
//#region src/runtime/proxy-component.ts
|
|
4445
4489
|
/**
|
|
4446
4490
|
* Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
|
|
@@ -4573,7 +4617,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4573
4617
|
plt.jmp(() => {
|
|
4574
4618
|
const propName = attrNameToPropName.get(attrName);
|
|
4575
4619
|
const hostRef = getHostRef(this);
|
|
4576
|
-
if (BUILD.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) return;
|
|
4620
|
+
if (BUILD.serializer && hostRef.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) return;
|
|
4577
4621
|
if (this.hasOwnProperty(propName) && BUILD.lazyLoad) {
|
|
4578
4622
|
newValue = this[propName];
|
|
4579
4623
|
delete this[propName];
|
|
@@ -4683,7 +4727,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4683
4727
|
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4684
4728
|
}
|
|
4685
4729
|
endNewInstance();
|
|
4686
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$)
|
|
4730
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) {
|
|
4731
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4732
|
+
if (ancestorConnected) await ancestorConnected;
|
|
4733
|
+
}
|
|
4687
4734
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4688
4735
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4689
4736
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -5084,8 +5131,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
5084
5131
|
}
|
|
5085
5132
|
connectedCallback(this);
|
|
5086
5133
|
if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
5087
|
-
|
|
5088
|
-
if (
|
|
5134
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
5135
|
+
if (ancestorConnected) {
|
|
5136
|
+
await ancestorConnected;
|
|
5137
|
+
if (!this.isConnected) return;
|
|
5138
|
+
}
|
|
5089
5139
|
}
|
|
5090
5140
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
5091
5141
|
if (BUILD.asyncLoading && hostRef) markFirstConnected(hostRef);
|
|
@@ -5233,7 +5283,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
5233
5283
|
if (!hostRef) return;
|
|
5234
5284
|
const i = deferredConnectedCallbacks.findIndex((host) => host === this);
|
|
5235
5285
|
if (i > -1) deferredConnectedCallbacks.splice(i, 1);
|
|
5236
|
-
if (hostRef
|
|
5286
|
+
if (hostRef.$vnode$?.$elm$?.isConnected === false) delete hostRef.$vnode$.$elm$;
|
|
5237
5287
|
});
|
|
5238
5288
|
}
|
|
5239
5289
|
componentOnReady() {
|