@stencil/unplugin 5.0.0-alpha.16 → 5.0.0-alpha.18

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/LICENSE.md ADDED
@@ -0,0 +1,27 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019-present Drifty Co.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ -----------------------------------------
24
+ Third-party components, software, and/or libraries (collectively, "components")
25
+ are included under the licenses specified by their authors. For information
26
+ about these third-party licenses, refer to the separate legal notices governing
27
+ such components at NOTICE file at the top level of the package.
package/dist/index.mjs CHANGED
@@ -549,25 +549,25 @@ function makeResolver(onBaseClass) {
549
549
  * Wires together four concerns into a single plugin that works across Vite,
550
550
  * Rollup, webpack, rspack, and bun:
551
551
  *
552
- * 1. **Component transform** — `transform` drives `transpileSync` on every
552
+ * 1. **Component transform** - `transform` drives `transpileSync` on every
553
553
  * `.tsx`/`.ts` file that carries Stencil decorators, producing
554
554
  * `customelement` output (self-registering class + `defineCustomElement`).
555
555
  *
556
- * 2. **CSS virtual modules** — Stencil emits `./foo.css?tag=my-cmp&…`
556
+ * 2. **CSS virtual modules** - Stencil emits `./foo.css?tag=my-cmp&…`
557
557
  * imports. `resolveId` rewrites these to `\0stencil-css:` virtual IDs;
558
558
  * `load` reads the real file, runs it through any installed preprocessors,
559
559
  * and returns `export default () => "…css…"`.
560
560
  *
561
- * 3. **Base-class inheritance** — when a component extends a class that does
561
+ * 3. **Base-class inheritance** - when a component extends a class that does
562
562
  * not itself extend `HTMLElement`, the custom-element registration breaks.
563
563
  * The plugin intercepts every file the compiler resolves via `resolveImport`
564
564
  * (during `transpileSync`), pre-transforms it with `transformAsBaseClass: true`
565
565
  * so it gets `extends HTMLElement`, and caches the result. `resolveId` then
566
566
  * redirects imports of those files to `\0stencil-base:` virtual modules so
567
- * the bundler always sees the injected version — regardless of module-graph
567
+ * the bundler always sees the injected version - regardless of module-graph
568
568
  * processing order.
569
569
  *
570
- * 4. **HMR** — Vite receives a custom `stencil:hmr` WebSocket event when a
570
+ * 4. **HMR** - Vite receives a custom `stencil:hmr` WebSocket event when a
571
571
  * component file changes; other bundlers use the `module.hot` re-execution
572
572
  * pattern. CSS changes are covered automatically by `addWatchFile`.
573
573
  */
@@ -627,8 +627,14 @@ const unpluginStencil = createUnplugin((options = {}, meta) => {
627
627
  let projectRoot = process.cwd();
628
628
  let configOverrides = {};
629
629
  const fileToTagName = /* @__PURE__ */ new Map();
630
- const cssFileToTagName = /* @__PURE__ */ new Map();
631
- const cssRealToVirtualId = /* @__PURE__ */ new Map();
630
+ const cssFileToTagNames = /* @__PURE__ */ new Map();
631
+ const cssRealToVirtualIds = /* @__PURE__ */ new Map();
632
+ function trackCssFile(realPath, tag, virtualId) {
633
+ if (!cssFileToTagNames.has(realPath)) cssFileToTagNames.set(realPath, /* @__PURE__ */ new Set());
634
+ cssFileToTagNames.get(realPath).add(tag);
635
+ if (!cssRealToVirtualIds.has(realPath)) cssRealToVirtualIds.set(realPath, /* @__PURE__ */ new Set());
636
+ cssRealToVirtualIds.get(realPath).add(virtualId);
637
+ }
632
638
  const baseClassRegistry = /* @__PURE__ */ new Map();
633
639
  function registerBaseClass(absPath, rawCode) {
634
640
  if (baseClassRegistry.has(absPath)) return;
@@ -694,15 +700,13 @@ const unpluginStencil = createUnplugin((options = {}, meta) => {
694
700
  const tag = qIdx !== -1 ? new URLSearchParams(id.slice(qIdx + 1)).get("tag") : null;
695
701
  if (realPath) {
696
702
  this.addWatchFile(realPath);
697
- if (tag) cssFileToTagName.set(realPath, tag);
698
- cssRealToVirtualId.set(realPath, id);
703
+ if (tag) trackCssFile(realPath, tag, id);
699
704
  }
700
705
  const cssResult = await loadStencilCss(id, isDev);
701
706
  if (cssResult) {
702
707
  if (tag) for (const dep of cssResult.deps) {
703
708
  this.addWatchFile(dep);
704
- cssFileToTagName.set(dep, tag);
705
- cssRealToVirtualId.set(dep, id);
709
+ trackCssFile(dep, tag, id);
706
710
  }
707
711
  return {
708
712
  code: cssResult.code,
@@ -718,17 +722,20 @@ const unpluginStencil = createUnplugin((options = {}, meta) => {
718
722
  projectRoot = config.root;
719
723
  },
720
724
  async handleHotUpdate({ file, server }) {
721
- const tagName = fileToTagName.get(file) ?? cssFileToTagName.get(file);
722
- if (!tagName) return;
723
- const virtualId = cssRealToVirtualId.get(file);
724
- if (virtualId) {
725
+ const tsxTag = fileToTagName.get(file);
726
+ const cssTagNames = cssFileToTagNames.get(file);
727
+ const tagNames = new Set(cssTagNames);
728
+ if (tsxTag) tagNames.add(tsxTag);
729
+ if (tagNames.size === 0) return;
730
+ const virtualIds = cssRealToVirtualIds.get(file);
731
+ if (virtualIds) for (const virtualId of virtualIds) {
725
732
  const virtualMod = server.moduleGraph.getModuleById?.(virtualId) ?? server.moduleGraph.idToModuleMap?.get(virtualId);
726
733
  if (virtualMod) server.moduleGraph.invalidateModule(virtualMod, /* @__PURE__ */ new Set(), Date.now(), true);
727
734
  }
728
- if (options.docs && fileToTagName.has(file)) {
735
+ if (options.docs && tsxTag) {
729
736
  let cemChanged = false;
730
737
  try {
731
- const prevSnapshot = JSON.stringify(docsRegistry.get(tagName));
738
+ const prevSnapshot = JSON.stringify(docsRegistry.get(tsxTag));
732
739
  const result = await transpile(readFileSync(file, "utf-8"), {
733
740
  file,
734
741
  componentExport: "customelement"
@@ -739,7 +746,7 @@ const unpluginStencil = createUnplugin((options = {}, meta) => {
739
746
  resolveImportedTypes(component, file);
740
747
  docsRegistry.set(item.tagName, component);
741
748
  }
742
- cemChanged = JSON.stringify(docsRegistry.get(tagName)) !== prevSnapshot;
749
+ cemChanged = JSON.stringify(docsRegistry.get(tsxTag)) !== prevSnapshot;
743
750
  } catch {}
744
751
  if (cemChanged) {
745
752
  const docsVirtualMod = server.moduleGraph.getModuleById?.(VIRTUAL_DOCS_PREFIX) ?? server.moduleGraph.idToModuleMap?.get(VIRTUAL_DOCS_PREFIX);
@@ -750,7 +757,7 @@ const unpluginStencil = createUnplugin((options = {}, meta) => {
750
757
  });
751
758
  }
752
759
  }
753
- server.ws.send({
760
+ for (const tagName of tagNames) server.ws.send({
754
761
  type: "custom",
755
762
  event: "stencil:hmr",
756
763
  data: { tagName }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/config.ts","../src/css.ts","../src/resolve-types.ts","../src/transform.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["/**\n * Stencil config auto-detection for @stencil/unplugin.\n *\n * Searches for a `stencil.config.ts` (or `.js` variant) in the project root,\n * loads it via jiti (so TypeScript is handled without a separate compile step),\n * and extracts the subset of flags that are meaningful at transpile time.\n *\n * `stencilConfigToOverrides` converts that subset to a `BuildOverrides` object\n * ready to pass to `transpileSync`.\n */\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { BuildOverrides, LightDomPatches } from '@stencil/core/compiler';\n\nimport type { StencilConfigSubset } from './options.js';\n\n// A real Stencil config always has at least one of these keys. Used to\n// distinguish an actual default-exported config from jiti's CJS interop\n// artefact where the module namespace itself lands on `mod.default`.\nconst STENCIL_CONFIG_KEYS = new Set([\n 'namespace',\n 'srcDir',\n 'outputTargets',\n 'plugins',\n 'signalBacking',\n 'compat',\n]);\n\nconst looksLikeConfig = (v: unknown): v is Record<string, unknown> =>\n v !== null &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n Object.keys(v as object).some((k) => STENCIL_CONFIG_KEYS.has(k));\n\nconst CONFIG_CANDIDATES = [\n 'stencil.config.ts',\n 'stencil.config.mts',\n 'stencil.config.js',\n 'stencil.config.mjs',\n];\n\n/**\n * Attempt to load the project's `stencil.config.ts` and return the\n * transpile-relevant fields. Returns `null` if no config file is found or\n * if loading fails for any reason.\n * @param cwd - project root to search in (usually `process.cwd()`)\n * @returns a subset of the Stencil config, or `null` if none is found\n */\nexport async function loadStencilConfig(cwd: string): Promise<StencilConfigSubset | null> {\n for (const filename of CONFIG_CANDIDATES) {\n const configPath = join(cwd, filename);\n if (!existsSync(configPath)) continue;\n try {\n const { createJiti } = await import('jiti');\n const jiti = createJiti(import.meta.url);\n const mod = (await jiti.import(configPath)) as Record<string, unknown>;\n // Named `config` export is the Stencil convention; fall back to a default\n // export only when it looks like a real config object (has at least one\n // known Stencil key) — otherwise jiti's CJS interop may surface the\n // module namespace object as `default`, which we must not treat as config.\n const raw = mod['config'] ?? (looksLikeConfig(mod['default']) ? mod['default'] : null);\n if (!raw || typeof raw !== 'object') return null;\n return extractSubset(raw as Record<string, unknown>);\n } catch {\n return null;\n }\n }\n return null;\n}\n\nfunction extractSubset(c: Record<string, unknown>): StencilConfigSubset {\n const result: StencilConfigSubset = {};\n if (c['signalBacking'] === true) result.signalBacking = true;\n const compat = c['compat'];\n if (compat && typeof compat === 'object') {\n const co = compat as Record<string, unknown>;\n const ldp = co['lightDomPatches'];\n const lifecycleDOMEvents = co['lifecycleDOMEvents'];\n const initializeNextTick = co['initializeNextTick'];\n if (ldp !== undefined || lifecycleDOMEvents !== undefined || initializeNextTick !== undefined) {\n result.compat = {};\n if (typeof ldp === 'boolean') result.compat.lightDomPatches = ldp;\n else if (ldp && typeof ldp === 'object')\n result.compat.lightDomPatches = ldp as LightDomPatches;\n if (lifecycleDOMEvents === true) result.compat.lifecycleDOMEvents = true;\n if (initializeNextTick === true) result.compat.initializeNextTick = true;\n }\n }\n return result;\n}\n\n/**\n * Convert a {@link StencilConfigSubset} to a {@link BuildOverrides} object.\n * The caller is responsible for merging this with any explicit\n * `transpileOptions.buildOverrides` (which should take precedence).\n * @param config - the Stencil config subset to convert\n * @returns a `BuildOverrides` object suitable for passing to `transpileSync`\n */\nexport function stencilConfigToOverrides(config: StencilConfigSubset): BuildOverrides {\n const o: BuildOverrides = {};\n if (config.signalBacking) {\n o.signalBacking = true;\n o.vdomSignals = true; // signalBacking implies vdomSignals\n }\n\n const compat = config.compat;\n if (!compat) return o;\n if (compat.lifecycleDOMEvents) o.lifecycleDOMEvents = true;\n if (compat.initializeNextTick) o.initializeNextTick = true;\n\n const ldp = compat.lightDomPatches;\n if (ldp === false) {\n // Explicitly disable — standalone runtime defaults all to true.\n o.lightDomPatches = false;\n o.slotChildNodes = false;\n o.slotCloneNode = false;\n o.slotDomMutations = false;\n o.slotTextContent = false;\n } else if (typeof ldp === 'object') {\n // Granular: enable only the named patches; disable the rest (defaults are all-true).\n o.lightDomPatches = true;\n o.slotChildNodes = !!ldp.childNodes;\n o.slotCloneNode = !!ldp.cloneNode;\n o.slotDomMutations = !!ldp.domMutations;\n o.slotTextContent = !!ldp.textContent;\n }\n // ldp === true or undefined: no-op — already the default in the standalone runtime.\n return o;\n}\n","/**\n * CSS pipeline for Stencil component stylesheets.\n *\n * When the Stencil compiler emits a style import such as\n * `./foo.css?tag=my-cmp&encapsulation=shadow`, `resolveStencilCss` rewrites it\n * to a `\\0stencil-css:` virtual module ID. The bundler then calls `load`, which\n * reads the real file and runs it through any installed preprocessors in order:\n * Sass/Less → PostCSS → lightningcss → scoped-selector rewrite (for scoped\n * encapsulation). The result is returned as `export default () => \"…css…\"` so\n * the bundler treats it as a normal JS module dependency.\n *\n * Each preprocessor step is silently skipped if the relevant peer dep is absent.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { getScopeId, scopeCss } from '@stencil/core/compiler';\nimport { isPackageExists } from 'local-pkg';\n\n// Matches Stencil's emitted style imports: `./foo.css?tag=my-cmp&…`\nconst STENCIL_CSS_RE = /\\.(?:css|scss|sass|less|styl)\\?[^/]*\\btag=/;\nconst STENCIL_CSS_PREFIX = '\\0stencil-css:';\n\n// Evaluated once at startup — avoids repeated filesystem probes per CSS file.\nconst PKG = {\n sass: isPackageExists('sass'),\n less: isPackageExists('less'),\n postcss: isPackageExists('postcss') && isPackageExists('postcss-load-config'),\n lightningcss: isPackageExists('lightningcss'),\n};\n\n/**\n * Rewrites a Stencil CSS import to a `\\0stencil-css:` virtual module ID.\n * The file extension is stored dotless as `__ext` so Vite's `CSS_LANGS_RE`\n * never matches the virtual ID and tries to own the module itself.\n * @param specifier - the raw import specifier from the component source\n * @param importer - absolute path of the importing file\n * @returns virtual module ID, or `null` for non-Stencil CSS imports\n */\nexport function resolveStencilCss(specifier: string, importer: string): string | null {\n if (!STENCIL_CSS_RE.test(specifier)) return null;\n const [base, query] = specifier.split('?');\n const absBase = resolve(dirname(importer), base);\n const ext = extname(absBase);\n const stem = absBase.slice(0, absBase.length - ext.length);\n return `${STENCIL_CSS_PREFIX}${stem}?${query}&__ext=${encodeURIComponent(ext.slice(1))}`;\n}\n\nexport function isStencilCss(id: string): boolean {\n return id.startsWith(STENCIL_CSS_PREFIX);\n}\n\n/**\n * Extracts the real CSS file path from a `\\0stencil-css:` virtual module ID.\n * @param id - virtual module ID produced by `resolveStencilCss`\n * @returns absolute file path, or `null` if not a Stencil CSS virtual module\n */\nexport function getRealCssPath(id: string): string | null {\n if (!id.startsWith(STENCIL_CSS_PREFIX)) return null;\n const withoutPrefix = id.slice(STENCIL_CSS_PREFIX.length);\n const qIdx = withoutPrefix.indexOf('?');\n const stem = qIdx === -1 ? withoutPrefix : withoutPrefix.slice(0, qIdx);\n const query = qIdx === -1 ? '' : withoutPrefix.slice(qIdx + 1);\n const ext = decodeURIComponent(new URLSearchParams(query).get('__ext') ?? 'css');\n return `${stem}.${ext}`;\n}\n\nasync function compileSass(\n source: string,\n filePath: string,\n indented: boolean,\n): Promise<{ css: string; deps: string[] }> {\n const sass = await import('sass');\n const mainUrl = `file://${filePath}`;\n const result = sass.compileString(source, {\n url: new URL(mainUrl),\n syntax: indented ? 'indented' : 'scss',\n });\n const deps = result.loadedUrls\n .filter((u) => u.protocol === 'file:' && u.href !== mainUrl)\n .map((u) => fileURLToPath(u));\n return { css: result.css, deps };\n}\n\nasync function compileLess(\n source: string,\n filePath: string,\n): Promise<{ css: string; deps: string[] }> {\n const less = await import('less');\n const result = await less.default.render(source, {\n filename: filePath,\n paths: [dirname(filePath)],\n });\n return { css: result.css, deps: result.imports ?? [] };\n}\n\n// Cache PostCSS config per directory to avoid repeated filesystem lookups.\nconst postcssConfigCache = new Map<\n string,\n { plugins: unknown[]; options: Record<string, unknown> } | null\n>();\n\nasync function runPostCss(css: string, filePath: string): Promise<string> {\n const dir = dirname(filePath);\n let config = postcssConfigCache.get(dir);\n\n if (config === undefined) {\n try {\n const { default: loadConfig } = await import('postcss-load-config');\n const loaded = await loadConfig({}, dir);\n config = {\n plugins: loaded.plugins as unknown[],\n options: loaded.options as Record<string, unknown>,\n };\n } catch {\n config = null;\n }\n postcssConfigCache.set(dir, config);\n }\n\n if (!config?.plugins.length) return css;\n\n const { default: postcss } = await import('postcss');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result = await postcss(config.plugins as any[]).process(css, {\n ...config.options,\n from: filePath,\n });\n return result.css;\n}\n\nasync function runLightningCss(css: string, filePath: string, minify: boolean): Promise<string> {\n const { transform } = await import('lightningcss');\n const result = transform({\n filename: filePath,\n code: Buffer.from(css),\n minify,\n });\n return result.code.toString();\n}\n\n/**\n * Loads a Stencil CSS virtual module.\n *\n * Processing order:\n * 1. Read raw file\n * 2. Preprocessor: Sass/SCSS (`sass`) or Less (`less`) if installed\n * 3. PostCSS with `postcss.config.*` if `postcss` + `postcss-load-config` are installed\n * 4. lightningcss if installed — syntax lowering, vendor prefixes, minification in prod\n * 5. Scoped selector rewrite for `encapsulation: 'scoped'`\n *\n * Each step is skipped silently if the relevant peer dep is not installed.\n * Returns `export default \"css string\"` so bundlers treat the import as a JS module.\n * @param id - virtual module id produced by `resolveStencilCss`\n * @param isDev - `true` in dev mode (disables minification)\n * @returns ESM string export of the processed CSS, or `null` if not a Stencil CSS virtual module\n */\nexport async function loadStencilCss(\n id: string,\n isDev = true,\n): Promise<{ code: string; deps: string[] } | null> {\n if (!id.startsWith(STENCIL_CSS_PREFIX)) return null;\n\n const withoutPrefix = id.slice(STENCIL_CSS_PREFIX.length);\n const qIdx = withoutPrefix.indexOf('?');\n const stem = qIdx === -1 ? withoutPrefix : withoutPrefix.slice(0, qIdx);\n const query = qIdx === -1 ? '' : withoutPrefix.slice(qIdx + 1);\n const params = new URLSearchParams(query);\n const tag = params.get('tag') ?? '';\n const encapsulation = params.get('encapsulation') ?? 'none';\n const ext = decodeURIComponent(params.get('__ext') ?? 'css');\n const filePath = `${stem}.${ext}`;\n\n if (!existsSync(filePath)) return { code: 'export default () => \"\"', deps: [] };\n\n let css = readFileSync(filePath, 'utf-8');\n let deps: string[] = [];\n\n if (PKG.sass && (ext === 'scss' || ext === 'sass')) {\n const r = await compileSass(css, filePath, ext === 'sass');\n css = r.css;\n deps = r.deps;\n } else if (PKG.less && ext === 'less') {\n const r = await compileLess(css, filePath);\n css = r.css;\n deps = r.deps;\n }\n\n if (PKG.postcss) css = await runPostCss(css, filePath);\n if (PKG.lightningcss) css = await runLightningCss(css, filePath, !isDev);\n\n if (encapsulation === 'scoped' && tag) {\n css = scopeCss(css, getScopeId(tag), false);\n }\n\n return { code: `export default () => ${JSON.stringify(css)};`, deps };\n}\n","/**\n * Resolves imported type references in CEM docs components.\n *\n * `transpileSync` uses a single-file TypeScript host, so imported types (e.g.\n * `ButtonVariant` from `'../types'`) can't be followed — `complexType.resolved`\n * ends up as `\"any\"`. This module creates a minimal ts.Program per referenced\n * types file (cached) and substitutes the actual expanded type text back into\n * the component's doc data before it enters the registry.\n */\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport ts from 'typescript';\nimport type { ComponentCompilerTypeReferences, JsonDocsComponent } from '@stencil/core/compiler';\n\nconst TYPE_FORMAT_FLAGS =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.InElementType;\n\ninterface TypesFileEntry {\n checker: ts.TypeChecker;\n exportTypes: Map<string, ts.Type>;\n}\n\nconst typesFileCache = new Map<string, TypesFileEntry>();\n\nfunction resolveTypesFilePath(specifier: string, fromDir: string): string | undefined {\n const base = resolve(fromDir, specifier);\n if (existsSync(base)) return base;\n for (const ext of ['.ts', '.tsx', '.d.ts']) {\n const candidate = base + ext;\n if (existsSync(candidate)) return candidate;\n }\n return undefined;\n}\n\nfunction getTypesFileEntry(absPath: string): TypesFileEntry {\n const cached = typesFileCache.get(absPath);\n if (cached) return cached;\n\n const options: ts.CompilerOptions = {\n ...ts.getDefaultCompilerOptions(),\n noEmit: true,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n };\n const program = ts.createProgram([absPath], options);\n const checker = program.getTypeChecker();\n const sourceFile = program.getSourceFile(absPath);\n const exportTypes = new Map<string, ts.Type>();\n\n if (sourceFile) {\n const moduleSymbol = checker.getSymbolAtLocation(sourceFile);\n if (moduleSymbol) {\n for (const symbol of checker.getExportsOfModule(moduleSymbol)) {\n exportTypes.set(symbol.name, checker.getDeclaredTypeOfSymbol(symbol));\n }\n }\n }\n\n const entry: TypesFileEntry = { checker, exportTypes };\n typesFileCache.set(absPath, entry);\n return entry;\n}\n\nfunction expandTypeName(\n typeName: string,\n references: ComponentCompilerTypeReferences,\n fromDir: string,\n): string | undefined {\n const ref = references[typeName];\n if (!ref || ref.location !== 'import' || !ref.path) return undefined;\n\n const absPath = resolveTypesFilePath(ref.path, fromDir);\n if (!absPath) return undefined;\n\n const { checker, exportTypes } = getTypesFileEntry(absPath);\n const type = exportTypes.get(typeName);\n if (!type) return undefined;\n\n return checker.typeToString(type, undefined, TYPE_FORMAT_FLAGS);\n}\n\nconst escapeRegExp = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\nfunction patchType(\n original: string,\n references: ComponentCompilerTypeReferences | undefined,\n fromDir: string,\n): string {\n if (!references) return original;\n let result = original;\n for (const typeName of Object.keys(references)) {\n const expanded = expandTypeName(typeName, references, fromDir);\n if (!expanded || expanded === typeName) continue;\n // Wrap in parens when substituting into a potentially larger expression\n // e.g. `ButtonVariant | undefined` → `('sm' | 'md') | undefined`\n result = result.replace(\n new RegExp(`\\\\b${escapeRegExp(typeName)}\\\\b`, 'g'),\n expanded.includes('|') || expanded.includes('&') ? `(${expanded})` : expanded,\n );\n }\n return result;\n}\n\n/**\n * Patches `prop.type` and `event.detail` in-place for any imported types that\n * resolved to `\"any\"` in single-file transpile mode.\n * @param component The CEM docs component to patch\n * @param componentAbsPath The absolute path to the component's source file (used to resolve relative imports)\n */\nexport function resolveImportedTypes(component: JsonDocsComponent, componentAbsPath: string): void {\n const dir = dirname(componentAbsPath);\n\n for (const prop of component.props) {\n if (prop.type !== 'any' || !prop.complexType?.references) continue;\n const patched = patchType(prop.complexType.original, prop.complexType.references, dir);\n if (patched !== prop.complexType.original) prop.type = patched;\n }\n\n for (const event of component.events) {\n if (event.detail !== 'any' || !event.complexType?.references) continue;\n const patched = patchType(event.complexType.original, event.complexType.references, dir);\n if (patched !== event.complexType.original) event.detail = patched;\n }\n}\n","/**\n * Component transpilation and base-class discovery.\n *\n * `transformStencil` is the main entry point: it calls `transpileSync` with\n * `componentExport: 'customelement'` so each component self-registers when\n * imported. Two code paths come out:\n *\n * - **Component** (`@Component` present): full customelement output with\n * `defineCustomElement`, optional HMR snippet appended in dev mode.\n * - **Decorated base class** (`@Prop`/`@State`/etc. but no `@Component`):\n * returned as-is — the compiler's `isStencilBaseClass` check already injects\n * `extends HTMLElement` via `updateNativeBaseClass`.\n *\n * `makeResolver` supplies the `resolveImport` callback that `transpileSync`\n * uses during metadata collection. It serves two purposes at once: returning\n * raw source so the compiler can merge inherited props/states into the\n * component's metadata, and calling `onBaseClass` so the plugin can\n * pre-transform and cache the file before the bundler's resolveId hook fires.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { cmpMetaToDocsComponent, transpileSync } from '@stencil/core/compiler';\nimport type { BuildOverrides, JsonDocsComponent } from '@stencil/core/compiler';\nimport type { SupportedFramework } from 'unplugin';\n\nimport type { StencilPluginOptions } from './options.js';\n\nconst SOURCE_EXTS = ['.tsx', '.ts', '.js'];\n\n// TypeScript JsxEmit enum values — stable across TS versions.\nconst JSX_EMIT: Record<string, number> = {\n react: 2,\n 'react-jsx': 4,\n 'react-jsxdev': 5,\n preserve: 1,\n 'react-native': 3,\n};\n\ntype JsxOpts = { jsx?: number; jsxImportSource?: string };\n\nlet cachedTsConfigJsx: JsxOpts | undefined;\n\nfunction readJsxOptsFromTsConfig(cwd: string): JsxOpts {\n if (cachedTsConfigJsx !== undefined) return cachedTsConfigJsx;\n const tsconfigPath = join(cwd, 'tsconfig.json');\n if (!existsSync(tsconfigPath)) return (cachedTsConfigJsx = {});\n try {\n const raw = readFileSync(tsconfigPath, 'utf-8');\n const stripped = raw.replace(/\\/\\/[^\\n]*/g, '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n const tsconfig = JSON.parse(stripped);\n const co = tsconfig?.compilerOptions ?? {};\n const jsxStr: string | undefined = co.jsx?.toLowerCase();\n if (jsxStr && jsxStr in JSX_EMIT) {\n return (cachedTsConfigJsx = {\n jsx: JSX_EMIT[jsxStr],\n jsxImportSource: co.jsxImportSource,\n });\n }\n } catch {\n // ignore unreadable / malformed tsconfig\n }\n return (cachedTsConfigJsx = {});\n}\n\n// Detects classic JSX mode: `import { …, h, … } from '@stencil/core'`\nconst IMPORTS_H_RE = /import\\s+\\{[^}]*\\bh\\b[^}]*\\}\\s+from\\s+['\"]@stencil\\/core['\"]/;\n\n/* Resolve jsx/jsxImportSource for transpileSync.\n * Priority: tsconfig.json > source heuristic (h import → classic; otherwise automatic runtime). */\nfunction resolveJsxOpts(code: string, cwd: string): JsxOpts {\n const fromTsConfig = readJsxOptsFromTsConfig(cwd);\n if (fromTsConfig.jsx !== undefined) return fromTsConfig;\n if (IMPORTS_H_RE.test(code)) {\n return { jsx: JSX_EMIT['react'] }; // jsxFactory: 'h' auto-applied by transpile-module\n }\n return { jsx: JSX_EMIT['react-jsx'], jsxImportSource: '@stencil/core' };\n}\n\n/**\n * Resolve an import specifier to an absolute path, trying source extensions\n * and the TypeScript ESM `.js` → `.ts`/`.tsx` remap.\n * @param specifier - the import specifier (relative or extensionless)\n * @param importer - absolute path of the importing file\n * @returns absolute path to the resolved file, or `null` if nothing found on disk\n */\nexport function resolveSpecifier(specifier: string, importer: string): string | null {\n const base = resolve(dirname(importer), specifier);\n // Vite normalizes module IDs to forward slashes; we must match that so\n // virtual-module keys stay consistent on Windows.\n const norm = (p: string) => p.replace(/\\\\/g, '/');\n\n if (existsSync(base)) return norm(base);\n\n for (const ext of SOURCE_EXTS) {\n const candidate = base + ext;\n if (existsSync(candidate)) return norm(candidate);\n }\n\n // TypeScript ESM: `./foo.js` may physically be `./foo.ts` or `./foo.tsx`\n if (base.endsWith('.js')) {\n const stem = base.slice(0, -3);\n for (const ext of ['.ts', '.tsx']) {\n const candidate = stem + ext;\n if (existsSync(candidate)) return norm(candidate);\n }\n }\n\n return null;\n}\n\n/**\n * Transpile a `.tsx`/`.ts` file for use in a bundler.\n *\n * Returns `{ code, map, tagName }` for Stencil component or base-class files,\n * `null` for everything else (plain TS utilities, non-TS files, etc.).\n * `tagName` is empty string for base classes with no `@Component`.\n *\n * `onBaseClass` is called for every file the compiler resolves via\n * `resolveImport` during metadata collection. The plugin uses this to\n * pre-transform those files before the bundler's resolveId hook fires.\n * @param code - source file contents\n * @param id - absolute file path\n * @param options - plugin options\n * @param dev - `true` in dev/watch mode (enables HMR snippet)\n * @param framework - active unplugin framework\n * @param onBaseClass - called for each file in the inheritance chain with its abs path and raw source\n * @param configOverrides - pass stencil config option overrides to the transpiler\n * @returns transformed output, or `null` if the file is not a Stencil file\n */\nexport function transformStencil(\n code: string,\n id: string,\n options: StencilPluginOptions,\n dev = false,\n framework: SupportedFramework | '' = '',\n onBaseClass?: (absPath: string, rawCode: string) => void,\n configOverrides?: BuildOverrides,\n): {\n code: string;\n map: string | null;\n tagName: string;\n docsComponent: JsonDocsComponent | null;\n} | null {\n if (!id.endsWith('.tsx') && !id.endsWith('.ts')) return null;\n if (id.endsWith('.d.ts')) return null;\n\n // Cheap regex guard — avoids paying transpileSync cost for plain TS files.\n if (!/(@Component|@Prop|@State|@Event|@Method|@Watch|@Listen)\\s*[(\\s]/.test(code)) return null;\n\n const jsxOpts = resolveJsxOpts(code, process.cwd());\n const result = transpileSync(code, {\n ...jsxOpts,\n ...options.transpileOptions,\n file: id,\n componentExport: 'customelement',\n styleImportData: 'queryparams',\n resolveImport: makeResolver(onBaseClass),\n buildOverrides: {\n ...configOverrides,\n ...options.transpileOptions?.buildOverrides,\n ...(dev ? { hotModuleReplacement: true, isDev: true } : {}),\n },\n });\n\n if (result.diagnostics.some((d) => d.level === 'error')) {\n const msgs = result.diagnostics\n .filter((d) => d.level === 'error')\n .map((d) => d.messageText)\n .join('\\n');\n throw new Error(`[@stencil/unplugin] transpile error in ${id}:\\n${msgs}`);\n }\n\n if (!result.data?.length) {\n // No @Component — this is a base class or mixin factory. Return the\n // compiled output; for decorated classes the compiler's isStencilBaseClass\n // check already injected `extends HTMLElement`. Plain classes without\n // decorators are handled via the baseClassRegistry virtual-module path.\n if (!/@Component\\s*[(\\s]/.test(code)) {\n return { code: result.code, map: result.map ?? null, tagName: '', docsComponent: null };\n }\n return null;\n }\n\n const tagName = result.data[0].tagName;\n const className = result.data[0].componentClassName;\n\n // In dev mode, re-export the class so hmrStandalone can find it in the\n // re-imported module (customelement mode strips the export keyword).\n const devExport = dev ? `\\nexport{${className}};` : '';\n const out = dev\n ? result.code + devExport + buildHmrSnippet(tagName, className, framework)\n : result.code;\n\n const docsComponent = cmpMetaToDocsComponent(result.data[0], id);\n\n return { code: out, map: result.map ?? null, tagName, docsComponent };\n}\n\n/**\n * Transpile a base-class file with `transformAsBaseClass: true` so the\n * compiler injects `extends HTMLElement` into any class without an existing\n * heritage clause, regardless of whether it carries Stencil decorators.\n *\n * The result is cached in `baseClassRegistry` (in plugin.ts) and served as a\n * virtual module, ensuring the bundler always sees the injected version even\n * for plain lifecycle-only classes that the `transform` hook would otherwise skip.\n * @param rawCode - raw source of the base-class file\n * @param absPath - absolute path to the file (used as `file` for source maps)\n * @param options - plugin options forwarded to `transpileSync`\n * @returns compiled JS output\n */\nexport function transpileBaseClass(\n rawCode: string,\n absPath: string,\n options: StencilPluginOptions,\n): string {\n const result = transpileSync(rawCode, {\n ...options.transpileOptions,\n file: absPath,\n componentExport: 'customelement',\n styleImportData: 'queryparams',\n transformAsBaseClass: true,\n });\n return result.code;\n}\n\n/* Builds the HMR client snippet appended to component output in dev mode.\n *\n * Two strategies depending on bundler:\n * - Vite / Farm: server sends a `stencil:hmr` WebSocket event via\n * `handleHotUpdate`; the client calls `el['s-hmr'](version)` which triggers\n * a cache-busted re-import and forced re-render.\n * - webpack / rspack / bun: use the `module.hot` re-execution pattern —\n * `dispose` marks the reload with a flag, `accept` re-runs the module, and\n * the new prototype is patched onto existing instances in-place. */\nfunction buildHmrSnippet(\n tagName: string,\n className: string,\n framework: SupportedFramework | '',\n): string {\n const tag = JSON.stringify(tagName);\n\n if (framework === 'webpack' || framework === 'rspack' || framework === 'bun') {\n const hotExpr =\n framework === 'bun'\n ? 'import.meta.hot'\n : \"(typeof module !== 'undefined' && module.hot) || import.meta.webpackHot\";\n\n return (\n `\\n${className}.__stencil_module__ = import.meta.url;` +\n `\\nvar _sHot = ${hotExpr};` +\n `\\nif (_sHot) {` +\n `\\n if (_sHot.data && _sHot.data.stencilHmr) {` +\n `\\n var _sCtor = customElements.get(${tag});` +\n `\\n if (_sCtor) Object.getOwnPropertyNames(${className}.prototype).forEach(function(k) {` +\n `\\n if (k !== 'constructor') Object.defineProperty(_sCtor.prototype, k, Object.getOwnPropertyDescriptor(${className}.prototype, k));` +\n `\\n });` +\n `\\n document.querySelectorAll(${tag}).forEach(function(el) { el.connectedCallback && el.connectedCallback(); });` +\n `\\n }` +\n `\\n _sHot.dispose(function(data) { data.stencilHmr = true; });` +\n `\\n _sHot.accept();` +\n `\\n}`\n );\n }\n\n // Vite and Farm both implement the Vite HMR API.\n // The s-hmr guard prevents ?s-hmr= re-imports from stacking up additional listeners.\n return (\n `\\n${className}.__stencil_module__ = import.meta.url;` +\n `\\nif (import.meta.hot && !import.meta.url.includes('s-hmr=')) {` +\n `\\n import.meta.hot.accept(() => {});` +\n `\\n import.meta.hot.on('stencil:hmr', function({ tagName }) {` +\n `\\n if (tagName === ${tag}) {` +\n `\\n var v = Date.now().toString(36);` +\n `\\n document.querySelectorAll(${tag}).forEach(function(el) { el['s-hmr'] && el['s-hmr'](v); });` +\n `\\n }` +\n `\\n });` +\n `\\n}`\n );\n}\n\n/* Builds the `resolveImport` callback for `transpileSync`.\n *\n * The compiler calls this for every import it encounters while walking the\n * inheritance chain during metadata collection. The callback returns the raw\n * source so the compiler can merge inherited props/states/events into the\n * component's metadata. As a side-effect it calls `onBaseClass` with the same\n * raw source, giving the plugin a chance to pre-transform and cache the file\n * before the bundler's resolveId hook fires for it. */\nfunction makeResolver(onBaseClass?: (absPath: string, rawCode: string) => void) {\n return (specifier: string, currentImporter: string): { code: string; path: string } | null => {\n const absPath = resolveSpecifier(specifier, currentImporter);\n if (!absPath) return null;\n\n const code = readFileSync(absPath, 'utf-8');\n onBaseClass?.(absPath, code);\n return { code, path: absPath };\n };\n}\n","/**\n * Unplugin factory for @stencil/unplugin.\n *\n * Wires together four concerns into a single plugin that works across Vite,\n * Rollup, webpack, rspack, and bun:\n *\n * 1. **Component transform** — `transform` drives `transpileSync` on every\n * `.tsx`/`.ts` file that carries Stencil decorators, producing\n * `customelement` output (self-registering class + `defineCustomElement`).\n *\n * 2. **CSS virtual modules** — Stencil emits `./foo.css?tag=my-cmp&…`\n * imports. `resolveId` rewrites these to `\\0stencil-css:` virtual IDs;\n * `load` reads the real file, runs it through any installed preprocessors,\n * and returns `export default () => \"…css…\"`.\n *\n * 3. **Base-class inheritance** — when a component extends a class that does\n * not itself extend `HTMLElement`, the custom-element registration breaks.\n * The plugin intercepts every file the compiler resolves via `resolveImport`\n * (during `transpileSync`), pre-transforms it with `transformAsBaseClass: true`\n * so it gets `extends HTMLElement`, and caches the result. `resolveId` then\n * redirects imports of those files to `\\0stencil-base:` virtual modules so\n * the bundler always sees the injected version — regardless of module-graph\n * processing order.\n *\n * 4. **HMR** — Vite receives a custom `stencil:hmr` WebSocket event when a\n * component file changes; other bundlers use the `module.hot` re-execution\n * pattern. CSS changes are covered automatically by `addWatchFile`.\n */\nimport { readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { createFilter } from '@rollup/pluginutils';\nimport { transpile, cmpMetaToDocsComponent, generateManifest } from '@stencil/core/compiler';\nimport { createUnplugin } from 'unplugin';\nimport type {\n BuildOverrides,\n CustomElementsManifest,\n JsonDocsComponent,\n} from '@stencil/core/compiler';\n\nimport { loadStencilConfig, stencilConfigToOverrides } from './config.js';\nimport { getRealCssPath, isStencilCss, loadStencilCss, resolveStencilCss } from './css.js';\nimport { resolveImportedTypes } from './resolve-types.js';\nimport { resolveSpecifier, transformStencil, transpileBaseClass } from './transform.js';\nimport type { StencilPluginOptions } from './options.js';\n\nexport const STENCIL_DOCS_ID = '@stencil/unplugin/docs';\nconst VIRTUAL_DOCS_PREFIX = '\\0stencil-docs:';\n\n// Module-level registry so getStencilDocs() is callable from outside the plugin\n// (e.g. from a Storybook preset running in Node.js).\nconst docsRegistry = new Map<string, JsonDocsComponent>();\n\n/**\n * Returns the current CEM. Only populated when `docs: true` is set.\n * @returns the current CEM, or an empty CEM if `docs: true` was not set.\n */\nexport function getStencilCEM(): CustomElementsManifest {\n return generateManifest({ components: [...docsRegistry.values()] });\n}\n\n/**\n * Scan the project for component source files and pre-populate the docs registry.\n * @param filter A function to filter which files should be included.\n * @returns A promise that resolves when the scan is complete.\n */\nasync function scanDocs(filter: (id: string) => boolean): Promise<void> {\n const cwd = process.cwd();\n let entries: string[];\n try {\n entries = readdirSync(cwd, { recursive: true, encoding: 'utf-8' }) as string[];\n } catch {\n return;\n }\n\n const files = entries\n .filter((rel) => (rel.endsWith('.tsx') || rel.endsWith('.ts')) && !rel.endsWith('.d.ts'))\n .map((rel) => join(cwd, rel))\n .filter((abs) => filter(abs));\n\n await Promise.all(\n files.map(async (abs) => {\n let code: string;\n try {\n code = readFileSync(abs, 'utf-8');\n } catch {\n return;\n }\n if (!/(@Component|@Prop|@State|@Event|@Method|@Watch|@Listen)\\s*[(\\s]/.test(code)) return;\n const result = await transpile(code, { file: abs, componentExport: 'customelement' });\n for (const item of result.data ?? []) {\n if (!item.tagName) continue;\n const component = cmpMetaToDocsComponent(item, abs);\n resolveImportedTypes(component, abs);\n docsRegistry.set(item.tagName, component);\n }\n }),\n );\n}\n\n// Null-byte prefix marks a virtual module — Rollup/Vite convention that\n// prevents the ID from being treated as a real filesystem path.\nconst VIRTUAL_BASE_PREFIX = '\\0stencil-base:';\n\n// Mirrors the compiler's hasSignalsImport check in static-to-meta/import.ts.\nconst SIGNALS_IMPORT_RE = /from\\s+['\"]@stencil\\/core\\/signals['\"]/;\n\nexport const unpluginStencil = createUnplugin(\n (options: StencilPluginOptions | undefined = {}, meta) => {\n const { framework } = meta;\n const filter = createFilter(\n options.include ?? [/\\.tsx?$/],\n options.exclude ?? ['node_modules/**'],\n );\n\n // Vite auto-detects dev mode via configResolved; other bundlers use options.dev.\n let isDev = options.dev ?? false;\n\n // For Vite, configResolved sets this to config.root (more accurate than process.cwd()).\n // For other bundlers, process.cwd() is the fallback.\n let projectRoot = process.cwd();\n\n // Merged BUILD overrides from auto-detected stencil.config + explicit stencilConfig.\n // Populated in buildStart; explicit transpileOptions.buildOverrides takes precedence\n // over this in transformStencil.\n let configOverrides: BuildOverrides = {};\n\n // Tracks which source file owns which custom-element tag name, used by the\n // Vite HMR handler to send targeted `stencil:hmr` events.\n const fileToTagName = new Map<string, string>();\n\n // Maps CSS dependency paths (including Sass @use/@import) → tag name so\n // changes to imported partials also trigger HMR for the component.\n const cssFileToTagName = new Map<string, string>();\n\n // Maps real CSS file path → virtual CSS module ID (\\0stencil-css:...) so\n // handleHotUpdate can locate and invalidate the right module in the graph.\n const cssRealToVirtualId = new Map<string, string>();\n\n // absPath → HTMLElement-injected JS. Populated during `transform` when\n // `transpileSync`'s resolveImport callback discovers a base-class file.\n // Rollup guarantees that resolveId for imports in a module's *output* fires\n // after the transform that produced them — so by the time the bundler asks\n // to resolve a base-class import, this map is already populated.\n const baseClassRegistry = new Map<string, string>();\n\n function registerBaseClass(absPath: string, rawCode: string) {\n if (baseClassRegistry.has(absPath)) return; // already processed this build\n baseClassRegistry.set(absPath, transpileBaseClass(rawCode, absPath, options));\n }\n\n return {\n name: '@stencil/unplugin',\n\n async buildStart() {\n const detected = await loadStencilConfig(projectRoot);\n // Merge: auto-detected config is the base; explicit stencilConfig overrides field-by-field.\n const merged = detected\n ? {\n ...detected,\n ...options.stencilConfig,\n compat: { ...detected.compat, ...options.stencilConfig?.compat },\n }\n : (options.stencilConfig ?? {});\n configOverrides = stencilConfigToOverrides(merged);\n if (options.docs) await scanDocs(filter);\n },\n\n resolveId(id, importer) {\n if (id === STENCIL_DOCS_ID) return VIRTUAL_DOCS_PREFIX;\n if (!importer) return null;\n\n const css = resolveStencilCss(id, importer);\n if (css) return css;\n\n if (baseClassRegistry.size > 0) {\n // Imports inside a virtual base-class module use the virtual ID as\n // importer — strip the prefix so resolveSpecifier works against the\n // real path on disk. This matters for multi-level inheritance chains.\n\n const realImporter = importer.startsWith(VIRTUAL_BASE_PREFIX)\n ? importer.slice(VIRTUAL_BASE_PREFIX.length)\n : importer;\n\n const abs = resolveSpecifier(id, realImporter);\n if (abs && baseClassRegistry.has(abs)) {\n return VIRTUAL_BASE_PREFIX + abs;\n }\n }\n\n return null;\n },\n\n transformInclude(id) {\n return filter(id.split('?')[0]);\n },\n\n transform(code, id) {\n const cleanId = id.split('?')[0];\n if (!configOverrides.vdomSignals && SIGNALS_IMPORT_RE.test(code)) {\n configOverrides = { ...configOverrides, vdomSignals: true };\n }\n const result = transformStencil(\n code,\n cleanId,\n options,\n isDev,\n framework,\n registerBaseClass,\n configOverrides,\n );\n if (result?.tagName) fileToTagName.set(cleanId, result.tagName);\n if (result?.docsComponent && options.docs) {\n resolveImportedTypes(result.docsComponent, cleanId);\n docsRegistry.set(result.docsComponent.tag, result.docsComponent);\n }\n return result;\n },\n\n loadInclude(id) {\n return id === VIRTUAL_DOCS_PREFIX || isStencilCss(id) || id.startsWith(VIRTUAL_BASE_PREFIX);\n },\n\n async load(id) {\n if (id === VIRTUAL_DOCS_PREFIX) {\n return `export default ${JSON.stringify(getStencilCEM())}`;\n }\n if (id.startsWith(VIRTUAL_BASE_PREFIX)) {\n const realPath = id.slice(VIRTUAL_BASE_PREFIX.length);\n this.addWatchFile(realPath); // re-invalidate this virtual module when the source changes\n return { code: baseClassRegistry.get(realPath) ?? '', map: null };\n }\n const realPath = getRealCssPath(id);\n const qIdx = id.indexOf('?');\n const tag = qIdx !== -1 ? new URLSearchParams(id.slice(qIdx + 1)).get('tag') : null;\n if (realPath) {\n this.addWatchFile(realPath);\n if (tag) cssFileToTagName.set(realPath, tag);\n cssRealToVirtualId.set(realPath, id);\n }\n const cssResult = await loadStencilCss(id, isDev);\n if (cssResult) {\n if (tag) {\n for (const dep of cssResult.deps) {\n this.addWatchFile(dep);\n cssFileToTagName.set(dep, tag);\n cssRealToVirtualId.set(dep, id);\n }\n }\n return { code: cssResult.code, map: null };\n }\n return null;\n },\n\n vite: {\n // Must run before Vite/rolldown's built-in TSX transform, which would\n // otherwise claim the file and emit react/jsx-dev-runtime imports.\n enforce: 'pre' as const,\n\n configResolved(config: { command: string; root: string }) {\n isDev = options.dev ?? config.command === 'serve';\n projectRoot = config.root;\n },\n\n async handleHotUpdate({\n file,\n server,\n }: {\n file: string;\n server: {\n ws: { send: (msg: unknown) => void };\n moduleGraph: {\n invalidateModule(\n mod: unknown,\n seen?: Set<unknown>,\n timestamp?: number,\n isHmr?: boolean,\n ): void;\n getModuleById?(id: string): unknown;\n idToModuleMap?: Map<string, unknown>;\n };\n };\n }) {\n const tagName = fileToTagName.get(file) ?? cssFileToTagName.get(file);\n if (!tagName) return;\n // Invalidate the virtual CSS module (\\0stencil-css:...) so Vite\n // rewrites its import URL with ?t=timestamp when serving the\n // re-fetched TSX — prevents the browser's ESM cache serving stale CSS.\n const virtualId = cssRealToVirtualId.get(file);\n if (virtualId) {\n const virtualMod =\n server.moduleGraph.getModuleById?.(virtualId) ??\n server.moduleGraph.idToModuleMap?.get(virtualId);\n if (virtualMod)\n server.moduleGraph.invalidateModule(virtualMod, new Set(), Date.now(), true);\n }\n // Update the docs registry and notify the client only when the CEM\n // actually changed (new/renamed prop, type update, JSDoc edit, etc.).\n // Pure implementation changes leave the CEM identical and fall through\n // to normal stencil:hmr so HMR is not disrupted.\n if (options.docs && fileToTagName.has(file)) {\n let cemChanged = false;\n try {\n const prevSnapshot = JSON.stringify(docsRegistry.get(tagName));\n const code = readFileSync(file, 'utf-8');\n const result = await transpile(code, { file, componentExport: 'customelement' });\n for (const item of result.data ?? []) {\n if (!item.tagName) continue;\n const component = cmpMetaToDocsComponent(item, file);\n resolveImportedTypes(component, file);\n docsRegistry.set(item.tagName, component);\n }\n cemChanged = JSON.stringify(docsRegistry.get(tagName)) !== prevSnapshot;\n } catch {\n // stale docs are acceptable on transpile error\n }\n if (cemChanged) {\n const docsVirtualMod =\n server.moduleGraph.getModuleById?.(VIRTUAL_DOCS_PREFIX) ??\n server.moduleGraph.idToModuleMap?.get(VIRTUAL_DOCS_PREFIX);\n if (docsVirtualMod)\n server.moduleGraph.invalidateModule(docsVirtualMod, new Set(), Date.now(), true);\n server.ws.send({ type: 'custom', event: 'stencil:docs-update' });\n }\n }\n server.ws.send({ type: 'custom', event: 'stencil:hmr', data: { tagName } });\n return [];\n },\n },\n };\n },\n);\n","export { unpluginStencil, getStencilCEM, STENCIL_DOCS_ID } from './plugin.js';\nexport type { StencilPluginOptions } from './options.js';\n\nimport { unpluginStencil } from './plugin.js';\n\nexport const stencilVite = unpluginStencil.vite;\nexport const stencilRollup = unpluginStencil.rollup;\nexport const stencilWebpack = unpluginStencil.webpack;\nexport const stencilEsbuild = unpluginStencil.esbuild;\nexport const stencilRspack = unpluginStencil.rspack;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,sBAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,mBAAmB,MACvB,MAAM,QACN,OAAO,MAAM,YACb,CAAC,MAAM,QAAQ,CAAC,KAChB,OAAO,KAAK,CAAW,EAAE,MAAM,MAAM,oBAAoB,IAAI,CAAC,CAAC;AAEjE,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;AACF;;;;;;;;AASA,eAAsB,kBAAkB,KAAkD;CACxF,KAAK,MAAM,YAAY,mBAAmB;EACxC,MAAM,aAAa,KAAK,KAAK,QAAQ;EACrC,IAAI,CAAC,WAAW,UAAU,GAAG;EAC7B,IAAI;GACF,MAAM,EAAE,eAAe,MAAM,OAAO;GAEpC,MAAM,MA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AgB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/config.ts","../src/css.ts","../src/resolve-types.ts","../src/transform.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["/**\n * Stencil config auto-detection for @stencil/unplugin.\n *\n * Searches for a `stencil.config.ts` (or `.js` variant) in the project root,\n * loads it via jiti (so TypeScript is handled without a separate compile step),\n * and extracts the subset of flags that are meaningful at transpile time.\n *\n * `stencilConfigToOverrides` converts that subset to a `BuildOverrides` object\n * ready to pass to `transpileSync`.\n */\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { BuildOverrides, LightDomPatches } from '@stencil/core/compiler';\n\nimport type { StencilConfigSubset } from './options.js';\n\n// A real Stencil config always has at least one of these keys. Used to\n// distinguish an actual default-exported config from jiti's CJS interop\n// artefact where the module namespace itself lands on `mod.default`.\nconst STENCIL_CONFIG_KEYS = new Set([\n 'namespace',\n 'srcDir',\n 'outputTargets',\n 'plugins',\n 'signalBacking',\n 'compat',\n]);\n\nconst looksLikeConfig = (v: unknown): v is Record<string, unknown> =>\n v !== null &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n Object.keys(v as object).some((k) => STENCIL_CONFIG_KEYS.has(k));\n\nconst CONFIG_CANDIDATES = [\n 'stencil.config.ts',\n 'stencil.config.mts',\n 'stencil.config.js',\n 'stencil.config.mjs',\n];\n\n/**\n * Attempt to load the project's `stencil.config.ts` and return the\n * transpile-relevant fields. Returns `null` if no config file is found or\n * if loading fails for any reason.\n * @param cwd - project root to search in (usually `process.cwd()`)\n * @returns a subset of the Stencil config, or `null` if none is found\n */\nexport async function loadStencilConfig(cwd: string): Promise<StencilConfigSubset | null> {\n for (const filename of CONFIG_CANDIDATES) {\n const configPath = join(cwd, filename);\n if (!existsSync(configPath)) continue;\n try {\n const { createJiti } = await import('jiti');\n const jiti = createJiti(import.meta.url);\n const mod = (await jiti.import(configPath)) as Record<string, unknown>;\n // Named `config` export is the Stencil convention; fall back to a default\n // export only when it looks like a real config object (has at least one\n // known Stencil key) — otherwise jiti's CJS interop may surface the\n // module namespace object as `default`, which we must not treat as config.\n const raw = mod['config'] ?? (looksLikeConfig(mod['default']) ? mod['default'] : null);\n if (!raw || typeof raw !== 'object') return null;\n return extractSubset(raw as Record<string, unknown>);\n } catch {\n return null;\n }\n }\n return null;\n}\n\nfunction extractSubset(c: Record<string, unknown>): StencilConfigSubset {\n const result: StencilConfigSubset = {};\n if (c['signalBacking'] === true) result.signalBacking = true;\n const compat = c['compat'];\n if (compat && typeof compat === 'object') {\n const co = compat as Record<string, unknown>;\n const ldp = co['lightDomPatches'];\n const lifecycleDOMEvents = co['lifecycleDOMEvents'];\n const initializeNextTick = co['initializeNextTick'];\n if (ldp !== undefined || lifecycleDOMEvents !== undefined || initializeNextTick !== undefined) {\n result.compat = {};\n if (typeof ldp === 'boolean') result.compat.lightDomPatches = ldp;\n else if (ldp && typeof ldp === 'object')\n result.compat.lightDomPatches = ldp as LightDomPatches;\n if (lifecycleDOMEvents === true) result.compat.lifecycleDOMEvents = true;\n if (initializeNextTick === true) result.compat.initializeNextTick = true;\n }\n }\n return result;\n}\n\n/**\n * Convert a {@link StencilConfigSubset} to a {@link BuildOverrides} object.\n * The caller is responsible for merging this with any explicit\n * `transpileOptions.buildOverrides` (which should take precedence).\n * @param config - the Stencil config subset to convert\n * @returns a `BuildOverrides` object suitable for passing to `transpileSync`\n */\nexport function stencilConfigToOverrides(config: StencilConfigSubset): BuildOverrides {\n const o: BuildOverrides = {};\n if (config.signalBacking) {\n o.signalBacking = true;\n o.vdomSignals = true; // signalBacking implies vdomSignals\n }\n\n const compat = config.compat;\n if (!compat) return o;\n if (compat.lifecycleDOMEvents) o.lifecycleDOMEvents = true;\n if (compat.initializeNextTick) o.initializeNextTick = true;\n\n const ldp = compat.lightDomPatches;\n if (ldp === false) {\n // Explicitly disable — standalone runtime defaults all to true.\n o.lightDomPatches = false;\n o.slotChildNodes = false;\n o.slotCloneNode = false;\n o.slotDomMutations = false;\n o.slotTextContent = false;\n } else if (typeof ldp === 'object') {\n // Granular: enable only the named patches; disable the rest (defaults are all-true).\n o.lightDomPatches = true;\n o.slotChildNodes = !!ldp.childNodes;\n o.slotCloneNode = !!ldp.cloneNode;\n o.slotDomMutations = !!ldp.domMutations;\n o.slotTextContent = !!ldp.textContent;\n }\n // ldp === true or undefined: no-op — already the default in the standalone runtime.\n return o;\n}\n","/**\n * CSS pipeline for Stencil component stylesheets.\n *\n * When the Stencil compiler emits a style import such as\n * `./foo.css?tag=my-cmp&encapsulation=shadow`, `resolveStencilCss` rewrites it\n * to a `\\0stencil-css:` virtual module ID. The bundler then calls `load`, which\n * reads the real file and runs it through any installed preprocessors in order:\n * Sass/Less → PostCSS → lightningcss → scoped-selector rewrite (for scoped\n * encapsulation). The result is returned as `export default () => \"…css…\"` so\n * the bundler treats it as a normal JS module dependency.\n *\n * Each preprocessor step is silently skipped if the relevant peer dep is absent.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { getScopeId, scopeCss } from '@stencil/core/compiler';\nimport { isPackageExists } from 'local-pkg';\n\n// Matches Stencil's emitted style imports: `./foo.css?tag=my-cmp&…`\nconst STENCIL_CSS_RE = /\\.(?:css|scss|sass|less|styl)\\?[^/]*\\btag=/;\nconst STENCIL_CSS_PREFIX = '\\0stencil-css:';\n\n// Evaluated once at startup — avoids repeated filesystem probes per CSS file.\nconst PKG = {\n sass: isPackageExists('sass'),\n less: isPackageExists('less'),\n postcss: isPackageExists('postcss') && isPackageExists('postcss-load-config'),\n lightningcss: isPackageExists('lightningcss'),\n};\n\n/**\n * Rewrites a Stencil CSS import to a `\\0stencil-css:` virtual module ID.\n * The file extension is stored dotless as `__ext` so Vite's `CSS_LANGS_RE`\n * never matches the virtual ID and tries to own the module itself.\n * @param specifier - the raw import specifier from the component source\n * @param importer - absolute path of the importing file\n * @returns virtual module ID, or `null` for non-Stencil CSS imports\n */\nexport function resolveStencilCss(specifier: string, importer: string): string | null {\n if (!STENCIL_CSS_RE.test(specifier)) return null;\n const [base, query] = specifier.split('?');\n const absBase = resolve(dirname(importer), base);\n const ext = extname(absBase);\n const stem = absBase.slice(0, absBase.length - ext.length);\n return `${STENCIL_CSS_PREFIX}${stem}?${query}&__ext=${encodeURIComponent(ext.slice(1))}`;\n}\n\nexport function isStencilCss(id: string): boolean {\n return id.startsWith(STENCIL_CSS_PREFIX);\n}\n\n/**\n * Extracts the real CSS file path from a `\\0stencil-css:` virtual module ID.\n * @param id - virtual module ID produced by `resolveStencilCss`\n * @returns absolute file path, or `null` if not a Stencil CSS virtual module\n */\nexport function getRealCssPath(id: string): string | null {\n if (!id.startsWith(STENCIL_CSS_PREFIX)) return null;\n const withoutPrefix = id.slice(STENCIL_CSS_PREFIX.length);\n const qIdx = withoutPrefix.indexOf('?');\n const stem = qIdx === -1 ? withoutPrefix : withoutPrefix.slice(0, qIdx);\n const query = qIdx === -1 ? '' : withoutPrefix.slice(qIdx + 1);\n const ext = decodeURIComponent(new URLSearchParams(query).get('__ext') ?? 'css');\n return `${stem}.${ext}`;\n}\n\nasync function compileSass(\n source: string,\n filePath: string,\n indented: boolean,\n): Promise<{ css: string; deps: string[] }> {\n const sass = await import('sass');\n const mainUrl = `file://${filePath}`;\n const result = sass.compileString(source, {\n url: new URL(mainUrl),\n syntax: indented ? 'indented' : 'scss',\n });\n const deps = result.loadedUrls\n .filter((u) => u.protocol === 'file:' && u.href !== mainUrl)\n .map((u) => fileURLToPath(u));\n return { css: result.css, deps };\n}\n\nasync function compileLess(\n source: string,\n filePath: string,\n): Promise<{ css: string; deps: string[] }> {\n const less = await import('less');\n const result = await less.default.render(source, {\n filename: filePath,\n paths: [dirname(filePath)],\n });\n return { css: result.css, deps: result.imports ?? [] };\n}\n\n// Cache PostCSS config per directory to avoid repeated filesystem lookups.\nconst postcssConfigCache = new Map<\n string,\n { plugins: unknown[]; options: Record<string, unknown> } | null\n>();\n\nasync function runPostCss(css: string, filePath: string): Promise<string> {\n const dir = dirname(filePath);\n let config = postcssConfigCache.get(dir);\n\n if (config === undefined) {\n try {\n const { default: loadConfig } = await import('postcss-load-config');\n const loaded = await loadConfig({}, dir);\n config = {\n plugins: loaded.plugins as unknown[],\n options: loaded.options as Record<string, unknown>,\n };\n } catch {\n config = null;\n }\n postcssConfigCache.set(dir, config);\n }\n\n if (!config?.plugins.length) return css;\n\n const { default: postcss } = await import('postcss');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result = await postcss(config.plugins as any[]).process(css, {\n ...config.options,\n from: filePath,\n });\n return result.css;\n}\n\nasync function runLightningCss(css: string, filePath: string, minify: boolean): Promise<string> {\n const { transform } = await import('lightningcss');\n const result = transform({\n filename: filePath,\n code: Buffer.from(css),\n minify,\n });\n return result.code.toString();\n}\n\n/**\n * Loads a Stencil CSS virtual module.\n *\n * Processing order:\n * 1. Read raw file\n * 2. Preprocessor: Sass/SCSS (`sass`) or Less (`less`) if installed\n * 3. PostCSS with `postcss.config.*` if `postcss` + `postcss-load-config` are installed\n * 4. lightningcss if installed — syntax lowering, vendor prefixes, minification in prod\n * 5. Scoped selector rewrite for `encapsulation: 'scoped'`\n *\n * Each step is skipped silently if the relevant peer dep is not installed.\n * Returns `export default \"css string\"` so bundlers treat the import as a JS module.\n * @param id - virtual module id produced by `resolveStencilCss`\n * @param isDev - `true` in dev mode (disables minification)\n * @returns ESM string export of the processed CSS, or `null` if not a Stencil CSS virtual module\n */\nexport async function loadStencilCss(\n id: string,\n isDev = true,\n): Promise<{ code: string; deps: string[] } | null> {\n if (!id.startsWith(STENCIL_CSS_PREFIX)) return null;\n\n const withoutPrefix = id.slice(STENCIL_CSS_PREFIX.length);\n const qIdx = withoutPrefix.indexOf('?');\n const stem = qIdx === -1 ? withoutPrefix : withoutPrefix.slice(0, qIdx);\n const query = qIdx === -1 ? '' : withoutPrefix.slice(qIdx + 1);\n const params = new URLSearchParams(query);\n const tag = params.get('tag') ?? '';\n const encapsulation = params.get('encapsulation') ?? 'none';\n const ext = decodeURIComponent(params.get('__ext') ?? 'css');\n const filePath = `${stem}.${ext}`;\n\n if (!existsSync(filePath)) return { code: 'export default () => \"\"', deps: [] };\n\n let css = readFileSync(filePath, 'utf-8');\n let deps: string[] = [];\n\n if (PKG.sass && (ext === 'scss' || ext === 'sass')) {\n const r = await compileSass(css, filePath, ext === 'sass');\n css = r.css;\n deps = r.deps;\n } else if (PKG.less && ext === 'less') {\n const r = await compileLess(css, filePath);\n css = r.css;\n deps = r.deps;\n }\n\n if (PKG.postcss) css = await runPostCss(css, filePath);\n if (PKG.lightningcss) css = await runLightningCss(css, filePath, !isDev);\n\n if (encapsulation === 'scoped' && tag) {\n css = scopeCss(css, getScopeId(tag), false);\n }\n\n return { code: `export default () => ${JSON.stringify(css)};`, deps };\n}\n","/**\n * Resolves imported type references in CEM docs components.\n *\n * `transpileSync` uses a single-file TypeScript host, so imported types (e.g.\n * `ButtonVariant` from `'../types'`) can't be followed — `complexType.resolved`\n * ends up as `\"any\"`. This module creates a minimal ts.Program per referenced\n * types file (cached) and substitutes the actual expanded type text back into\n * the component's doc data before it enters the registry.\n */\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport ts from 'typescript';\nimport type { ComponentCompilerTypeReferences, JsonDocsComponent } from '@stencil/core/compiler';\n\nconst TYPE_FORMAT_FLAGS =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.InElementType;\n\ninterface TypesFileEntry {\n checker: ts.TypeChecker;\n exportTypes: Map<string, ts.Type>;\n}\n\nconst typesFileCache = new Map<string, TypesFileEntry>();\n\nfunction resolveTypesFilePath(specifier: string, fromDir: string): string | undefined {\n const base = resolve(fromDir, specifier);\n if (existsSync(base)) return base;\n for (const ext of ['.ts', '.tsx', '.d.ts']) {\n const candidate = base + ext;\n if (existsSync(candidate)) return candidate;\n }\n return undefined;\n}\n\nfunction getTypesFileEntry(absPath: string): TypesFileEntry {\n const cached = typesFileCache.get(absPath);\n if (cached) return cached;\n\n const options: ts.CompilerOptions = {\n ...ts.getDefaultCompilerOptions(),\n noEmit: true,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n };\n const program = ts.createProgram([absPath], options);\n const checker = program.getTypeChecker();\n const sourceFile = program.getSourceFile(absPath);\n const exportTypes = new Map<string, ts.Type>();\n\n if (sourceFile) {\n const moduleSymbol = checker.getSymbolAtLocation(sourceFile);\n if (moduleSymbol) {\n for (const symbol of checker.getExportsOfModule(moduleSymbol)) {\n exportTypes.set(symbol.name, checker.getDeclaredTypeOfSymbol(symbol));\n }\n }\n }\n\n const entry: TypesFileEntry = { checker, exportTypes };\n typesFileCache.set(absPath, entry);\n return entry;\n}\n\nfunction expandTypeName(\n typeName: string,\n references: ComponentCompilerTypeReferences,\n fromDir: string,\n): string | undefined {\n const ref = references[typeName];\n if (!ref || ref.location !== 'import' || !ref.path) return undefined;\n\n const absPath = resolveTypesFilePath(ref.path, fromDir);\n if (!absPath) return undefined;\n\n const { checker, exportTypes } = getTypesFileEntry(absPath);\n const type = exportTypes.get(typeName);\n if (!type) return undefined;\n\n return checker.typeToString(type, undefined, TYPE_FORMAT_FLAGS);\n}\n\nconst escapeRegExp = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\nfunction patchType(\n original: string,\n references: ComponentCompilerTypeReferences | undefined,\n fromDir: string,\n): string {\n if (!references) return original;\n let result = original;\n for (const typeName of Object.keys(references)) {\n const expanded = expandTypeName(typeName, references, fromDir);\n if (!expanded || expanded === typeName) continue;\n // Wrap in parens when substituting into a potentially larger expression\n // e.g. `ButtonVariant | undefined` → `('sm' | 'md') | undefined`\n result = result.replace(\n new RegExp(`\\\\b${escapeRegExp(typeName)}\\\\b`, 'g'),\n expanded.includes('|') || expanded.includes('&') ? `(${expanded})` : expanded,\n );\n }\n return result;\n}\n\n/**\n * Patches `prop.type` and `event.detail` in-place for any imported types that\n * resolved to `\"any\"` in single-file transpile mode.\n * @param component The CEM docs component to patch\n * @param componentAbsPath The absolute path to the component's source file (used to resolve relative imports)\n */\nexport function resolveImportedTypes(component: JsonDocsComponent, componentAbsPath: string): void {\n const dir = dirname(componentAbsPath);\n\n for (const prop of component.props) {\n if (prop.type !== 'any' || !prop.complexType?.references) continue;\n const patched = patchType(prop.complexType.original, prop.complexType.references, dir);\n if (patched !== prop.complexType.original) prop.type = patched;\n }\n\n for (const event of component.events) {\n if (event.detail !== 'any' || !event.complexType?.references) continue;\n const patched = patchType(event.complexType.original, event.complexType.references, dir);\n if (patched !== event.complexType.original) event.detail = patched;\n }\n}\n","/**\n * Component transpilation and base-class discovery.\n *\n * `transformStencil` is the main entry point: it calls `transpileSync` with\n * `componentExport: 'customelement'` so each component self-registers when\n * imported. Two code paths come out:\n *\n * - **Component** (`@Component` present): full customelement output with\n * `defineCustomElement`, optional HMR snippet appended in dev mode.\n * - **Decorated base class** (`@Prop`/`@State`/etc. but no `@Component`):\n * returned as-is — the compiler's `isStencilBaseClass` check already injects\n * `extends HTMLElement` via `updateNativeBaseClass`.\n *\n * `makeResolver` supplies the `resolveImport` callback that `transpileSync`\n * uses during metadata collection. It serves two purposes at once: returning\n * raw source so the compiler can merge inherited props/states into the\n * component's metadata, and calling `onBaseClass` so the plugin can\n * pre-transform and cache the file before the bundler's resolveId hook fires.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { cmpMetaToDocsComponent, transpileSync } from '@stencil/core/compiler';\nimport type { BuildOverrides, JsonDocsComponent } from '@stencil/core/compiler';\nimport type { SupportedFramework } from 'unplugin';\n\nimport type { StencilPluginOptions } from './options.js';\n\nconst SOURCE_EXTS = ['.tsx', '.ts', '.js'];\n\n// TypeScript JsxEmit enum values — stable across TS versions.\nconst JSX_EMIT: Record<string, number> = {\n react: 2,\n 'react-jsx': 4,\n 'react-jsxdev': 5,\n preserve: 1,\n 'react-native': 3,\n};\n\ntype JsxOpts = { jsx?: number; jsxImportSource?: string };\n\nlet cachedTsConfigJsx: JsxOpts | undefined;\n\nfunction readJsxOptsFromTsConfig(cwd: string): JsxOpts {\n if (cachedTsConfigJsx !== undefined) return cachedTsConfigJsx;\n const tsconfigPath = join(cwd, 'tsconfig.json');\n if (!existsSync(tsconfigPath)) return (cachedTsConfigJsx = {});\n try {\n const raw = readFileSync(tsconfigPath, 'utf-8');\n const stripped = raw.replace(/\\/\\/[^\\n]*/g, '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n const tsconfig = JSON.parse(stripped);\n const co = tsconfig?.compilerOptions ?? {};\n const jsxStr: string | undefined = co.jsx?.toLowerCase();\n if (jsxStr && jsxStr in JSX_EMIT) {\n return (cachedTsConfigJsx = {\n jsx: JSX_EMIT[jsxStr],\n jsxImportSource: co.jsxImportSource,\n });\n }\n } catch {\n // ignore unreadable / malformed tsconfig\n }\n return (cachedTsConfigJsx = {});\n}\n\n// Detects classic JSX mode: `import { …, h, … } from '@stencil/core'`\nconst IMPORTS_H_RE = /import\\s+\\{[^}]*\\bh\\b[^}]*\\}\\s+from\\s+['\"]@stencil\\/core['\"]/;\n\n/* Resolve jsx/jsxImportSource for transpileSync.\n * Priority: tsconfig.json > source heuristic (h import → classic; otherwise automatic runtime). */\nfunction resolveJsxOpts(code: string, cwd: string): JsxOpts {\n const fromTsConfig = readJsxOptsFromTsConfig(cwd);\n if (fromTsConfig.jsx !== undefined) return fromTsConfig;\n if (IMPORTS_H_RE.test(code)) {\n return { jsx: JSX_EMIT['react'] }; // jsxFactory: 'h' auto-applied by transpile-module\n }\n return { jsx: JSX_EMIT['react-jsx'], jsxImportSource: '@stencil/core' };\n}\n\n/**\n * Resolve an import specifier to an absolute path, trying source extensions\n * and the TypeScript ESM `.js` → `.ts`/`.tsx` remap.\n * @param specifier - the import specifier (relative or extensionless)\n * @param importer - absolute path of the importing file\n * @returns absolute path to the resolved file, or `null` if nothing found on disk\n */\nexport function resolveSpecifier(specifier: string, importer: string): string | null {\n const base = resolve(dirname(importer), specifier);\n // Vite normalizes module IDs to forward slashes; we must match that so\n // virtual-module keys stay consistent on Windows.\n const norm = (p: string) => p.replace(/\\\\/g, '/');\n\n if (existsSync(base)) return norm(base);\n\n for (const ext of SOURCE_EXTS) {\n const candidate = base + ext;\n if (existsSync(candidate)) return norm(candidate);\n }\n\n // TypeScript ESM: `./foo.js` may physically be `./foo.ts` or `./foo.tsx`\n if (base.endsWith('.js')) {\n const stem = base.slice(0, -3);\n for (const ext of ['.ts', '.tsx']) {\n const candidate = stem + ext;\n if (existsSync(candidate)) return norm(candidate);\n }\n }\n\n return null;\n}\n\n/**\n * Transpile a `.tsx`/`.ts` file for use in a bundler.\n *\n * Returns `{ code, map, tagName }` for Stencil component or base-class files,\n * `null` for everything else (plain TS utilities, non-TS files, etc.).\n * `tagName` is empty string for base classes with no `@Component`.\n *\n * `onBaseClass` is called for every file the compiler resolves via\n * `resolveImport` during metadata collection. The plugin uses this to\n * pre-transform those files before the bundler's resolveId hook fires.\n * @param code - source file contents\n * @param id - absolute file path\n * @param options - plugin options\n * @param dev - `true` in dev/watch mode (enables HMR snippet)\n * @param framework - active unplugin framework\n * @param onBaseClass - called for each file in the inheritance chain with its abs path and raw source\n * @param configOverrides - pass stencil config option overrides to the transpiler\n * @returns transformed output, or `null` if the file is not a Stencil file\n */\nexport function transformStencil(\n code: string,\n id: string,\n options: StencilPluginOptions,\n dev = false,\n framework: SupportedFramework | '' = '',\n onBaseClass?: (absPath: string, rawCode: string) => void,\n configOverrides?: BuildOverrides,\n): {\n code: string;\n map: string | null;\n tagName: string;\n docsComponent: JsonDocsComponent | null;\n} | null {\n if (!id.endsWith('.tsx') && !id.endsWith('.ts')) return null;\n if (id.endsWith('.d.ts')) return null;\n\n // Cheap regex guard — avoids paying transpileSync cost for plain TS files.\n if (!/(@Component|@Prop|@State|@Event|@Method|@Watch|@Listen)\\s*[(\\s]/.test(code)) return null;\n\n const jsxOpts = resolveJsxOpts(code, process.cwd());\n const result = transpileSync(code, {\n ...jsxOpts,\n ...options.transpileOptions,\n file: id,\n componentExport: 'customelement',\n styleImportData: 'queryparams',\n resolveImport: makeResolver(onBaseClass),\n buildOverrides: {\n ...configOverrides,\n ...options.transpileOptions?.buildOverrides,\n ...(dev ? { hotModuleReplacement: true, isDev: true } : {}),\n },\n });\n\n if (result.diagnostics.some((d) => d.level === 'error')) {\n const msgs = result.diagnostics\n .filter((d) => d.level === 'error')\n .map((d) => d.messageText)\n .join('\\n');\n throw new Error(`[@stencil/unplugin] transpile error in ${id}:\\n${msgs}`);\n }\n\n if (!result.data?.length) {\n // No @Component — this is a base class or mixin factory. Return the\n // compiled output; for decorated classes the compiler's isStencilBaseClass\n // check already injected `extends HTMLElement`. Plain classes without\n // decorators are handled via the baseClassRegistry virtual-module path.\n if (!/@Component\\s*[(\\s]/.test(code)) {\n return { code: result.code, map: result.map ?? null, tagName: '', docsComponent: null };\n }\n return null;\n }\n\n const tagName = result.data[0].tagName;\n const className = result.data[0].componentClassName;\n\n // In dev mode, re-export the class so hmrStandalone can find it in the\n // re-imported module (customelement mode strips the export keyword).\n const devExport = dev ? `\\nexport{${className}};` : '';\n const out = dev\n ? result.code + devExport + buildHmrSnippet(tagName, className, framework)\n : result.code;\n\n const docsComponent = cmpMetaToDocsComponent(result.data[0], id);\n\n return { code: out, map: result.map ?? null, tagName, docsComponent };\n}\n\n/**\n * Transpile a base-class file with `transformAsBaseClass: true` so the\n * compiler injects `extends HTMLElement` into any class without an existing\n * heritage clause, regardless of whether it carries Stencil decorators.\n *\n * The result is cached in `baseClassRegistry` (in plugin.ts) and served as a\n * virtual module, ensuring the bundler always sees the injected version even\n * for plain lifecycle-only classes that the `transform` hook would otherwise skip.\n * @param rawCode - raw source of the base-class file\n * @param absPath - absolute path to the file (used as `file` for source maps)\n * @param options - plugin options forwarded to `transpileSync`\n * @returns compiled JS output\n */\nexport function transpileBaseClass(\n rawCode: string,\n absPath: string,\n options: StencilPluginOptions,\n): string {\n const result = transpileSync(rawCode, {\n ...options.transpileOptions,\n file: absPath,\n componentExport: 'customelement',\n styleImportData: 'queryparams',\n transformAsBaseClass: true,\n });\n return result.code;\n}\n\n/* Builds the HMR client snippet appended to component output in dev mode.\n *\n * Two strategies depending on bundler:\n * - Vite / Farm: server sends a `stencil:hmr` WebSocket event via\n * `handleHotUpdate`; the client calls `el['s-hmr'](version)` which triggers\n * a cache-busted re-import and forced re-render.\n * - webpack / rspack / bun: use the `module.hot` re-execution pattern —\n * `dispose` marks the reload with a flag, `accept` re-runs the module, and\n * the new prototype is patched onto existing instances in-place. */\nfunction buildHmrSnippet(\n tagName: string,\n className: string,\n framework: SupportedFramework | '',\n): string {\n const tag = JSON.stringify(tagName);\n\n if (framework === 'webpack' || framework === 'rspack' || framework === 'bun') {\n const hotExpr =\n framework === 'bun'\n ? 'import.meta.hot'\n : \"(typeof module !== 'undefined' && module.hot) || import.meta.webpackHot\";\n\n return (\n `\\n${className}.__stencil_module__ = import.meta.url;` +\n `\\nvar _sHot = ${hotExpr};` +\n `\\nif (_sHot) {` +\n `\\n if (_sHot.data && _sHot.data.stencilHmr) {` +\n `\\n var _sCtor = customElements.get(${tag});` +\n `\\n if (_sCtor) Object.getOwnPropertyNames(${className}.prototype).forEach(function(k) {` +\n `\\n if (k !== 'constructor') Object.defineProperty(_sCtor.prototype, k, Object.getOwnPropertyDescriptor(${className}.prototype, k));` +\n `\\n });` +\n `\\n document.querySelectorAll(${tag}).forEach(function(el) { el.connectedCallback && el.connectedCallback(); });` +\n `\\n }` +\n `\\n _sHot.dispose(function(data) { data.stencilHmr = true; });` +\n `\\n _sHot.accept();` +\n `\\n}`\n );\n }\n\n // Vite and Farm both implement the Vite HMR API.\n // The s-hmr guard prevents ?s-hmr= re-imports from stacking up additional listeners.\n return (\n `\\n${className}.__stencil_module__ = import.meta.url;` +\n `\\nif (import.meta.hot && !import.meta.url.includes('s-hmr=')) {` +\n `\\n import.meta.hot.accept(() => {});` +\n `\\n import.meta.hot.on('stencil:hmr', function({ tagName }) {` +\n `\\n if (tagName === ${tag}) {` +\n `\\n var v = Date.now().toString(36);` +\n `\\n document.querySelectorAll(${tag}).forEach(function(el) { el['s-hmr'] && el['s-hmr'](v); });` +\n `\\n }` +\n `\\n });` +\n `\\n}`\n );\n}\n\n/* Builds the `resolveImport` callback for `transpileSync`.\n *\n * The compiler calls this for every import it encounters while walking the\n * inheritance chain during metadata collection. The callback returns the raw\n * source so the compiler can merge inherited props/states/events into the\n * component's metadata. As a side-effect it calls `onBaseClass` with the same\n * raw source, giving the plugin a chance to pre-transform and cache the file\n * before the bundler's resolveId hook fires for it. */\nfunction makeResolver(onBaseClass?: (absPath: string, rawCode: string) => void) {\n return (specifier: string, currentImporter: string): { code: string; path: string } | null => {\n const absPath = resolveSpecifier(specifier, currentImporter);\n if (!absPath) return null;\n\n const code = readFileSync(absPath, 'utf-8');\n onBaseClass?.(absPath, code);\n return { code, path: absPath };\n };\n}\n","/**\n * Unplugin factory for @stencil/unplugin.\n *\n * Wires together four concerns into a single plugin that works across Vite,\n * Rollup, webpack, rspack, and bun:\n *\n * 1. **Component transform** - `transform` drives `transpileSync` on every\n * `.tsx`/`.ts` file that carries Stencil decorators, producing\n * `customelement` output (self-registering class + `defineCustomElement`).\n *\n * 2. **CSS virtual modules** - Stencil emits `./foo.css?tag=my-cmp&…`\n * imports. `resolveId` rewrites these to `\\0stencil-css:` virtual IDs;\n * `load` reads the real file, runs it through any installed preprocessors,\n * and returns `export default () => \"…css…\"`.\n *\n * 3. **Base-class inheritance** - when a component extends a class that does\n * not itself extend `HTMLElement`, the custom-element registration breaks.\n * The plugin intercepts every file the compiler resolves via `resolveImport`\n * (during `transpileSync`), pre-transforms it with `transformAsBaseClass: true`\n * so it gets `extends HTMLElement`, and caches the result. `resolveId` then\n * redirects imports of those files to `\\0stencil-base:` virtual modules so\n * the bundler always sees the injected version - regardless of module-graph\n * processing order.\n *\n * 4. **HMR** - Vite receives a custom `stencil:hmr` WebSocket event when a\n * component file changes; other bundlers use the `module.hot` re-execution\n * pattern. CSS changes are covered automatically by `addWatchFile`.\n */\nimport { readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { createFilter } from '@rollup/pluginutils';\nimport { transpile, cmpMetaToDocsComponent, generateManifest } from '@stencil/core/compiler';\nimport { createUnplugin } from 'unplugin';\nimport type {\n BuildOverrides,\n CustomElementsManifest,\n JsonDocsComponent,\n} from '@stencil/core/compiler';\n\nimport { loadStencilConfig, stencilConfigToOverrides } from './config.js';\nimport { getRealCssPath, isStencilCss, loadStencilCss, resolveStencilCss } from './css.js';\nimport { resolveImportedTypes } from './resolve-types.js';\nimport { resolveSpecifier, transformStencil, transpileBaseClass } from './transform.js';\nimport type { StencilPluginOptions } from './options.js';\n\nexport const STENCIL_DOCS_ID = '@stencil/unplugin/docs';\nconst VIRTUAL_DOCS_PREFIX = '\\0stencil-docs:';\n\n// Module-level registry so getStencilDocs() is callable from outside the plugin\n// (e.g. from a Storybook preset running in Node.js).\nconst docsRegistry = new Map<string, JsonDocsComponent>();\n\n/**\n * Returns the current CEM. Only populated when `docs: true` is set.\n * @returns the current CEM, or an empty CEM if `docs: true` was not set.\n */\nexport function getStencilCEM(): CustomElementsManifest {\n return generateManifest({ components: [...docsRegistry.values()] });\n}\n\n/**\n * Scan the project for component source files and pre-populate the docs registry.\n * @param filter A function to filter which files should be included.\n * @returns A promise that resolves when the scan is complete.\n */\nasync function scanDocs(filter: (id: string) => boolean): Promise<void> {\n const cwd = process.cwd();\n let entries: string[];\n try {\n entries = readdirSync(cwd, { recursive: true, encoding: 'utf-8' }) as string[];\n } catch {\n return;\n }\n\n const files = entries\n .filter((rel) => (rel.endsWith('.tsx') || rel.endsWith('.ts')) && !rel.endsWith('.d.ts'))\n .map((rel) => join(cwd, rel))\n .filter((abs) => filter(abs));\n\n await Promise.all(\n files.map(async (abs) => {\n let code: string;\n try {\n code = readFileSync(abs, 'utf-8');\n } catch {\n return;\n }\n if (!/(@Component|@Prop|@State|@Event|@Method|@Watch|@Listen)\\s*[(\\s]/.test(code)) return;\n const result = await transpile(code, { file: abs, componentExport: 'customelement' });\n for (const item of result.data ?? []) {\n if (!item.tagName) continue;\n const component = cmpMetaToDocsComponent(item, abs);\n resolveImportedTypes(component, abs);\n docsRegistry.set(item.tagName, component);\n }\n }),\n );\n}\n\n// Null-byte prefix marks a virtual module - Rollup/Vite convention that\n// prevents the ID from being treated as a real filesystem path.\nconst VIRTUAL_BASE_PREFIX = '\\0stencil-base:';\n\n// Mirrors the compiler's hasSignalsImport check in static-to-meta/import.ts.\nconst SIGNALS_IMPORT_RE = /from\\s+['\"]@stencil\\/core\\/signals['\"]/;\n\nexport const unpluginStencil = createUnplugin(\n (options: StencilPluginOptions | undefined = {}, meta) => {\n const { framework } = meta;\n const filter = createFilter(\n options.include ?? [/\\.tsx?$/],\n options.exclude ?? ['node_modules/**'],\n );\n\n // Vite auto-detects dev mode via configResolved; other bundlers use options.dev.\n let isDev = options.dev ?? false;\n\n // For Vite, configResolved sets this to config.root (more accurate than process.cwd()).\n // For other bundlers, process.cwd() is the fallback.\n let projectRoot = process.cwd();\n\n // Merged BUILD overrides from auto-detected stencil.config + explicit stencilConfig.\n // Populated in buildStart; explicit transpileOptions.buildOverrides takes precedence\n // over this in transformStencil.\n let configOverrides: BuildOverrides = {};\n\n // Tracks which source file owns which custom-element tag name, used by the\n // Vite HMR handler to send targeted `stencil:hmr` events.\n const fileToTagName = new Map<string, string>();\n\n // Maps CSS file paths → tag names that use them. A shared CSS file can be\n // used by multiple components, so this is a Set per file path.\n const cssFileToTagNames = new Map<string, Set<string>>();\n\n // Maps real CSS file path → virtual CSS module IDs (\\0stencil-css:...).\n // Multiple components may share the same CSS file, each with their own\n // virtual module ID (different tag/encapsulation query params).\n const cssRealToVirtualIds = new Map<string, Set<string>>();\n\n function trackCssFile(realPath: string, tag: string, virtualId: string) {\n if (!cssFileToTagNames.has(realPath)) cssFileToTagNames.set(realPath, new Set());\n cssFileToTagNames.get(realPath)!.add(tag);\n if (!cssRealToVirtualIds.has(realPath)) cssRealToVirtualIds.set(realPath, new Set());\n cssRealToVirtualIds.get(realPath)!.add(virtualId);\n }\n\n // absPath → HTMLElement-injected JS. Populated during `transform` when\n // `transpileSync`'s resolveImport callback discovers a base-class file.\n // Rollup guarantees that resolveId for imports in a module's *output* fires\n // after the transform that produced them - so by the time the bundler asks\n // to resolve a base-class import, this map is already populated.\n const baseClassRegistry = new Map<string, string>();\n\n function registerBaseClass(absPath: string, rawCode: string) {\n if (baseClassRegistry.has(absPath)) return; // already processed this build\n baseClassRegistry.set(absPath, transpileBaseClass(rawCode, absPath, options));\n }\n\n return {\n name: '@stencil/unplugin',\n\n async buildStart() {\n const detected = await loadStencilConfig(projectRoot);\n // Merge: auto-detected config is the base; explicit stencilConfig overrides field-by-field.\n const merged = detected\n ? {\n ...detected,\n ...options.stencilConfig,\n compat: { ...detected.compat, ...options.stencilConfig?.compat },\n }\n : (options.stencilConfig ?? {});\n configOverrides = stencilConfigToOverrides(merged);\n if (options.docs) await scanDocs(filter);\n },\n\n resolveId(id, importer) {\n if (id === STENCIL_DOCS_ID) return VIRTUAL_DOCS_PREFIX;\n if (!importer) return null;\n\n const css = resolveStencilCss(id, importer);\n if (css) return css;\n\n if (baseClassRegistry.size > 0) {\n // Imports inside a virtual base-class module use the virtual ID as\n // importer - strip the prefix so resolveSpecifier works against the\n // real path on disk. This matters for multi-level inheritance chains.\n\n const realImporter = importer.startsWith(VIRTUAL_BASE_PREFIX)\n ? importer.slice(VIRTUAL_BASE_PREFIX.length)\n : importer;\n\n const abs = resolveSpecifier(id, realImporter);\n if (abs && baseClassRegistry.has(abs)) {\n return VIRTUAL_BASE_PREFIX + abs;\n }\n }\n\n return null;\n },\n\n transformInclude(id) {\n return filter(id.split('?')[0]);\n },\n\n transform(code, id) {\n const cleanId = id.split('?')[0];\n if (!configOverrides.vdomSignals && SIGNALS_IMPORT_RE.test(code)) {\n configOverrides = { ...configOverrides, vdomSignals: true };\n }\n const result = transformStencil(\n code,\n cleanId,\n options,\n isDev,\n framework,\n registerBaseClass,\n configOverrides,\n );\n if (result?.tagName) fileToTagName.set(cleanId, result.tagName);\n if (result?.docsComponent && options.docs) {\n resolveImportedTypes(result.docsComponent, cleanId);\n docsRegistry.set(result.docsComponent.tag, result.docsComponent);\n }\n return result;\n },\n\n loadInclude(id) {\n return id === VIRTUAL_DOCS_PREFIX || isStencilCss(id) || id.startsWith(VIRTUAL_BASE_PREFIX);\n },\n\n async load(id) {\n if (id === VIRTUAL_DOCS_PREFIX) {\n return `export default ${JSON.stringify(getStencilCEM())}`;\n }\n if (id.startsWith(VIRTUAL_BASE_PREFIX)) {\n const realPath = id.slice(VIRTUAL_BASE_PREFIX.length);\n this.addWatchFile(realPath); // re-invalidate this virtual module when the source changes\n return { code: baseClassRegistry.get(realPath) ?? '', map: null };\n }\n const realPath = getRealCssPath(id);\n const qIdx = id.indexOf('?');\n const tag = qIdx !== -1 ? new URLSearchParams(id.slice(qIdx + 1)).get('tag') : null;\n if (realPath) {\n this.addWatchFile(realPath);\n if (tag) trackCssFile(realPath, tag, id);\n }\n const cssResult = await loadStencilCss(id, isDev);\n if (cssResult) {\n if (tag) {\n for (const dep of cssResult.deps) {\n this.addWatchFile(dep);\n trackCssFile(dep, tag, id);\n }\n }\n return { code: cssResult.code, map: null };\n }\n return null;\n },\n\n vite: {\n // Must run before Vite/rolldown's built-in TSX transform, which would\n // otherwise claim the file and emit react/jsx-dev-runtime imports.\n enforce: 'pre' as const,\n\n configResolved(config: { command: string; root: string }) {\n isDev = options.dev ?? config.command === 'serve';\n projectRoot = config.root;\n },\n\n async handleHotUpdate({\n file,\n server,\n }: {\n file: string;\n server: {\n ws: { send: (msg: unknown) => void };\n moduleGraph: {\n invalidateModule(\n mod: unknown,\n seen?: Set<unknown>,\n timestamp?: number,\n isHmr?: boolean,\n ): void;\n getModuleById?(id: string): unknown;\n idToModuleMap?: Map<string, unknown>;\n };\n };\n }) {\n // Collect all tag names affected by this file change\n const tsxTag = fileToTagName.get(file);\n const cssTagNames = cssFileToTagNames.get(file);\n const tagNames = new Set<string>(cssTagNames);\n if (tsxTag) tagNames.add(tsxTag);\n if (tagNames.size === 0) return;\n\n // Invalidate every virtual CSS module that depends on this file so\n // Vite adds ?t=timestamp when re-serving the TSX - busts browser cache.\n const virtualIds = cssRealToVirtualIds.get(file);\n if (virtualIds) {\n for (const virtualId of virtualIds) {\n const virtualMod =\n server.moduleGraph.getModuleById?.(virtualId) ??\n server.moduleGraph.idToModuleMap?.get(virtualId);\n if (virtualMod)\n server.moduleGraph.invalidateModule(virtualMod, new Set(), Date.now(), true);\n }\n }\n // Update the docs registry and notify the client only when the CEM\n // actually changed (new/renamed prop, type update, JSDoc edit, etc.).\n // Pure implementation changes leave the CEM identical and fall through\n // to normal stencil:hmr so HMR is not disrupted.\n if (options.docs && tsxTag) {\n let cemChanged = false;\n try {\n const prevSnapshot = JSON.stringify(docsRegistry.get(tsxTag));\n const code = readFileSync(file, 'utf-8');\n const result = await transpile(code, { file, componentExport: 'customelement' });\n for (const item of result.data ?? []) {\n if (!item.tagName) continue;\n const component = cmpMetaToDocsComponent(item, file);\n resolveImportedTypes(component, file);\n docsRegistry.set(item.tagName, component);\n }\n cemChanged = JSON.stringify(docsRegistry.get(tsxTag)) !== prevSnapshot;\n } catch {\n // stale docs are acceptable on transpile error\n }\n if (cemChanged) {\n const docsVirtualMod =\n server.moduleGraph.getModuleById?.(VIRTUAL_DOCS_PREFIX) ??\n server.moduleGraph.idToModuleMap?.get(VIRTUAL_DOCS_PREFIX);\n if (docsVirtualMod)\n server.moduleGraph.invalidateModule(docsVirtualMod, new Set(), Date.now(), true);\n server.ws.send({ type: 'custom', event: 'stencil:docs-update' });\n }\n }\n for (const tagName of tagNames) {\n server.ws.send({ type: 'custom', event: 'stencil:hmr', data: { tagName } });\n }\n return [];\n },\n },\n };\n },\n);\n","export { unpluginStencil, getStencilCEM, STENCIL_DOCS_ID } from './plugin.js';\nexport type { StencilPluginOptions } from './options.js';\n\nimport { unpluginStencil } from './plugin.js';\n\nexport const stencilVite = unpluginStencil.vite;\nexport const stencilRollup = unpluginStencil.rollup;\nexport const stencilWebpack = unpluginStencil.webpack;\nexport const stencilEsbuild = unpluginStencil.esbuild;\nexport const stencilRspack = unpluginStencil.rspack;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,sBAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,mBAAmB,MACvB,MAAM,QACN,OAAO,MAAM,YACb,CAAC,MAAM,QAAQ,CAAC,KAChB,OAAO,KAAK,CAAW,EAAE,MAAM,MAAM,oBAAoB,IAAI,CAAC,CAAC;AAEjE,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;AACF;;;;;;;;AASA,eAAsB,kBAAkB,KAAkD;CACxF,KAAK,MAAM,YAAY,mBAAmB;EACxC,MAAM,aAAa,KAAK,KAAK,QAAQ;EACrC,IAAI,CAAC,WAAW,UAAU,GAAG;EAC7B,IAAI;GACF,MAAM,EAAE,eAAe,MAAM,OAAO;GAEpC,MAAM,MAAO,MADA,WAAW,OAAO,KAAK,GACd,EAAE,OAAO,UAAU;GAKzC,MAAM,MAAM,IAAI,cAAc,gBAAgB,IAAI,UAAU,IAAI,IAAI,aAAa;GACjF,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,OAAO;GAC5C,OAAO,cAAc,GAA8B;EACrD,QAAQ;GACN,OAAO;EACT;CACF;CACA,OAAO;AACT;AAEA,SAAS,cAAc,GAAiD;CACtE,MAAM,SAA8B,CAAC;CACrC,IAAI,EAAE,qBAAqB,MAAM,OAAO,gBAAgB;CACxD,MAAM,SAAS,EAAE;CACjB,IAAI,UAAU,OAAO,WAAW,UAAU;EACxC,MAAM,KAAK;EACX,MAAM,MAAM,GAAG;EACf,MAAM,qBAAqB,GAAG;EAC9B,MAAM,qBAAqB,GAAG;EAC9B,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undler plugin for Stencil components (Vite, Rollup, Webpack, esbuild)",
5
+ "homepage": "https://stenciljs.com/",
5
6
  "license": "MIT",
7
+ "author": "StencilJs Contributors",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/stenciljs/core.git"
11
+ },
6
12
  "files": [
7
13
  "dist"
8
14
  ],
@@ -20,14 +26,6 @@
20
26
  "default": "./dist/docs.mjs"
21
27
  }
22
28
  },
23
- "scripts": {
24
- "build": "tsdown",
25
- "typecheck": "tsc --noEmit",
26
- "test": "pnpm run test:unit",
27
- "test:unit": "vitest run --config vitest.config.ts",
28
- "test:browser": "vitest run --config vitest.browser.config.ts",
29
- "playground": "vite playground"
30
- },
31
29
  "dependencies": {
32
30
  "@rollup/pluginutils": "^5.4.0",
33
31
  "jiti": "^2.0.0",
@@ -35,19 +33,19 @@
35
33
  "unplugin": "^3.0.0"
36
34
  },
37
35
  "devDependencies": {
38
- "@stencil/core": "workspace:*",
39
36
  "@types/less": "^3.0.8",
40
- "@vitest/browser": "catalog:",
41
- "@vitest/browser-playwright": "catalog:",
37
+ "@vitest/browser": "^4.1.7",
38
+ "@vitest/browser-playwright": "^4.1.7",
42
39
  "less": "^4.6.7",
43
40
  "lightningcss": "^1.32.0",
44
41
  "postcss": "^8.5.15",
45
42
  "postcss-load-config": "^6.0.1",
46
43
  "sass": "^1.101.0",
47
- "tsdown": "catalog:",
48
- "typescript": "catalog:",
44
+ "tsdown": ">=0.21.0 <1.0.0",
45
+ "typescript": ">4.0.0 <7.0.0",
49
46
  "vite": "^8.1.0",
50
- "vitest": "catalog:"
47
+ "vitest": "^4.1.7",
48
+ "@stencil/core": "5.0.0-alpha.18"
51
49
  },
52
50
  "peerDependencies": {
53
51
  "@stencil/core": "^5.0.0-0",
@@ -74,5 +72,13 @@
74
72
  "sass": {
75
73
  "optional": true
76
74
  }
75
+ },
76
+ "scripts": {
77
+ "build": "tsdown",
78
+ "typecheck": "tsc --noEmit",
79
+ "test": "pnpm run test:unit",
80
+ "test:unit": "vitest run --config vitest.config.ts",
81
+ "test:browser": "vitest run --config vitest.browser.config.ts",
82
+ "playground": "vite playground"
77
83
  }
78
- }
84
+ }