@stencil/core 5.0.0-beta.12 → 5.0.0-beta.13
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-CdFmjaQa.mjs → client-NHI55T4R.mjs} +7 -4
- package/dist/compiler/browser.d.ts +96 -54
- package/dist/compiler/browser.js +140 -18
- package/dist/compiler/index.d.mts +87 -2
- package/dist/compiler/index.mjs +3 -3
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/{compiler-BjKDj129.mjs → compiler-Dr9JHtLp.mjs} +3571 -2384
- package/dist/declarations/stencil-public-compiler.d.ts +85 -59
- package/dist/declarations/stencil-public-docs.d.ts +23 -0
- package/dist/declarations/stencil-public-runtime.d.ts +2 -2
- package/dist/{index-CKnzMkZC.d.mts → index-BBJVAnzJ.d.mts} +2 -2
- package/dist/{index-Cw1NW9FW.d.mts → index-BilaSOF5.d.mts} +87 -61
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-HKfDhPR3.mjs → node-DrwzfDH1.mjs} +1 -1
- package/dist/runtime/client/lazy.js +87 -84
- package/dist/runtime/client/runtime.d.ts +5 -6
- package/dist/runtime/client/runtime.js +87 -84
- package/dist/runtime/index.d.ts +2 -3
- package/dist/runtime/index.js +85 -82
- package/dist/runtime/server/index.d.mts +4 -5
- package/dist/runtime/server/index.mjs +97 -84
- package/dist/runtime/server/runner.mjs +27 -41
- package/dist/sys/node/index.d.mts +1 -1
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.mjs +2 -2
- package/dist/testing/index.d.mts +77 -58
- package/dist/testing/index.mjs +167 -156
- package/package.json +5 -4
|
@@ -2277,8 +2277,8 @@ declare const setErrorHandler: (handler: ErrorHandler) => ErrorHandler;
|
|
|
2277
2277
|
//#endregion
|
|
2278
2278
|
//#region src/client/client-style.d.ts
|
|
2279
2279
|
declare const styles: StyleMap;
|
|
2280
|
-
declare const
|
|
2281
|
-
declare const
|
|
2280
|
+
declare const modeResolver: ResolutionHandler[];
|
|
2281
|
+
declare const setScopedSSR: (_opts: SsrFactoryOptions) => void;
|
|
2282
2282
|
declare const needsScopedSSR: () => boolean;
|
|
2283
2283
|
//#endregion
|
|
2284
2284
|
//#region src/client/client-task-queue.d.ts
|
|
@@ -2384,7 +2384,7 @@ type Ctor<T = {}> = new (...args: any[]) => T;
|
|
|
2384
2384
|
declare function Mixin(...mixins: ((base: Ctor) => Ctor)[]): Ctor<{}>;
|
|
2385
2385
|
//#endregion
|
|
2386
2386
|
//#region src/runtime/mode.d.ts
|
|
2387
|
-
declare const setMode: (handler: ResolutionHandler) =>
|
|
2387
|
+
declare const setMode: (handler: ResolutionHandler) => void;
|
|
2388
2388
|
declare const getMode: (ref: RuntimeRef) => string;
|
|
2389
2389
|
//#endregion
|
|
2390
2390
|
//#region src/runtime/nonce.d.ts
|
|
@@ -2442,10 +2442,9 @@ declare const normalizeWatchers: (raw: ComponentConstructorChangeHandlers | unde
|
|
|
2442
2442
|
*
|
|
2443
2443
|
* @param propValue the new value to coerce to some type
|
|
2444
2444
|
* @param propType the type of the prop, expressed as a binary number
|
|
2445
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
2446
2445
|
* @returns the parsed/coerced value
|
|
2447
2446
|
*/
|
|
2448
|
-
declare const parsePropertyValue: (propValue: unknown, propType: number
|
|
2447
|
+
declare const parsePropertyValue: (propValue: unknown, propType: number) => any;
|
|
2449
2448
|
//#endregion
|
|
2450
2449
|
//#region src/runtime/platform-options.d.ts
|
|
2451
2450
|
interface SetPlatformOptions {
|
|
@@ -2542,4 +2541,4 @@ declare const jsxs: typeof jsx;
|
|
|
2542
2541
|
*/
|
|
2543
2542
|
declare const jsxDEV: typeof jsx;
|
|
2544
2543
|
//#endregion
|
|
2545
|
-
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, type HTMLStencilElement, HYDRATED_STYLE_ID, Host, type JSXBase, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule,
|
|
2544
|
+
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, type HTMLStencilElement, HYDRATED_STYLE_ID, Host, type JSXBase, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
|
|
@@ -488,8 +488,8 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
488
488
|
//#endregion
|
|
489
489
|
//#region src/client/client-style.ts
|
|
490
490
|
const styles = /*@__PURE__*/ new Map();
|
|
491
|
-
const
|
|
492
|
-
const
|
|
491
|
+
const modeResolver = [];
|
|
492
|
+
const setScopedSSR = (_opts) => {};
|
|
493
493
|
const needsScopedSSR = () => false;
|
|
494
494
|
//#endregion
|
|
495
495
|
//#region src/runtime/runtime-constants.ts
|
|
@@ -1847,10 +1847,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1847
1847
|
const isComplex = isComplexType(newValue);
|
|
1848
1848
|
if (!BUILD$1.lazyLoad) {
|
|
1849
1849
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1850
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1850
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1851
1851
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1852
1852
|
elm["s-pp"].set(memberName, newValue);
|
|
1853
|
-
return;
|
|
1853
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1854
1854
|
}
|
|
1855
1855
|
}
|
|
1856
1856
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -4128,8 +4128,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4128
4128
|
};
|
|
4129
4129
|
//#endregion
|
|
4130
4130
|
//#region src/runtime/mode.ts
|
|
4131
|
-
const computeMode = (elm) =>
|
|
4132
|
-
const setMode = (handler) =>
|
|
4131
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4132
|
+
const setMode = (handler) => {
|
|
4133
|
+
modeResolver.length = 0;
|
|
4134
|
+
modeResolver.push(handler);
|
|
4135
|
+
};
|
|
4133
4136
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
4134
4137
|
//#endregion
|
|
4135
4138
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4194,23 +4197,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4194
4197
|
*
|
|
4195
4198
|
* @param propValue the new value to coerce to some type
|
|
4196
4199
|
* @param propType the type of the prop, expressed as a binary number
|
|
4197
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4198
4200
|
* @returns the parsed/coerced value
|
|
4199
4201
|
*/
|
|
4200
|
-
const parsePropertyValue = (propValue, propType
|
|
4202
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4201
4203
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4202
4204
|
/**
|
|
4203
4205
|
* ensure this value is of the correct prop type
|
|
4204
4206
|
*/
|
|
4205
|
-
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4206
|
-
/**
|
|
4207
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4208
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4209
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4210
|
-
*/
|
|
4211
|
-
if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4212
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4213
|
-
}
|
|
4207
|
+
if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4214
4208
|
/**
|
|
4215
4209
|
* force it to be a number
|
|
4216
4210
|
*/
|
|
@@ -4252,7 +4246,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4252
4246
|
if (BUILD$1.signalBacking) {
|
|
4253
4247
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4254
4248
|
if (sig !== void 0) {
|
|
4255
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4249
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4256
4250
|
if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4257
4251
|
const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4258
4252
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4270,7 +4264,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4270
4264
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4271
4265
|
const flags = hostRef.$flags$;
|
|
4272
4266
|
const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4273
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4267
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4274
4268
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4275
4269
|
if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4276
4270
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4319,6 +4313,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4319
4313
|
*/
|
|
4320
4314
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4321
4315
|
/**
|
|
4316
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4317
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4318
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4319
|
+
*
|
|
4320
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4321
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4322
|
+
*/
|
|
4323
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4324
|
+
const instance = hostRef.$lazyInstance$;
|
|
4325
|
+
if (!instance) return;
|
|
4326
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4327
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4328
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4329
|
+
}
|
|
4330
|
+
};
|
|
4331
|
+
/**
|
|
4322
4332
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4323
4333
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4324
4334
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4375,9 +4385,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4375
4385
|
if (BUILD$1.lazyLoad) {
|
|
4376
4386
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4377
4387
|
const ref = getHostRef(this);
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
return instance[memberName];
|
|
4388
|
+
if (!ref) return prototype[memberName];
|
|
4389
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4381
4390
|
}
|
|
4382
4391
|
if (!BUILD$1.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4383
4392
|
},
|
|
@@ -4392,7 +4401,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4392
4401
|
}
|
|
4393
4402
|
if (origSetter) {
|
|
4394
4403
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4395
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4404
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4396
4405
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4397
4406
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4398
4407
|
return;
|
|
@@ -4404,26 +4413,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4404
4413
|
if (BUILD$1.lazyLoad) {
|
|
4405
4414
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4406
4415
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4407
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4408
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4409
|
-
});
|
|
4410
4416
|
return;
|
|
4411
4417
|
}
|
|
4412
|
-
const parsedValue = parsePropertyValue(newValue, memberFlags
|
|
4413
|
-
|
|
4418
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4419
|
+
if (ref.$lazyInstance$) {
|
|
4414
4420
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4415
4421
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4416
|
-
ref.$lazyInstance$[memberName] =
|
|
4422
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4417
4423
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4418
|
-
};
|
|
4419
|
-
if (ref.$lazyInstance$) setterSetVal(parsedValue);
|
|
4420
|
-
else {
|
|
4421
|
-
ref.$instanceValues$.set(memberName, parsedValue);
|
|
4422
|
-
ref.$fetchedCbList$.push(() => {
|
|
4423
|
-
const pendingValue = ref.$instanceValues$.get(memberName);
|
|
4424
|
-
if (ref.$lazyInstance$[memberName] !== pendingValue) setterSetVal(pendingValue);
|
|
4425
|
-
});
|
|
4426
|
-
}
|
|
4424
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4427
4425
|
}
|
|
4428
4426
|
} });
|
|
4429
4427
|
} else if (BUILD$1.lazyLoad && BUILD$1.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4475,10 +4473,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4475
4473
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4476
4474
|
if (BUILD$1.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4477
4475
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4478
|
-
if (isBooleanTarget)
|
|
4479
|
-
|
|
4476
|
+
if (isBooleanTarget) {
|
|
4477
|
+
if (BUILD$1.isDev && newValue === "false") consoleDevWarn(`<${cmpMeta.$tagName$} ${attrName}="false">: boolean attributes are true when present, regardless of value. Remove the attribute or set the "${propName}" property to false instead.`);
|
|
4478
|
+
newValue = newValue !== null;
|
|
4479
|
+
}
|
|
4480
4480
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4481
|
-
if (!isSpuriousBooleanRemoval && newValue !=
|
|
4481
|
+
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4482
4482
|
});
|
|
4483
4483
|
};
|
|
4484
4484
|
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
@@ -4539,7 +4539,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4539
4539
|
} catch (e) {
|
|
4540
4540
|
consoleError(e, elm);
|
|
4541
4541
|
}
|
|
4542
|
-
if (BUILD$1.member)
|
|
4542
|
+
if (BUILD$1.member) {
|
|
4543
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4544
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4545
|
+
}
|
|
4543
4546
|
endNewInstance();
|
|
4544
4547
|
if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4545
4548
|
if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
@@ -4759,48 +4762,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4759
4762
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4760
4763
|
);
|
|
4761
4764
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4762
|
-
if (
|
|
4763
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4764
|
-
if (ctor) {
|
|
4765
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4766
|
-
if (key === "constructor") continue;
|
|
4767
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4768
|
-
}
|
|
4769
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4770
|
-
if (styleDesc) {
|
|
4771
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
4772
|
-
const newStyle = NewClass.style;
|
|
4773
|
-
if (newStyle) {
|
|
4774
|
-
const scopeId = getScopeId(cmpMeta);
|
|
4775
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4776
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
4777
|
-
tag: cmpMeta.$tagName$,
|
|
4778
|
-
scopeId,
|
|
4779
|
-
isShadow,
|
|
4780
|
-
cssLen: newStyle.length
|
|
4781
|
-
});
|
|
4782
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
4783
|
-
}
|
|
4784
|
-
}
|
|
4785
|
-
}
|
|
4786
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4787
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4788
|
-
const hostRef = getHostRef(el);
|
|
4789
|
-
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4790
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4791
|
-
hostRef.$rmListeners$ = void 0;
|
|
4792
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4793
|
-
}
|
|
4794
|
-
if (!isShadow && hostRef) {
|
|
4795
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4796
|
-
attachStyles(hostRef);
|
|
4797
|
-
}
|
|
4798
|
-
forceUpdate(el);
|
|
4799
|
-
});
|
|
4765
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4800
4766
|
} catch (e) {
|
|
4801
4767
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4802
4768
|
}
|
|
4803
4769
|
};
|
|
4770
|
+
/**
|
|
4771
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4772
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4773
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4774
|
+
*
|
|
4775
|
+
* @param cmpMeta runtime metadata for the component
|
|
4776
|
+
* @param NewClass the component's newly executed class
|
|
4777
|
+
*/
|
|
4778
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4779
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4780
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4781
|
+
if (ctor && ctor !== NewClass) {
|
|
4782
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4783
|
+
if (key === "constructor") continue;
|
|
4784
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4785
|
+
}
|
|
4786
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4787
|
+
if (styleDesc) {
|
|
4788
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4789
|
+
const newStyle = NewClass.style;
|
|
4790
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4794
|
+
const hostRef = getHostRef(el);
|
|
4795
|
+
if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
|
|
4796
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4797
|
+
hostRef.$rmListeners$ = void 0;
|
|
4798
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4799
|
+
}
|
|
4800
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4801
|
+
forceUpdate(el);
|
|
4802
|
+
});
|
|
4803
|
+
};
|
|
4804
4804
|
//#endregion
|
|
4805
4805
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4806
4806
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4823,9 +4823,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4823
4823
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4824
4824
|
}
|
|
4825
4825
|
if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4826
|
-
if (BUILD$1.hotModuleReplacement)
|
|
4827
|
-
|
|
4828
|
-
|
|
4826
|
+
if (BUILD$1.hotModuleReplacement) {
|
|
4827
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4828
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4829
|
+
};
|
|
4830
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
4831
|
+
}
|
|
4829
4832
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4830
4833
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4831
4834
|
if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
@@ -5341,4 +5344,4 @@ function hasKeys(obj) {
|
|
|
5341
5344
|
return false;
|
|
5342
5345
|
}
|
|
5343
5346
|
//#endregion
|
|
5344
|
-
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule,
|
|
5347
|
+
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ type Ctor<T = {}> = new (...args: any[]) => T;
|
|
|
78
78
|
declare function Mixin(...mixins: ((base: Ctor) => Ctor)[]): Ctor<{}>;
|
|
79
79
|
//#endregion
|
|
80
80
|
//#region src/runtime/mode.d.ts
|
|
81
|
-
declare const setMode: (handler: ResolutionHandler) =>
|
|
81
|
+
declare const setMode: (handler: ResolutionHandler) => void;
|
|
82
82
|
declare const getMode: (ref: RuntimeRef) => string;
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/runtime/nonce.d.ts
|
|
@@ -136,10 +136,9 @@ declare const normalizeWatchers: (raw: ComponentConstructorChangeHandlers | unde
|
|
|
136
136
|
*
|
|
137
137
|
* @param propValue the new value to coerce to some type
|
|
138
138
|
* @param propType the type of the prop, expressed as a binary number
|
|
139
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
140
139
|
* @returns the parsed/coerced value
|
|
141
140
|
*/
|
|
142
|
-
declare const parsePropertyValue: (propValue: unknown, propType: number
|
|
141
|
+
declare const parsePropertyValue: (propValue: unknown, propType: number) => any;
|
|
143
142
|
//#endregion
|
|
144
143
|
//#region src/runtime/platform-options.d.ts
|
|
145
144
|
interface SetPlatformOptions {
|
package/dist/runtime/index.js
CHANGED
|
@@ -371,7 +371,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
371
371
|
//#endregion
|
|
372
372
|
//#region src/client/client-style.ts
|
|
373
373
|
const styles = /*@__PURE__*/ new Map();
|
|
374
|
-
const
|
|
374
|
+
const modeResolver = [];
|
|
375
375
|
const needsScopedSSR = () => false;
|
|
376
376
|
//#endregion
|
|
377
377
|
//#region src/runtime/runtime-constants.ts
|
|
@@ -1719,10 +1719,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1719
1719
|
const isComplex = isComplexType(newValue);
|
|
1720
1720
|
if (!BUILD.lazyLoad) {
|
|
1721
1721
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1722
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1722
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1723
1723
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1724
1724
|
elm["s-pp"].set(memberName, newValue);
|
|
1725
|
-
return;
|
|
1725
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1726
1726
|
}
|
|
1727
1727
|
}
|
|
1728
1728
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -4000,8 +4000,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4000
4000
|
};
|
|
4001
4001
|
//#endregion
|
|
4002
4002
|
//#region src/runtime/mode.ts
|
|
4003
|
-
const computeMode = (elm) =>
|
|
4004
|
-
const setMode = (handler) =>
|
|
4003
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4004
|
+
const setMode = (handler) => {
|
|
4005
|
+
modeResolver.length = 0;
|
|
4006
|
+
modeResolver.push(handler);
|
|
4007
|
+
};
|
|
4005
4008
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
4006
4009
|
//#endregion
|
|
4007
4010
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4066,23 +4069,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4066
4069
|
*
|
|
4067
4070
|
* @param propValue the new value to coerce to some type
|
|
4068
4071
|
* @param propType the type of the prop, expressed as a binary number
|
|
4069
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4070
4072
|
* @returns the parsed/coerced value
|
|
4071
4073
|
*/
|
|
4072
|
-
const parsePropertyValue = (propValue, propType
|
|
4074
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4073
4075
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4074
4076
|
/**
|
|
4075
4077
|
* ensure this value is of the correct prop type
|
|
4076
4078
|
*/
|
|
4077
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4078
|
-
/**
|
|
4079
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4080
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4081
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4082
|
-
*/
|
|
4083
|
-
if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4084
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4085
|
-
}
|
|
4079
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4086
4080
|
/**
|
|
4087
4081
|
* force it to be a number
|
|
4088
4082
|
*/
|
|
@@ -4124,7 +4118,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4124
4118
|
if (BUILD.signalBacking) {
|
|
4125
4119
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4126
4120
|
if (sig !== void 0) {
|
|
4127
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4121
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4128
4122
|
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4129
4123
|
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4130
4124
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4142,7 +4136,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4142
4136
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4143
4137
|
const flags = hostRef.$flags$;
|
|
4144
4138
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4145
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4139
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4146
4140
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4147
4141
|
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4148
4142
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4191,6 +4185,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4191
4185
|
*/
|
|
4192
4186
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4193
4187
|
/**
|
|
4188
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4189
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4190
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4191
|
+
*
|
|
4192
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4193
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4194
|
+
*/
|
|
4195
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4196
|
+
const instance = hostRef.$lazyInstance$;
|
|
4197
|
+
if (!instance) return;
|
|
4198
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4199
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4200
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4201
|
+
}
|
|
4202
|
+
};
|
|
4203
|
+
/**
|
|
4194
4204
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4195
4205
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4196
4206
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4247,9 +4257,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4247
4257
|
if (BUILD.lazyLoad) {
|
|
4248
4258
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4249
4259
|
const ref = getHostRef(this);
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
return instance[memberName];
|
|
4260
|
+
if (!ref) return prototype[memberName];
|
|
4261
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4253
4262
|
}
|
|
4254
4263
|
if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4255
4264
|
},
|
|
@@ -4264,7 +4273,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4264
4273
|
}
|
|
4265
4274
|
if (origSetter) {
|
|
4266
4275
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4267
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4276
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4268
4277
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4269
4278
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4270
4279
|
return;
|
|
@@ -4276,26 +4285,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4276
4285
|
if (BUILD.lazyLoad) {
|
|
4277
4286
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4278
4287
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4279
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4280
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4281
|
-
});
|
|
4282
4288
|
return;
|
|
4283
4289
|
}
|
|
4284
|
-
const parsedValue = parsePropertyValue(newValue, memberFlags
|
|
4285
|
-
|
|
4290
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4291
|
+
if (ref.$lazyInstance$) {
|
|
4286
4292
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4287
4293
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4288
|
-
ref.$lazyInstance$[memberName] =
|
|
4294
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4289
4295
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4290
|
-
};
|
|
4291
|
-
if (ref.$lazyInstance$) setterSetVal(parsedValue);
|
|
4292
|
-
else {
|
|
4293
|
-
ref.$instanceValues$.set(memberName, parsedValue);
|
|
4294
|
-
ref.$fetchedCbList$.push(() => {
|
|
4295
|
-
const pendingValue = ref.$instanceValues$.get(memberName);
|
|
4296
|
-
if (ref.$lazyInstance$[memberName] !== pendingValue) setterSetVal(pendingValue);
|
|
4297
|
-
});
|
|
4298
|
-
}
|
|
4296
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4299
4297
|
}
|
|
4300
4298
|
} });
|
|
4301
4299
|
} else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4347,10 +4345,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4347
4345
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4348
4346
|
if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4349
4347
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4350
|
-
if (isBooleanTarget)
|
|
4351
|
-
|
|
4348
|
+
if (isBooleanTarget) {
|
|
4349
|
+
if (BUILD.isDev && newValue === "false") consoleDevWarn(`<${cmpMeta.$tagName$} ${attrName}="false">: boolean attributes are true when present, regardless of value. Remove the attribute or set the "${propName}" property to false instead.`);
|
|
4350
|
+
newValue = newValue !== null;
|
|
4351
|
+
}
|
|
4352
4352
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4353
|
-
if (!isSpuriousBooleanRemoval && newValue !=
|
|
4353
|
+
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4354
4354
|
});
|
|
4355
4355
|
};
|
|
4356
4356
|
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
@@ -4411,7 +4411,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4411
4411
|
} catch (e) {
|
|
4412
4412
|
consoleError(e, elm);
|
|
4413
4413
|
}
|
|
4414
|
-
if (BUILD.member)
|
|
4414
|
+
if (BUILD.member) {
|
|
4415
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4416
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4417
|
+
}
|
|
4415
4418
|
endNewInstance();
|
|
4416
4419
|
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
|
|
4417
4420
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
@@ -4631,48 +4634,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4631
4634
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4632
4635
|
);
|
|
4633
4636
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4634
|
-
if (
|
|
4635
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4636
|
-
if (ctor) {
|
|
4637
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4638
|
-
if (key === "constructor") continue;
|
|
4639
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4640
|
-
}
|
|
4641
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4642
|
-
if (styleDesc) {
|
|
4643
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
4644
|
-
const newStyle = NewClass.style;
|
|
4645
|
-
if (newStyle) {
|
|
4646
|
-
const scopeId = getScopeId(cmpMeta);
|
|
4647
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4648
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
4649
|
-
tag: cmpMeta.$tagName$,
|
|
4650
|
-
scopeId,
|
|
4651
|
-
isShadow,
|
|
4652
|
-
cssLen: newStyle.length
|
|
4653
|
-
});
|
|
4654
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
4655
|
-
}
|
|
4656
|
-
}
|
|
4657
|
-
}
|
|
4658
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4659
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4660
|
-
const hostRef = getHostRef(el);
|
|
4661
|
-
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4662
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4663
|
-
hostRef.$rmListeners$ = void 0;
|
|
4664
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4665
|
-
}
|
|
4666
|
-
if (!isShadow && hostRef) {
|
|
4667
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4668
|
-
attachStyles(hostRef);
|
|
4669
|
-
}
|
|
4670
|
-
forceUpdate(el);
|
|
4671
|
-
});
|
|
4637
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4672
4638
|
} catch (e) {
|
|
4673
4639
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4674
4640
|
}
|
|
4675
4641
|
};
|
|
4642
|
+
/**
|
|
4643
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4644
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4645
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4646
|
+
*
|
|
4647
|
+
* @param cmpMeta runtime metadata for the component
|
|
4648
|
+
* @param NewClass the component's newly executed class
|
|
4649
|
+
*/
|
|
4650
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4651
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4652
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4653
|
+
if (ctor && ctor !== NewClass) {
|
|
4654
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4655
|
+
if (key === "constructor") continue;
|
|
4656
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4657
|
+
}
|
|
4658
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4659
|
+
if (styleDesc) {
|
|
4660
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4661
|
+
const newStyle = NewClass.style;
|
|
4662
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4666
|
+
const hostRef = getHostRef(el);
|
|
4667
|
+
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4668
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4669
|
+
hostRef.$rmListeners$ = void 0;
|
|
4670
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4671
|
+
}
|
|
4672
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4673
|
+
forceUpdate(el);
|
|
4674
|
+
});
|
|
4675
|
+
};
|
|
4676
4676
|
//#endregion
|
|
4677
4677
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4678
4678
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4695,9 +4695,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4695
4695
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4696
4696
|
}
|
|
4697
4697
|
if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4698
|
-
if (BUILD.hotModuleReplacement)
|
|
4699
|
-
|
|
4700
|
-
|
|
4698
|
+
if (BUILD.hotModuleReplacement) {
|
|
4699
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4700
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4701
|
+
};
|
|
4702
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
4703
|
+
}
|
|
4701
4704
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4702
4705
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4703
4706
|
if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|