@mui/internal-docs-infra 0.13.1-canary.28 → 0.13.1-canary.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.13.1-canary.28",
3
+ "version": "0.13.1-canary.29",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "license": "MIT",
@@ -813,5 +813,5 @@
813
813
  "bin": {
814
814
  "docs-infra": "./cli/index.mjs"
815
815
  },
816
- "gitSha": "5ada69268ff795656026874c514429285e0dba31"
816
+ "gitSha": "86a5228c41898421f1082ea32df84fe2464f2f84"
817
817
  }
@@ -0,0 +1,11 @@
1
+ import type * as tae from '@mui/internal-typescript-api-extractor';
2
+ /**
3
+ * Drops type-only exports that repeat a namespaced component re-export under its original name,
4
+ * such as `DialogTrigger` and `DialogTrigger.Props` (reached through `export type *`) next to
5
+ * `Dialog.Trigger` and `Dialog.Trigger.Props`. They would be documented twice, and the members
6
+ * would win the flat-name mapping over the namespaced names.
7
+ *
8
+ * Plain flat types (`ProgressStatus` next to `Progress.Status`) are kept, since the pipeline turns
9
+ * them into aliases of their namespaced names, and so are value exports, which are real API.
10
+ */
11
+ export declare function dropTypeOnlyDuplicates(exports: tae.ExportNode[]): tae.ExportNode[];
@@ -0,0 +1,31 @@
1
+ import { isComponentType } from "./typeGuards.mjs";
2
+
3
+ /**
4
+ * Drops type-only exports that repeat a namespaced component re-export under its original name,
5
+ * such as `DialogTrigger` and `DialogTrigger.Props` (reached through `export type *`) next to
6
+ * `Dialog.Trigger` and `Dialog.Trigger.Props`. They would be documented twice, and the members
7
+ * would win the flat-name mapping over the namespaced names.
8
+ *
9
+ * Plain flat types (`ProgressStatus` next to `Progress.Status`) are kept, since the pipeline turns
10
+ * them into aliases of their namespaced names, and so are value exports, which are real API.
11
+ */
12
+ export function dropTypeOnlyDuplicates(exports) {
13
+ const names = new Set(exports.map(node => node.name));
14
+ const reexportNames = new Map();
15
+ for (const node of exports) {
16
+ if (node.reexportedFrom && node.name.includes('.')) {
17
+ reexportNames.set(node.reexportedFrom, node.name);
18
+ }
19
+ }
20
+ return exports.filter(node => {
21
+ const [head, ...rest] = node.name.split('.');
22
+ const reexportName = reexportNames.get(head);
23
+ if (node.isValue || reexportName === undefined) {
24
+ return true;
25
+ }
26
+ if (rest.length === 0) {
27
+ return !isComponentType(node.type);
28
+ }
29
+ return !names.has([reexportName, ...rest].join('.'));
30
+ });
31
+ }
@@ -5,6 +5,7 @@ import ts from 'typescript';
5
5
  import { createOptimizedProgram } from "./createOptimizedProgram.mjs";
6
6
  import { augmentComponentsWithInheritedProps } from "./inheritedExternalProps.mjs";
7
7
  import { findConstantNamespaces, foldConstantNamespaces } from "./constantGroups.mjs";
8
+ import { dropTypeOnlyDuplicates } from "./dropTypeOnlyDuplicates.mjs";
8
9
  import { PARSER_OPTIONS } from "./constants.mjs";
9
10
  import { extractJSDocText, isJSDocNodeArray } from "./extractJSDocText.mjs";
10
11
  import { PerformanceTracker } from "./performanceTracking.mjs";
@@ -292,7 +293,7 @@ export async function processTypes(request) {
292
293
  // Modules of constants exported as a namespace (`export * as ButtonDataAttributes`)
293
294
  // arrive flattened into one export per member; document each as a single group.
294
295
  const constantNamespaces = findConstantNamespaces(entrypoint, program);
295
- const exports = foldConstantNamespaces(parsed.exports, constantNamespaces);
296
+ const exports = foldConstantNamespaces(dropTypeOnlyDuplicates(parsed.exports), constantNamespaces);
296
297
 
297
298
  // Re-add configured props that the parser dropped because they are
298
299
  // inherited from an externally declared type in node_modules