@stencil/core 5.0.0-rc.1 → 5.0.0-rc.11

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.
@@ -1,9 +1,9 @@
1
1
  import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import { A as SSR_PROP_REF_PREFIX, D as HYDRATE_ID, E as HYDRATE_CHILD_ID, O as SERVER_BUILD_FLAGS, T as HYDRATED_CSS, k as SSR_PROPS_REGISTRY_KEY, w as CLIENT_BUILD_FLAGS } from "./client-BMtGBEQV.mjs";
3
- import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, E as COLLECTION_MANIFEST_FILE_NAME, J as STANDALONE, L as EVENT_FLAGS, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, S as ASSETS, T as COLLECTION_APP_DATA_FILE_NAME, U as LOADER_BUNDLE, X as STYLE_EXT, Y as STATS, a as isBoolean$1, b as unique, c as isFunction, d as isObject, et as WATCH_FLAGS, f as isString$1, g as sortBy, i as fromEntries, l as isIterable, m as noop, p as mergeIntoWith, r as flatOne, t as dashToPascalCase, u as isNumber$1, v as toDashCase, w as COLLECTION, y as toTitleCase, z as GLOBAL_STYLE } from "./helpers-pTCZhNi0.mjs";
4
- import { C as isRootPath, D as byteSize, E as stringifyRuntimeData, O as escapeRegExpSpecialCharacters, S as splitLineBreaks, _ as createOnWarnFn, a as getRolldownSourceMapOptions, c as relativizeSourceMap, d as map, f as ok, g as loadTypeScriptDiagnostics, h as loadTypeScriptDiagnostic, i as getInlineSourceMappingUrlLinker, l as rolldownToStencilSourceMap, m as augmentDiagnosticWithNode, n as validateComponentTag, o as getSourceMappingUrlForEndOfFile, r as isRemoteUrl, t as validateComponentModes, u as err, v as isRolldownError, w as formatComponentRuntimeMeta, x as normalizeDiagnostics, y as loadRolldownDiagnostics } from "./validation-C1mr0klL.mjs";
5
- import { $ as buildWarn, A as isOutputTargetDocsVscode, B as isValidConfigOutputTarget, C as isOutputTargetDistLazy, D as isOutputTargetDocsCustomElementsManifest, E as isOutputTargetDocsCustom, F as isOutputTargetSsrWasm, G as normalizeFsPath, H as shouldExcludeComponent, I as isOutputTargetStandalone, J as relative$1, K as normalizeFsPathQuery, L as isOutputTargetStats, M as isOutputTargetLoaderBundle, N as isOutputTargetServerRenderer, O as isOutputTargetDocsJson, P as isOutputTargetSsr, Q as buildJsonFileError, R as isOutputTargetTypes, S as isOutputTargetCustom, T as isOutputTargetDocsAgentSkill, U as join$2, V as relativeImport, Y as resolve$2, Z as buildError, a as hasDependency, b as isOutputTargetCollection, d as parsePackageJson, et as catchError, f as readOnlyArrayHasStringMember, g as getComponentsDtsSrcFilePath, h as filterExcludedComponents, i as getTextDocs, it as isGlob, j as isOutputTargetGlobalStyle, k as isOutputTargetDocsReadme, l as isTsFile, m as filterActiveTargets, n as createJsVarName, nt as hasWarning, o as isDtsFile, p as readPackageJson, q as normalizePath, r as generatePreamble, t as addDocBlock, tt as hasError, u as isTsxFile, v as getComponentsFromModules, w as isOutputTargetDocs, x as isOutputTargetCopy, y as isOutputTargetAssets, z as isOutputTargetWww } from "./util-CP6-333M.mjs";
6
- import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-Bkq8vRnu.mjs";
2
+ import { A as SSR_PROP_REF_PREFIX, D as HYDRATE_ID, E as HYDRATE_CHILD_ID, O as SERVER_BUILD_FLAGS, T as HYDRATED_CSS, k as SSR_PROPS_REGISTRY_KEY, w as CLIENT_BUILD_FLAGS } from "./client-QadqfKfL.mjs";
3
+ import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, E as COLLECTION_MANIFEST_FILE_NAME, J as STANDALONE, L as EVENT_FLAGS, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, S as ASSETS, T as COLLECTION_APP_DATA_FILE_NAME, U as LOADER_BUNDLE, X as STYLE_EXT, Y as STATS, a as isBoolean$1, b as unique, c as isFunction, d as isObject, et as WATCH_FLAGS, f as isString$1, g as sortBy, i as fromEntries, l as isIterable, m as noop, p as mergeIntoWith, r as flatOne, t as dashToPascalCase, u as isNumber$1, v as toDashCase, w as COLLECTION, y as toTitleCase, z as GLOBAL_STYLE } from "./helpers-k8xQHE77.mjs";
4
+ import { C as isRootPath, D as byteSize, E as stringifyRuntimeData, O as escapeRegExpSpecialCharacters, S as splitLineBreaks, _ as createOnWarnFn, a as getRolldownSourceMapOptions, c as relativizeSourceMap, d as map, f as ok, g as loadTypeScriptDiagnostics, h as loadTypeScriptDiagnostic, i as getInlineSourceMappingUrlLinker, l as rolldownToStencilSourceMap, m as augmentDiagnosticWithNode, n as validateComponentTag, o as getSourceMappingUrlForEndOfFile, r as isRemoteUrl, t as validateComponentModes, u as err, v as isRolldownError, w as formatComponentRuntimeMeta, x as normalizeDiagnostics, y as loadRolldownDiagnostics } from "./validation-GfBzquhJ.mjs";
5
+ import { $ as buildWarn, A as isOutputTargetDocsVscode, B as isValidConfigOutputTarget, C as isOutputTargetDistLazy, D as isOutputTargetDocsCustomElementsManifest, E as isOutputTargetDocsCustom, F as isOutputTargetSsrWasm, G as normalizeFsPath, H as shouldExcludeComponent, I as isOutputTargetStandalone, J as relative$1, K as normalizeFsPathQuery, L as isOutputTargetStats, M as isOutputTargetLoaderBundle, N as isOutputTargetServerRenderer, O as isOutputTargetDocsJson, P as isOutputTargetSsr, Q as buildJsonFileError, R as isOutputTargetTypes, S as isOutputTargetCustom, T as isOutputTargetDocsAgentSkill, U as join$2, V as relativeImport, Y as resolve$2, Z as buildError, a as hasDependency, b as isOutputTargetCollection, d as parsePackageJson, et as catchError, f as readOnlyArrayHasStringMember, g as getComponentsDtsSrcFilePath, h as filterExcludedComponents, i as getTextDocs, it as isGlob, j as isOutputTargetGlobalStyle, k as isOutputTargetDocsReadme, l as isTsFile, m as filterActiveTargets, n as createJsVarName, nt as hasWarning, o as isDtsFile, p as readPackageJson, q as normalizePath, r as generatePreamble, t as addDocBlock, tt as hasError, u as isTsxFile, v as getComponentsFromModules, w as isOutputTargetDocs, x as isOutputTargetCopy, y as isOutputTargetAssets, z as isOutputTargetWww } from "./util-Cj2D3x_h.mjs";
6
+ import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-BR2GYgzY.mjs";
7
7
  import ts, { default as ts$1 } from "typescript";
