@stencil/unplugin 5.0.0-beta.12 → 5.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +15 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1050 -346
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs.map
CHANGED
|
@@ -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 // TypeScript ESM: `./foo.js` may physically be `./foo.ts` or `./foo.tsx` -\n // mirrors resolveSpecifier's remap in transform.ts.\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 candidate;\n }\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\nconst hasReferences = (references: ComponentCompilerTypeReferences | undefined): boolean =>\n !!references && Object.keys(references).length > 0;\n\n/**\n * Patches `prop.type` and `event.detail` in-place for any imported/inherited\n * types that weren't fully resolved by Stencil's compiler.\n *\n * Under-resolved types don't always show up as the literal string `\"any\"` -\n * a prop inherited from a same-project base class (merged via a single-file\n * mini `ts.Program`, which can't follow cross-file imports) can resolve to\n * the type's own unexpanded name instead (e.g. `\"Validator\"`), since that's\n * what a TypeScript checker falls back to for a type it can't bind. Either\n * way, a `location: 'import'` reference on the prop means there's something\n * worth trying to expand here.\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.complexType || !hasReferences(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.complexType || !hasReferences(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 specPage = options.mode === 'spec-page';\n const jsxOpts = resolveJsxOpts(code, process.cwd());\n const result = transpileSync(code, {\n ...jsxOpts,\n ...options.transpileOptions,\n file: id,\n ...(specPage\n ? {\n componentExport: null,\n componentMetadata: 'compilerstatic' as const,\n coreImportPath: '@stencil/core/testing',\n // No CSS loader is wired for spec-page mode - `newSpecPage()` tests are\n // behavioral and don't need real stylesheets. `null` skips the style assignment entirely.\n style: null,\n }\n : { componentExport: 'customelement' as const }),\n styleImportData: 'queryparams',\n resolveImport: makeResolver(onBaseClass),\n buildOverrides: {\n ...configOverrides,\n ...options.transpileOptions?.buildOverrides,\n ...(dev && !specPage ? { 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 let out = result.code;\n if (!specPage) {\n // customelement mode strips the export keyword, so re-export the class\n // ourselves — consumers import it by name, and\n // hmrStandalone needs it in the re-imported module in dev mode\n const namedExport = `\\nexport{${className}};`;\n out = dev\n ? result.code + namedExport + buildHmrSnippet(tagName, className, framework)\n : result.code + namedExport;\n }\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 *\n * 5. **spec-page module resolution** - `mode: 'spec-page'` (`stencilSpecPage`)\n * redirects every bare `@stencil/core` import to `@stencil/core/testing` via\n * `resolveId`, so the whole test file - not just compiler output - resolves\n * to a single platform instance.\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 * Recursively collect `.tsx`/`.ts` file paths under `dir`, pruning\n * `node_modules` and hidden directories (`.git`, `.vite`, etc.) as it goes.\n *\n * `readdirSync(dir, { recursive: true })` can't prune during traversal - it\n * walks everything first and only lets the caller filter the flat result\n * afterward, which is disastrous under a symlink-heavy `node_modules` (e.g.\n * pnpm's `.pnpm` store, which flattens every dependency in the workspace) -\n * it can take minutes just to list, blocking `buildStart` the whole time.\n *\n * @param dir the directory to walk\n * @param out accumulator array of absolute file paths, mutated in place\n */\nfunction collectSourceFiles(dir: string, out: string[]): void {\n let entries: import('node:fs').Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n const abs = join(dir, entry.name);\n if (entry.isDirectory()) {\n collectSourceFiles(abs, out);\n } else if (\n entry.isFile() &&\n (abs.endsWith('.tsx') || abs.endsWith('.ts')) &&\n !abs.endsWith('.d.ts')\n ) {\n out.push(abs);\n }\n }\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 const allFiles: string[] = [];\n collectSourceFiles(cwd, allFiles);\n const files = allFiles.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\n// `this.resolve` isn't part of unplugin's cross-bundler `resolveId` context type\n// (not every backend has it), but it is present on Vite/Rollup's real plugin\n// context - the only framework `stencilSpecPage` runs through (`unpluginStencil.vite`).\ninterface RollupResolveContext {\n resolve(\n id: string,\n importer?: string,\n options?: { skipSelf?: boolean },\n ): Promise<{ id: string; external?: boolean } | null>;\n}\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 async resolveId(id, importer) {\n if (id === STENCIL_DOCS_ID) return VIRTUAL_DOCS_PREFIX;\n\n // spec-page mode transpiles components against `@stencil/core/testing`'s\n // platform (hostRefs, mode chain, etc. - a separate module instance from\n // the real runtime). Any other file that imports the bare `@stencil/core`\n // specifier - a test file calling `setMode`, a helper, a mock - would\n // otherwise resolve to that other instance and silently stop working.\n // Redirecting here (like Jest's old `moduleNameMapper`) guarantees a\n // single platform instance for every file, not just compiler output.\n if (options.mode === 'spec-page' && id === '@stencil/core') {\n return (this as unknown as RollupResolveContext).resolve(\n '@stencil/core/testing',\n importer,\n { skipSelf: true },\n );\n }\n\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';\nimport type { StencilPluginOptions } from './options.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\n/**\n * Vite plugin that transpiles components for use with `newSpecPage()` from\n * `@stencil/core/testing`, instead of the self-registering custom-element\n * output the other exports produce. Use in `vitest.config.ts`.\n *\n * Also redirects any bare `@stencil/core` import to `@stencil/core/testing`\n * for the whole test file, so mistakenly importing e.g. `setMode` from\n * `@stencil/core` doesn't silently resolve to a disconnected platform instance.\n * @param options - plugin options; `mode` is fixed to `'spec-page'` and cannot be overridden\n * @returns a Vite plugin\n */\nexport const stencilSpecPage = (options: Omit<StencilPluginOptions, 'mode'> = {}) =>\n unpluginStencil.vite({ ...options, mode: 'spec-page' });\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,sCAAsB,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,CAAC,CAAC,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,YAAY,GACd,CAAC,CAAC,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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.ts","../src/component-types.ts","../src/config.ts","../src/global-css.ts","../src/transform.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["/**\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, transpileSync } from '@stencil/core/compiler';\nimport { isPackageExists } from 'local-pkg';\nimport type { ComponentCompilerMeta } from '@stencil/core/compiler';\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 * Runs a `.css`/`.scss`/`.sass`/`.less` file through Stencil's preprocessor chain:\n * 1. Preprocessor: Sass/SCSS (`sass`) or Less (`less`) if installed\n * 2. PostCSS with `postcss.config.*` if `postcss` + `postcss-load-config` are installed\n * 3. lightningcss if installed — syntax lowering, vendor prefixes, minification in prod\n * Each step is skipped silently if the relevant peer dep is not installed.\n *\n * Shared by `loadStencilCss` (per-component `?tag=` styles) and `global-css.ts`\n * (including the files that feed `@import \"stencil-component-globals\"`/`\"stencil-css-components\"`)\n *\n * @param filePath - absolute path to the source file, with its real extension\n * @param isDev - `true` in dev mode (disables minification)\n * @returns the processed CSS and any extra files it depends on (e.g. Sass `@use`/`@import`), or\n * `null` if the file doesn't exist\n */\nexport async function processCssFile(\n filePath: string,\n isDev: boolean,\n): Promise<{ css: string; deps: string[] } | null> {\n if (!existsSync(filePath)) return null;\n\n const ext = extname(filePath).slice(1);\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 return { css, deps };\n}\n\n/**\n * Loads a Stencil CSS virtual module.\n *\n * Runs the file through {@link processCssFile}, then applies the scoped-selector rewrite for\n * `encapsulation: 'scoped'`. Returns `export default \"css string\"` so bundlers treat the import\n * 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 const result = await processCssFile(filePath, isDev);\n if (!result) return { code: 'export default () => \"\"', deps: [] };\n\n let { css } = result;\n if (encapsulation === 'scoped' && tag) {\n css = scopeCss(css, getScopeId(tag), false);\n }\n\n return { code: `export default () => ${JSON.stringify(css)};`, deps: result.deps };\n}\n\n/**\n * Compiles a Sass/Less stylesheet to plain CSS for doc extraction. Unlike {@link processCssFile},\n * this skips PostCSS and lightningcss - to leave JSDoc-style comments alone.\n *\n * @param filePath - absolute path to the source stylesheet\n * @returns plain CSS text, or `null` if the file doesn't exist\n */\nasync function compileCssForDocs(filePath: string): Promise<string | null> {\n if (!existsSync(filePath)) return null;\n\n const ext = extname(filePath).slice(1);\n const css = readFileSync(filePath, 'utf-8');\n\n if (PKG.sass && (ext === 'scss' || ext === 'sass')) {\n return (await compileSass(css, filePath, ext === 'sass')).css;\n }\n if (PKG.less && ext === 'less') {\n return (await compileLess(css, filePath)).css;\n }\n return css;\n}\n\n/**\n * Populates `cmp.styleDocs` from `cmp.styles` - the CSS custom-property docs a bundler plugin\n * needs to assemble a custom-elements-manifest entry for a component's stylesheet(s).\n *\n * @param cmp - component metadata from `transpile`/`transpileSync`, mutated in place\n * @param componentPath - absolute path to the component's `.tsx`/`.ts` file, used to build a\n * synthetic `file` for `transpileSync`\n */\nexport async function collectStyleDocsForComponent(\n cmp: ComponentCompilerMeta,\n componentPath: string,\n): Promise<void> {\n const cssBase = componentPath.replace(/\\.\\w+$/, '.css');\n\n for (const style of cmp.styles ?? []) {\n const cssTexts: string[] = [];\n if (style.styleStr) cssTexts.push(style.styleStr);\n for (const external of style.externalStyles ?? []) {\n if (!external.absolutePath) continue;\n const css = await compileCssForDocs(external.absolutePath);\n if (css) cssTexts.push(css);\n }\n\n for (const css of cssTexts) {\n const params = new URLSearchParams({\n tag: cmp.tagName,\n mode: style.modeName,\n encapsulation: cmp.encapsulation ?? 'none',\n });\n const result = transpileSync(css, { file: `${cssBase}?${params}`, docs: true });\n if (result.styleDocs?.length) {\n cmp.styleDocs ??= [];\n cmp.styleDocs.push(...result.styleDocs);\n }\n }\n }\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 // TypeScript ESM: `./foo.js` may physically be `./foo.ts` or `./foo.tsx` -\n // mirrors resolveSpecifier's remap in transform.ts.\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 candidate;\n }\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\nconst hasReferences = (references: ComponentCompilerTypeReferences | undefined): boolean =>\n !!references && Object.keys(references).length > 0;\n\n/**\n * Patches `prop.type` and `event.detail` in-place for any imported/inherited\n * types that weren't fully resolved by Stencil's compiler.\n *\n * Under-resolved types don't always show up as the literal string `\"any\"` -\n * a prop inherited from a same-project base class (merged via a single-file\n * mini `ts.Program`, which can't follow cross-file imports) can resolve to\n * the type's own unexpanded name instead (e.g. `\"Validator\"`), since that's\n * what a TypeScript checker falls back to for a type it can't bind. Either\n * way, a `location: 'import'` reference on the prop means there's something\n * worth trying to expand here.\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.complexType || !hasReferences(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.complexType || !hasReferences(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 * The project-wide component scan behind the docs/CEM and the virtual global-stylesheet imports.\n *\n * The registries are module-level on purpose: `getStencilCEM()` is public API called from outside\n * any plugin instance (e.g. a Storybook preset running in Node.js).\n */\nimport { readdirSync, readFileSync, statSync } from 'node:fs';\nimport { join, normalize } from 'node:path';\nimport {\n cmpMetaToDocsComponent,\n generateManifest,\n parseCssOnlyComponents,\n transpile,\n} from '@stencil/core/compiler';\nimport type {\n ComponentCompilerMeta,\n ComponentGlobalStyle,\n CustomElementsManifest,\n JsonDocsComponent,\n} from '@stencil/core/compiler';\n\nimport { collectStyleDocsForComponent } from './css.js';\nimport { resolveImportedTypes } from './resolve-types.js';\n\nexport const docsRegistry = new Map<string, JsonDocsComponent>();\n\n// The project-wide data `@import \"stencil-component-globals\"`/`\"stencil-css-components\"` need,\n// populated by the same scanDocs() walk. Tag names for `@import \"stencil-hydrate\"` come from\n// docsRegistry.\nexport const componentGlobalStyles: ComponentGlobalStyle[] = [];\nexport const cssOnlyComponentFiles = new Set<string>();\n// the tags each file in cssOnlyComponentFiles registered, so they can be dropped when it changes\nconst cssOnlyTagsByFile = new Map<string, string[]>();\n\n// Compiler metadata per tag - what `components.d.ts` is generated from (see `component-types.ts`).\n// JS-backed and CSS-only components are kept apart because core orders them that way.\nexport const componentMetaRegistry = new Map<string, ComponentCompilerMeta>();\nexport const cssOnlyMetaRegistry = new Map<string, ComponentCompilerMeta>();\n// the tags each `.tsx`/`.ts` file defined, so they can be dropped when it changes\nconst tagsBySourceFile = new Map<string, string[]>();\n\n/**\n * A snapshot of the whole docs registry's content, used to detect whether a CSS-only\n * component's docs changed after a re-scan. A `.css` file's tag(s) aren't known until after parsing\n * - and it may define more than one; compares the whole registry rather than one entry.\n * Cheap in practice: only runs on file save\n *\n * @returns a string that changes whenever any registry entry's content does\n */\nexport const getRegistrySnapshot = (): string =>\n JSON.stringify([...docsRegistry.entries()].sort(([a], [b]) => a.localeCompare(b)));\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// cheap pre-filter before transpiling a file that might define a component\nconst COMPONENT_DECORATOR_RE = /(@Component|@Prop|@State|@Event|@Method|@Watch|@Listen)\\s*[(\\s]/;\n\nconst isTsSourceFile = (abs: string): boolean =>\n (abs.endsWith('.tsx') || abs.endsWith('.ts')) && !abs.endsWith('.d.ts');\n\nconst isCssFile = (abs: string): boolean => abs.endsWith('.css');\n\n/**\n * Recursively collect file paths matching `matches` under `dir`, pruning\n * `node_modules` and hidden directories (`.git`, `.vite`, etc.) as it goes.\n *\n * `readdirSync(dir, { recursive: true })` can't prune during traversal - it\n * walks everything first and only lets the caller filter the flat result\n * afterward, which is disastrous under a symlink-heavy `node_modules` (e.g.\n * pnpm's `.pnpm` store, which flattens every dependency in the workspace) -\n * it can take minutes just to list, blocking `buildStart` the whole time.\n *\n * @param dir the directory to walk\n * @param matches predicate applied to each file's absolute path\n * @param out accumulator array of absolute file paths, mutated in place\n */\nexport function collectFiles(dir: string, matches: (abs: string) => boolean, out: string[]): void {\n let entries: import('node:fs').Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n const abs = join(dir, entry.name);\n if (entry.isDirectory()) {\n collectFiles(abs, matches, out);\n } else if (entry.isFile() && matches(abs)) {\n out.push(abs);\n }\n }\n}\n\n/**\n * Parse a single `.css` file for CSS-only components (pure-CSS custom-element definitions\n * marked with a `@component` JSDoc tag - see `@stencil/core/compiler`'s `parseCssOnlyComponents`)\n * and register each one in the docs registry with `cssOnly: true` - replacing whatever the file\n * registered before, so a component whose definition was removed (or whose file was deleted)\n * stops being emitted.\n * @param file absolute path to the `.css` file\n */\nexport async function scanCssOnlyDocsFile(file: string): Promise<void> {\n // native separators, so the same file is one registry entry whichever form a watcher reports it in\n const abs = normalize(file);\n let code = '';\n try {\n code = readFileSync(abs, 'utf-8');\n } catch {\n // deleted/unreadable - defines nothing now\n }\n // Cheap guard, same one parseCssOnlyComponents applies internally - skip the\n // postcss parse cost for the vast majority of .css files that aren't components.\n const { components } = code.includes('@component')\n ? await parseCssOnlyComponents(abs, code)\n : { components: [] };\n\n for (const tag of cssOnlyTagsByFile.get(abs) ?? []) {\n docsRegistry.delete(tag);\n cssOnlyMetaRegistry.delete(tag);\n }\n if (components.length > 0) {\n cssOnlyComponentFiles.add(abs);\n cssOnlyTagsByFile.set(\n abs,\n components.map((c) => c.tagName),\n );\n } else {\n cssOnlyComponentFiles.delete(abs);\n cssOnlyTagsByFile.delete(abs);\n }\n for (const item of components) {\n // No resolveImportedTypes call here - a CSS-only component's props are always literal\n // unions/primitives with empty `references`, never an imported TS type to resolve.\n docsRegistry.set(item.tagName, { ...cmpMetaToDocsComponent(item, abs), cssOnly: true });\n cssOnlyMetaRegistry.set(item.tagName, item);\n }\n}\n\n/**\n * @param file a stylesheet path, in either separator form\n * @returns whether it currently defines CSS-only components\n */\nexport const isCssOnlyComponentFile = (file: string): boolean =>\n cssOnlyComponentFiles.has(normalize(file));\n\n/**\n * Re-scan a changed stylesheet that defines (or used to define) CSS-only components - that changes\n * which ones exist, not just their CSS.\n * @param file the changed file\n */\nexport async function rescanIfCssOnlyComponent(file: string): Promise<void> {\n if (!isCssFile(file)) return;\n // Vite reports `/`-separated paths even on Windows, where the registry holds native ones\n const abs = normalize(file);\n let code = '';\n try {\n code = readFileSync(abs, 'utf-8');\n } catch {\n // deleted/unreadable - a registered file still needs re-scanning, to drop what it defined\n }\n if (code.includes('@component') || cssOnlyComponentFiles.has(abs)) {\n await scanCssOnlyDocsFile(abs);\n }\n}\n\n/**\n * Scan a changed directory for `.css` files not yet known as CSS-only components - a watcher\n * may report a file added to a watched directory as the directory itself.\n * @param dir the changed path - ignored unless it's a directory\n */\nexport async function rescanNewCssOnlyComponents(dir: string): Promise<void> {\n try {\n if (!statSync(dir).isDirectory()) return;\n } catch {\n return;\n }\n const cssFiles: string[] = [];\n collectFiles(dir, isCssFile, cssFiles);\n await Promise.all(cssFiles.filter((f) => !cssOnlyComponentFiles.has(f)).map(scanCssOnlyDocsFile));\n}\n\n/**\n * Re-derives one component's docs from its `.tsx` / `.ts` source and merges the result into the\n * docs registry.\n *\n * @param tag the custom-element tag name to refresh\n * @param filePath absolute path to the component's `.tsx`/`.ts` source\n * @returns `true` if the registry entry's content actually changed\n */\nexport async function refreshComponentDocs(tag: string, filePath: string): Promise<boolean> {\n const prevSnapshot = JSON.stringify(docsRegistry.get(tag));\n try {\n const code = readFileSync(filePath, 'utf-8');\n const result = await transpile(code, { file: filePath, componentExport: 'customelement' });\n\n for (const item of result.data ?? []) {\n if (!item.tagName) continue;\n await collectStyleDocsForComponent(item, filePath);\n const component = cmpMetaToDocsComponent(item, filePath);\n resolveImportedTypes(component, filePath);\n docsRegistry.set(item.tagName, component);\n }\n } catch {\n return false; // stale docs are acceptable on transpile error\n }\n return JSON.stringify(docsRegistry.get(tag)) !== prevSnapshot;\n}\n\n/**\n * Re-derive a changed (or added, or deleted) `.tsx`/`.ts` file's compiler metadata - replacing\n * whatever it defined before, so a removed or renamed component stops being typed.\n * @param file absolute path to the source file\n * @returns whether the file defines, or used to define, any component\n */\nexport async function refreshComponentMeta(file: string): Promise<boolean> {\n const abs = normalize(file);\n let code = '';\n try {\n code = readFileSync(abs, 'utf-8');\n } catch {\n // deleted - defines nothing now\n }\n const previous = tagsBySourceFile.get(abs) ?? [];\n let items: ComponentCompilerMeta[] = [];\n if (COMPONENT_DECORATOR_RE.test(code)) {\n try {\n const result = await transpile(code, { file: abs, componentExport: 'customelement' });\n items = ((result.data ?? []) as ComponentCompilerMeta[]).filter((item) => item.tagName);\n } catch {\n return previous.length > 0; // stale types are acceptable on transpile error\n }\n }\n for (const tag of previous) componentMetaRegistry.delete(tag);\n for (const item of items) componentMetaRegistry.set(item.tagName, item);\n if (items.length > 0)\n tagsBySourceFile.set(\n abs,\n items.map((item) => item.tagName),\n );\n else tagsBySourceFile.delete(abs);\n return previous.length > 0 || items.length > 0;\n}\n\n/**\n * Scan the project for component source files (`.tsx`/`.ts`) and CSS-only components\n * (`.css`), pre-populating the docs registry, `componentGlobalStyles`, and\n * `cssOnlyComponentFiles` - the project-wide data the virtual global-stylesheet imports need\n * (see `global-css.ts`), gathered eagerly so it doesn't depend on module-graph visitation order.\n * @param filter A function to filter which `.tsx`/`.ts` files should be included - not applied\n * to `.css` files, since the default `include` (`/\\.tsx?$/`) would otherwise exclude all of them.\n * @param collectStyleDocs Whether to also collect CSS custom-property docs for each component's\n * stylesheet(s) - the extra parse cost only pays off when `options.docs` is set.\n * @returns A promise that resolves when the scan is complete.\n */\nexport async function scanDocs(\n filter: (id: string) => boolean,\n collectStyleDocs: boolean,\n): Promise<void> {\n // module-level, so a later plugin instance in the same process (e.g. Vite restarting its dev\n // server after a config change) must start over rather than append\n componentGlobalStyles.length = 0;\n for (const tags of cssOnlyTagsByFile.values()) for (const tag of tags) docsRegistry.delete(tag);\n cssOnlyTagsByFile.clear();\n cssOnlyComponentFiles.clear();\n componentMetaRegistry.clear();\n cssOnlyMetaRegistry.clear();\n tagsBySourceFile.clear();\n const cwd = process.cwd();\n const allFiles: string[] = [];\n collectFiles(cwd, (abs) => isTsSourceFile(abs) || isCssFile(abs), allFiles);\n\n const tsxFiles = allFiles.filter((abs) => isTsSourceFile(abs) && filter(abs));\n const cssFiles = allFiles.filter(isCssFile);\n\n await Promise.all([\n ...tsxFiles.map(async (abs) => {\n let code: string;\n try {\n code = readFileSync(abs, 'utf-8');\n } catch {\n return;\n }\n if (!COMPONENT_DECORATOR_RE.test(code)) return;\n const result = await transpile(code, { file: abs, componentExport: 'customelement' });\n for (const item of (result.data ?? []) as ComponentCompilerMeta[]) {\n if (!item.tagName) continue;\n if (collectStyleDocs) await collectStyleDocsForComponent(item, abs);\n const component = cmpMetaToDocsComponent(item, abs);\n resolveImportedTypes(component, abs);\n docsRegistry.set(item.tagName, component);\n componentMetaRegistry.set(item.tagName, item);\n tagsBySourceFile.set(normalize(abs), [\n ...(tagsBySourceFile.get(normalize(abs)) ?? []),\n item.tagName,\n ]);\n if (item.globalStyles?.length) componentGlobalStyles.push(...item.globalStyles);\n }\n }),\n ...cssFiles.map(scanCssOnlyDocsFile),\n ]);\n}\n","/**\n * `components.d.ts` - the typings `stencil build` writes to `srcDir`, generated here from the\n * project scan with core's own generator, so a project whose dev loop never runs the Stencil\n * compiler (Storybook, a Vite app authoring components from source) still gets them, kept current\n * as sources change. Same generator, same inputs, same order: if `stencil build --watch` runs\n * alongside, both write identical content.\n */\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { generateComponentTypesFile } from '@stencil/core/compiler';\nimport type { ComponentCompilerMeta, ComponentTypesConfig } from '@stencil/core/compiler';\n\nimport { componentMetaRegistry, cssOnlyMetaRegistry } from './project-scan.js';\n\nconst byTagName = (a: ComponentCompilerMeta, b: ComponentCompilerMeta) =>\n a.tagName.localeCompare(b.tagName);\n\n/**\n * Write `<srcDir>/components.d.ts` from the current registries, unless its content is unchanged -\n * so an editor's TS server, or a `stencil build --watch`, isn't disturbed for nothing.\n * @param config `srcDir` (absolute) plus the other fields that affect the output\n * @returns whether the file was (re)written\n */\nexport function writeComponentTypes(config: ComponentTypesConfig): boolean {\n const filePath = join(config.srcDir, 'components.d.ts');\n // core's order: JS-backed components, then CSS-only ones, each sorted by tag\n const content = generateComponentTypesFile(\n [\n ...[...componentMetaRegistry.values()].sort(byTagName),\n ...[...cssOnlyMetaRegistry.values()].sort(byTagName),\n ],\n config,\n );\n let existing: string | undefined;\n try {\n existing = readFileSync(filePath, 'utf-8');\n } catch {\n // not written yet\n }\n if (existing === content) return false;\n writeFileSync(filePath, content);\n return true;\n}\n","/**\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 'srcDir',\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 if (typeof c['srcDir'] === 'string') result.srcDir = c['srcDir'];\n // `null` is a meaningful, explicit value here (disables the hydrated-flag CSS entirely) -\n // only `undefined` (the key absent) should fall through to validateHydrated's own default.\n if ('hydratedFlag' in c)\n result.hydratedFlag = c['hydratedFlag'] as StencilConfigSubset['hydratedFlag'];\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 * Stencil's three virtual global-stylesheet imports - `@import \"stencil-hydrate\"`,\n * `\"stencil-component-globals\"` and `\"stencil-css-components\"` - as real stylesheets.\n *\n * Their CSS, gathered by the project-wide scan (see `scanDocs` in `plugin.ts`), is written to\n * `<dir>/<name>.css` and each specifier resolves to that file, so the bundler handles it like any\n * other stylesheet: wherever it's imported from (partials, Sass, Less) and with whatever\n * `@import` modifiers. Vite doesn't consult plugins when resolving CSS `@import`, so there it's\n * reached through an alias ({@link virtualGlobalStylesheetAlias}); other bundlers go through\n * `resolveId`.\n */\nimport { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { buildHydrateCss } from '@stencil/core/compiler';\nimport type { ComponentGlobalStyle, HydratedFlag, JsonDocsComponent } from '@stencil/core/compiler';\n\nimport { processCssFile } from './css.js';\nimport { collectFiles } from './project-scan.js';\n\nconst VIRTUAL_GLOBAL_IMPORTS = [\n 'stencil-hydrate',\n 'stencil-component-globals',\n 'stencil-css-components',\n] as const;\n\nconst VIRTUAL_GLOBAL_ID_RE = new RegExp(`^(${VIRTUAL_GLOBAL_IMPORTS.join('|')})$`);\n\n/** Matches a mention of any virtual global-stylesheet import name. */\nconst VIRTUAL_GLOBAL_IMPORT_RE = new RegExp(`\\\\b(?:${VIRTUAL_GLOBAL_IMPORTS.join('|')})\\\\b`);\n\n// Less prefixes an `@import (css)` inside a partial with the partial's directory\nconst VIRTUAL_GLOBAL_SUFFIX_RE = new RegExp(`(?:^|[\\\\\\\\/])(${VIRTUAL_GLOBAL_IMPORTS.join('|')})$`);\n\n/**\n * The virtual import a specifier refers to - either exactly, or with a directory prefix, which\n * callers should only accept when no such file exists (see {@link VIRTUAL_GLOBAL_SUFFIX_RE}).\n * @param id a module specifier\n * @returns the virtual import's name, if the specifier ends in one\n */\nconst getVirtualGlobalImportName = (id: string): string | undefined =>\n VIRTUAL_GLOBAL_SUFFIX_RE.exec(id)?.[1];\n\n/**\n * @param dir the directory {@link writeVirtualGlobalStylesheets} writes to\n * @param name a virtual global-stylesheet import\n * @returns the path of its generated stylesheet\n */\nconst virtualGlobalStylesheetPath = (dir: string, name: string): string => join(dir, `${name}.css`);\n\n/**\n * A Vite alias sending each virtual import to its generated stylesheet in `dir`.\n * @param dir the directory {@link writeVirtualGlobalStylesheets} writes to\n * @returns the alias entry\n */\nexport const virtualGlobalStylesheetAlias = (dir: string) => ({\n find: VIRTUAL_GLOBAL_ID_RE,\n replacement: virtualGlobalStylesheetPath(dir, '$1'),\n});\n\n/**\n * A webpack-style alias map (`name$` = exact match) sending each virtual import to its generated\n * stylesheet in `dir` - for bundlers whose CSS `@import` resolution skips plugins (rspack).\n * @param dir the directory {@link writeVirtualGlobalStylesheets} writes to\n * @returns the alias map\n */\nexport const virtualGlobalStylesheetAliasMap = (dir: string): Record<string, string> =>\n Object.fromEntries(\n VIRTUAL_GLOBAL_IMPORTS.map((name) => [`${name}$`, virtualGlobalStylesheetPath(dir, name)]),\n );\n\n/**\n * Tags `stencil-hydrate` hides until hydrated. CSS-only components never hydrate, so including\n * them would hide them for good.\n * @param components every component in the docs registry\n * @returns the real (JS-backed) components' tag names\n */\nexport const getHydrateTagNames = (components: Iterable<JsonDocsComponent>): Set<string> =>\n new Set([...components].filter((c) => !c.cssOnly).map((c) => c.tag));\n\n/** Project-wide data the three stylesheets are built from, gathered by `scanDocs`. */\nexport interface GlobalCssProjectData {\n /** Every component's `@Component({ globalStyle / globalStyleUrl })` entries. */\n componentGlobalStyles: ComponentGlobalStyle[];\n /** `.css` files that define at least one CSS-only component (`@component`-marked). */\n cssOnlyComponentFiles: Set<string>;\n /** Tags hidden until hydrated - see {@link getHydrateTagNames}. */\n tagNames: Set<string>;\n hydratedFlag: HydratedFlag | null;\n}\n\n// Processed CSS per ingredient file (a globalStyleUrl / CSS-only-component file) and the files it\n// pulled in, keyed on their latest mtime - so regenerating reprocesses only what changed, in any\n// bundler's watch mode, without having to be told what changed.\nconst processedFileCache = new Map<string, { css: string; deps: string[]; mtimeMs: number }>();\n\nconst latestMtime = (filePaths: string[]): number => {\n let latest = 0;\n for (const filePath of filePaths) {\n try {\n latest = Math.max(latest, statSync(filePath).mtimeMs);\n } catch {\n // missing - reprocess and let that report it\n return Number.NaN;\n }\n }\n return latest;\n};\n\nasync function collectFileParts(\n filePaths: Iterable<string>,\n isDev: boolean,\n): Promise<{ css: string; deps: string[] }> {\n const parts: string[] = [];\n const deps: string[] = [];\n for (const filePath of filePaths) {\n deps.push(filePath);\n let processed = processedFileCache.get(filePath);\n if (!processed || processed.mtimeMs !== latestMtime([filePath, ...processed.deps])) {\n const result = await processCssFile(filePath, isDev);\n if (!result) continue;\n processed = { ...result, mtimeMs: latestMtime([filePath, ...result.deps]) };\n processedFileCache.set(filePath, processed);\n }\n parts.push(processed.css);\n deps.push(...processed.deps);\n }\n return { css: parts.join('\\n'), deps };\n}\n\nasync function collectComponentGlobalStyles(\n entries: ComponentGlobalStyle[],\n isDev: boolean,\n): Promise<{ css: string; deps: string[] }> {\n const inline: string[] = [];\n const filePaths: string[] = [];\n for (const gs of entries) {\n if (gs.styleStr) inline.push(gs.styleStr);\n else if (gs.absolutePath) filePaths.push(gs.absolutePath);\n }\n const { css: fileCss, deps } = await collectFileParts(filePaths, isDev);\n return { css: [...inline, fileCss].filter(Boolean).join('\\n'), deps };\n}\n\n/**\n * Write each virtual import's CSS to `<dir>/<name>.css` - all three, even when empty, so they\n * always resolve. Files whose content is unchanged are left alone, so they don't trigger HMR.\n * @param dir the directory to write to\n * @param data project-wide data collected by `scanDocs`\n * @param isDev `true` in dev mode (disables minification in the ingredient preprocessing chain)\n * @returns the paths of files that were (re)written, and every ingredient file the CSS came from\n * (register these as watch files)\n */\nexport async function writeVirtualGlobalStylesheets(\n dir: string,\n data: GlobalCssProjectData,\n isDev: boolean,\n): Promise<{ written: string[]; deps: string[] }> {\n const globals = await collectComponentGlobalStyles(data.componentGlobalStyles, isDev);\n const cssOnly = await collectFileParts(data.cssOnlyComponentFiles, isDev);\n const contents: Record<(typeof VIRTUAL_GLOBAL_IMPORTS)[number], string> = {\n 'stencil-hydrate': buildHydrateCss(data.hydratedFlag, [...data.tagNames]),\n 'stencil-component-globals': globals.css,\n 'stencil-css-components': cssOnly.css,\n };\n\n mkdirSync(dir, { recursive: true });\n const written: string[] = [];\n for (const name of VIRTUAL_GLOBAL_IMPORTS) {\n const filePath = virtualGlobalStylesheetPath(dir, name);\n let existing: string | undefined;\n try {\n existing = readFileSync(filePath, 'utf-8');\n } catch {\n // not written yet\n }\n if (existing !== contents[name]) {\n writeFileSync(filePath, contents[name]);\n written.push(filePath);\n }\n }\n return { written, deps: [...globals.deps, ...cssOnly.deps] };\n}\n\nconst STYLE_FILE_RE = /\\.(css|scss|sass|less|styl|stylus|pcss)$/;\n\nconst mentionsVirtualGlobalImport = (abs: string): boolean => {\n try {\n return VIRTUAL_GLOBAL_IMPORT_RE.test(readFileSync(abs, 'utf-8'));\n } catch {\n return false;\n }\n};\n\n/**\n * Cheap text check of every stylesheet under `root` for a virtual global-stylesheet import -\n * gates the full project scan the generated stylesheets need.\n * @param root the project root\n * @returns whether any stylesheet mentions one\n */\nfunction projectUsesVirtualGlobalImports(root: string): boolean {\n const styleFiles: string[] = [];\n collectFiles(root, (abs) => STYLE_FILE_RE.test(abs), styleFiles);\n return styleFiles.some(mentionsVirtualGlobalImport);\n}\n\n/**\n * One plugin instance's generated virtual global stylesheets: where they live, and generating\n * them on first use - so projects that never use them don't pay for the project scan - then\n * regenerating them as sources change.\n * @param prepare loads whatever the stylesheets are built from (config, project scan)\n * @param isDev whether this is a dev build (unminified, and a separate output dir)\n * @returns the stylesheets' controls, one per plugin hook that needs them\n */\nexport function createVirtualGlobalCss(\n prepare: () => Promise<GlobalCssProjectData>,\n isDev: () => boolean,\n) {\n let dir = '';\n let written: ReturnType<typeof writeVirtualGlobalStylesheets> | null = null;\n let deps: string[] = [];\n const write = async () => {\n const result = await writeVirtualGlobalStylesheets(dir, await prepare(), isDev());\n deps = result.deps;\n return result;\n };\n\n const ensure = () => (written ??= write());\n // regenerate from current sources - ingredient changes are picked up by mtime\n const rewrite = async () => {\n await written;\n written = write();\n return written;\n };\n const refresh = () => (written ? rewrite() : ensure());\n const useDefaultDir = (root: string) => {\n dir ||= resolve(root, 'node_modules', '.stencil', 'virtual-css', isDev() ? 'serve' : 'build');\n };\n const isPath = (id: string) => !!dir && dirname(id) === dir;\n\n return {\n get dir() {\n return dir;\n },\n /** @returns whether they've been generated yet, i.e. something uses them */\n get started() {\n return !!written;\n },\n /** @returns the ingredient files the last generation drew from */\n get deps() {\n return deps;\n },\n setDir(value: string) {\n dir = value;\n },\n /** Use the default dir under `root`, unless one's already been set. */\n useDefaultDir,\n isPath,\n refresh,\n\n /**\n * @param id a module specifier\n * @param importer the importing file\n * @returns the generated stylesheet it refers to, if it's a virtual import. A directory-prefixed\n * name (as Less writes `(css)` imports in a partial) only counts when no such file exists.\n */\n async resolveId(id: string, importer?: string): Promise<string | undefined> {\n // Vite's alias has already swapped a JS import's name for its generated path - that's a use\n // too, even if no stylesheet mentions one (e.g. a Storybook preview entry importing them)\n if (isPath(id)) {\n await ensure();\n return id;\n }\n const name = getVirtualGlobalImportName(id);\n if (!name || (name !== id && importer && existsSync(resolve(dirname(importer), id)))) {\n return undefined;\n }\n await ensure();\n return virtualGlobalStylesheetPath(dir, name);\n },\n\n /**\n * Regenerated on every load, so a watch-mode rebuild sees ingredient changes.\n * @param id a generated stylesheet's path\n * @returns its CSS, and the ingredient files to register as watch files\n */\n async load(id: string): Promise<{ code: string; deps: string[] }> {\n await rewrite();\n return { code: readFileSync(id, 'utf-8'), deps };\n },\n\n /**\n * For bundlers that read the generated files straight from disk before compiling (webpack,\n * rspack) - (re)write them before every compile, once some stylesheet uses them.\n * @param root the project root\n */\n async forCompile(root: string) {\n if (!written && !projectUsesVirtualGlobalImports(root)) return;\n useDefaultDir(root);\n await refresh();\n },\n\n /**\n * Vite HMR: generate them once a stylesheet first mentions one, then regenerate on every\n * relevant change.\n * @param file the changed file\n * @returns the generated stylesheets whose content changed\n */\n async hotUpdate(file: string): Promise<string[]> {\n if (!written) {\n if (STYLE_FILE_RE.test(file) && mentionsVirtualGlobalImport(file)) await ensure();\n return [];\n }\n if (!/\\.(css|tsx?)$/.test(file)) return [];\n return (await rewrite()).written;\n },\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 { collectStyleDocsForComponent } from './css.js';\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 async 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): Promise<{\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 specPage = options.mode === 'spec-page';\n const jsxOpts = resolveJsxOpts(code, process.cwd());\n const result = transpileSync(code, {\n ...jsxOpts,\n ...options.transpileOptions,\n file: id,\n ...(specPage\n ? {\n componentExport: null,\n componentMetadata: 'compilerstatic' as const,\n coreImportPath: '@stencil/core/testing',\n // No CSS loader is wired for spec-page mode - `newSpecPage()` tests are\n // behavioral and don't need real stylesheets. `null` skips the style assignment entirely.\n style: null,\n }\n : { componentExport: 'customelement' as const }),\n styleImportData: 'queryparams',\n resolveImport: makeResolver(onBaseClass),\n buildOverrides: {\n ...configOverrides,\n ...options.transpileOptions?.buildOverrides,\n ...(dev && !specPage ? { 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 let out = result.code;\n if (!specPage) {\n // customelement mode strips the export keyword, so re-export the class\n // ourselves — consumers import it by name, and\n // hmrStandalone needs it in the re-imported module in dev mode\n const namedExport = `\\nexport{${className}};`;\n out = dev\n ? result.code + namedExport + buildHmrSnippet(tagName, className, framework)\n : result.code + namedExport;\n }\n\n if (options.docs) await collectStyleDocsForComponent(result.data[0], id);\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 class goes to the runtime's `s-hmr-apply` hook, which patches it\n * onto the registered one and re-renders live instances. */\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 && _sCtor['s-hmr-apply']) _sCtor['s-hmr-apply'](${className});` +\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 6 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 *\n * 5. **spec-page module resolution** - `mode: 'spec-page'` (`stencilSpecPage`)\n * redirects every bare `@stencil/core` import to `@stencil/core/testing` via\n * `resolveId`, so the whole test file - not just compiler output - resolves\n * to a single platform instance.\n *\n * 6. **Virtual global-stylesheet imports** - `@import \"stencil-component-globals\"`/\n * `\"stencil-hydrate\"`/`\"stencil-css-components\"` resolve to generated stylesheets (see\n * `global-css.ts`) via `resolveId`, or under Vite - which doesn't consult plugins for CSS\n * `@import` - via an alias. The bundler then treats them like any other CSS. `load` registers\n * their ingredient files (e.g. a component's `globalStyleUrl`) for watch mode;\n * `handleHotUpdate` regenerates them for Vite HMR.\n *\n * 7. **`components.d.ts`** - with `types: true`, written to `srcDir` from the project scan by\n * core's own generator (see `component-types.ts`), and rewritten as component sources change.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { createFilter } from '@rollup/pluginutils';\nimport { validateHydrated } from '@stencil/core/compiler';\nimport { createUnplugin } from 'unplugin';\nimport type { BuildOverrides, ComponentTypesConfig, HydratedFlag } from '@stencil/core/compiler';\nimport type { ModuleNode, ViteDevServer } from 'vite';\n\nimport { writeComponentTypes } from './component-types.js';\nimport { loadStencilConfig, stencilConfigToOverrides } from './config.js';\nimport { getRealCssPath, isStencilCss, loadStencilCss, resolveStencilCss } from './css.js';\nimport {\n createVirtualGlobalCss,\n getHydrateTagNames,\n virtualGlobalStylesheetAlias,\n virtualGlobalStylesheetAliasMap,\n} from './global-css.js';\nimport {\n componentGlobalStyles,\n cssOnlyComponentFiles,\n docsRegistry,\n getRegistrySnapshot,\n getStencilCEM,\n isCssOnlyComponentFile,\n refreshComponentDocs,\n refreshComponentMeta,\n rescanIfCssOnlyComponent,\n rescanNewCssOnlyComponents,\n scanCssOnlyDocsFile,\n scanDocs,\n} from './project-scan.js';\nimport { resolveImportedTypes } from './resolve-types.js';\nimport { resolveSpecifier, transformStencil, transpileBaseClass } from './transform.js';\nimport type { StencilPluginOptions } from './options.js';\n\nexport { getStencilCEM } from './project-scan.js';\n\nexport const STENCIL_DOCS_ID = '@stencil/unplugin/docs';\nconst VIRTUAL_DOCS_PREFIX = '\\0stencil-docs:';\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\n// `this.resolve` isn't part of unplugin's cross-bundler `resolveId` context type\n// (not every backend has it), but it is present on Vite/Rollup's real plugin\n// context - the only framework `stencilSpecPage` runs through (`unpluginStencil.vite`).\ninterface RollupResolveContext {\n resolve(\n id: string,\n importer?: string,\n options?: { skipSelf?: boolean },\n ): Promise<{ id: string; external?: boolean } | null>;\n}\n\n/** The parts of Vite's dev server `handleHotUpdate` uses. */\ninterface HmrServer {\n ws: { send: (msg: unknown) => void };\n moduleGraph: {\n invalidateModule(\n mod: ModuleNode,\n seen?: Set<unknown>,\n timestamp?: number,\n isHmr?: boolean,\n ): void;\n getModuleById?(id: string): ModuleNode | undefined;\n getModulesByFile?(file: string): Set<ModuleNode> | undefined;\n idToModuleMap?: Map<string, ModuleNode>;\n };\n}\n\nconst getModuleById = (server: HmrServer, id: string) =>\n server.moduleGraph.getModuleById?.(id) ?? server.moduleGraph.idToModuleMap?.get(id);\n\nconst invalidate = (server: HmrServer, mod: ModuleNode) =>\n server.moduleGraph.invalidateModule(mod, new Set(), Date.now(), true);\n\n// Vite keys its module graph by forward-slash paths on every OS; Node's `path` uses `\\` on Windows\nconst toViteFilePath = (filePath: string) => filePath.replace(/\\\\/g, '/');\n\nconst PLUGIN_NAME = '@stencil/unplugin';\n\ninterface Tapable<Args extends unknown[], Result = void> {\n tap(name: string, fn: (...args: Args) => Result): void;\n}\n\ninterface LoaderContextDeps {\n resourcePath: string;\n addDependency(path: string): void;\n addContextDependency(path: string): void;\n}\n\n/** The parts of a webpack/rspack compiler used to keep the generated stylesheets current. */\ninterface BundlerCompiler {\n hooks: {\n watchRun: {\n tapPromise(\n name: string,\n fn: (compiler: {\n modifiedFiles?: ReadonlySet<string>;\n removedFiles?: ReadonlySet<string>;\n }) => Promise<void>,\n ): void;\n };\n beforeCompile: { tapPromise(name: string, fn: () => Promise<void>): void };\n thisCompilation: Tapable<[compilation: unknown]>;\n };\n webpack: {\n NormalModule: {\n getCompilationHooks(compilation: unknown): {\n beforeLoaders?: Tapable<\n [loaders: unknown, module: { resource?: string }, loaderContext: LoaderContextDeps]\n >;\n loader?: Tapable<[loaderContext: LoaderContextDeps]>;\n };\n };\n };\n}\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 // Reverse of fileToTagName - lets a linked-stylesheet change (which only knows its own\n // path, via cssFileToTagNames below) find the owning `.tsx` to re-derive docs from.\n const tagToFile = 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 // Validated once in buildStart from the detected/explicit stencil.config. `null` means\n // hydratedFlag is explicitly disabled - same meaning as the full compiler's config.\n let hydratedFlag: HydratedFlag | null = null;\n\n // What `options.types` generates `components.d.ts` with - set alongside hydratedFlag.\n let typesConfig: ComponentTypesConfig | null = null;\n\n // Memoized so scanDocs() - a full project walk - runs at most once per build, however many\n // triggers ask for it.\n let projectScanPromise: Promise<void> | null = null;\n function ensureProjectScanned(): Promise<void> {\n if (!projectScanPromise) projectScanPromise = scanDocs(filter, options.docs === true);\n return projectScanPromise;\n }\n\n async function loadConfig() {\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 hydratedFlag = validateHydrated({ hydratedFlag: merged.hydratedFlag });\n typesConfig = {\n srcDir: resolve(projectRoot, merged.srcDir ?? 'src'),\n signalBacking: !!merged.signalBacking,\n };\n }\n // Some bundlers (rspack's `beforeCompile`) ask for the virtual stylesheets before `buildStart`.\n let stencilConfigLoaded: Promise<void> | null = null;\n\n // The generated virtual global stylesheets (see `global-css.ts`) - their dir is set by Vite's\n // `config` hook / rspack's plugin hook, otherwise in `buildStart`.\n const virtualCss = createVirtualGlobalCss(\n async () => {\n stencilConfigLoaded ??= loadConfig();\n await Promise.all([stencilConfigLoaded, ensureProjectScanned()]);\n return {\n componentGlobalStyles,\n cssOnlyComponentFiles,\n tagNames: getHydrateTagNames(docsRegistry.values()),\n hydratedFlag,\n };\n },\n () => isDev,\n );\n\n /**\n * webpack/rspack: they read the generated stylesheets straight from disk (`load` never runs for\n * them), so this (re)writes them before every compile and makes their modules depend on the\n * ingredient files - otherwise an ingredient edit neither triggers a watch-mode rebuild nor\n * invalidates the cached stylesheet module. `src/` too, so a newly added CSS-only component\n * does - not the whole project root, where build output would trigger rebuilds in a loop.\n * @param compiler the webpack/rspack compiler\n */\n function watchVirtualCssForCompiles(compiler: BundlerCompiler) {\n // before regenerating: a changed/added stylesheet may change which CSS-only components\n // exist. Here rather than `watchChange`, which isn't awaited before the compile starts.\n compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async ({ modifiedFiles, removedFiles }) => {\n if (!virtualCss.started) return;\n for (const file of [...(modifiedFiles ?? []), ...(removedFiles ?? [])]) {\n await rescanIfCssOnlyComponent(file);\n // a file added to a watched directory is reported as the directory itself\n await rescanNewCssOnlyComponents(file);\n }\n });\n compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, () =>\n virtualCss.forCompile(projectRoot),\n );\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {\n const addIngredients = (resource: string | undefined, loaderContext: LoaderContextDeps) => {\n if (!resource || !virtualCss.isPath(resource)) return;\n for (const dep of virtualCss.deps) loaderContext.addDependency(dep);\n const srcDir = resolve(projectRoot, 'src');\n if (existsSync(srcDir)) loaderContext.addContextDependency(srcDir);\n };\n const hooks = compiler.webpack.NormalModule.getCompilationHooks(compilation);\n // webpack discards dependencies added in `loader` (the loader run starts a fresh list), and\n // hasn't set `resourcePath` yet in `beforeLoaders`; rspack only has `loader`\n if (hooks.beforeLoaders) {\n hooks.beforeLoaders.tap(PLUGIN_NAME, (_loaders, module, ctx) =>\n addIngredients(module.resource, ctx),\n );\n } else {\n hooks.loader?.tap(PLUGIN_NAME, (ctx) => addIngredients(ctx.resourcePath, ctx));\n }\n });\n }\n\n /**\n * `options.types`: bring the registries up to date with a changed file - a component source,\n * or a stylesheet that defines (or used to define) CSS-only components - then rewrite\n * `components.d.ts` if its content changed.\n * @param file the changed, added or deleted file\n */\n async function updateComponentTypes(file: string) {\n if (!options.types || !typesConfig) return;\n if (/\\.tsx?$/.test(file) && !file.endsWith('.d.ts') && filter(file)) {\n await refreshComponentMeta(file);\n } else {\n await rescanIfCssOnlyComponent(file);\n // a file added to a watched directory may be reported as the directory itself\n await rescanNewCssOnlyComponents(file);\n }\n writeComponentTypes(typesConfig);\n }\n\n /**\n * Vite HMR: tell the client its docs changed, invalidating the docs virtual module.\n * @param server the dev server\n */\n function notifyDocsChanged(server: HmrServer) {\n const docsVirtualMod = getModuleById(server, VIRTUAL_DOCS_PREFIX);\n if (docsVirtualMod) invalidate(server, docsVirtualMod);\n server.ws.send({ type: 'custom', event: 'stencil:docs-update' });\n }\n\n /**\n * Vite HMR, `docs` only: refresh docs affected by a changed stylesheet - a CSS-only\n * component's own file, or a regular component's linked `styleUrl`.\n * @param file the changed stylesheet\n * @param server the dev server\n */\n async function refreshDocsForStylesheet(file: string, server: HmrServer) {\n let code = '';\n try {\n code = readFileSync(file, 'utf-8');\n } catch {\n // deleted - a file that defined CSS-only components still needs re-scanning\n }\n try {\n // one that no longer does (definition removed, or file deleted) too, to drop them\n if (code.includes('@component') || isCssOnlyComponentFile(file)) {\n // CSS-only components have no tracked tag / virtual-module entries (they're\n // never imported directly by anything) - handle their docs-registry refresh here.\n // No stencil:hmr to send; no JS component instance, only docs need refreshing.\n const prevSnapshot = JSON.stringify(getRegistrySnapshot());\n await scanCssOnlyDocsFile(file);\n if (JSON.stringify(getRegistrySnapshot()) !== prevSnapshot) notifyDocsChanged(server);\n } else {\n // A regular component's *linked* stylesheet (styleUrl) - re-derive docs from\n // each owning tag's `.tsx` source, the same as if that file had changed directly.\n let anyChanged = false;\n for (const tag of cssFileToTagNames.get(file) ?? []) {\n const ownerFile = tagToFile.get(tag);\n if (ownerFile && (await refreshComponentDocs(tag, ownerFile))) anyChanged = true;\n }\n if (anyChanged) notifyDocsChanged(server);\n }\n } catch {\n // stale docs are acceptable on parse error\n }\n }\n\n /**\n * Vite HMR: regenerate the virtual global stylesheets and hot-update whatever imports the ones\n * that changed. Vite doesn't watch them (under node_modules), so they're returned as HMR modules\n * - the documented pattern for hot-updating an untracked dependency.\n * @param file the changed file\n * @param server the dev server\n * @returns the modules to hot-update\n */\n async function hotUpdateVirtualCss(file: string, server: HmrServer): Promise<ModuleNode[]> {\n // with `docs`, refreshDocsForStylesheet already re-scanned CSS-only components\n if (virtualCss.started && !options.docs) await rescanIfCssOnlyComponent(file);\n const modules: ModuleNode[] = [];\n for (const written of await virtualCss.hotUpdate(file)) {\n for (const mod of server.moduleGraph.getModulesByFile?.(toViteFilePath(written)) ?? []) {\n invalidate(server, mod);\n modules.push(mod);\n }\n }\n return modules;\n }\n\n /**\n * Vite HMR: send `stencil:hmr` for every component the changed file belongs to.\n * @param file the changed file\n * @param server the dev server\n * @returns whether the file belongs to any component\n */\n async function hotUpdateComponents(file: string, server: HmrServer): Promise<boolean> {\n const tsxTag = fileToTagName.get(file);\n const tagNames = new Set<string>(cssFileToTagNames.get(file));\n if (tsxTag) tagNames.add(tsxTag);\n if (tagNames.size === 0) return false;\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 for (const virtualId of cssRealToVirtualIds.get(file) ?? []) {\n const virtualMod = getModuleById(server, virtualId);\n if (virtualMod) invalidate(server, virtualMod);\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 && (await refreshComponentDocs(tsxTag, file))) {\n notifyDocsChanged(server);\n }\n for (const tagName of tagNames) {\n server.ws.send({ type: 'custom', event: 'stencil:hmr', data: { tagName } });\n }\n return true;\n }\n\n return {\n name: '@stencil/unplugin',\n\n async buildStart() {\n // reloaded every build, so a watch-mode rebuild picks up stencil.config changes\n stencilConfigLoaded = loadConfig();\n await stencilConfigLoaded;\n if (options.docs || options.types) await ensureProjectScanned();\n if (options.types && typesConfig) writeComponentTypes(typesConfig);\n virtualCss.useDefaultDir(projectRoot);\n // Vite never asks `resolveId` about CSS `@import`s, so generate up front if they're used -\n // and regenerate on a watch-mode rebuild, which reads them straight from disk\n if (framework === 'vite') await virtualCss.forCompile(projectRoot);\n },\n\n async resolveId(id, importer) {\n if (id === STENCIL_DOCS_ID) return VIRTUAL_DOCS_PREFIX;\n\n const virtualCssPath = await virtualCss.resolveId(id, importer);\n if (virtualCssPath) return virtualCssPath;\n\n // spec-page mode transpiles components against `@stencil/core/testing`'s\n // platform (hostRefs, mode chain, etc. - a separate module instance from\n // the real runtime). Any other file that imports the bare `@stencil/core`\n // specifier - a test file calling `setMode`, a helper, a mock - would\n // otherwise resolve to that other instance and silently stop working.\n // Redirecting here (like Jest's old `moduleNameMapper`) guarantees a\n // single platform instance for every file, not just compiler output.\n if (options.mode === 'spec-page' && id === '@stencil/core') {\n return (this as unknown as RollupResolveContext).resolve(\n '@stencil/core/testing',\n importer,\n { skipSelf: true },\n );\n }\n\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 async transform(code, id) {\n const cleanId = id.split('?')[0];\n\n if (!configOverrides.vdomSignals && SIGNALS_IMPORT_RE.test(code)) {\n configOverrides = { ...configOverrides, vdomSignals: true };\n }\n const result = await transformStencil(\n code,\n cleanId,\n options,\n isDev,\n framework,\n registerBaseClass,\n configOverrides,\n );\n if (result?.tagName) {\n fileToTagName.set(cleanId, result.tagName);\n tagToFile.set(result.tagName, cleanId);\n }\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 (\n id === VIRTUAL_DOCS_PREFIX ||\n isStencilCss(id) ||\n id.startsWith(VIRTUAL_BASE_PREFIX) ||\n virtualCss.isPath(id)\n );\n },\n\n async load(id) {\n if (id === VIRTUAL_DOCS_PREFIX) {\n return `export default ${JSON.stringify(getStencilCEM())}`;\n }\n if (virtualCss.isPath(id)) {\n const { code, deps } = await virtualCss.load(id);\n for (const dep of deps) this.addWatchFile(dep);\n return { code, map: null };\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 // Watch mode for bundlers `load` regenerates for (Vite: `handleHotUpdate`; webpack/rspack:\n // `watchVirtualCssForCompiles`) - only a change in which CSS-only components exist needs a\n // re-scan first.\n async watchChange(id) {\n if (!['vite', 'webpack', 'rspack'].includes(framework) && virtualCss.started) {\n await rescanIfCssOnlyComponent(id);\n }\n // Vite: after its own HMR handling instead - see `handleHotUpdate`\n if (framework !== 'vite') await updateComponentTypes(id);\n },\n\n // webpack/rspack read the resolved stylesheets straight from disk (`load` never runs for\n // them), so (re)write them before every compile - watch-mode rebuilds included.\n webpack(compiler) {\n watchVirtualCssForCompiles(compiler);\n },\n\n // rspack's `css-loader` resolves `@import` natively, without asking `resolveId` - alias the\n // virtual imports to their generated stylesheets instead, like Vite.\n rspack(compiler) {\n virtualCss.useDefaultDir(compiler.options.context ?? projectRoot);\n const alias = compiler.options.resolve.alias;\n compiler.options.resolve.alias = {\n ...(alias && !Array.isArray(alias) ? alias : {}),\n ...virtualGlobalStylesheetAliasMap(virtualCss.dir),\n };\n watchVirtualCssForCompiles(compiler);\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 config(userConfig: { root?: string }, env: { command: string }) {\n // per command: a dev server and a build in the same project (e.g. an app plus\n // Storybook) generate differently-optimized CSS and mustn't overwrite each other's\n virtualCss.setDir(\n resolve(\n userConfig.root ?? process.cwd(),\n 'node_modules',\n '.stencil',\n 'virtual-css',\n env.command,\n ),\n );\n return { resolve: { alias: [virtualGlobalStylesheetAlias(virtualCss.dir)] } };\n },\n\n configResolved(config: { command: string; root: string }) {\n isDev = options.dev ?? config.command === 'serve';\n projectRoot = config.root;\n },\n\n // Vite only runs `handleHotUpdate` for changed files - adding or deleting a CSS-only\n // component changes the generated stylesheets too\n configureServer(server: ViteDevServer) {\n const onAddedOrDeleted = async (file: string) => {\n if (file.endsWith('.css')) {\n if (options.docs) await refreshDocsForStylesheet(file, server);\n for (const mod of await hotUpdateVirtualCss(file, server))\n await server.reloadModule(mod);\n }\n await updateComponentTypes(file);\n };\n server.watcher.on('add', onAddedOrDeleted);\n server.watcher.on('unlink', onAddedOrDeleted);\n },\n\n async handleHotUpdate({ file, server }: { file: string; server: HmrServer }) {\n if (options.docs && file.endsWith('.css')) await refreshDocsForStylesheet(file, server);\n const hmrModules = await hotUpdateVirtualCss(file, server);\n const isComponentFile = await hotUpdateComponents(file, server);\n // last: the docs/stylesheet handling above compares registry snapshots across its own\n // re-scan, which re-scanning here first would hide\n await updateComponentTypes(file);\n if (!isComponentFile && hmrModules.length === 0) return undefined;\n return hmrModules;\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';\nimport type { StencilPluginOptions } from './options.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\n/**\n * Vite plugin that transpiles components for use with `newSpecPage()` from\n * `@stencil/core/testing`, instead of the self-registering custom-element\n * output the other exports produce. Use in `vitest.config.ts`.\n *\n * Also redirects any bare `@stencil/core` import to `@stencil/core/testing`\n * for the whole test file, so mistakenly importing e.g. `setMode` from\n * `@stencil/core` doesn't silently resolve to a disconnected platform instance.\n * @param options - plugin options; `mode` is fixed to `'spec-page'` and cannot be overridden\n * @returns a Vite plugin\n */\nexport const st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IACzD,MAAM,kBAAkB,MAAM,oBAAoB,MAAM,MAAM;IAG9D,MAAM,qBAAqB,IAAI;IAC/B,IAAI,CAAC,mBAAmB,WAAW,WAAW,GAAG,OAAO,KAAA;IACxD,OAAO;GACT;EACF;CACF;AACF,CACF;;;AC/nBA,MAAa,cAAc,gBAAgB;AAC3C,MAAa,gBAAgB,gBAAgB;AAC7C,MAAa,iBAAiB,gBAAgB;AAC9C,MAAa,iBAAiB,gBAAgB;AAC9C,MAAa,gBAAgB,gBAAgB;;;;;;;;;;;;AAa7C,MAAa,mBAAmB,UAA8C,CAAC,MAC7E,gBAAgB,KAAK;CAAE,GAAG;CAAS,MAAM;AAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/unplugin",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.13",
|
|
4
4
|
"description": "Universal bundler plugin for Stencil components (Vite, Rollup, Webpack, esbuild)",
|
|
5
5
|
"homepage": "https://stenciljs.com/",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"typescript": ">5.0.0 <7.0.0",
|
|
46
46
|
"vite": "^8.2.1",
|
|
47
47
|
"vitest": "^4.1.10",
|
|
48
|
-
"@stencil/core": "5.0.0-beta.
|
|
48
|
+
"@stencil/core": "5.0.0-beta.13"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"less": "^4.0.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"postcss-load-config": "^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
55
55
|
"sass": "^1.0.0",
|
|
56
56
|
"typescript": ">=5.0.0",
|
|
57
|
-
"@stencil/core": "^5.0.0 || 5.0.0-beta.
|
|
57
|
+
"@stencil/core": "^5.0.0 || 5.0.0-beta.13"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"less": {
|