@stencil/core 5.0.0-beta.0 → 5.0.0-beta.2

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.
@@ -1650,6 +1650,12 @@ interface TransformCssToEsmOutput {
1650
1650
  varName: string;
1651
1651
  importPath: string;
1652
1652
  }[];
1653
+ /**
1654
+ * Whether `output` itself has an observable side effect (a plain, untagged CSS file's
1655
+ * generated module self-injects CSSStyleSheets; a Stencil component's tagged `styleUrl`
1656
+ * output doesn't)
1657
+ */
1658
+ moduleSideEffects?: boolean;
1653
1659
  }
1654
1660
  interface PackageJsonData {
1655
1661
  name?: string;
@@ -1845,10 +1851,19 @@ interface StencilConfig {
1845
1851
  */
1846
1852
  rolldownConfig?: RolldownConfig;
1847
1853
  /**
1848
- * Sets if the JS browser files are minified or not. Stencil uses `terser` under the hood.
1854
+ * Sets if the JS browser files are minified or not.
1849
1855
  * Defaults to `false` in dev mode and `true` in production mode.
1850
1856
  */
1851
1857
  minifyJs?: boolean;
1858
+ /**
1859
+ * Which minifier to use for JS output when `minifyJs` is enabled.
1860
+ *
1861
+ * - `oxc`: built into rolldown. Much faster than terser. Output may be slightly larger.
1862
+ * - `terser`: slower, but currently produces the smallest output.
1863
+ *
1864
+ * Defaults to `oxc`.
1865
+ */
1866
+ jsMinifier?: 'terser' | 'oxc';
1852
1867
  /**
1853
1868
  * Sets if the CSS is minified or not.
1854
1869
  * Defaults to `false` in dev mode and `true` in production mode.
@@ -2194,7 +2209,7 @@ type RequireFields<T, K extends keyof T> = T & { [P in K]-?: T[P]; };
2194
2209
  /**
2195
2210
  * Fields in {@link Config} to make required for {@link ValidatedConfig}
2196
2211
  */
2197
- type StrictConfigFields = keyof Pick<Config, 'cacheDir' | 'devServer' | 'compat' | 'fsNamespace' | 'hydratedFlag' | 'logLevel' | 'logger' | 'minifyCss' | 'minifyJs' | 'namespace' | 'outputTargets' | 'packageJsonFilePath' | 'rolldownConfig' | 'rootDir' | 'srcDir' | 'srcIndexHtml' | 'sys' | 'transformAliasedImportPaths'>;
2212
+ type StrictConfigFields = keyof Pick<Config, 'cacheDir' | 'devServer' | 'compat' | 'fsNamespace' | 'hydratedFlag' | 'jsMinifier' | 'logLevel' | 'logger' | 'minifyCss' | 'minifyJs' | 'namespace' | 'outputTargets' | 'packageJsonFilePath' | 'rolldownConfig' | 'rootDir' | 'srcDir' | 'srcIndexHtml' | 'sys' | 'transformAliasedImportPaths'>;
2198
2213
  /**
2199
2214
  * A version of {@link Config} that makes certain fields required. This type represents a valid configuration entity.
2200
2215
  * When a configuration is received by the user, it is a bag of unverified data. In order to make stricter guarantees
@@ -4457,7 +4472,7 @@ type BuildOverrideKeys = 'hotModuleReplacement' | 'signalBacking' | 'vdomSignals
4457
4472
  * and types stay in sync with the authoritative definition.
4458
4473
  */
4459
4474
  type BuildOverrides = Pick<BuildConditionals, BuildOverrideKeys>;
4460
- type CompileTarget = 'latest' | 'esnext' | 'es2020' | 'es2019' | 'es2018' | 'es2017' | 'es2015' | string | undefined;
4475
+ type CompileTarget = 'latest' | 'esnext' | 'es2022' | 'es2020' | 'es2019' | 'es2018' | 'es2017' | string | undefined;
4461
4476
  interface TranspileResults {
4462
4477
  code: string;
4463
4478
  data?: any[];
@@ -463,7 +463,7 @@ declare function getAssetPath(path: string): string;
463
463
  * @param vnode - The virtual DOM tree to render
464
464
  * @param container - The container element to render the virtual DOM tree to
465
465
  */
466
- declare function render(vnode: VNode, container: Element): void;
466
+ declare function render(vnode: VNode, container: globalThis.Element): void;
467
467
  /**
468
468
  * Used to manually set the base path where assets can be found. For lazy-loaded
469
469
  * builds the asset path is automatically set and assets copied to the correct
@@ -567,6 +567,22 @@ declare function setTagTransformer(transformer: TagTransformer): void;
567
567
  * @returns the transformed tag e.g. `new-my-tag`
568
568
  */
569
569
  declare function transformTag(tag: string): string;
570
+ /**
571
+ * Registers a root - a shadowRoot, or `document` - to receive every plain CSS import
572
+ * (e.g. a dependency's own `import './foo.css'`) applied as a side effect.
573
+ * Call once per component instance that needs it, e.g. in `connectedCallback`.
574
+ * Pair with {@link unregisterSideEffectStyleTarget} in `disconnectedCallback`.
575
+ *
576
+ * @param root the root to register
577
+ */
578
+ declare function registerSideEffectStyleTarget(root: DocumentOrShadowRoot): void;
579
+ /**
580
+ * Removes a root registered via {@link registerSideEffectStyleTarget} - call in
581
+ * `disconnectedCallback`.
582
+ *
583
+ * @param root the root to unregister
584
+ */
585
+ declare function unregisterSideEffectStyleTarget(root: DocumentOrShadowRoot): void;
570
586
  type MixinFactory = (base: MixedInCtor) => MixedInCtor;
571
587
  /**
572
588
  * A constructor type that can be used as the base for mixin factories.
@@ -1169,7 +1185,7 @@ declare namespace JSXBase {
1169
1185
  type?: string;
1170
1186
  value?: string | string[] | number;
1171
1187
  popoverTargetAction?: string;
1172
- popoverTargetElement?: Element | null;
1188
+ popoverTargetElement?: globalThis.Element | null;
1173
1189
  popoverTarget?: string;
1174
1190
  command?: string;
1175
1191
  commandFor?: string;
@@ -1341,7 +1357,7 @@ declare namespace JSXBase {
1341
1357
  webkitEntries?: any;
1342
1358
  width?: number | string;
1343
1359
  popoverTargetAction?: string;
1344
- popoverTargetElement?: Element | null;
1360
+ popoverTargetElement?: globalThis.Element | null;
1345
1361
  popoverTarget?: string;
1346
1362
  }
1347
1363
  interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -2047,7 +2063,7 @@ declare namespace JSXBase {
2047
2063
  [key: `aria${string}`]: string | boolean | undefined;
2048
2064
  }
2049
2065
  }
2050
- interface JSXAttributes<T = Element> {
2066
+ interface JSXAttributes<T = globalThis.Element> {
2051
2067
  key?: string | number;
2052
2068
  ref?: (elm?: T) => void;
2053
2069
  children?: any;
@@ -2064,4 +2080,4 @@ interface CustomElementsDefineOptions {
2064
2080
  ce?: (eventName: string, opts?: any) => CustomEvent;
2065
2081
  }
2066
2082
  //#endregion
2067
- export { AttachInternals, AttachInternalsDecorator, AttachInternalsOptions, AttrDeserialize, AttrDeserializeDecorator, Build, ChildNode, Component, ComponentDecorator, ComponentDidLoad, ComponentDidUpdate, ComponentInterface, ComponentOptions, ComponentShouldUpdateChanges, ComponentWillLoad, ComponentWillUpdate, CustomElementsDefineOptions, Element, ElementDecorator, EncapsulationOptions, Env, ErrorHandler, Event, EventDecorator, EventEmitter, EventOptions, Fragment, FunctionalComponent, FunctionalUtilities, HTMLStencilElement, Host, HostAttributes, LocalJSX as JSX, JSXAttributes, JSXBase, Listen, ListenDecorator, ListenOptions, ListenTargetOptions, Method, MethodDecorator, MethodOptions, MixedInCtor, Mixin, ModeStyles, NoneEncapsulation, Prop, PropDecorator, PropOptions, PropSerialize, PropSerializeDecorator, QueueApi, RafCallback, ReactiveController, ReactiveControllerHost, ReactiveControllerHostInterface, ResolutionHandler, ResolveVarFunction, ScopedEncapsulation, ShadowEncapsulation, ShadowRootOptions, SignalRef, SlotPatch, State, StateDecorator, TagTransformer, UserBuildConditionals, VNode, VNodeData, Watch, WatchDecorator, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, h, jsx, jsxs, readTask, render, resolveVar, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setTagTransformer, transformTag, writeTask };
2083
+ export { AttachInternals, AttachInternalsDecorator, AttachInternalsOptions, AttrDeserialize, AttrDeserializeDecorator, Build, ChildNode, Component, ComponentDecorator, ComponentDidLoad, ComponentDidUpdate, ComponentInterface, ComponentOptions, ComponentShouldUpdateChanges, ComponentWillLoad, ComponentWillUpdate, CustomElementsDefineOptions, Element, ElementDecorator, EncapsulationOptions, Env, ErrorHandler, Event, EventDecorator, EventEmitter, EventOptions, Fragment, FunctionalComponent, FunctionalUtilities, HTMLStencilElement, Host, HostAttributes, LocalJSX as JSX, JSXAttributes, JSXBase, Listen, ListenDecorator, ListenOptions, ListenTargetOptions, Method, MethodDecorator, MethodOptions, MixedInCtor, Mixin, ModeStyles, NoneEncapsulation, Prop, PropDecorator, PropOptions, PropSerialize, PropSerializeDecorator, QueueApi, RafCallback, ReactiveController, ReactiveControllerHost, ReactiveControllerHostInterface, ResolutionHandler, ResolveVarFunction, ScopedEncapsulation, ShadowEncapsulation, ShadowRootOptions, SignalRef, SlotPatch, State, StateDecorator, TagTransformer, UserBuildConditionals, VNode, VNodeData, Watch, WatchDecorator, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, h, jsx, jsxs, readTask, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setTagTransformer, transformTag, unregisterSideEffectStyleTarget, writeTask };
@@ -1,9 +1,6 @@
1
1
  import "rolldown";
2
2
  import "typescript";
3
3
  //#region src/declarations/stencil-public-runtime.d.ts
4
- interface ElementDecorator {
5
- (): PropertyDecorator;
6
- }
7
4
  interface EventDecorator {
8
5
  (opts?: EventOptions): PropertyDecorator;
9
6
  }
@@ -25,11 +22,6 @@ interface EventOptions {
25
22
  */
26
23
  composed?: boolean;
27
24
  }
28
- /**
29
- * The `@Element()` decorator is a reference to the actual host element
30
- * once it has rendered.
31
- */
32
- declare const Element$1: ElementDecorator;
33
25
  /**
34
26
  * Components can emit data and events using the Event Emitter decorator.
35
27
  * To dispatch Custom DOM events for other components to handle, use the
@@ -460,7 +452,7 @@ declare namespace JSXBase {
460
452
  type?: string;
461
453
  value?: string | string[] | number;
462
454
  popoverTargetAction?: string;
463
- popoverTargetElement?: Element$1 | null;
455
+ popoverTargetElement?: globalThis.Element | null;
464
456
  popoverTarget?: string;
465
457
  command?: string;
466
458
  commandFor?: string;
@@ -632,7 +624,7 @@ declare namespace JSXBase {
632
624
  webkitEntries?: any;
633
625
  width?: number | string;
634
626
  popoverTargetAction?: string;
635
- popoverTargetElement?: Element$1 | null;
627
+ popoverTargetElement?: globalThis.Element | null;
636
628
  popoverTarget?: string;
637
629
  }
638
630
  interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -1338,7 +1330,7 @@ declare namespace JSXBase {
1338
1330
  [key: `aria${string}`]: string | boolean | undefined;
1339
1331
  }
1340
1332
  }
1341
- interface JSXAttributes<T = Element$1> {
1333
+ interface JSXAttributes<T = globalThis.Element> {
1342
1334
  key?: string | number;
1343
1335
  ref?: (elm?: T) => void;
1344
1336
  children?: any;
@@ -1838,10 +1838,19 @@ interface StencilConfig {
1838
1838
  */
1839
1839
  rolldownConfig?: RolldownConfig;
1840
1840
  /**
1841
- * Sets if the JS browser files are minified or not. Stencil uses `terser` under the hood.
1841
+ * Sets if the JS browser files are minified or not.
1842
1842
  * Defaults to `false` in dev mode and `true` in production mode.
1843
1843
  */
1844
1844
  minifyJs?: boolean;
1845
+ /**
1846
+ * Which minifier to use for JS output when `minifyJs` is enabled.
1847
+ *
1848
+ * - `oxc`: built into rolldown. Much faster than terser. Output may be slightly larger.
1849
+ * - `terser`: slower, but currently produces the smallest output.
1850
+ *
1851
+ * Defaults to `oxc`.
1852
+ */
1853
+ jsMinifier?: 'terser' | 'oxc';
1845
1854
  /**
1846
1855
  * Sets if the CSS is minified or not.
1847
1856
  * Defaults to `false` in dev mode and `true` in production mode.
@@ -2187,7 +2196,7 @@ type RequireFields<T, K extends keyof T> = T & { [P in K]-?: T[P]; };
2187
2196
  /**
2188
2197
  * Fields in {@link Config} to make required for {@link ValidatedConfig}
2189
2198
  */
2190
- type StrictConfigFields = keyof Pick<Config, 'cacheDir' | 'devServer' | 'compat' | 'fsNamespace' | 'hydratedFlag' | 'logLevel' | 'logger' | 'minifyCss' | 'minifyJs' | 'namespace' | 'outputTargets' | 'packageJsonFilePath' | 'rolldownConfig' | 'rootDir' | 'srcDir' | 'srcIndexHtml' | 'sys' | 'transformAliasedImportPaths'>;
2199
+ type StrictConfigFields = keyof Pick<Config, 'cacheDir' | 'devServer' | 'compat' | 'fsNamespace' | 'hydratedFlag' | 'jsMinifier' | 'logLevel' | 'logger' | 'minifyCss' | 'minifyJs' | 'namespace' | 'outputTargets' | 'packageJsonFilePath' | 'rolldownConfig' | 'rootDir' | 'srcDir' | 'srcIndexHtml' | 'sys' | 'transformAliasedImportPaths'>;
2191
2200
  /**
2192
2201
  * A version of {@link Config} that makes certain fields required. This type represents a valid configuration entity.
2193
2202
  * When a configuration is received by the user, it is a bag of unverified data. In order to make stricter guarantees
@@ -4450,7 +4459,7 @@ type BuildOverrideKeys = 'hotModuleReplacement' | 'signalBacking' | 'vdomSignals
4450
4459
  * and types stay in sync with the authoritative definition.
4451
4460
  */
4452
4461
  type BuildOverrides = Pick<BuildConditionals, BuildOverrideKeys>;
4453
- type CompileTarget = 'latest' | 'esnext' | 'es2020' | 'es2019' | 'es2018' | 'es2017' | 'es2015' | string | undefined;
4462
+ type CompileTarget = 'latest' | 'esnext' | 'es2022' | 'es2020' | 'es2019' | 'es2018' | 'es2017' | string | undefined;
4454
4463
  interface TranspileResults {
4455
4464
  code: string;
4456
4465
  data?: any[];
@@ -6062,6 +6071,12 @@ interface TransformCssToEsmOutput {
6062
6071
  varName: string;
6063
6072
  importPath: string;
6064
6073
  }[];
6074
+ /**
6075
+ * Whether `output` itself has an observable side effect (a plain, untagged CSS file's
6076
+ * generated module self-injects CSSStyleSheets; a Stencil component's tagged `styleUrl`
6077
+ * output doesn't)
6078
+ */
6079
+ moduleSideEffects?: boolean;
6065
6080
  }
6066
6081
  interface PackageJsonData {
6067
6082
  name?: string;
@@ -1,4 +1,4 @@
1
- import { Gn as FunctionalComponent, Qn as VNode, Wn as ErrorHandler, Xn as TagTransformer, Yn as ResolutionHandler, Zn as UserBuildConditionals, a as HostElement, l as PropsType, qn as RafCallback, t as ChildType, u as RuntimeRef } from "./index-RrQfiPWK.mjs";
1
+ import { Gn as FunctionalComponent, Qn as VNode, Wn as ErrorHandler, Xn as TagTransformer, Yn as ResolutionHandler, Zn as UserBuildConditionals, a as HostElement, l as PropsType, qn as RafCallback, t as ChildType, u as RuntimeRef } from "./index-BopBfjPu.mjs";
2
2
  //#region src/client/client-build.d.ts
3
3
  declare const Build: UserBuildConditionals;
4
4
  //#endregion
package/dist/index.d.mts CHANGED
@@ -57,6 +57,7 @@ export {
57
57
  Prop,
58
58
  readTask,
59
59
  ReactiveControllerHost,
60
+ registerSideEffectStyleTarget,
60
61
  render,
61
62
  resolveVar,
62
63
  setAssetPath,
@@ -67,6 +68,7 @@ export {
67
68
  setTagTransformer,
68
69
  State,
69
70
  transformTag,
71
+ unregisterSideEffectStyleTarget,
70
72
  Watch,
71
73
  writeTask,
72
74
  } from './declarations/stencil-public-runtime';
package/dist/index.mjs CHANGED
@@ -88,4 +88,84 @@ const AttrDeserialize = (_propName) => () => {};
88
88
  */
89
89
  const resolveVar = (variable) => String(variable);
90
90
  //#endregion
91
- export { AttachInternals, AttrDeserialize, Build, Component, Element, Event, Fragment, Host, Listen, Method, Mixin, Prop, PropSerialize, ReactiveControllerHost, State, Watch, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, h, readTask, render, resolveVar, setAssetPath, setErrorHandler, setMode, setPlatformHelpers, setTagTransformer, transformTag, writeTask };
91
+ //#region src/runtime/inject-side-effect-style.ts
92
+ const styleSheets = /* @__PURE__ */ new Map();
93
+ const knownRoots = /* @__PURE__ */ new Set();
94
+ const adoptedRoots = /* @__PURE__ */ new WeakMap();
95
+ const knownFontFaces = /* @__PURE__ */ new Set();
96
+ const adopt = (root, sheet) => {
97
+ let roots = adoptedRoots.get(sheet);
98
+ if (!roots) {
99
+ roots = /* @__PURE__ */ new WeakSet();
100
+ adoptedRoots.set(sheet, roots);
101
+ }
102
+ if (!roots.has(root)) {
103
+ roots.add(root);
104
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
105
+ }
106
+ };
107
+ /**
108
+ * Registers a root (a shadow root, or `document`) to receive every side-effect CSS import
109
+ * (a plain, non-component `import './foo.css'`), now and in future. Call in `connectedCallback`,
110
+ * paired with `unregisterSideEffectStyleTarget` in `disconnectedCallback` so the registry doesn't
111
+ * hold disconnected roots forever.
112
+ * @param root the root to register
113
+ */
114
+ function registerSideEffectStyleTarget(root) {
115
+ knownRoots.add(root);
116
+ for (const sheet of styleSheets.values()) adopt(root, sheet);
117
+ }
118
+ /**
119
+ * Removes a root registered via `registerSideEffectStyleTarget` - call in `disconnectedCallback`.
120
+ * @param root the root to unregister
121
+ */
122
+ function unregisterSideEffectStyleTarget(root) {
123
+ knownRoots.delete(root);
124
+ }
125
+ const FONT_FACE_RE = /@font-face\s*\{[^{}]*\}/g;
126
+ /**
127
+ * Splits `@font-face` rules out of a CSS text - exported standalone (from private
128
+ * module state - usually 3rd party node_modules) exported for testing
129
+ * @param cssText the CSS text to split
130
+ * @returns the font-face rules joined together (`null` if there were none) and the remaining CSS
131
+ */
132
+ function splitFontFaces(cssText) {
133
+ const fontFaces = cssText.match(FONT_FACE_RE);
134
+ if (!fontFaces) return {
135
+ fontFaceText: null,
136
+ rest: cssText
137
+ };
138
+ return {
139
+ fontFaceText: fontFaces.join("\n"),
140
+ rest: cssText.replace(FONT_FACE_RE, "")
141
+ };
142
+ }
143
+ /**
144
+ * Applies plain (non-component) CSS text to every registered root - respects shadow DOM
145
+ * encapsulation instead of always reaching for the top-level document. Not meant to be called
146
+ * directly: this is what the compiler's CSS-to-ESM output calls for CSS with no Stencil `tag`
147
+ * (i.e. not a component's own `styleUrl`), typically a third-party dependency's CSS import.
148
+ *
149
+ * `@font-face` rules are pulled out and adopted onto top-level `document` not per-root
150
+ * (Chromium (https://issues.chromium.org/issues/41085401) per-root never loads).
151
+ * @param cssText the CSS text to apply
152
+ */
153
+ function injectSideEffectStyle(cssText) {
154
+ const { fontFaceText, rest } = splitFontFaces(cssText);
155
+ if (fontFaceText && !knownFontFaces.has(fontFaceText)) {
156
+ knownFontFaces.add(fontFaceText);
157
+ const fontFaceSheet = new CSSStyleSheet();
158
+ fontFaceSheet.replaceSync(fontFaceText);
159
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, fontFaceSheet];
160
+ }
161
+ if (!rest.trim()) return;
162
+ let sheet = styleSheets.get(rest);
163
+ if (!sheet) {
164
+ sheet = new CSSStyleSheet();
165
+ sheet.replaceSync(rest);
166
+ styleSheets.set(rest, sheet);
167
+ }
168
+ for (const root of knownRoots) adopt(root, sheet);
169
+ }
170
+ //#endregion
171
+ export { AttachInternals, AttrDeserialize, Build, Component, Element, Event, Fragment, Host, Listen, Method, Mixin, Prop, PropSerialize, ReactiveControllerHost, State, Watch, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, h, injectSideEffectStyle, readTask, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setMode, setPlatformHelpers, setTagTransformer, transformTag, unregisterSideEffectStyleTarget, writeTask };
@@ -463,8 +463,6 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
463
463
  if (module) return module[exportName];
464
464
  const retryCount = failedLoadAttempts.get(bundleId) ?? 0;
465
465
  const cacheBustParams = [retryCount > 0 ? `s-retry=${retryCount}` : "", BUILD.hotModuleReplacement && hmrVersionId ? `s-hmr=${hmrVersionId}` : ""].filter(Boolean).join("&");
466
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
467
- const entryFile = `${bundleId}.entry.js${cacheBustParams ? "?" + cacheBustParams : ""}`;
468
466
  const onLoad = (importedModule) => {
469
467
  if (!BUILD.hotModuleReplacement) {
470
468
  failedLoadAttempts.delete(bundleId);
@@ -476,6 +474,8 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
476
474
  failedLoadAttempts.set(bundleId, retryCount + 1);
477
475
  consoleError(e, hostRef.$hostElement$);
478
476
  };
477
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
478
+ const entryFile = `${bundleId}.entry.js${cacheBustParams ? "?" + cacheBustParams : ""}`;
479
479
  if (lazyLoadBasePath) return import(
480
480
  /* @vite-ignore */
481
481
  /* webpackInclude: /\.entry\.js$/ */
@@ -3719,12 +3719,13 @@ const restoreSafeSelector = (placeholders, content) => {
3719
3719
  const _polyfillHost = "-shadowcsshost";
3720
3720
  const _polyfillSlotted = "-shadowcssslotted";
3721
3721
  const _polyfillHostContext = "-shadowcsscontext";
3722
+ const _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
3722
3723
  let _cssColonHostRe;
3723
3724
  let _cssColonHostContextRe;
3724
3725
  let _cssColonSlottedRe;
3725
- const getCssColonHostRe = () => _cssColonHostRe ??= /* @__PURE__ */ new RegExp("(-shadowcsshost)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
3726
- const getCssColonHostContextRe = () => _cssColonHostContextRe ??= /* @__PURE__ */ new RegExp("(-shadowcsscontext)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
3727
- const getCssColonSlottedRe = () => _cssColonSlottedRe ??= /* @__PURE__ */ new RegExp("(-shadowcssslotted)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
3726
+ const getCssColonHostRe = () => _cssColonHostRe ??= new RegExp("(-shadowcsshost" + _parenSuffix, "gim");
3727
+ const getCssColonHostContextRe = () => _cssColonHostContextRe ??= new RegExp("(-shadowcsscontext" + _parenSuffix, "gim");
3728
+ const getCssColonSlottedRe = () => _cssColonSlottedRe ??= new RegExp("(-shadowcssslotted" + _parenSuffix, "gim");
3728
3729
  const _polyfillHostNoCombinator = "-shadowcsshost-no-combinator";
3729
3730
  const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
3730
3731
  const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
@@ -3987,12 +3988,13 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
3987
3988
  else return shallowPart.trim();
3988
3989
  }).join(", ");
3989
3990
  };
3991
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
3990
3992
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
3991
3993
  return processRules(cssText, (rule) => {
3992
3994
  let selector = rule.selector;
3993
3995
  let content = rule.content;
3994
3996
  if (rule.selector[0] !== "@") selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
3995
- else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
3997
+ else if (isScopableAtRule(rule.selector)) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
3996
3998
  return {
3997
3999
  selector: selector.replace(/\s{2,}/g, " ").trim(),
3998
4000
  content
@@ -4084,14 +4086,12 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
4084
4086
  rule.selector = placeholder + rule.selector;
4085
4087
  return rule;
4086
4088
  };
4087
- cssText = processRules(cssText, (rule) => {
4089
+ const commentSelectors = (input) => processRules(input, (rule) => {
4088
4090
  if (rule.selector[0] !== "@") return processCommentedSelector(rule);
4089
- else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
4090
- rule.content = processRules(rule.content, processCommentedSelector);
4091
- return rule;
4092
- }
4091
+ if (isScopableAtRule(rule.selector)) rule.content = commentSelectors(rule.content);
4093
4092
  return rule;
4094
4093
  });
4094
+ cssText = commentSelectors(cssText);
4095
4095
  }
4096
4096
  const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
4097
4097
  cssText = [scoped.cssText, ...commentsWithHash].join("\n");
@@ -4290,6 +4290,14 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4290
4290
  //#endregion
4291
4291
  //#region src/runtime/proxy-component.ts
4292
4292
  /**
4293
+ * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
4294
+ * recognize an `attributeChangedCallback` it triggered itself.
4295
+ *
4296
+ * @param propValue the current value of a reflected prop
4297
+ * @returns the string the attribute would hold, or `null` if the attribute would be removed
4298
+ */
4299
+ const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
4300
+ /**
4293
4301
  * Attach a series of runtime constructs to a compiled Stencil component
4294
4302
  * constructor, including getters and setters for the `@Prop` and `@State`
4295
4303
  * decorators, callbacks for when attributes change, and so on.
@@ -4437,7 +4445,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4437
4445
  return;
4438
4446
  }
4439
4447
  const propFlags = members.find(([m]) => m === propName);
4440
- const isBooleanTarget = propFlags && propFlags[1][0] & MEMBER_FLAGS.Boolean;
4448
+ const propMemberFlags = propFlags ? propFlags[1][0] : 0;
4449
+ const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
4450
+ if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
4441
4451
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4442
4452
  if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
4443
4453
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
@@ -5053,6 +5063,86 @@ const hostListenerOpts = (flags) => supportsListenerOptions ? {
5053
5063
  capture: (flags & LISTENER_FLAGS.Capture) !== 0
5054
5064
  } : (flags & LISTENER_FLAGS.Capture) !== 0;
5055
5065
  //#endregion
5066
+ //#region src/runtime/inject-side-effect-style.ts
5067
+ const styleSheets = /* @__PURE__ */ new Map();
5068
+ const knownRoots = /* @__PURE__ */ new Set();
5069
+ const adoptedRoots = /* @__PURE__ */ new WeakMap();
5070
+ const knownFontFaces = /* @__PURE__ */ new Set();
5071
+ const adopt = (root, sheet) => {
5072
+ let roots = adoptedRoots.get(sheet);
5073
+ if (!roots) {
5074
+ roots = /* @__PURE__ */ new WeakSet();
5075
+ adoptedRoots.set(sheet, roots);
5076
+ }
5077
+ if (!roots.has(root)) {
5078
+ roots.add(root);
5079
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
5080
+ }
5081
+ };
5082
+ /**
5083
+ * Registers a root (a shadow root, or `document`) to receive every side-effect CSS import
5084
+ * (a plain, non-component `import './foo.css'`), now and in future. Call in `connectedCallback`,
5085
+ * paired with `unregisterSideEffectStyleTarget` in `disconnectedCallback` so the registry doesn't
5086
+ * hold disconnected roots forever.
5087
+ * @param root the root to register
5088
+ */
5089
+ function registerSideEffectStyleTarget(root) {
5090
+ knownRoots.add(root);
5091
+ for (const sheet of styleSheets.values()) adopt(root, sheet);
5092
+ }
5093
+ /**
5094
+ * Removes a root registered via `registerSideEffectStyleTarget` - call in `disconnectedCallback`.
5095
+ * @param root the root to unregister
5096
+ */
5097
+ function unregisterSideEffectStyleTarget(root) {
5098
+ knownRoots.delete(root);
5099
+ }
5100
+ const FONT_FACE_RE = /@font-face\s*\{[^{}]*\}/g;
5101
+ /**
5102
+ * Splits `@font-face` rules out of a CSS text - exported standalone (from private
5103
+ * module state - usually 3rd party node_modules) exported for testing
5104
+ * @param cssText the CSS text to split
5105
+ * @returns the font-face rules joined together (`null` if there were none) and the remaining CSS
5106
+ */
5107
+ function splitFontFaces(cssText) {
5108
+ const fontFaces = cssText.match(FONT_FACE_RE);
5109
+ if (!fontFaces) return {
5110
+ fontFaceText: null,
5111
+ rest: cssText
5112
+ };
5113
+ return {
5114
+ fontFaceText: fontFaces.join("\n"),
5115
+ rest: cssText.replace(FONT_FACE_RE, "")
5116
+ };
5117
+ }
5118
+ /**
5119
+ * Applies plain (non-component) CSS text to every registered root - respects shadow DOM
5120
+ * encapsulation instead of always reaching for the top-level document. Not meant to be called
5121
+ * directly: this is what the compiler's CSS-to-ESM output calls for CSS with no Stencil `tag`
5122
+ * (i.e. not a component's own `styleUrl`), typically a third-party dependency's CSS import.
5123
+ *
5124
+ * `@font-face` rules are pulled out and adopted onto top-level `document` not per-root
5125
+ * (Chromium (https://issues.chromium.org/issues/41085401) per-root never loads).
5126
+ * @param cssText the CSS text to apply
5127
+ */
5128
+ function injectSideEffectStyle(cssText) {
5129
+ const { fontFaceText, rest } = splitFontFaces(cssText);
5130
+ if (fontFaceText && !knownFontFaces.has(fontFaceText)) {
5131
+ knownFontFaces.add(fontFaceText);
5132
+ const fontFaceSheet = new CSSStyleSheet();
5133
+ fontFaceSheet.replaceSync(fontFaceText);
5134
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, fontFaceSheet];
5135
+ }
5136
+ if (!rest.trim()) return;
5137
+ let sheet = styleSheets.get(rest);
5138
+ if (!sheet) {
5139
+ sheet = new CSSStyleSheet();
5140
+ sheet.replaceSync(rest);
5141
+ styleSheets.set(rest, sheet);
5142
+ }
5143
+ for (const root of knownRoots) adopt(root, sheet);
5144
+ }
5145
+ //#endregion
5056
5146
  //#region src/runtime/mixin.ts
5057
5147
  const baseClass = BUILD.lazyLoad ? class {} : globalThis.HTMLElement || class {};
5058
5148
  function Mixin(...mixins) {
@@ -5224,4 +5314,4 @@ function hasKeys(obj) {
5224
5314
  return false;
5225
5315
  }
5226
5316
  //#endregion
5227
- 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, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, win, writeTask };
5317
+ 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, modeResolutionChain, 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 };
@@ -2,9 +2,6 @@ import { BUILD, Env, NAMESPACE } from "@stencil/core/app-data";
2
2
  import "rolldown";
3
3
  import "typescript";
4
4
  //#region src/declarations/stencil-public-runtime.d.ts
5
- interface ElementDecorator {
6
- (): PropertyDecorator;
7
- }
8
5
  interface EventDecorator {
9
6
  (opts?: EventOptions): PropertyDecorator;
10
7
  }
@@ -32,11 +29,6 @@ interface UserBuildConditionals {
32
29
  isServer: boolean;
33
30
  isTesting: boolean;
34
31
  }
35
- /**
36
- * The `@Element()` decorator is a reference to the actual host element
37
- * once it has rendered.
38
- */
39
- declare const Element$2: ElementDecorator;
40
32
  /**
41
33
  * Components can emit data and events using the Event Emitter decorator.
42
34
  * To dispatch Custom DOM events for other components to handle, use the
@@ -471,7 +463,7 @@ declare namespace JSXBase {
471
463
  type?: string;
472
464
  value?: string | string[] | number;
473
465
  popoverTargetAction?: string;
474
- popoverTargetElement?: Element$2 | null;
466
+ popoverTargetElement?: globalThis.Element | null;
475
467
  popoverTarget?: string;
476
468
  command?: string;
477
469
  commandFor?: string;
@@ -643,7 +635,7 @@ declare namespace JSXBase {
643
635
  webkitEntries?: any;
644
636
  width?: number | string;
645
637
  popoverTargetAction?: string;
646
- popoverTargetElement?: Element$2 | null;
638
+ popoverTargetElement?: globalThis.Element | null;
647
639
  popoverTarget?: string;
648
640
  }
649
641
  interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -1349,7 +1341,7 @@ declare namespace JSXBase {
1349
1341
  [key: `aria${string}`]: string | boolean | undefined;
1350
1342
  }
1351
1343
  }
1352
- interface JSXAttributes<T = Element$2> {
1344
+ interface JSXAttributes<T = globalThis.Element> {
1353
1345
  key?: string | number;
1354
1346
  ref?: (elm?: T) => void;
1355
1347
  children?: any;
@@ -2359,6 +2351,32 @@ declare const Fragment: FunctionalComponent;
2359
2351
  //#region src/runtime/host-listener.d.ts
2360
2352
  declare const addHostEventListeners: (elm: HostElement, hostRef: HostRef, listeners?: ComponentRuntimeHostListener[]) => void;
2361
2353
  //#endregion
2354
+ //#region src/runtime/inject-side-effect-style.d.ts
2355
+ /**
2356
+ * Registers a root (a shadow root, or `document`) to receive every side-effect CSS import
2357
+ * (a plain, non-component `import './foo.css'`), now and in future. Call in `connectedCallback`,
2358
+ * paired with `unregisterSideEffectStyleTarget` in `disconnectedCallback` so the registry doesn't
2359
+ * hold disconnected roots forever.
2360
+ * @param root the root to register
2361
+ */
2362
+ declare function registerSideEffectStyleTarget(root: DocumentOrShadowRoot): void;
2363
+ /**
2364
+ * Removes a root registered via `registerSideEffectStyleTarget` - call in `disconnectedCallback`.
2365
+ * @param root the root to unregister
2366
+ */
2367
+ declare function unregisterSideEffectStyleTarget(root: DocumentOrShadowRoot): void;
2368
+ /**
2369
+ * Applies plain (non-component) CSS text to every registered root - respects shadow DOM
2370
+ * encapsulation instead of always reaching for the top-level document. Not meant to be called
2371
+ * directly: this is what the compiler's CSS-to-ESM output calls for CSS with no Stencil `tag`
2372
+ * (i.e. not a component's own `styleUrl`), typically a third-party dependency's CSS import.
2373
+ *
2374
+ * `@font-face` rules are pulled out and adopted onto top-level `document` not per-root
2375
+ * (Chromium (https://issues.chromium.org/issues/41085401) per-root never loads).
2376
+ * @param cssText the CSS text to apply
2377
+ */
2378
+ declare function injectSideEffectStyle(cssText: string): void;
2379
+ //#endregion
2362
2380
  //#region src/runtime/mixin.d.ts
2363
2381
  type Ctor<T = {}> = new (...args: any[]) => T;
2364
2382
  declare function Mixin(...mixins: ((base: Ctor) => Ctor)[]): Ctor<{}>;
@@ -2522,4 +2540,4 @@ declare const jsxs: typeof jsx;
2522
2540
  */
2523
2541
  declare const jsxDEV: typeof jsx;
2524
2542
  //#endregion
2525
- 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, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, win, writeTask };
2543
+ 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, modeResolutionChain, 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 };