@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
|
@@ -227,6 +227,11 @@ const HOST_FLAGS = {
|
|
|
227
227
|
* is true while an initialization attempt is merely queued/in-flight.
|
|
228
228
|
*/
|
|
229
229
|
hasFailedLoad: 2048,
|
|
230
|
+
/**
|
|
231
|
+
* Set while `renderVdom` patches the host, so writes of a serialized reflected value
|
|
232
|
+
* coming from the runtime's own reflection aren't applied back to the prop.
|
|
233
|
+
*/
|
|
234
|
+
isReflecting: 16384,
|
|
230
235
|
devOnRender: 4096,
|
|
231
236
|
devOnDidLoad: 8192
|
|
232
237
|
};
|
|
@@ -1033,7 +1038,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
1033
1038
|
return toReturn;
|
|
1034
1039
|
}
|
|
1035
1040
|
if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
|
|
1036
|
-
return HostElementPrototype.__prepend(newChild);
|
|
1041
|
+
return HostElementPrototype.__prepend.call(this, newChild);
|
|
1037
1042
|
});
|
|
1038
1043
|
};
|
|
1039
1044
|
};
|
|
@@ -1702,7 +1707,7 @@ const attachStyles = (hostRef) => {
|
|
|
1702
1707
|
else if (BUILD$1.hydrateServerSide && BUILD$1.shadowModeClosed && flags & CMP_FLAGS.shadowNeedsScopedCss && flags & CMP_FLAGS.shadowModeClosed) styleContainerNode = elm;
|
|
1703
1708
|
else styleContainerNode = elm.getRootNode();
|
|
1704
1709
|
const scopeId = addStyle(styleContainerNode, cmpMeta, hostRef.$modeName$);
|
|
1705
|
-
if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
|
|
1710
|
+
if ((BUILD$1.shadowDom || BUILD$1.scoped) && BUILD$1.cssAnnotations && flags & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss)) {
|
|
1706
1711
|
elm["s-sc"] = scopeId;
|
|
1707
1712
|
elm.classList.add(scopeId + "-h");
|
|
1708
1713
|
}
|
|
@@ -1789,12 +1794,51 @@ const isComplexType = (o) => {
|
|
|
1789
1794
|
return o === "object" || o === "function";
|
|
1790
1795
|
};
|
|
1791
1796
|
//#endregion
|
|
1792
|
-
//#region src/runtime/
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1797
|
+
//#region src/runtime/parse-property-value.ts
|
|
1798
|
+
/**
|
|
1799
|
+
* Parse a new property value for a given property type.
|
|
1800
|
+
*
|
|
1801
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1802
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1803
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
1804
|
+
* 2. the type stored from `propType`.
|
|
1805
|
+
*
|
|
1806
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1807
|
+
*
|
|
1808
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1809
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1810
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1811
|
+
* ```tsx
|
|
1812
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
1813
|
+
* ```
|
|
1814
|
+
*
|
|
1815
|
+
* HTML prop values on the other hand, will always a string
|
|
1816
|
+
*
|
|
1817
|
+
* @param propValue the new value to coerce to some type
|
|
1818
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
1819
|
+
* @returns the parsed/coerced value
|
|
1820
|
+
*/
|
|
1821
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
1822
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
1823
|
+
/**
|
|
1824
|
+
* ensure this value is of the correct prop type
|
|
1825
|
+
*/
|
|
1826
|
+
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
1827
|
+
/**
|
|
1828
|
+
* force it to be a number
|
|
1829
|
+
*/
|
|
1830
|
+
if (BUILD$1.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
1831
|
+
/**
|
|
1832
|
+
* could have been passed as a number or boolean but we still want it as a string
|
|
1833
|
+
*/
|
|
1834
|
+
if (BUILD$1.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
1835
|
+
return propValue;
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* not sure exactly what type we want so no need to change to a different type
|
|
1839
|
+
*/
|
|
1840
|
+
return propValue;
|
|
1841
|
+
};
|
|
1798
1842
|
//#endregion
|
|
1799
1843
|
//#region src/runtime/event-emitter.ts
|
|
1800
1844
|
const createEvent = (ref, name, flags) => {
|
|
@@ -2745,7 +2789,9 @@ render() {
|
|
|
2745
2789
|
checkSlotFallbackVisibility = false;
|
|
2746
2790
|
checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
|
|
2747
2791
|
}
|
|
2792
|
+
if (BUILD$1.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
2748
2793
|
patch(oldVNode, rootVnode, isInitialLoad);
|
|
2794
|
+
if (BUILD$1.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
2749
2795
|
if (BUILD$1.slotRelocation) {
|
|
2750
2796
|
plt.$flags$ |= PLATFORM_FLAGS.isTmpDisconnected;
|
|
2751
2797
|
if (checkSlotRelocate) {
|
|
@@ -2856,24 +2902,24 @@ const markFirstConnected = (hostRef) => {
|
|
|
2856
2902
|
hostRef.$onFirstConnectResolve$ = void 0;
|
|
2857
2903
|
};
|
|
2858
2904
|
/**
|
|
2859
|
-
*
|
|
2860
|
-
* Shared by the lazy ({@link initializeComponent})
|
|
2861
|
-
* `connectedCallback` paths so a component never
|
|
2862
|
-
* ancestor, regardless of load order.
|
|
2863
|
-
*
|
|
2864
|
-
*
|
|
2865
|
-
*
|
|
2905
|
+
* Get a promise for `ancestorElm` to be defined and its real `connectedCallback` to have
|
|
2906
|
+
* completed, or `undefined` if it already has. Shared by the lazy ({@link initializeComponent})
|
|
2907
|
+
* and standalone (`bootstrap-standalone.ts`) `connectedCallback` paths so a component never
|
|
2908
|
+
* connects before its nearest Stencil ancestor, regardless of load order. Callers only `await`
|
|
2909
|
+
* a returned promise, so a component whose ancestor is already connected carries on
|
|
2910
|
+
* synchronously instead of losing a microtask. Lazy's proxy classes are always pre-defined, so
|
|
2911
|
+
* the `whenDefined` wait only does real work for standalone's autoloader, where the ancestor
|
|
2912
|
+
* tag may not be defined yet.
|
|
2866
2913
|
*
|
|
2867
2914
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2868
2915
|
* @param registry the registry the waiting component is defined in
|
|
2916
|
+
* @returns a promise to await, or `undefined` if there's nothing to wait for
|
|
2869
2917
|
*/
|
|
2870
|
-
const
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
}
|
|
2876
|
-
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
2918
|
+
const whenAncestorConnected = (ancestorElm, registry) => {
|
|
2919
|
+
const pendingConnect = (hostRef) => hostRef && !(hostRef.$flags$ & HOST_FLAGS.hasFiredConnected) ? ensureFirstConnectPromise(hostRef) : void 0;
|
|
2920
|
+
const ancestorHostRef = getHostRef(ancestorElm);
|
|
2921
|
+
if (!BUILD$1.lazyLoad && !ancestorHostRef) return registry.whenDefined(ancestorElm.tagName.toLowerCase()).then(() => pendingConnect(getHostRef(ancestorElm)));
|
|
2922
|
+
return pendingConnect(ancestorHostRef);
|
|
2877
2923
|
};
|
|
2878
2924
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
2879
2925
|
if (BUILD$1.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
@@ -2893,10 +2939,10 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
2893
2939
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
2894
2940
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
2895
2941
|
if (isInitialLoad) {
|
|
2896
|
-
const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2897
|
-
if (pendingConnects && pendingConnects.length > 0) return Promise.all(pendingConnects).then(dispatch).catch(dispatch);
|
|
2898
2942
|
queueMicrotask(() => {
|
|
2899
|
-
|
|
2943
|
+
const pendingConnects = BUILD$1.asyncLoading ? hostRef.$hostElement$["s-pc"] : void 0;
|
|
2944
|
+
if (pendingConnects && pendingConnects.length > 0) Promise.all(pendingConnects).then(dispatch, dispatch);
|
|
2945
|
+
else dispatch();
|
|
2900
2946
|
});
|
|
2901
2947
|
return;
|
|
2902
2948
|
}
|
|
@@ -3199,6 +3245,124 @@ const serverSideConnected = (elm) => {
|
|
|
3199
3245
|
}
|
|
3200
3246
|
};
|
|
3201
3247
|
//#endregion
|
|
3248
|
+
//#region src/runtime/set-value.ts
|
|
3249
|
+
/**
|
|
3250
|
+
* The value a reflected prop writes to its attribute: the serialized value if it has one.
|
|
3251
|
+
* @param hostRef the component's host ref
|
|
3252
|
+
* @param propName the prop
|
|
3253
|
+
* @param val the prop's value
|
|
3254
|
+
* @returns the value to reflect
|
|
3255
|
+
*/
|
|
3256
|
+
const getReflectedValue = (hostRef, propName, val) => BUILD$1.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
|
|
3257
|
+
/**
|
|
3258
|
+
* Write a reflected prop's attribute as soon as the prop changes, like native elements do,
|
|
3259
|
+
* so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
|
|
3260
|
+
* @param hostRef the component's host ref
|
|
3261
|
+
* @param cmpMeta the component's runtime metadata
|
|
3262
|
+
* @param elm the host element
|
|
3263
|
+
* @param propName the prop that changed
|
|
3264
|
+
* @param oldAttrVal the previously reflected value
|
|
3265
|
+
* @param newAttrVal the value to reflect
|
|
3266
|
+
*/
|
|
3267
|
+
const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
|
|
3268
|
+
if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
|
|
3269
|
+
const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
|
|
3270
|
+
if (!attrName) return;
|
|
3271
|
+
if (BUILD$1.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
3272
|
+
setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
|
|
3273
|
+
if (BUILD$1.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
3274
|
+
};
|
|
3275
|
+
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
3276
|
+
const run = (inst) => {
|
|
3277
|
+
let attrVal = val;
|
|
3278
|
+
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
3279
|
+
const [[methodName]] = Object.entries(serializer);
|
|
3280
|
+
attrVal = inst[methodName](attrVal, propName);
|
|
3281
|
+
}
|
|
3282
|
+
hostRef.$serializerValues$.set(propName, attrVal);
|
|
3283
|
+
};
|
|
3284
|
+
if (instance) run(instance);
|
|
3285
|
+
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
3286
|
+
};
|
|
3287
|
+
const getValue = (ref, propName) => {
|
|
3288
|
+
if (BUILD$1.signalBacking) {
|
|
3289
|
+
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
3290
|
+
if (sig !== void 0) return sig.value;
|
|
3291
|
+
}
|
|
3292
|
+
return getHostRef(ref).$instanceValues$.get(propName);
|
|
3293
|
+
};
|
|
3294
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
3295
|
+
const hostRef = getHostRef(ref);
|
|
3296
|
+
if (BUILD$1.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
3297
|
+
if (BUILD$1.signalBacking) {
|
|
3298
|
+
const sig = hostRef?.$signalValues$?.get(propName);
|
|
3299
|
+
if (sig !== void 0) {
|
|
3300
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3301
|
+
if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
3302
|
+
const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3303
|
+
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
3304
|
+
}
|
|
3305
|
+
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
3306
|
+
return;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
if (!hostRef) {
|
|
3310
|
+
if (BUILD$1.lazyLoad) throw new Error(BUILD$1.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
|
|
3311
|
+
return;
|
|
3312
|
+
}
|
|
3313
|
+
const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3314
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
3315
|
+
const flags = hostRef.$flags$;
|
|
3316
|
+
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3317
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3318
|
+
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
3319
|
+
if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
3320
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
3321
|
+
const oldAttrVal = BUILD$1.reflect && getReflectedValue(hostRef, propName, oldVal);
|
|
3322
|
+
if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
3323
|
+
if (BUILD$1.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
|
|
3324
|
+
if (BUILD$1.isDev) {
|
|
3325
|
+
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);
|
|
3326
|
+
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);
|
|
3327
|
+
}
|
|
3328
|
+
if (BUILD$1.propChangeCallback && cmpMeta.$watchers$) {
|
|
3329
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
3330
|
+
if (watchMethods) watchMethods.map((watcher) => {
|
|
3331
|
+
try {
|
|
3332
|
+
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
3333
|
+
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
3334
|
+
if (BUILD$1.signalBacking && !hostRef.$signalValues$) return;
|
|
3335
|
+
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
3336
|
+
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
3337
|
+
});
|
|
3338
|
+
else instance[watchMethodName](newVal, oldVal, propName);
|
|
3339
|
+
}
|
|
3340
|
+
} catch (e) {
|
|
3341
|
+
consoleError(e, elm);
|
|
3342
|
+
}
|
|
3343
|
+
});
|
|
3344
|
+
}
|
|
3345
|
+
if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
3346
|
+
if (instance.componentShouldUpdate) {
|
|
3347
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3348
|
+
changes[propName] = {
|
|
3349
|
+
newVal,
|
|
3350
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
};
|
|
3357
|
+
//#endregion
|
|
3358
|
+
//#region src/runtime/signals-core.ts
|
|
3359
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
3360
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
3361
|
+
const untracked = (fn) => getCore().untracked(fn);
|
|
3362
|
+
function signal(value, options) {
|
|
3363
|
+
return getCore().signal(value, options);
|
|
3364
|
+
}
|
|
3365
|
+
//#endregion
|
|
3202
3366
|
//#region src/runtime/signals.ts
|
|
3203
3367
|
const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
|
|
3204
3368
|
/**
|
|
@@ -3243,6 +3407,14 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3243
3407
|
}
|
|
3244
3408
|
prevScheduleVal = newVal;
|
|
3245
3409
|
}));
|
|
3410
|
+
if (BUILD$1.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
|
|
3411
|
+
let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
|
|
3412
|
+
disposers.push(effect(() => {
|
|
3413
|
+
const attrVal = getReflectedValue(hostRef, memberName, sig.value);
|
|
3414
|
+
untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
|
|
3415
|
+
prevAttrVal = attrVal;
|
|
3416
|
+
}));
|
|
3417
|
+
}
|
|
3246
3418
|
if (BUILD$1.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
|
|
3247
3419
|
const watchMethods = cmpMeta.$watchers$[memberName];
|
|
3248
3420
|
let prevWatchVal = sig.peek();
|
|
@@ -3311,7 +3483,7 @@ const initializeEffects = (elm, hostRef) => {
|
|
|
3311
3483
|
* Modified for Stencil's compiler and vdom
|
|
3312
3484
|
*/
|
|
3313
3485
|
const h = (nodeName, vnodeData, ...children) => {
|
|
3314
|
-
if (typeof nodeName === "string") nodeName = transformTag(nodeName);
|
|
3486
|
+
if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
|
|
3315
3487
|
let child = null;
|
|
3316
3488
|
let key = null;
|
|
3317
3489
|
let slotName = null;
|
|
@@ -3489,7 +3661,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3489
3661
|
let scopeId;
|
|
3490
3662
|
if (BUILD$1.scoped) {
|
|
3491
3663
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
3492
|
-
if (cmpMeta && cmpMeta.$flags$ & CMP_FLAGS.needsScopedEncapsulation && hostElm["s-sc"]) {
|
|
3664
|
+
if (cmpMeta && cmpMeta.$flags$ & (CMP_FLAGS.needsScopedEncapsulation | CMP_FLAGS.shadowNeedsScopedCss) && hostElm["s-sc"]) {
|
|
3493
3665
|
scopeId = hostElm["s-sc"];
|
|
3494
3666
|
hostElm.classList.add(scopeId + "-h");
|
|
3495
3667
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
@@ -3785,7 +3957,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
3785
3957
|
if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
|
|
3786
3958
|
do {
|
|
3787
3959
|
const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
|
|
3788
|
-
if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
|
|
3960
|
+
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)) {
|
|
3789
3961
|
slottedNode["s-sn"] = slotName;
|
|
3790
3962
|
group.push({
|
|
3791
3963
|
slot: slotNode,
|
|
@@ -4307,134 +4479,6 @@ const normalizeWatchers = (raw) => {
|
|
|
4307
4479
|
return out;
|
|
4308
4480
|
};
|
|
4309
4481
|
//#endregion
|
|
4310
|
-
//#region src/runtime/parse-property-value.ts
|
|
4311
|
-
/**
|
|
4312
|
-
* Parse a new property value for a given property type.
|
|
4313
|
-
*
|
|
4314
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
4315
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
4316
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
4317
|
-
* 2. the type stored from `propType`.
|
|
4318
|
-
*
|
|
4319
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
4320
|
-
*
|
|
4321
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
4322
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
4323
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
4324
|
-
* ```tsx
|
|
4325
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
4326
|
-
* ```
|
|
4327
|
-
*
|
|
4328
|
-
* HTML prop values on the other hand, will always a string
|
|
4329
|
-
*
|
|
4330
|
-
* @param propValue the new value to coerce to some type
|
|
4331
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
4332
|
-
* @returns the parsed/coerced value
|
|
4333
|
-
*/
|
|
4334
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
4335
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
4336
|
-
/**
|
|
4337
|
-
* ensure this value is of the correct prop type
|
|
4338
|
-
*/
|
|
4339
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4340
|
-
/**
|
|
4341
|
-
* force it to be a number
|
|
4342
|
-
*/
|
|
4343
|
-
if (BUILD$1.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
4344
|
-
/**
|
|
4345
|
-
* could have been passed as a number or boolean but we still want it as a string
|
|
4346
|
-
*/
|
|
4347
|
-
if (BUILD$1.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
4348
|
-
return propValue;
|
|
4349
|
-
}
|
|
4350
|
-
/**
|
|
4351
|
-
* not sure exactly what type we want so no need to change to a different type
|
|
4352
|
-
*/
|
|
4353
|
-
return propValue;
|
|
4354
|
-
};
|
|
4355
|
-
//#endregion
|
|
4356
|
-
//#region src/runtime/set-value.ts
|
|
4357
|
-
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
4358
|
-
const run = (inst) => {
|
|
4359
|
-
let attrVal = val;
|
|
4360
|
-
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
4361
|
-
const [[methodName]] = Object.entries(serializer);
|
|
4362
|
-
attrVal = inst[methodName](attrVal, propName);
|
|
4363
|
-
}
|
|
4364
|
-
hostRef.$serializerValues$.set(propName, attrVal);
|
|
4365
|
-
};
|
|
4366
|
-
if (instance) run(instance);
|
|
4367
|
-
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
4368
|
-
};
|
|
4369
|
-
const getValue = (ref, propName) => {
|
|
4370
|
-
if (BUILD$1.signalBacking) {
|
|
4371
|
-
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
4372
|
-
if (sig !== void 0) return sig.value;
|
|
4373
|
-
}
|
|
4374
|
-
return getHostRef(ref).$instanceValues$.get(propName);
|
|
4375
|
-
};
|
|
4376
|
-
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
4377
|
-
const hostRef = getHostRef(ref);
|
|
4378
|
-
if (BUILD$1.signalBacking) {
|
|
4379
|
-
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4380
|
-
if (sig !== void 0) {
|
|
4381
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4382
|
-
if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4383
|
-
const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4384
|
-
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
4385
|
-
}
|
|
4386
|
-
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
4387
|
-
return;
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
if (!hostRef) {
|
|
4391
|
-
if (BUILD$1.lazyLoad) throw new Error(BUILD$1.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
|
|
4392
|
-
return;
|
|
4393
|
-
}
|
|
4394
|
-
if (BUILD$1.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
4395
|
-
const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4396
|
-
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4397
|
-
const flags = hostRef.$flags$;
|
|
4398
|
-
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4399
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4400
|
-
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4401
|
-
if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4402
|
-
hostRef.$instanceValues$.set(propName, newVal);
|
|
4403
|
-
if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
4404
|
-
if (BUILD$1.isDev) {
|
|
4405
|
-
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);
|
|
4406
|
-
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);
|
|
4407
|
-
}
|
|
4408
|
-
if (BUILD$1.propChangeCallback && cmpMeta.$watchers$) {
|
|
4409
|
-
const watchMethods = cmpMeta.$watchers$[propName];
|
|
4410
|
-
if (watchMethods) watchMethods.map((watcher) => {
|
|
4411
|
-
try {
|
|
4412
|
-
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4413
|
-
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
4414
|
-
if (BUILD$1.signalBacking && !hostRef.$signalValues$) return;
|
|
4415
|
-
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
4416
|
-
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
4417
|
-
});
|
|
4418
|
-
else instance[watchMethodName](newVal, oldVal, propName);
|
|
4419
|
-
}
|
|
4420
|
-
} catch (e) {
|
|
4421
|
-
consoleError(e, elm);
|
|
4422
|
-
}
|
|
4423
|
-
});
|
|
4424
|
-
}
|
|
4425
|
-
if (BUILD$1.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4426
|
-
if (instance.componentShouldUpdate) {
|
|
4427
|
-
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4428
|
-
changes[propName] = {
|
|
4429
|
-
newVal,
|
|
4430
|
-
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4431
|
-
};
|
|
4432
|
-
}
|
|
4433
|
-
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4434
|
-
}
|
|
4435
|
-
}
|
|
4436
|
-
};
|
|
4437
|
-
//#endregion
|
|
4438
4482
|
//#region src/runtime/proxy-component.ts
|
|
4439
4483
|
/**
|
|
4440
4484
|
* Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
|
|
@@ -4567,7 +4611,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4567
4611
|
plt.jmp(() => {
|
|
4568
4612
|
const propName = attrNameToPropName.get(attrName);
|
|
4569
4613
|
const hostRef = getHostRef(this);
|
|
4570
|
-
if (BUILD$1.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) return;
|
|
4614
|
+
if (BUILD$1.serializer && hostRef.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) return;
|
|
4571
4615
|
if (this.hasOwnProperty(propName) && BUILD$1.lazyLoad) {
|
|
4572
4616
|
newValue = this[propName];
|
|
4573
4617
|
delete this[propName];
|
|
@@ -4677,7 +4721,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4677
4721
|
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4678
4722
|
}
|
|
4679
4723
|
endNewInstance();
|
|
4680
|
-
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$)
|
|
4724
|
+
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) {
|
|
4725
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4726
|
+
if (ancestorConnected) await ancestorConnected;
|
|
4727
|
+
}
|
|
4681
4728
|
if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4682
4729
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4683
4730
|
if (BUILD$1.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -5078,8 +5125,11 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
5078
5125
|
}
|
|
5079
5126
|
connectedCallback(this);
|
|
5080
5127
|
if (BUILD$1.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
5081
|
-
|
|
5082
|
-
if (
|
|
5128
|
+
const ancestorConnected = whenAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
5129
|
+
if (ancestorConnected) {
|
|
5130
|
+
await ancestorConnected;
|
|
5131
|
+
if (!this.isConnected) return;
|
|
5132
|
+
}
|
|
5083
5133
|
}
|
|
5084
5134
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
5085
5135
|
if (BUILD$1.asyncLoading && hostRef) markFirstConnected(hostRef);
|
|
@@ -5227,7 +5277,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
5227
5277
|
if (!hostRef) return;
|
|
5228
5278
|
const i = deferredConnectedCallbacks.findIndex((host) => host === this);
|
|
5229
5279
|
if (i > -1) deferredConnectedCallbacks.splice(i, 1);
|
|
5230
|
-
if (hostRef
|
|
5280
|
+
if (hostRef.$vnode$?.$elm$?.isConnected === false) delete hostRef.$vnode$.$elm$;
|
|
5231
5281
|
});
|
|
5232
5282
|
}
|
|
5233
5283
|
componentOnReady() {
|