@stencil/core 5.0.0-beta.12 → 5.0.0-beta.14

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.
@@ -1467,10 +1467,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
1467
1467
  const isComplex = isComplexType(newValue);
1468
1468
  if (!BUILD$1.lazyLoad) {
1469
1469
  const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
1470
- if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && typeof customElements !== "undefined" && !customElements.get(elm.tagName.toLowerCase())) {
1470
+ if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
1471
1471
  if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
1472
1472
  elm["s-pp"].set(memberName, newValue);
1473
- return;
1473
+ if (isComplex || /[A-Z]/.test(memberName)) return;
1474
1474
  }
1475
1475
  }
1476
1476
  if ((isProp || isComplex && newValue !== null) && !isSvg) try {
@@ -3625,7 +3625,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
3625
3625
  else return shallowPart.trim();
3626
3626
  }).join(", ");
3627
3627
  };
3628
- const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
3628
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
3629
3629
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
3630
3630
  return processRules(cssText, (rule) => {
3631
3631
  let selector = rule.selector;
@@ -3744,8 +3744,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
3744
3744
  };
3745
3745
  //#endregion
3746
3746
  //#region src/runtime/mode.ts
3747
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
3748
- const setMode = (handler) => modeResolutionChain.push(handler);
3747
+ const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
3748
+ const setMode = (handler) => {
3749
+ modeResolver.length = 0;
3750
+ modeResolver.push(handler);
3751
+ };
3749
3752
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
3750
3753
  //#endregion
3751
3754
  //#region src/runtime/normalize-watchers.ts
@@ -3810,23 +3813,14 @@ const normalizeWatchers = (raw) => {
3810
3813
  *
3811
3814
  * @param propValue the new value to coerce to some type
3812
3815
  * @param propType the type of the prop, expressed as a binary number
3813
- * @param isFormAssociated whether the component is form-associated (optional)
3814
3816
  * @returns the parsed/coerced value
3815
3817
  */
3816
- const parsePropertyValue = (propValue, propType, isFormAssociated) => {
3818
+ const parsePropertyValue = (propValue, propType) => {
3817
3819
  if (propValue != null && !isComplexType(propValue)) {
3818
3820
  /**
3819
3821
  * ensure this value is of the correct prop type
3820
3822
  */
3821
- if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) {
3822
- /**
3823
- * For form-associated components, according to HTML spec, the presence of any boolean attribute
3824
- * (regardless of its value, even "false") should make the property true.
3825
- * For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
3826
- */
3827
- if (BUILD$1.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
3828
- else return propValue === "false" ? false : propValue === "" || !!propValue;
3829
- }
3823
+ if (BUILD$1.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
3830
3824
  /**
3831
3825
  * force it to be a number
3832
3826
  */
@@ -3868,7 +3862,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3868
3862
  if (BUILD$1.signalBacking) {
3869
3863
  const sig = hostRef?.$signalValues$?.get(propName);
3870
3864
  if (sig !== void 0) {
3871
- const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
3865
+ const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3872
3866
  if (BUILD$1.serializer && BUILD$1.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
3873
3867
  const elm = BUILD$1.lazyLoad ? hostRef.$hostElement$ : ref;
3874
3868
  applySerializers(hostRef, cmpMeta, propName, parsed, BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm);
@@ -3886,7 +3880,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3886
3880
  const oldVal = hostRef.$instanceValues$.get(propName);
3887
3881
  const flags = hostRef.$flags$;
3888
3882
  const instance = BUILD$1.lazyLoad ? hostRef.$lazyInstance$ : elm;
3889
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0], BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
3883
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
3890
3884
  const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
3891
3885
  if ((!BUILD$1.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
3892
3886
  hostRef.$instanceValues$.set(propName, newVal);
@@ -3935,6 +3929,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
3935
3929
  */
3936
3930
  const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
3937
3931
  /**
3932
+ * Hand values written to a lazy component's element before its instance existed to the
3933
+ * instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
3934
+ * whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
3935
+ *
3936
+ * @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
3937
+ * @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
3938
+ */
3939
+ const replayPendingSetterValues = (hostRef, cmpMeta) => {
3940
+ const instance = hostRef.$lazyInstance$;
3941
+ if (!instance) return;
3942
+ for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
3943
+ const pendingValue = hostRef.$instanceValues$.get(memberName);
3944
+ if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
3945
+ }
3946
+ };
3947
+ /**
3938
3948
  * Attach a series of runtime constructs to a compiled Stencil component
3939
3949
  * constructor, including getters and setters for the `@Prop` and `@State`
3940
3950
  * decorators, callbacks for when attributes change, and so on.
@@ -3991,9 +4001,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3991
4001
  if (BUILD$1.lazyLoad) {
3992
4002
  if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
3993
4003
  const ref = getHostRef(this);
3994
- const instance = ref ? ref.$lazyInstance$ : prototype;
3995
- if (!instance) return;
3996
- return instance[memberName];
4004
+ if (!ref) return prototype[memberName];
4005
+ return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
3997
4006
  }
3998
4007
  if (!BUILD$1.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
3999
4008
  },
@@ -4008,7 +4017,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4008
4017
  }
4009
4018
  if (origSetter) {
4010
4019
  if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
4011
- origSetter.apply(this, [parsePropertyValue(newValue, memberFlags, BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated))]);
4020
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
4012
4021
  newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
4013
4022
  setValue(this, memberName, newValue, cmpMeta);
4014
4023
  return;
@@ -4020,26 +4029,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4020
4029
  if (BUILD$1.lazyLoad) {
4021
4030
  if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
4022
4031
  setValue(this, memberName, newValue, cmpMeta);
4023
- if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
4024
- if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
4025
- });
4026
4032
  return;
4027
4033
  }
4028
- const parsedValue = parsePropertyValue(newValue, memberFlags, BUILD$1.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4029
- const setterSetVal = (val) => {
4034
+ const parsedValue = parsePropertyValue(newValue, memberFlags);
4035
+ if (ref.$lazyInstance$) {
4030
4036
  const currentValue = ref.$lazyInstance$[memberName];
4031
4037
  if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
4032
- ref.$lazyInstance$[memberName] = val;
4038
+ ref.$lazyInstance$[memberName] = parsedValue;
4033
4039
  setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
4034
- };
4035
- if (ref.$lazyInstance$) setterSetVal(parsedValue);
4036
- else {
4037
- ref.$instanceValues$.set(memberName, parsedValue);
4038
- ref.$fetchedCbList$.push(() => {
4039
- const pendingValue = ref.$instanceValues$.get(memberName);
4040
- if (ref.$lazyInstance$[memberName] !== pendingValue) setterSetVal(pendingValue);
4041
- });
4042
- }
4040
+ } else ref.$instanceValues$.set(memberName, parsedValue);
4043
4041
  }
4044
4042
  } });
4045
4043
  } else if (BUILD$1.lazyLoad && BUILD$1.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
@@ -4091,10 +4089,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4091
4089
  const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
4092
4090
  if (BUILD$1.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
4093
4091
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4094
- if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
4095
- const currentValue = BUILD$1.lazyLoad && propMemberFlags & MEMBER_FLAGS.Setter ? hostRef.$instanceValues$.get(propName) : this[propName];
4092
+ if (isBooleanTarget) {
4093
+ if (BUILD$1.isDev && newValue === "false") `${cmpMeta.$tagName$}${attrName}${propName}`;
4094
+ newValue = newValue !== null;
4095
+ }
4096
4096
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
4097
- if (!isSpuriousBooleanRemoval && newValue != currentValue && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4097
+ if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4098
4098
  });
4099
4099
  };
4100
4100
  Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
@@ -4155,7 +4155,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4155
4155
  } catch (e) {
4156
4156
  consoleError(e, elm);
4157
4157
  }
4158
- if (BUILD$1.member) hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4158
+ if (BUILD$1.member) {
4159
+ hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
4160
+ replayPendingSetterValues(hostRef, cmpMeta);
4161
+ }
4159
4162
  endNewInstance();
4160
4163
  if (BUILD$1.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$);
4161
4164
  if (!(BUILD$1.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
@@ -4257,9 +4260,16 @@ const connectedCallback = (elm) => {
4257
4260
  }
4258
4261
  if (BUILD$1.asyncLoading) {
4259
4262
  let ancestorComponent = elm;
4260
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) if (BUILD$1.hydrateClientSide && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
4261
- attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4262
- break;
4263
+ while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
4264
+ if (BUILD$1.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
4265
+ ancestorComponent["s-p"] = [];
4266
+ ancestorComponent["s-rc"] = [];
4267
+ ancestorComponent["s-pc"] = [];
4268
+ }
4269
+ if (ancestorComponent["s-p"]) {
4270
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
4271
+ break;
4272
+ }
4263
4273
  }
4264
4274
  }
4265
4275
  if (BUILD$1.prop && !BUILD$1.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
@@ -4375,48 +4385,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4375
4385
  `${modulePath}?s-hmr=${hmrVersionId}`
4376
4386
  );
4377
4387
  const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4378
- if (!NewClass) return;
4379
- const ctor = customElements.get(cmpMeta.$tagName$);
4380
- if (ctor) {
4381
- for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4382
- if (key === "constructor") continue;
4383
- Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4384
- }
4385
- const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4386
- if (styleDesc) {
4387
- Object.defineProperty(ctor, "style", styleDesc);
4388
- const newStyle = NewClass.style;
4389
- if (newStyle) {
4390
- const scopeId = getScopeId(cmpMeta);
4391
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4392
- console.log("[stencil-hmr] registerStyle", {
4393
- tag: cmpMeta.$tagName$,
4394
- scopeId,
4395
- isShadow,
4396
- cssLen: newStyle.length
4397
- });
4398
- registerStyle(scopeId, newStyle, isShadow);
4399
- }
4400
- }
4401
- }
4402
- const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4403
- document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4404
- const hostRef = getHostRef(el);
4405
- if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
4406
- hostRef.$rmListeners$.map((rmListener) => rmListener());
4407
- hostRef.$rmListeners$ = void 0;
4408
- addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4409
- }
4410
- if (!isShadow && hostRef) {
4411
- console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
4412
- attachStyles(hostRef);
4413
- }
4414
- forceUpdate(el);
4415
- });
4388
+ if (NewClass) hmrApplyClass(cmpMeta, NewClass);
4416
4389
  } catch (e) {
4417
4390
  console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
4418
4391
  }
4419
4392
  };
4393
+ /**
4394
+ * Patch a re-executed component class onto the registered one and re-render every live instance.
4395
+ * Shared by the standalone re-import above and bundlers that re-execute the module themselves
4396
+ * (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
4397
+ *
4398
+ * @param cmpMeta runtime metadata for the component
4399
+ * @param NewClass the component's newly executed class
4400
+ */
4401
+ const hmrApplyClass = (cmpMeta, NewClass) => {
4402
+ const ctor = customElements.get(cmpMeta.$tagName$);
4403
+ const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
4404
+ if (ctor && ctor !== NewClass) {
4405
+ for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4406
+ if (key === "constructor") continue;
4407
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4408
+ }
4409
+ const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
4410
+ if (styleDesc) {
4411
+ Object.defineProperty(ctor, "style", styleDesc);
4412
+ const newStyle = NewClass.style;
4413
+ if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
4414
+ }
4415
+ }
4416
+ document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
4417
+ const hostRef = getHostRef(el);
4418
+ if (BUILD$1.hostListener && hostRef?.$rmListeners$) {
4419
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
4420
+ hostRef.$rmListeners$ = void 0;
4421
+ addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
4422
+ }
4423
+ if (!isShadow && hostRef) attachStyles(hostRef);
4424
+ forceUpdate(el);
4425
+ });
4426
+ };
4420
4427
  //#endregion
4421
4428
  //#region src/runtime/bootstrap-standalone.ts
4422
4429
  const defineCustomElement = (Cstr, compactMeta) => {
@@ -4439,9 +4446,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4439
4446
  cmpMeta.$serializers$ = Cstr.$serializers$;
4440
4447
  }
4441
4448
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
4442
- if (BUILD$1.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4443
- hmrStart(this, cmpMeta, hmrVersionId);
4444
- };
4449
+ if (BUILD$1.hotModuleReplacement) {
4450
+ Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4451
+ hmrStart(this, cmpMeta, hmrVersionId);
4452
+ };
4453
+ Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
4454
+ }
4445
4455
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD$1.slotCloneNode || BUILD$1.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
4446
4456
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
4447
4457
  if (BUILD$1.lightDomPatches || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
@@ -5031,7 +5041,7 @@ function proxyHostElement(elm, cstr) {
5031
5041
  const [[methodName]] = Object.entries(deserializer);
5032
5042
  attrPropVal = cstr.prototype[methodName](attrValue, memberName);
5033
5043
  }
5034
- else attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
5044
+ else attrPropVal = parsePropertyValue(attrValue, memberFlags);
5035
5045
  }
5036
5046
  if (propValue !== void 0) {
5037
5047
  attrPropVal = propValue;
@@ -5110,6 +5120,7 @@ function ssrApp(win, opts, results, afterSsr, resolve, abortController) {
5110
5120
  setScopedSsr(opts);
5111
5121
  let tmrId;
5112
5122
  let ranCompleted = false;
5123
+ let modeResolverSnapshot;
5113
5124
  const abortedPromise = new Promise((res) => {
5114
5125
  if (abortController.signal.aborted) res();
5115
5126
  else abortController.signal.addEventListener("abort", () => res(), { once: true });
@@ -5118,6 +5129,11 @@ function ssrApp(win, opts, results, afterSsr, resolve, abortController) {
5118
5129
  $nativeClearTimeout(tmrId);
5119
5130
  createdElements.clear();
5120
5131
  connectedElements.clear();
5132
+ if (modeResolverSnapshot) {
5133
+ modeResolver.length = 0;
5134
+ modeResolver.push(...modeResolverSnapshot);
5135
+ modeResolverSnapshot = void 0;
5136
+ }
5121
5137
  if (!ranCompleted) {
5122
5138
  ranCompleted = true;
5123
5139
  try {
@@ -5201,6 +5217,10 @@ function ssrApp(win, opts, results, afterSsr, resolve, abortController) {
5201
5217
  tmrId = $nativeSetTimeout(timeoutExceeded, opts.timeout);
5202
5218
  plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", win.document.baseURI).href;
5203
5219
  globalScripts();
5220
+ if (Array.isArray(opts.modes)) {
5221
+ modeResolverSnapshot = modeResolver.slice();
5222
+ opts.modes.forEach((mode) => setMode(mode));
5223
+ }
5204
5224
  patchChild(win.document.body);
5205
5225
  waitLoop().then(hydratedComplete).catch(hydratedError);
5206
5226
  } catch (e) {
@@ -5461,7 +5481,7 @@ const Build = {
5461
5481
  isTesting: false
5462
5482
  };
5463
5483
  const styles = /* @__PURE__ */ new Map();
5464
- const modeResolutionChain = [];
5484
+ const modeResolver = [];
5465
5485
  /**
5466
5486
  * Server-side implementation of getAssetPath.
5467
5487
  *
@@ -5493,4 +5513,4 @@ const setScopedSsr = (opts) => {
5493
5513
  const needsScopedSSR = () => scopedSSR;
5494
5514
  let scopedSSR = false;
5495
5515
  //#endregion
5496
- export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, injectSideEffectStyle, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, registerSideEffectStyleTarget, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
5516
+ export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, injectSideEffectStyle, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, registerSideEffectStyleTarget, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
@@ -8047,10 +8047,12 @@ var MockTokenList = class {
8047
8047
  token = String(token);
8048
8048
  return getItems(this.elm, this.attr).includes(token);
8049
8049
  }
8050
- toggle(token) {
8050
+ toggle(token, force) {
8051
8051
  token = String(token);
8052
- if (this.contains(token) === true) this.remove(token);
8053
- else this.add(token);
8052
+ const shouldAdd = force === void 0 ? !this.contains(token) : !!force;
8053
+ if (shouldAdd) this.add(token);
8054
+ else this.remove(token);
8055
+ return shouldAdd;
8054
8056
  }
8055
8057
  get length() {
8056
8058
  return getItems(this.elm, this.attr).length;
@@ -12257,39 +12259,6 @@ function createWindowFromHtml(templateHtml, uniqueId) {
12257
12259
  return cloneWindow(templateWindow);
12258
12260
  }
12259
12261
  //#endregion
12260
- //#region src/runtime/runtime-constants.ts
12261
- const HYDRATED_STYLE_ID = "sty-id";
12262
- const STENCIL_DOC_DATA = "_stencilDocData";
12263
- //#endregion
12264
- //#region src/utils/helpers.ts
12265
- const isString = (v) => typeof v === "string";
12266
- //#endregion
12267
- //#region src/runtime/mode.ts
12268
- const setMode = (handler) => modeResolutionChain.push(handler);
12269
- BUILD.lazyLoad || globalThis.HTMLElement;
12270
- //#endregion
12271
- //#region src/runtime/tag-transform.ts
12272
- let tagTransformer = void 0;
12273
- /**
12274
- * Transforms a tag name using the current tag transformer
12275
- * @param tag - the tag to transform e.g. `my-tag`
12276
- * @returns the transformed tag e.g. `new-my-tag`
12277
- */
12278
- function transformTag(tag) {
12279
- if (!tagTransformer) return tag;
12280
- return tagTransformer(tag);
12281
- }
12282
- /**
12283
- * Sets the tag transformer to be used when rendering custom elements
12284
- * @param transformer the transformer function to use. Must return a string
12285
- */
12286
- function setTagTransformer(transformer) {
12287
- tagTransformer = transformer;
12288
- }
12289
- //#endregion
12290
- //#region src/server/platform/index.ts
12291
- const modeResolutionChain = [];
12292
- //#endregion
12293
12262
  //#region src/compiler/html/canonical-link.ts
12294
12263
  const updateCanonicalLink = (doc, href) => {
12295
12264
  let canonicalLinkElm = doc.head.querySelector("link[rel=\"canonical\"]");
@@ -12316,6 +12285,9 @@ const relocateMetaCharset = (doc) => {
12316
12285
  head.insertBefore(charsetElm, head.firstChild);
12317
12286
  };
12318
12287
  //#endregion
12288
+ //#region src/utils/helpers.ts
12289
+ const isString = (v) => typeof v === "string";
12290
+ //#endregion
12319
12291
  //#region src/utils/message-utils.ts
12320
12292
  /**
12321
12293
  * Builds a diagnostic from an `Error`, appends it to the `diagnostics` parameter, and returns the created diagnostic
@@ -13136,6 +13108,30 @@ const removeUnusedStyleText = (usedSelectors, diagnostics, styleElm) => {
13136
13108
  }
13137
13109
  };
13138
13110
  //#endregion
13111
+ //#region src/runtime/runtime-constants.ts
13112
+ const HYDRATED_STYLE_ID = "sty-id";
13113
+ const STENCIL_DOC_DATA = "_stencilDocData";
13114
+ BUILD.lazyLoad || globalThis.HTMLElement;
13115
+ //#endregion
13116
+ //#region src/runtime/tag-transform.ts
13117
+ let tagTransformer = void 0;
13118
+ /**
13119
+ * Transforms a tag name using the current tag transformer
13120
+ * @param tag - the tag to transform e.g. `my-tag`
13121
+ * @returns the transformed tag e.g. `new-my-tag`
13122
+ */
13123
+ function transformTag(tag) {
13124
+ if (!tagTransformer) return tag;
13125
+ return tagTransformer(tag);
13126
+ }
13127
+ /**
13128
+ * Sets the tag transformer to be used when rendering custom elements
13129
+ * @param transformer the transformer function to use. Must return a string
13130
+ */
13131
+ function setTagTransformer(transformer) {
13132
+ tagTransformer = transformer;
13133
+ }
13134
+ //#endregion
13139
13135
  //#region src/server/runner/inspect-element.ts
13140
13136
  function inspectElement(results, elm, depth) {
13141
13137
  const children = [...Array.from(elm.children), ...Array.from(elm.shadowRoot ? elm.shadowRoot.children : [])];
@@ -13546,14 +13542,6 @@ async function render(win, opts, results) {
13546
13542
  try {
13547
13543
  await Promise.resolve(beforeHydrateFn(win.document));
13548
13544
  return new Promise((resolve) => {
13549
- if (Array.isArray(opts.modes)) {
13550
- /**
13551
- * Reset the mode resolution chain as we expect every `renderToString` call to render
13552
- * the components in new environment/document.
13553
- */
13554
- modeResolutionChain.length = 0;
13555
- opts.modes.forEach((mode) => setMode(mode));
13556
- }
13557
13545
  return ssrFactory(win, opts, results, afterSsr, resolve);
13558
13546
  });
13559
13547
  } catch (e) {
@@ -1,4 +1,4 @@
1
- import { J as CompilerSystem, jt as Logger } from "../../index-Cw1NW9FW.mjs";
1
+ import { Nt as Logger, Y as CompilerSystem } from "../../index-BilaSOF5.mjs";
2
2
  //#region src/sys/node/logger/index.d.ts
3
3
  /**
4
4
  * Create a logger to run in a Node environment
@@ -1,2 +1,2 @@
1
- import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-HKfDhPR3.mjs";
1
+ import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-Bw9pHJOq.mjs";
2
2
  export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1,5 +1,5 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-BjKDj129.mjs";
2
- import { t as createNodeSys } from "../../node-HKfDhPR3.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-Bit_AiP4.mjs";
2
+ import { t as createNodeSys } from "../../node-Bw9pHJOq.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
5
5
  * Initialize a worker thread, setting up various machinery for managing