@mui/internal-docs-infra 0.13.1-canary.22 → 0.13.1-canary.24

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.
Files changed (25) hide show
  1. package/package.json +3 -3
  2. package/pipeline/loadServerTypesMeta/builtInTypes.d.mts +1 -1
  3. package/pipeline/loadServerTypesMeta/constantGroups.d.mts +1 -1
  4. package/pipeline/loadServerTypesMeta/constantGroups.mjs +8 -2
  5. package/pipeline/loadServerTypesMeta/constants.d.mts +1 -1
  6. package/pipeline/loadServerTypesMeta/createOptimizedProgram.mjs +0 -1
  7. package/pipeline/loadServerTypesMeta/externalTypes.d.mts +1 -1
  8. package/pipeline/loadServerTypesMeta/format.d.mts +1 -1
  9. package/pipeline/loadServerTypesMeta/formatClass.d.mts +1 -1
  10. package/pipeline/loadServerTypesMeta/formatComponent.d.mts +1 -1
  11. package/pipeline/loadServerTypesMeta/formatFunction.d.mts +1 -1
  12. package/pipeline/loadServerTypesMeta/formatHook.d.mts +1 -1
  13. package/pipeline/loadServerTypesMeta/formatRaw.d.mts +1 -1
  14. package/pipeline/loadServerTypesMeta/formatType.d.mts +1 -1
  15. package/pipeline/loadServerTypesMeta/inheritedExternalProps.d.mts +1 -1
  16. package/pipeline/loadServerTypesMeta/inheritedExternalProps.mjs +1 -1
  17. package/pipeline/loadServerTypesMeta/loadTypescriptConfig.d.mts +4 -0
  18. package/pipeline/loadServerTypesMeta/loadTypescriptConfig.mjs +41 -76
  19. package/pipeline/loadServerTypesMeta/parseTestSources.d.mts +1 -1
  20. package/pipeline/loadServerTypesMeta/parseTestSources.mjs +1 -1
  21. package/pipeline/loadServerTypesMeta/processTypes.d.mts +1 -1
  22. package/pipeline/loadServerTypesMeta/processTypes.mjs +1 -1
  23. package/pipeline/loadServerTypesMeta/rewriteTypes.d.mts +1 -1
  24. package/pipeline/loadServerTypesMeta/templateLiteral.d.mts +1 -1
  25. package/pipeline/loadServerTypesMeta/typeGuards.d.mts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.13.1-canary.22",
3
+ "version": "0.13.1-canary.24",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "license": "MIT",
@@ -33,6 +33,7 @@
33
33
  "@csstools/postcss-light-dark-function": "^3.0.7",
34
34
  "@csstools/postcss-relative-color-syntax": "^4.0.15",
35
35
  "@csstools/postcss-stepped-value-functions": "^5.0.9",
36
+ "@mui/internal-typescript-api-extractor": "0.1.1-canary.0",
36
37
  "@orama/orama": "^3.1.18",
37
38
  "@orama/plugin-qps": "^3.1.18",
38
39
  "@orama/stemmers": "^3.1.18",
@@ -64,7 +65,6 @@
64
65
  "remark-typography": "^0.8.10",
65
66
  "sucrase": "^3.35.1",
66
67
  "typescript": "npm:@typescript/typescript6@6.0.2",
67
- "typescript-api-extractor": "1.0.0-beta.7",
68
68
  "uint8-to-base64": "^0.2.1",
69
69
  "unified": "^11.0.5",
70
70
  "unist-util-visit": "^5.1.0",
@@ -813,5 +813,5 @@
813
813
  "bin": {
814
814
  "docs-infra": "./cli/index.mjs"
815
815
  },
816
- "gitSha": "80d3ec0d49901ddda4af788aeb3b1b51e21c07cc"
816
+ "gitSha": "a60bc3c76a3193bef52588d5c28a818dbf7c4fb7"
817
817
  }
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  /**
3
3
  * Checks if a type name belongs to a built-in namespace.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import type * as tae from 'typescript-api-extractor';
2
+ import type * as tae from '@mui/internal-typescript-api-extractor';
3
3
  /** Which of a component's tables a constant group holds. */
4
4
  export type ConstantGroupKind = 'dataAttributes' | 'cssVariables';