8
8
  import { readFileSync } from "node:fs";
9
9
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -461,9 +461,9 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
461
461
  };
462
462
  //#endregion
463
463
  //#region src/version.ts
464
- const version = "5.0.0-rc.1";
465
- const buildId = "1794513770";
466
- const vermoji = "🌹";
464
+ const version = "5.0.0-rc.11";
465
+ const buildId = "1795624141";
466
+ const vermoji = "🚃";
467
467
  /**
468
468
  * Get the installed version of a tool/dependency.
469
469
  * Handles packages with exports maps that point to subdirectories.
@@ -1459,6 +1459,7 @@ const createCssOnlyComponentMeta = (def) => ({
1459
1459
  internal: false,
1460
1460
  isCollectionDependency: false,
1461
1461
  isPlain: false,
1462
+ isCssOnly: true,
1462
1463
  isUpdateable: false,
1463
1464
  jsFilePath: "",
1464
1465
  listeners: [],
@@ -1527,6 +1528,33 @@ const propertyToStyleDoc = (prop) => ({
1527
1528
  */
1528
1529
  const isJsDocComment = (commentText) => commentText.startsWith("*") || commentText.startsWith("!");
1529
1530
  /**
1531
+ * An explicit `@prop` annotation tag in a CSS docstring. `@cssprop`/`@cssproperty` are also
1532
+ * recognized as synonyms (the more common names in other web-component-analyzer/docgen
1533
+ * ecosystems).
1534
+ */
1535
+ const CSS_PROP_ANNOTATION_RE = /@(?:cssproperty|cssprop|prop)\b/;
1536
+ /**
1537
+ * An annotation tag that documents something by name (`@prop --x`, `@slot name`, ...) rather
1538
+ * than describing the node below its comment.
1539
+ */
1540
+ const CSS_ANNOTATION_TAG_RE = /@(?:component|cssproperty|cssprop|prop|attr|slot)\b/;
1541
+ const INTERNAL_TAG_RE = /@internal\b/;
1542
+ /**
1543
+ * Whether a comment marks the node immediately following it as internal - excluded from docs,
1544
+ * matching `@internal` on component members.
1545
+ * @param commentText a postcss `Comment` node's `.text`
1546
+ * @returns `true` if the comment is a JSDoc-style comment holding an `@internal` tag
1547
+ */
1548
+ const isInternalDocComment = (commentText) => isJsDocComment(commentText) && INTERNAL_TAG_RE.test(commentText);
1549
+ /**
1550
+ * Whether a comment describes the node immediately following it (a declaration, rule or
1551
+ * at-rule). A comment holding annotation tags documents the things it names instead, and an
1552
+ * `@internal` comment hides the node.
1553
+ * @param commentText a postcss `Comment` node's `.text`
1554
+ * @returns `true` if the comment is a JSDoc-style description of the next node
1555
+ */
1556
+ const isNodeDocComment = (commentText) => isJsDocComment(commentText) && !CSS_ANNOTATION_TAG_RE.test(commentText) && !INTERNAL_TAG_RE.test(commentText);
1557
+ /**
1530
1558
  * Strip the leading `*`/`!` marker and per-line `*` prefixes, returning trimmed lines.
1531
1559
  * @param commentText a postcss `Comment` node's `.text`
1532
1560
  * @returns the comment's lines, delimiters and leading `*`s stripped
@@ -1690,7 +1718,10 @@ const parseCssComponentFile = async (filePath, cssText) => {
1690
1718
  }
1691
1719
  }
1692
1720
  collectAttributeRuleDocs(rawRoot, (selector) => defs.get(selector.tag ?? ""), attributeRuleDocs);
1693
- for (const [def, docsByName] of attributeRuleDocs) for (const attr of def.attributes) if (attr.source === "auto") attr.docs = docsByName.get(attr.name) ?? attr.docs;
1721
+ for (const [def, docsByName] of attributeRuleDocs) {
1722
+ def.attributes = def.attributes.filter((attr) => attr.source !== "auto" || docsByName.get(attr.name) !== null);
1723
+ for (const attr of def.attributes) if (attr.source === "auto") attr.docs = docsByName.get(attr.name) ?? attr.docs;
1724
+ }
1694
1725
  for (const node of nodes) {
1695
1726
  if (node.type !== "rule") continue;
1696
1727
  for (const selector of parseSelectorList(node.selector)) {
@@ -1704,9 +1735,10 @@ const parseCssComponentFile = async (filePath, cssText) => {
1704
1735
  if (node.type !== "atrule" || node.name !== "property") continue;
1705
1736
  const propName = node.params.trim();
1706
1737
  if (!propName.startsWith("--")) continue;
1707
- const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
1708
1738
  const prev = nodes[i - 1];
1709
- const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1739
+ const isInternal = prev?.type === "comment" && isInternalDocComment(prev.text);
1740
+ const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
1741
+ const docs = prev && prev.type === "comment" && isNodeDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1710
1742
  for (const def of defs.values()) {
1711
1743
  const existing = def.properties.find((p) => p.name === propName);
1712
1744
  if (existing) {
@@ -1715,6 +1747,7 @@ const parseCssComponentFile = async (filePath, cssText) => {
1715
1747
  if (initialValue) existing.default ??= initialValue;
1716
1748
  continue;
1717
1749
  }
1750
+ if (isInternal) continue;
1718
1751
  const prop = {
1719
1752
  name: propName,
1720
1753
  docs,
@@ -1738,6 +1771,7 @@ const parseCssComponentFile = async (filePath, cssText) => {
1738
1771
  * @param def the CSS-only component definition the found slots belong to
1739
1772
  */