5
5
  export interface ConstantGroupTarget {
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { EnumMember, EnumNode, ExportNode, TypeName } from 'typescript-api-extractor';
2
+ import { EnumMember, EnumNode, ExportNode, TypeName } from '@mui/internal-typescript-api-extractor';
3
3
  import { formatPropertyComment } from "./formatType.mjs";
4
4
  import { isComponentType, isEnumType } from "./typeGuards.mjs";
5
5
 
@@ -119,7 +119,13 @@ export function foldConstantNamespaces(exports, namespaces) {
119
119
  if (!members) {
120
120
  members = [];
121
121
  groups.set(namespace, members);
122
- folded.push(new ExportNode(namespace, new EnumNode(new TypeName(namespace), members, undefined), undefined));
122
+ folded.push(new ExportNode(namespace, new EnumNode(new TypeName(namespace), members, undefined), undefined,
123
+ // `export * as X` binds a module namespace object.
124
+ {
125
+ isValue: true,
126
+ isType: false,
127
+ isNamespace: true
128
+ }));
123
129
  }
124
130
  // Typed as a string, but the parser stores numeric enum values as numbers too; do
125
131
  // the same so both forms render alike.
@@ -1,4 +1,4 @@
1
- import type { ParserOptions } from 'typescript-api-extractor';
1
+ import type { ParserOptions } from '@mui/internal-typescript-api-extractor';
2
2
  /**
3
3
  * Extraction policy the pipeline hands to `typescript-api-extractor`.
4
4
  *
@@ -303,7 +303,6 @@ function getOrCreateLanguageService(projectPath, compilerOptions) {
303
303
  // Create optimized compiler options
304
304
  const optimizedOptions = {
305
305
  ...compilerOptions,
306
- baseUrl: compilerOptions.baseUrl || projectPath,
307
306
  rootDir: compilerOptions.rootDir || projectPath,
308
307
  types: compilerOptions.types || [],
309
308
  skipLibCheck: true
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  /**
3
3
  * Metadata for an external type discovered during formatting.
4
4
  * These are types referenced in props/params that are not publicly exported,
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  import type { Root as HastRoot } from 'hast';
3
3
  import type { ExternalTypesCollector } from "./externalTypes.mjs";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  import type { FormattedParameter, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
3
3
  import type { TypeRewriteContext } from "./rewriteTypes.mjs";
4
4
  import type { ExternalTypesCollector } from "./externalTypes.mjs";
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  import type { FormattedProperty, FormattedEnumMember, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
3
3
  import type { ComponentConstantGroups } from "./constantGroups.mjs";
4
4
  import type { TypeRewriteContext } from "./rewriteTypes.mjs";
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  import type { FormattedParameter, FormattedProperty, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
3
3
  import type { TypeRewriteContext } from "./rewriteTypes.mjs";
4
4
  import type { ExternalTypesCollector } from "./externalTypes.mjs";
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  import type { FormattedProperty, FormattedParameter, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
3
3
  import type { TypeRewriteContext } from "./rewriteTypes.mjs";
4
4
  import type { ExternalTypesCollector } from "./externalTypes.mjs";
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  import type { FormattedProperty, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
3
3
  import type { ConstantGroupTarget } from "./constantGroups.mjs";
4
4
  import type { TypeRewriteContext } from "./rewriteTypes.mjs";
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  import type { ExternalTypesCollector } from "./externalTypes.mjs";
3
3
  export interface FormatTypeOptions {
4
4
  removeUndefined?: boolean;
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import type { ExportNode } from 'typescript-api-extractor';
2
+ import type { ExportNode } from '@mui/internal-typescript-api-extractor';
3
3
  /**
4
4
  * Props to re-include for a single externally declared type. Either a list of
5
5
  * prop names, or an object that additionally pins the package the type must be
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { CallSignature, Documentation, ExternalTypeNode, FunctionNode, IntrinsicNode, LiteralNode, Parameter, PropertyNode, TypeName, UnionNode } from 'typescript-api-extractor';
2
+ import { CallSignature, Documentation, ExternalTypeNode, FunctionNode, IntrinsicNode, LiteralNode, Parameter, PropertyNode, TypeName, UnionNode } from '@mui/internal-typescript-api-extractor';
3
3
  import { isComponentType, isObjectType } from "./typeGuards.mjs";
4
4
 
5
5
  /**
@@ -1,4 +1,8 @@
1
1
  import ts from 'typescript';
2
+ /**
3
+ * Loads a tsconfig and caches the result until the tsconfig or any file it extends changes.
4
+ * Failed loads are not cached, so a fixed tsconfig is picked up on the next call.
5
+ */
2
6
  export declare function loadTypescriptConfig(configPath: string): Promise<{
3
7
  projectPath: string;
4
8
  options: ts.CompilerOptions;
@@ -23,113 +23,70 @@ function getTsConfigWatchers() {
23
23
  }
24
24
  return processObj[TSCONFIG_WATCHERS_KEY];
25
25
  }
26
- function setupFileWatcher(configPath) {
26
+ function setupFileWatcher(filePath) {
27
27
  const cache = getTsConfigCache();
28
28
  const watchers = getTsConfigWatchers();
29
29
 
30
30
  // Skip if already watching this file
31
- if (watchers.has(configPath)) {
31
+ if (watchers.has(filePath)) {
32
32
  return;
33
33
  }
34
34
 
35
35
  // Mark as watching
36
- watchers.add(configPath);
36
+ watchers.add(filePath);
37
37
 
38
38
  // Set up file watcher
39
- const watcher = fs.watch(configPath);
39
+ const watcher = fs.watch(filePath);
40
40
 
41
41
  // Handle file changes
42
42
  (async () => {
43
43
  try {
44
44
  for await (const event of watcher) {
45
45
  if (event.eventType === 'change') {
46
- // Purge this config and any configs that might extend it
47
- const cachedPaths = Array.from(cache.keys());
48
- const toPurge = cachedPaths.filter(cachedPath => cachedPath === configPath || cachedPath.includes(configPath));
49
- toPurge.forEach(pathToPurge => {
50
- cache.delete(pathToPurge);
51
- });
46
+ // Any cached config may extend the changed file, purge them all
47
+ cache.clear();
52
48
  }
53
49
  }
54
50
  } catch (error) {
55
51
  // Watcher was closed or file was deleted
56
- watchers.delete(configPath);
52
+ watchers.delete(filePath);
57
53
  }
58
54
  })();
59
55
  }
60
- function mergeConfig(target, source) {
61
- for (const key in source) {
62
- if (Object.prototype.hasOwnProperty.call(source, key)) {
63
- if (typeof target[key] === 'object' && target[key] !== null && typeof source[key] === 'object' && source[key] !== null && !Array.isArray(target[key]) && !Array.isArray(source[key])) {
64
- mergeConfig(target[key], source[key]);
65
- } else {
66
- target[key] = source[key];
67
- }
68
- }
69
- }
70
- return target;
71
- }
56
+ const FORMAT_DIAGNOSTICS_HOST = {
57
+ getCanonicalFileName: fileName => fileName,
58
+ getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
59
+ getNewLine: () => ts.sys.newLine
60
+ };
61
+
62
+ /**
63
+ * Reads and parses a tsconfig, letting TypeScript resolve `extends` with the same
64
+ * semantics as `tsc`. Throws the first configuration error as an `Error`.
65
+ */
72
66
  async function loadTypescriptConfigUncached(configPath) {
73
- const dependencies = [configPath];
74
67
  const projectPath = path.dirname(configPath);
75
68
  const data = await fs.readFile(configPath, 'utf-8');
76
- const {
77
- config,
78
- error
79
- } = ts.readConfigFile(configPath, filePath => {
80
- if (filePath !== configPath) {
81
- throw new Error(`Unexpected file path: ${filePath}`);
82
- }
83
- return data.toString();
84
- });
85
- if (error) {
86
- throw error;
69
+ const sourceFile = ts.readJsonConfigFile(configPath, () => data);
70
+ const parsed = ts.parseJsonSourceFileConfigFileContent(sourceFile, ts.sys, projectPath, undefined, configPath);
71
+ const [diagnostic] = ts.getConfigFileParsingDiagnostics(parsed);
72
+ if (diagnostic) {
73
+ throw new Error(ts.formatDiagnostic(diagnostic, FORMAT_DIAGNOSTICS_HOST).trim());
87
74
  }
88
- const {
89
- options,
90
- errors,
91
- raw
92
- } = ts.parseJsonConfigFileContent(config, ts.sys, projectPath);
93
- options.configFilePath = configPath;
94
- let mergedConfig = options;
95
- if (raw.extends) {
96
- const extendedConfigPath = path.resolve(projectPath, raw.extends);
97
- const {
98
- options: parentOptions,
99
- projectPath: parentPath,
100
- dependencies: parentDependencies
101
- } = await loadTypescriptConfig(extendedConfigPath);
102
- dependencies.push(...parentDependencies);
103
75
 
104
- // scope compilerOptions.paths relative to the tsconfig location
105
- if (parentOptions.paths) {
106
- Object.keys(parentOptions.paths).forEach(key => {
107
- if (!parentOptions.paths) {
108
- return;
109
- }
110
- const paths = [];
111
- parentOptions.paths[key].forEach(relativePath => {
112
- const absolutePath = path.resolve(parentPath, relativePath);
113
- let scopedPath = path.relative(projectPath, absolutePath);
114
- if (!scopedPath.startsWith('.')) {
115
- scopedPath = `./${scopedPath}`;
116
- }
117
- paths.push(scopedPath);
118
- });
119
- parentOptions.paths[key] = paths;
120
- });
121
- }
122
- mergedConfig = mergeConfig(parentOptions, mergedConfig);
123
- }
124
- if (errors.length > 0) {
125
- throw errors[0];
126
- }
76
+ // TypeScript reports extended files with forward slashes
77
+ const extendedFiles = (sourceFile.extendedSourceFiles ?? []).map(file => path.normalize(file));
78
+ extendedFiles.forEach(setupFileWatcher);
127
79
  return {
128
80
  projectPath,
129
- options: mergedConfig,
130
- dependencies
81
+ options: parsed.options,
82
+ dependencies: [configPath, ...extendedFiles]
131
83
  };
132
84
  }
85
+
86
+ /**
87
+ * Loads a tsconfig and caches the result until the tsconfig or any file it extends changes.
88
+ * Failed loads are not cached, so a fixed tsconfig is picked up on the next call.
89
+ */
133
90
  export async function loadTypescriptConfig(configPath) {
134
91
  const cache = getTsConfigCache();
135
92
 
@@ -145,5 +102,13 @@ export async function loadTypescriptConfig(configPath) {
145
102
  // Create and cache the promise
146
103
  const promise = loadTypescriptConfigUncached(configPath);
147
104
  cache.set(configPath, promise);
148
- return promise;
105
+ try {
106
+ return await promise;
107
+ } catch (error) {
108
+ // Leave a newer load alone if the cache was purged while this one ran
109
+ if (cache.get(configPath) === promise) {
110
+ cache.delete(configPath);
111
+ }
112
+ throw error;
113
+ }
149
114
  }
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import type * as tae from 'typescript-api-extractor';
2
+ import type * as tae from '@mui/internal-typescript-api-extractor';
3
3
  export interface ParseTestSourcesOptions {
4
4
  /**
5
5
  * Declarations placed in the virtual default library. Types declared here are external
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { parseFromProgram } from 'typescript-api-extractor';
2
+ import { parseFromProgram } from '@mui/internal-typescript-api-extractor';
3
3
  import { PARSER_OPTIONS } from "./constants.mjs";
4
4
  const ROOT = '/virtual';
5
5
  const LIB_PATH = `${ROOT}/lib.d.ts`;
@@ -1,5 +1,5 @@
1
1
  import type { CompilerOptions } from 'typescript';
2
- import type { ExportNode } from 'typescript-api-extractor';
2
+ import type { ExportNode } from '@mui/internal-typescript-api-extractor';
3
3
  import type { InheritedExternalPropsConfig } from "./inheritedExternalProps.mjs";
4
4
  import type { PerformanceLog } from "./performanceTracking.mjs";
5
5
  export interface VariantResult {
@@ -1,6 +1,6 @@
1
1
  // eslint-disable-next-line n/prefer-node-protocol
2
2
  import { fileURLToPath } from 'url';
3
- import { parseFromProgram } from 'typescript-api-extractor';
3
+ import { parseFromProgram } from '@mui/internal-typescript-api-extractor';
4
4
  import ts from 'typescript';
5
5
  import { createOptimizedProgram } from "./createOptimizedProgram.mjs";
6
6
  import { augmentComponentsWithInheritedProps } from "./inheritedExternalProps.mjs";
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  /**
3
3
  * A map from original type names to their canonical export names.
4
4
  * For example: "DialogTrigger" -> "AlertDialog.Trigger"
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  /**
3
3
  * Writes a template literal type as TypeScript source, such as `` `${number}px` ``.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type * as tae from 'typescript-api-extractor';
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
2
  /**
3
3
  * Type guard to check if a type node is an external type reference.
4
4
  * Works with both class instances and serialized objects from typescript-api-extractor.