1740
1773
  const collectAutoDetectedSlots = (container, def) => {
1774
+ const internal = /* @__PURE__ */ new Set();
1741
1775
  for (const nested of container.nodes) {
1742
1776
  if (nested.type !== "rule") continue;
1743
1777
  const names = /* @__PURE__ */ new Set();
@@ -1748,10 +1782,15 @@ const collectAutoDetectedSlots = (container, def) => {
1748
1782
  } catch {
1749
1783
  continue;
1750
1784
  }
1785
+ const prev = nested.prev();
1786
+ const isInternal = prev?.type === "comment" && isInternalDocComment(prev.text);
1751
1787
  for (const name of names) {
1752
- if (def.slots.some((s) => s.name === name)) continue;
1753
- const prev = nested.prev();
1754
- const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1788
+ if (internal.has(name) || def.slots.some((s) => s.name === name)) continue;
1789
+ if (isInternal) {
1790
+ internal.add(name);
1791
+ continue;
1792
+ }
1793
+ const docs = prev && prev.type === "comment" && isNodeDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
1755
1794
  def.slots.push({
1756
1795
  name,
1757
1796
  docs,
@@ -1848,8 +1887,8 @@ const collectAutoDetectedAttributes = (selector, def) => {
1848
1887
  };
1849
1888
  /**
1850
1889
  * Record the JSDoc comment directly above each of `container`'s child rules as the description
1851
- * of the attributes in that rule's leading compound selector. The first documented rule for an
1852
- * attribute wins.
1890
+ * of the attributes in that rule's leading compound selector, or `null` for an `@internal`
1891
+ * comment. The first documented rule for an attribute wins.
1853
1892
  * @param container a container whose direct child rules to scan
1854
1893
  * @param defFor the component a child rule's selector belongs to, if any
1855
1894
  * @param out collected descriptions, per component, by attribute name
@@ -1857,14 +1896,16 @@ const collectAutoDetectedAttributes = (selector, def) => {
1857
1896
  const collectAttributeRuleDocs = (container, defFor, out) => {
1858
1897
  for (const node of container.nodes) {
1859
1898
  const prev = node.prev();
1860
- if (node.type !== "rule" || prev?.type !== "comment" || !isJsDocComment(prev.text)) continue;
1899
+ if (node.type !== "rule" || prev?.type !== "comment") continue;
1900
+ const isInternal = isInternalDocComment(prev.text);
1901
+ if (!isInternal && !isNodeDocComment(prev.text)) continue;
1861
1902
  let selectors;
1862
1903
  try {
1863
1904
  selectors = parseSelectorList(node.selector);
1864
1905
  } catch {
1865
1906
  continue;
1866
1907
  }
1867
- const docs = normalizeJsDocText(prev.text);
1908
+ const docs = isInternal ? null : normalizeJsDocText(prev.text);
1868
1909
  for (const selector of selectors) {
1869
1910
  const def = defFor(selector);
1870
1911
  if (!def) continue;
@@ -1887,7 +1928,7 @@ const collectAutoDetectedCustomProperties = (container, def) => {
1887
1928
  if (child.type !== "decl" || !child.prop.startsWith("--")) continue;
1888
1929
  if (def.properties.some((p) => p.name === child.prop)) continue;
1889
1930
  const prev = children[i - 1];
1890
- if (!prev || prev.type !== "comment" || !isJsDocComment(prev.text)) continue;
1931
+ if (!prev || prev.type !== "comment" || !isNodeDocComment(prev.text)) continue;
1891
1932
  def.properties.push({
1892
1933
  name: child.prop,
1893
1934
  docs: normalizeJsDocText(prev.text),
@@ -2065,28 +2106,40 @@ const scanFiles = async (config, compilerCtx, buildCtx, cache, filePaths) => {
2065
2106
  }));
2066
2107
  };
2067
2108
  /**
2068
- * Load a CSS-only component source file's text. A plain `.css` file is read as-is; any other
2069
- * `STYLE_EXT` extension is run through the configured `plugins` first (e.g. `@stencil/sass`
2070
- * compiling `.scss` to CSS) - the same pipeline `collectCssOnlyComponentStyles` uses to emit
2071
- * this file's CSS, so discovery parses exactly what gets shipped.
2109
+ * Load a CSS-only component source file's text. Only files whose raw source contains
2110
+ * `@component` are considered - a definition belongs to the file that literally contains it,
2111
+ * so preprocessor partials and importers are never compiled standalone here. A plain `.css`
2112
+ * file is returned as-is; any other `STYLE_EXT` extension is run through the configured
2113
+ * `plugins` first (e.g. `@stencil/sass` compiling `.scss` to CSS) - the same pipeline
2114
+ * `collectCssOnlyComponentStyles` uses to emit this file's CSS, so discovery parses exactly
2115
+ * what gets shipped.
2072
2116
  *
2073
2117
  * @param config the validated Stencil config
2074
2118
  * @param compilerCtx the compiler context, used to read the file and register watch files
2075
2119
  * @param buildCtx the current build context, used for plugin transform diagnostics
2076
2120
  * @param filePath absolute path to the source file to load
2077
- * @returns the (possibly preprocessed) CSS text, or `null` if the file couldn't be loaded
2121
+ * @returns the (possibly preprocessed) CSS text, or `null` if the file couldn't be loaded or
2122
+ * has no `@component` marker
2078
2123
  */
2079
2124
  const loadCssOnlyComponentSource = async (config, compilerCtx, buildCtx, filePath) => {
2080
- if (filePath.toLowerCase().endsWith(".css")) try {
2081
- return await compilerCtx.fs.readFile(filePath);
2125
+ let rawText;
2126
+ try {
2127
+ rawText = await compilerCtx.fs.readFile(filePath);
2082
2128
  } catch {
2083
2129
  return null;
2084
2130
  }
2131
+ if (!rawText.includes("@component")) return null;
2132
+ if (filePath.toLowerCase().endsWith(".css")) return rawText;
2085
2133
  const transformResults = await runPluginTransforms(config, compilerCtx, buildCtx, filePath);
2086
2134
  if (!transformResults) return null;
2087
- if (typeof transformResults === "string") return transformResults;
2088
- for (const dep of transformResults.dependencies ?? []) compilerCtx.addWatchFile(dep);
2089
- return transformResults.code ?? null;
2135
+ const code = typeof transformResults === "string" ? transformResults : transformResults.code;
2136
+ if (typeof transformResults !== "string") for (const dep of transformResults.dependencies ?? []) compilerCtx.addWatchFile(dep);
2137
+ if (code != null && !code.includes("@component")) {
2138
+ const warn = buildWarn(buildCtx.diagnostics);
2139
+ warn.messageText = `"${relative$1(config.rootDir, filePath)}" contains "@component" but its preprocessed output does not, so no CSS-only components were discovered in it. Is the preprocessor stripping comments (e.g. sass \`outputStyle: 'compressed'\`)?`;
2140
+ warn.absFilePath = filePath;
2141
+ }
2142
+ return code ?? null;
2090
2143
  };
2091
2144
  const flattenCache = (cache) => Array.from(cache.values()).flat();
2092
2145
  /**
@@ -7983,6 +8036,31 @@ const generateRolldownOutput = async (build, options, config, entryModules) => {
7983
8036
  });
7984
8037
  };
7985
8038
  //#endregion
8039
+ //#region src/compiler/output-targets/dist-lazy/cjs-import-meta-url-plugin.ts
8040
+ /**
8041
+ * With `platform: 'browser'` (shared with the ESM output), Rolldown renders `import.meta.url`
8042
+ * in CJS as `{}.url`. Replace it with the same expression Rolldown emits for `platform: 'node'`.
8043
+ */
8044
+ const EMPTY_IMPORT_META_URL = /\{\}\.url\b/g;
8045
+ const CJS_FILE_URL = `require("url").pathToFileURL(__filename).href`;
8046
+ /**
8047
+ * A Rolldown output plugin that restores `import.meta.url` in CJS chunks.
8048
+ * @param sourceMap whether to generate a source map for the replacement
8049
+ * @returns a Rolldown plugin
8050
+ */
8051
+ const cjsImportMetaUrlPlugin = (sourceMap) => ({
8052
+ name: "cjsImportMetaUrlPlugin",
8053
+ renderChunk(code) {
8054
+ if (!code.includes("{}.url")) return null;
8055
+ const s = new MagicString(code);
8056
+ s.replaceAll(EMPTY_IMPORT_META_URL, CJS_FILE_URL);
8057
+ return {
8058
+ code: s.toString(),
8059
+ map: sourceMap ? s.generateMap({ hires: true }) : null
8060
+ };
8061
+ }
8062
+ });
8063
+ //#endregion
7986
8064
  //#region src/compiler/output-targets/dist-lazy/write-lazy-entry-module.ts
7987
8065
  const writeLazyModule = async (compilerCtx, outputTargetType, destinations, code, sourceMap, rolldownResult) => {
7988
8066
  const fileName = rolldownResult.fileName;
@@ -8102,9 +8180,9 @@ const generateCaseClause = (bundleId) => {
8102
8180
  const generateCaseClauseCjs = (bundleId) => {
8103
8181
  return `
8104
8182
  case '${bundleId}':
8105
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
8183
+ return Promise.resolve().then(function () { return require(
8106
8184
  /* webpackMode: "lazy" */
8107
- './${bundleId}.entry.js')); }).then(onLoad, onError);`;
8185
+ './${bundleId}.entry.js'); }).then(onLoad, onError);`;
8108
8186
  };
8109
8187
  const generateLazyEntryModule = async (config, compilerCtx, buildCtx, rolldownResult, outputTargetType, destinations, sourceTarget, shouldMinify, isBrowserBuild) => {
8110
8188
  const entryModule = buildCtx.entryModules.find((em) => em.entryKey === rolldownResult.entryKey);
@@ -8325,7 +8403,7 @@ const generateCjs = async (config, compilerCtx, buildCtx, rolldownBuild, outputT
8325
8403
  entryFileNames: "[name].cjs",
8326
8404
  assetFileNames: "[name]-[hash][extname]",
8327
8405
  ...getRolldownSourceMapOptions(config),
8328
- plugins: [lazyBundleIdPlugin(buildCtx, config, false, 8, ".cjs")]
8406
+ plugins: [lazyBundleIdPlugin(buildCtx, config, false, 8, ".cjs"), cjsImportMetaUrlPlugin(!!config.sourceMap)]
8329
8407
  };
8330
8408
  if (config.compat.enableImportInjection) esmOpts.dynamicImportInCjs = false;
8331
8409
  const results = await generateRolldownOutput(rolldownBuild, esmOpts, config, buildCtx.entryModules);
@@ -8333,6 +8411,7 @@ const generateCjs = async (config, compilerCtx, buildCtx, rolldownBuild, outputT
8333
8411
  const destinations = cjsOutputs.map((o) => o.cjsDir).filter((cjsDir) => typeof cjsDir === "string");
8334
8412
  buildCtx.commonJsComponentBundle = await generateLazyModules(config, compilerCtx, buildCtx, outputTargetType, destinations, results, "es2022", false);
8335
8413
  await generateShortcuts$1(compilerCtx, results, cjsOutputs);
8414
+ await writeCjsPackageJson(compilerCtx, cjsOutputs);
8336
8415
  }
8337
8416
  }
8338
8417
  return {
@@ -8340,6 +8419,14 @@ const generateCjs = async (config, compilerCtx, buildCtx, rolldownBuild, outputT
8340
8419
  buildCtx
8341
8420
  };
8342
8421
  };
8422
+ /**
8423
+ * Chunks and lazy entries in the CJS dir keep a `.js` extension, so scope them as CommonJS
8424
+ * in case the consuming package sets `"type": "module"`.
8425
+ * @param compilerCtx the current compiler context
8426
+ * @param outputTargets the output targets with a CJS dir
8427
+ * @returns a promise that resolves once each `package.json` is written
8428
+ */
8429
+ const writeCjsPackageJson = (compilerCtx, outputTargets) => Promise.all(outputTargets.map((o) => compilerCtx.fs.writeFile(join$2(o.cjsDir, "package.json"), `{"type":"commonjs"}\n`, { outputTargetType: o.type })));
8343
8430
  const generateShortcuts$1 = (compilerCtx, rolldownResult, outputTargets) => {
8344
8431
  const indexFilename = rolldownResult.find((r) => r.type === "chunk" && r.isIndex).fileName;
8345
8432
  return Promise.all(outputTargets.map(async (o) => {
@@ -8922,8 +9009,57 @@ const ProgressTask = {
8922
9009
  const AUTO_GENERATE_COMMENT = `<!-- Auto Generated Below -->`;
8923
9010
  const NOTE = `*Built with [StencilJS](https://stenciljs.com/)*`;
8924
9011
  //#endregion
9012
+ //#region src/compiler/docs/jsdoc-links.ts
9013
+ /**
9014
+ * Matches JSDoc inline link tags that reference a URL, in the
9015
+ * `[label]{@link url}`, `{@link url|label}` or `{@link url label}` form.
9016
+ */
9017
+ const JSDOC_URL_LINK_REGEX = /(?:\[([^\]]*)\])?\{@link\s+(https?:\/\/[^\s|}]+)(?:\s*[|\s]\s*([^}]*?))?\s*\}/g;
9018
+ /**
9019
+ * Converts JSDoc inline link tags that reference a URL into markdown links.
9020
+ *
9021
+ * Documentation output targets (docs-readme, docs-json, docs-vscode) treat their
9022
+ * `docs` fields as markdown, so URL-based `{@link}` tags are converted so they
9023
+ * render as links.
9024
+ *
9025
+ * Symbol links like `{@link MyClass#foo}` are left untouched, since resolving them
9026
+ * to a URL would require type information the docs generators do not have.
9027
+ *
9028
+ * @param text the JSDoc text to convert
9029
+ * @returns the text with URL-based `{@link}` tags converted to markdown links
9030
+ */
9031
+ const convertJsdocLinksToMarkdown = (text) => {
9032
+ if (!text || !text.includes("{@link")) return text;
9033
+ return text.replace(JSDOC_URL_LINK_REGEX, (_match, prefixLabel, url, label) => {
9034
+ return `[${prefixLabel?.trim() || label?.trim() || url}](${url})`;
9035
+ });
9036
+ };
9037
+ /**
9038
+ * Converts URL-based `{@link}` tags in the text of JSDoc tag infos (e.g. the texts
9039
+ * behind `@deprecated` or `@returns`) into markdown links, so tag-derived docs
9040
+ * fields render as links too.
9041
+ * @param tags the JSDoc tag infos to convert
9042
+ * @returns new tag infos with URL-based `{@link}` tags converted to markdown links
9043
+ */
9044
+ const convertJsdocTagsToMarkdown = (tags) => {
9045
+ return tags.map((tag) => ({
9046
+ ...tag,
9047
+ text: convertJsdocLinksToMarkdown(tag.text)
9048
+ }));
9049
+ };
9050
+ //#endregion
8925
9051
  //#region src/compiler/docs/generate-doc-data.ts
8926
9052
  /**
9053
+ * Converts the text and tag texts of a component's JSDoc into markdown, so every
9054
+ * docs field derived from it renders URL-based `{@link}` tags as markdown links.
9055
+ * @param jsdoc the JSDoc to convert
9056
+ * @returns the converted JSDoc
9057
+ */
9058
+ const convertCompilerJsDoc = (jsdoc) => ({
9059
+ text: convertJsdocLinksToMarkdown(jsdoc.text),
9060
+ tags: convertJsdocTagsToMarkdown(jsdoc.tags)
9061
+ });
9062
+ /**
8927
9063
  * Generate metadata that will be used to generate any given documentation-related
8928
9064
  * output target(s)
8929
9065
  *
@@ -8974,32 +9110,35 @@ const getDocsComponents = async (config, compilerCtx, buildCtx) => {
8974
9110
  const usagesDir = normalizePath(join$2(dirPath, "usage"));
8975
9111
  const readme = await getUserReadmeContent(compilerCtx, readmePath);
8976
9112
  const usage = await generateUsages(compilerCtx, usagesDir);
8977
- return moduleFile.cmps.filter((cmp) => !cmp.internal && !cmp.isCollectionDependency).map((cmp) => ({
8978
- dirPath,
8979
- filePath: normalizePath(relative$1(config.rootDir, filePath), false),
8980
- fileName: basename$1(filePath),
8981
- readmePath,
8982
- usagesDir,
8983
- tag: cmp.tagName,
8984
- readme,
8985
- overview: cmp.docs.text,
8986
- usage,
8987
- docs: generateDocs(readme, cmp.docs),
8988
- docsTags: cmp.docs.tags,
8989
- encapsulation: getDocsEncapsulation(cmp),
8990
- dependents: cmp.directDependents,
8991
- dependencies: cmp.directDependencies,
8992
- dependencyGraph: buildDocsDepGraph(cmp, buildCtx.components),
8993
- deprecation: getDocsDeprecationText(cmp.docs.tags),
8994
- props: getDocsProperties(cmp),
8995
- methods: getDocsMethods(cmp.methods),
8996
- events: getDocsEvents(cmp.events),
8997
- styles: getDocsStyles(cmp),
8998
- slots: getDocsSlots(cmp.htmlSlots, cmp.docs.tags),
8999
- parts: getDocsParts(cmp.htmlParts, cmp.docs.tags),
9000
- customStates: getDocsCustomStates(cmp),
9001
- listeners: getDocsListeners(cmp.listeners)
9002
- }));
9113
+ return moduleFile.cmps.filter((cmp) => !cmp.internal && !cmp.isCollectionDependency).map((cmp) => {
9114
+ const docs = convertCompilerJsDoc(cmp.docs);
9115
+ return {
9116
+ dirPath,
9117
+ filePath: normalizePath(relative$1(config.rootDir, filePath), false),
9118
+ fileName: basename$1(filePath),
9119
+ readmePath,
9120
+ usagesDir,
9121
+ tag: cmp.tagName,
9122
+ readme,
9123
+ overview: docs.text,
9124
+ usage,
9125
+ docs: generateDocs(readme, docs),
9126
+ docsTags: docs.tags,
9127
+ encapsulation: getDocsEncapsulation(cmp),
9128
+ dependents: cmp.directDependents,
9129
+ dependencies: cmp.directDependencies,
9130
+ dependencyGraph: buildDocsDepGraph(cmp, buildCtx.components),
9131
+ deprecation: getDocsDeprecationText(docs.tags),
9132
+ props: getDocsProperties(cmp),
9133
+ methods: getDocsMethods(cmp.methods),
9134
+ events: getDocsEvents(cmp.events),
9135
+ styles: getDocsStyles(cmp),
9136
+ slots: getDocsSlots(cmp.htmlSlots, docs.tags),
9137
+ parts: getDocsParts(cmp.htmlParts, docs.tags),
9138
+ customStates: getDocsCustomStates(cmp),
9139
+ listeners: getDocsListeners(cmp.listeners)
9140
+ };
9141
+ });
9003
9142
  }));
9004
9143
  return sortBy(flatOne(results), (cmp) => cmp.tag);
9005
9144
  };
@@ -9017,6 +9156,7 @@ const getCssOnlyDocsComponents = async (config, compilerCtx, buildCtx) => {
9017
9156
  const usagesDir = normalizePath(join$2(dirPath, "usage"));
9018
9157
  const readme = await getUserReadmeContent(compilerCtx, readmePath);
9019
9158
  const usage = await generateUsages(compilerCtx, usagesDir);
9159
+ const docs = convertCompilerJsDoc(cmp.docs);
9020
9160
  return {
9021
9161
  dirPath,
9022
9162
  filePath: normalizePath(relative$1(config.rootDir, filePath), false),
@@ -9025,21 +9165,21 @@ const getCssOnlyDocsComponents = async (config, compilerCtx, buildCtx) => {
9025
9165
  usagesDir,
9026
9166
  tag: cmp.tagName,
9027
9167
  readme,
9028
- overview: cmp.docs.text,
9168
+ overview: docs.text,
9029
9169
  usage,
9030
- docs: generateDocs(readme, cmp.docs),
9031
- docsTags: cmp.docs.tags,
9170
+ docs: generateDocs(readme, docs),
9171
+ docsTags: docs.tags,
9032
9172
  encapsulation: getDocsEncapsulation(cmp),
9033
9173
  dependents: cmp.directDependents,
9034
9174
  dependencies: cmp.directDependencies,
9035
9175
  dependencyGraph: buildDocsDepGraph(cmp, buildCtx.components),
9036
- deprecation: getDocsDeprecationText(cmp.docs.tags),
9176
+ deprecation: getDocsDeprecationText(docs.tags),
9037
9177
  props: getDocsProperties(cmp),
9038
9178
  methods: getDocsMethods(cmp.methods),
9039
9179
  events: getDocsEvents(cmp.events),
9040
9180
  styles: getDocsStyles(cmp),
9041
- slots: getDocsSlots(cmp.htmlSlots, cmp.docs.tags),
9042
- parts: getDocsParts(cmp.htmlParts, cmp.docs.tags),
9181
+ slots: getDocsSlots(cmp.htmlSlots, docs.tags),
9182
+ parts: getDocsParts(cmp.htmlParts, docs.tags),
9043
9183
  customStates: getDocsCustomStates(cmp),
9044
9184
  listeners: getDocsListeners(cmp.listeners),
9045
9185
  cssOnly: true
@@ -9089,23 +9229,26 @@ const getDocsProperties = (cmpMeta) => {
9089
9229
  * @returns the derived metadata
9090
9230
  */
9091
9231
  const getRealProperties = (properties) => {
9092
- return properties.filter((member) => !member.internal).map((member) => ({
9093
- name: member.name,
9094
- type: member.complexType.resolved,
9095
- complexType: member.complexType,
9096
- mutable: member.mutable,
9097
- attr: member.attribute,
9098
- reflectToAttr: !!member.reflect,
9099
- docs: member.docs.text,
9100
- docsTags: member.docs.tags,
9101
- default: member.defaultValue,
9102
- deprecation: getDocsDeprecationText(member.docs.tags),
9103
- values: parseTypeIntoValues(member.complexType.resolved),
9104
- optional: member.optional,
9105
- required: member.required,
9106
- getter: member.getter,
9107
- setter: member.setter
9108
- }));
9232
+ return properties.filter((member) => !member.internal).map((member) => {
9233
+ const docs = convertCompilerJsDoc(member.docs);
9234
+ return {
9235
+ name: member.name,
9236
+ type: member.complexType.resolved,
9237
+ complexType: member.complexType,
9238
+ mutable: member.mutable,
9239
+ attr: member.attribute,
9240
+ reflectToAttr: !!member.reflect,
9241
+ docs: docs.text,
9242
+ docsTags: docs.tags,
9243
+ default: member.defaultValue,
9244
+ deprecation: getDocsDeprecationText(docs.tags),
9245
+ values: parseTypeIntoValues(member.complexType.resolved),
9246
+ optional: member.optional,
9247
+ required: member.required,
9248
+ getter: member.getter,
9249
+ setter: member.setter
9250
+ };
9251
+ });
9109
9252
  };
9110
9253
  /**
9111
9254
  * Generate a collection of JSDoc metadata for props on a component
@@ -9119,7 +9262,7 @@ const getVirtualProperties = (virtualProps) => {
9119
9262
  mutable: false,
9120
9263
  attr: member.name,
9121
9264
  reflectToAttr: false,
9122
- docs: member.docs,
9265
+ docs: convertJsdocLinksToMarkdown(member.docs),
9123
9266
  docsTags: [],
9124
9267
  default: void 0,
9125
9268
  deprecation: void 0,
@@ -9170,32 +9313,38 @@ const parseTypeIntoValues = (type) => {
9170
9313
  return [];
9171
9314
  };
9172
9315
  const getDocsMethods = (methods) => {
9173
- return sortBy(methods, (member) => member.name).filter((member) => !member.internal).map((member) => ({
9174
- name: member.name,
9175
- returns: {
9176
- type: member.complexType.return,
9177
- docs: member.docs.tags.filter((t) => t.name === "return" || t.name === "returns").map((t) => t.text).join("\n")
9178
- },
9179
- complexType: member.complexType,
9180
- signature: `${member.name}${member.complexType.signature}`,
9181
- parameters: member.complexType.parameters,
9182
- docs: member.docs.text,
9183
- docsTags: member.docs.tags,
9184
- deprecation: getDocsDeprecationText(member.docs.tags)
9185
- }));
9316
+ return sortBy(methods, (member) => member.name).filter((member) => !member.internal).map((member) => {
9317
+ const docs = convertCompilerJsDoc(member.docs);
9318
+ return {
9319
+ name: member.name,
9320
+ returns: {
9321
+ type: member.complexType.return,
9322
+ docs: docs.tags.filter((t) => t.name === "return" || t.name === "returns").map((t) => t.text).join("\n")
9323
+ },
9324
+ complexType: member.complexType,
9325
+ signature: `${member.name}${member.complexType.signature}`,
9326
+ parameters: member.complexType.parameters,
9327
+ docs: docs.text,
9328
+ docsTags: docs.tags,
9329
+ deprecation: getDocsDeprecationText(docs.tags)
9330
+ };
9331
+ });
9186
9332
  };
9187
9333
  const getDocsEvents = (events) => {
9188
- return sortBy(events, (eventMeta) => eventMeta.name.toLowerCase()).filter((eventMeta) => !eventMeta.internal).map((eventMeta) => ({
9189
- event: eventMeta.name,
9190
- detail: eventMeta.complexType.resolved,
9191
- bubbles: eventMeta.bubbles,
9192
- complexType: eventMeta.complexType,
9193
- cancelable: eventMeta.cancelable,
9194
- composed: eventMeta.composed,
9195
- docs: eventMeta.docs.text,
9196
- docsTags: eventMeta.docs.tags,
9197
- deprecation: getDocsDeprecationText(eventMeta.docs.tags)
9198
- }));
9334
+ return sortBy(events, (eventMeta) => eventMeta.name.toLowerCase()).filter((eventMeta) => !eventMeta.internal).map((eventMeta) => {
9335
+ const docs = convertCompilerJsDoc(eventMeta.docs);
9336
+ return {
9337
+ event: eventMeta.name,
9338
+ detail: eventMeta.complexType.resolved,
9339
+ bubbles: eventMeta.bubbles,
9340
+ complexType: eventMeta.complexType,
9341
+ cancelable: eventMeta.cancelable,
9342
+ composed: eventMeta.composed,
9343
+ docs: docs.text,
9344
+ docsTags: docs.tags,
9345
+ deprecation: getDocsDeprecationText(docs.tags)
9346
+ };
9347
+ });
9199
9348
  };
9200
9349
  /**
9201
9350
  * Transforms the {@link d.StyleDoc} metadata for a component into a {@link d.JsonDocsStyle}, providing sensible
@@ -9209,7 +9358,7 @@ const getDocsStyles = (cmpMeta) => {
9209
9358
  return {
9210
9359
  name: compilerStyleDoc.name,
9211
9360
  annotation: compilerStyleDoc.annotation || "",
9212
- docs: compilerStyleDoc.docs || "",
9361
+ docs: convertJsdocLinksToMarkdown(compilerStyleDoc.docs || ""),
9213
9362
  mode: compilerStyleDoc.mode && compilerStyleDoc.mode !== "$" ? compilerStyleDoc.mode : void 0,
9214
9363
  ...compilerStyleDoc.syntax && { syntax: compilerStyleDoc.syntax },
9215
9364
  ...compilerStyleDoc.default && { default: compilerStyleDoc.default }
@@ -9268,7 +9417,7 @@ const getDocsCustomStates = (cmpMeta) => {
9268
9417
  return sortBy(cmpMeta.attachInternalsCustomStates.map((state) => ({
9269
9418
  name: state.name,
9270
9419
  initialValue: state.initialValue,
9271
- docs: state.docs || ""
9420
+ docs: convertJsdocLinksToMarkdown(state.docs || "")
9272
9421
  })), (state) => state.name);
9273
9422
  };
9274
9423
  /**
@@ -9285,10 +9434,10 @@ const getDocsCustomStates = (cmpMeta) => {
9285
9434
  const cmpMetaToDocsComponent = (cmp, filePath, rootDir = process.cwd()) => {
9286
9435
  const normalizedFilePath = normalizePath(filePath);
9287
9436
  const dirPath = normalizePath(dirname$1(normalizedFilePath));
9288
- const docs = cmp.docs ?? {
9437
+ const docs = convertCompilerJsDoc(cmp.docs ?? {
9289
9438
  text: "",
9290
9439
  tags: []
9291
- };
9440
+ });
9292
9441
  return {
9293
9442
  dirPath,
9294
9443
  filePath: normalizePath(relative$1(rootDir, normalizedFilePath), false),
@@ -11296,8 +11445,8 @@ const generateComponentTypes = (cmp, typeImportData, areTypesInternal, signalBac
11296
11445
  ...eventAttributes,
11297
11446
  ...formAssociatedAttrs
11298
11447
  ], true, areTypesInternal);
11299
- const elementInterface = hasMethodConflicts ? generateElementInterfaceWithConflictResolution(htmlElementName, tagNameAsPascal, conflictingMethods, htmlElementEventListenerProperties, cmp.docs) : generateStandardElementInterface(htmlElementName, tagNameAsPascal, htmlElementEventListenerProperties, cmp.docs);
11300
- if (signalBacking && cmp.properties.length > 0) {
11448
+ const elementInterface = cmp.isCssOnly ? [addDocBlock(` interface ${htmlElementName} extends HTMLElement {`, cmp.docs, 4), ` }`] : hasMethodConflicts ? generateElementInterfaceWithConflictResolution(htmlElementName, tagNameAsPascal, conflictingMethods, htmlElementEventListenerProperties, cmp.docs) : generateStandardElementInterface(htmlElementName, tagNameAsPascal, htmlElementEventListenerProperties, cmp.docs);
11449
+ if (signalBacking && !cmp.isCssOnly && cmp.properties.length > 0) {
11301
11450
  const signalsPropNames = (areTypesInternal ? cmp.properties : cmp.properties.filter((p) => !p.internal)).map((p) => `"${p.name}"`).join(" | ");
11302
11451
  if (signalsPropNames) elementInterface.splice(-1, 0, ` readonly [STENCIL_SIGNALS_SYMBOL]?: ReadonlyMap<${signalsPropNames}, ReadonlySignal<unknown>>;`);
11303
11452
  }
@@ -14401,7 +14550,7 @@ const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => {
14401
14550
  const conditionals = getStandaloneBuildConditionals(config, buildCtx.components);
14402
14551
  mergeCollectionBuildFlags(conditionals, compilerCtx.collections);
14403
14552
  return {
14404
- id: "customElements",
14553
+ id: `customElements-${outputTarget.customElementsExportBehavior ?? "default"}`,
14405
14554
  platform: "client",
14406
14555
  conditionals,
14407
14556
  customBeforeTransformers: getCustomBeforeTransformers(config, compilerCtx, buildCtx.components, outputTarget, buildCtx),
@@ -18821,6 +18970,7 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
18821
18970
  hasSignalsImport: false,
18822
18971
  hasWatchCallback: false,
18823
18972
  isPlain: false,
18973
+ isCssOnly: false,
18824
18974
  htmlAttrNames: [],
18825
18975
  htmlTagNames: [],
18826
18976
  htmlParts: [],
@@ -20474,7 +20624,7 @@ const validateFilesField = async (config, compilerCtx, buildCtx) => {
20474
20624
  const packageJsonDir = dirname$1(config.packageJsonFilePath);
20475
20625
  const absPath = join$2(packageJsonDir, pkgFile);
20476
20626
  if (!await compilerCtx.fs.access(absPath)) {
20477
- const msg = `Unable to find "${pkgFile}" within the package.json "files" array.`;
20627
+ const msg = `"${pkgFile}" is listed in the package.json "files" array but could not be found on disk.`;
20478
20628
  packageJsonError(config, compilerCtx, buildCtx, msg, `"${pkgFile}"`);
20479
20629
  }
20480
20630
  }
@@ -23867,6 +24017,7 @@ const autoprefixCss = async (cssText, opts, filePath, minify = false) => {
23867
24017
  };
23868
24018
  if (typeof e.name === "string") diagnostic.header = e.name;
23869
24019
  if (typeof e.message === "string") diagnostic.messageText = e.message;
24020
+ if (e.data?.type === "SelectorError" && e.loc && typeof e.loc.line === "number") diagnostic.messageText = getSelectorErrorMessage(typeof e.source === "string" ? e.source : cssText, e.loc, diagnostic.messageText, e.data.value?.type);
23870
24021
  if (filePath) diagnostic.absFilePath = filePath;
23871
24022
  else if (typeof e.fileName === "string" && e.fileName !== "style.css") diagnostic.absFilePath = e.fileName;
23872
24023
  if (e.loc && typeof e.loc.line === "number") {
@@ -23896,6 +24047,25 @@ const autoprefixCss = async (cssText, opts, filePath, minify = false) => {
23896
24047
  return output;
23897
24048
  };
23898
24049
  /**
24050
+ * Lightning CSS selector errors (e.g. `Invalid state`) don't name the selector, and for
24051
+ * preprocessed styles the reported line is in the compiled CSS, not the source file.
24052
+ * @param sourceText the CSS that failed to parse
24053
+ * @param loc the 1-based error location reported by Lightning CSS
24054
+ * @param loc.line the error line
24055
+ * @param loc.column the error column
24056
+ * @param message the original error message
24057
+ * @param errorType the Lightning CSS selector error type
24058
+ * @returns a message that includes the offending selector
24059
+ */
24060
+ const getSelectorErrorMessage = (sourceText, loc, message, errorType) => {
24061
+ const offset = sourceText.split("\n").slice(0, loc.line - 1).reduce((acc, line) => acc + line.length + 1, 0) + (loc.column ?? 1) - 1;
24062
+ const start = Math.max(sourceText.lastIndexOf("{", offset), sourceText.lastIndexOf("}", offset), sourceText.lastIndexOf(";", offset));
24063
+ const end = sourceText.indexOf("{", offset);
24064
+ const selector = sourceText.slice(start + 1, end === -1 ? void 0 : end).trim();
24065
+ if (!selector) return message;
24066
+ return `Invalid CSS selector "${selector}": ${message}.${errorType === "InvalidState" ? ` A pseudo-class can't follow a pseudo-element (e.g. \`::before:dir(rtl)\`); move it before (\`:dir(rtl)::before\`).` : ""}`;
24067
+ };
24068
+ /**
23899
24069
  * Default browserslist targets used when autoprefixing CSS.
23900
24070
  * Targets ES2017 browsers (2022+) only.
23901
24071
  */
@@ -25344,7 +25514,7 @@ function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsul
25344
25514
  const child = children[i];
25345
25515
  if (child.type !== "decl" || !child.prop.startsWith("--") || hasName(child.prop)) continue;
25346
25516
  const prev = children[i - 1];
25347
- if (!prev || prev.type !== "comment" || !isJsDocComment(prev.text)) continue;
25517
+ if (!prev || prev.type !== "comment" || !isNodeDocComment(prev.text)) continue;
25348
25518
  styleDocs.push({
25349
25519
  name: child.prop,
25350
25520
  docs: normalizeJsDocText(prev.text),
@@ -25356,9 +25526,10 @@ function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsul
25356
25526
  root.walkAtRules("property", (node) => {
25357
25527
  const propName = node.params.trim();
25358
25528
  if (!propName.startsWith("--")) return;
25359
- const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
25360
25529
  const prev = node.prev();
25361
- const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
25530
+ const isInternal = prev?.type === "comment" && isInternalDocComment(prev.text);
25531
+ const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
25532
+ const docs = prev && prev.type === "comment" && isNodeDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
25362
25533
  const existing = styleDocs.find((styleDoc) => styleDoc.name === propName);
25363
25534
  if (existing) {
25364
25535
  existing.docs ||= docs;
@@ -25366,6 +25537,7 @@ function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsul
25366
25537
  if (initialValue) existing.default ??= initialValue;
25367
25538
  return;
25368
25539
  }
25540
+ if (isInternal) return;
25369
25541
  styleDocs.push({
25370
25542
  name: propName,
25371
25543
  docs,
@@ -25411,12 +25583,6 @@ const CSS_DOC_START = /\/\*(\*|!)/;
25411
25583
  * Closing syntax for a CSS docstring
25412
25584
  */
25413
25585
  const CSS_DOC_END = "*/";
25414
- /**
25415
- * The `@prop` annotation we support within CSS docstrings. `@cssprop`/`@cssproperty` are also
25416
- * recognized as synonyms (the more common names in other web-component-analyzer/docgen
25417
- * ecosystems).
25418
- */
25419
- const CSS_PROP_ANNOTATION_RE = /@(?:cssproperty|cssprop|prop)\b/;
25420
25586
  //#endregion
25421
25587
  //#region src/compiler/style/css-to-esm.ts
25422
25588
  /**
@@ -27100,8 +27266,27 @@ const transpileModule = (config, input, transformOpts) => {
27100
27266
  if (tsCompilerOptions.jsx != null && !isAutomaticRuntime && !isString$1(tsCompilerOptions.jsxFragmentFactory)) tsCompilerOptions.jsxFragmentFactory = "Fragment";
27101
27267
  if (tsCompilerOptions.paths && !isString$1(tsCompilerOptions.baseUrl)) tsCompilerOptions.baseUrl = ".";
27102
27268
  const sourceFile = ts.createSourceFile(sourceFilePath, input, tsCompilerOptions.target);
27103
- const program = ts.createProgram([sourceFilePath], tsCompilerOptions, {
27104
- getSourceFile: (fileName) => normalizePath(fileName) === normalizePath(sourceFilePath) ? sourceFile : void 0,
27269
+ const importedSources = /* @__PURE__ */ new Map();
27270
+ const resolveImport = input.includes("resolveVar(") ? transformOpts.resolveImport : void 0;
27271
+ const resolveViaCallback = (specifier, containingFile) => {
27272
+ let resolved = null;
27273
+ try {
27274
+ resolved = resolveImport(specifier, containingFile, { kind: "type-info" });
27275
+ } catch {}
27276
+ if (!resolved) return void 0;
27277
+ const extension = getResolvedExtension(resolved.path);
27278
+ if (!extension) return void 0;
27279
+ const resolvedFileName = normalizePath(resolved.path.split("?")[0]);
27280
+ if (resolvedFileName !== normalizePath(sourceFilePath) && !importedSources.has(resolvedFileName)) importedSources.set(resolvedFileName, ts.createSourceFile(resolvedFileName, resolved.code, tsCompilerOptions.target, true));
27281
+ return {
27282
+ resolvedFileName,
27283
+ extension,
27284
+ isExternalLibraryImport: false
27285
+ };
27286
+ };
27287
+ if (resolveImport) tsCompilerOptions.noResolve = false;
27288
+ const compilerHost = {
27289
+ getSourceFile: (fileName) => normalizePath(fileName) === normalizePath(sourceFilePath) ? sourceFile : importedSources.get(normalizePath(fileName)),
27105
27290
  writeFile: (name, text) => {
27106
27291
  if (name.endsWith(".js.map") || name.endsWith(".mjs.map")) results.map = text;
27107
27292
  else if (name.endsWith(".js") || name.endsWith(".mjs")) results.code = text;
@@ -27111,11 +27296,13 @@ const transpileModule = (config, input, transformOpts) => {
27111
27296
  getCanonicalFileName: (fileName) => fileName,
27112
27297
  getCurrentDirectory: () => transformOpts.currentDirectory || (typeof process !== "undefined" ? process.cwd() : "/"),
27113
27298
  getNewLine: () => ts.sys && ts.sys.newLine || "\n",
27114
- fileExists: (fileName) => normalizePath(fileName) === normalizePath(sourceFilePath),
27299
+ fileExists: (fileName) => normalizePath(fileName) === normalizePath(sourceFilePath) || importedSources.has(normalizePath(fileName)),
27115
27300
  readFile: () => "",
27116
27301
  directoryExists: () => true,
27117
- getDirectories: () => []
27118
- });
27302
+ getDirectories: () => [],
27303
+ ...resolveImport ? { resolveModuleNameLiterals: (moduleLiterals, containingFile) => moduleLiterals.map((literal) => ({ resolvedModule: resolveViaCallback(literal.text, containingFile) })) } : {}
27304
+ };
27305
+ const program = ts.createProgram([sourceFilePath], tsCompilerOptions, compilerHost);
27119
27306
  const typeChecker = program.getTypeChecker();
27120
27307
  const transformers = {
27121
27308
  before: [
@@ -27132,18 +27319,36 @@ const transpileModule = (config, input, transformOpts) => {
27132
27319
  }
27133
27320
  if (transformOpts.componentExport === "customelement" || transformOpts.componentExport === "module") transformers.after.push(nativeComponentTransform(compilerCtx, transformOpts, buildCtx));
27134
27321
  else transformers.after.push(lazyComponentTransform(compilerCtx, transformOpts, buildCtx));
27135
- program.emit(void 0, void 0, void 0, false, transformers);
27322
+ program.emit(sourceFile, void 0, void 0, false, transformers);
27136
27323
  if (transformOpts.buildOverrides && results.code) {
27137
27324
  const mutations = Object.entries(transformOpts.buildOverrides).filter(([, v]) => v !== void 0).map(([k, v]) => `__stencilBUILD.${k}=${v};`).join("");
27138
27325
  if (mutations) results.code = `import{BUILD as __stencilBUILD}from"${STENCIL_APP_DATA_ID}";\n${mutations}\n` + results.code;
27139
27326
  }
27140
- const tsDiagnostics = [...program.getSyntacticDiagnostics()];
27327
+ const tsDiagnostics = [...program.getSyntacticDiagnostics(sourceFile)];
27141
27328
  if (config.validateTypes) tsDiagnostics.push(...program.getOptionsDiagnostics());
27142
27329
  buildCtx.diagnostics.push(...loadTypeScriptDiagnostics(tsDiagnostics));
27143
27330
  results.diagnostics.push(...buildCtx.diagnostics);
27144
27331
  results.moduleFile = compilerCtx.moduleMap.get(results.sourceFilePath);
27145
27332
  return results;
27146
27333
  };
27334
+ /**
27335
+ * Maps a `resolveImport` result path to the TypeScript extension the program should parse it
27336
+ * as. Only TypeScript sources are taken - `noLib`/no `allowJs` means anything else would be
27337
+ * dropped by the program anyway, so it stays unresolved exactly as it did before.
27338
+ *
27339
+ * @param path the resolved path returned by the `resolveImport` callback
27340
+ * @returns the matching `ts.Extension`, or `undefined` if the file can't add type info
27341
+ */
27342
+ const getResolvedExtension = (path) => {
27343
+ const bare = path.split("?")[0];
27344
+ if (bare.endsWith(".d.ts")) return ts.Extension.Dts;
27345
+ if (bare.endsWith(".d.mts")) return ts.Extension.Dmts;
27346
+ if (bare.endsWith(".d.cts")) return ts.Extension.Dcts;
27347
+ if (bare.endsWith(".tsx")) return ts.Extension.Tsx;
27348
+ if (bare.endsWith(".mts")) return ts.Extension.Mts;
27349
+ if (bare.endsWith(".cts")) return ts.Extension.Cts;
27350
+ if (bare.endsWith(".ts")) return ts.Extension.Ts;
27351
+ };
27147
27352
  const getScriptTargetKind = (transformOpts) => {
27148
27353
  const target = transformOpts.target && transformOpts.target.toUpperCase();
27149
27354
  if (isNumber$1(ts.ScriptTarget[target])) return ts.ScriptTarget[target];