@mui/internal-docs-infra 0.9.1-canary.0 → 0.10.1-canary.1

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 (44) hide show
  1. package/CodeHighlighter/types.d.mts +2 -0
  2. package/abstractCreateDemo/abstractCreateDemo.d.mts +2 -1
  3. package/abstractCreateDemo/abstractCreateDemo.mjs +1 -0
  4. package/cli/index.mjs +1 -1
  5. package/cli/loadNextConfig.d.mts +1 -0
  6. package/cli/loadNextConfig.mjs +13 -4
  7. package/cli/runValidate.mjs +5 -2
  8. package/cli/validateWorker.mjs +2 -1
  9. package/package.json +12 -2
  10. package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasis.d.mts +17 -0
  11. package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasis.mjs +611 -135
  12. package/pipeline/lintJavascriptDemoFocus/index.d.mts +1 -0
  13. package/pipeline/lintJavascriptDemoFocus/index.mjs +1 -0
  14. package/pipeline/lintJavascriptDemoFocus/lintJavascriptDemoFocus.d.mts +40 -0
  15. package/pipeline/lintJavascriptDemoFocus/lintJavascriptDemoFocus.mjs +395 -0
  16. package/pipeline/loadCodeVariant/loadCodeVariant.mjs +16 -15
  17. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.mts +6 -0
  18. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.mjs +4 -4
  19. package/pipeline/loadPrecomputedTypes/loadPrecomputedTypes.d.mts +3 -0
  20. package/pipeline/loadPrecomputedTypes/loadPrecomputedTypes.mjs +1 -0
  21. package/pipeline/loadServerTypes/highlightTypes.d.mts +2 -1
  22. package/pipeline/loadServerTypes/highlightTypes.mjs +2 -2
  23. package/pipeline/loadServerTypes/highlightTypesMeta.d.mts +3 -0
  24. package/pipeline/loadServerTypes/highlightTypesMeta.mjs +12 -11
  25. package/pipeline/loadServerTypes/loadServerTypes.d.mts +3 -0
  26. package/pipeline/loadServerTypes/loadServerTypes.mjs +11 -7
  27. package/pipeline/loadServerTypesMeta/socketClient.mjs +16 -7
  28. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.mjs +22 -1
  29. package/pipeline/loaderUtils/parseImportsAndComments.mjs +7 -0
  30. package/pipeline/parseSource/addLineGutters.mjs +4 -0
  31. package/pipeline/parseSource/calculateFrameRanges.d.mts +35 -7
  32. package/pipeline/parseSource/calculateFrameRanges.mjs +236 -27
  33. package/pipeline/parseSource/createFrame.d.mts +1 -1
  34. package/pipeline/parseSource/createFrame.mjs +6 -3
  35. package/pipeline/parseSource/parseSource.mjs +7 -3
  36. package/pipeline/parseSource/restructureFrames.mjs +4 -13
  37. package/pipeline/transformHtmlCodeBlock/transformHtmlCodeBlock.d.mts +17 -1
  38. package/pipeline/transformHtmlCodeBlock/transformHtmlCodeBlock.mjs +10 -5
  39. package/useCode/Pre.mjs +34 -4
  40. package/useCode/useCode.mjs +1 -0
  41. package/useCode/useFileNavigation.d.mts +2 -0
  42. package/useCode/useFileNavigation.mjs +17 -7
  43. package/withDocsInfra/withDocsInfra.d.mts +17 -0
  44. package/withDocsInfra/withDocsInfra.mjs +14 -2
@@ -24,6 +24,8 @@ export type Externals = Record<string, ExternalImportItem[]>;
24
24
  export interface HastRoot extends Root {
25
25
  data?: RootData & {
26
26
  totalLines?: number;
27
+ collapsible?: boolean;
28
+ frameSize?: number;
27
29
  };
28
30
  }
29
31
  export type VariantSource = string | HastRoot | {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { Code, CodeHighlighterProps, ContentLoadingProps, ContentProps, LoadCodeMeta, LoadSource, LoadVariantMeta, ParseSource } from "../CodeHighlighter/types.mjs";
2
+ import type { Code, CodeHighlighterProps, ContentLoadingProps, ContentProps, LoadCodeMeta, LoadSource, LoadVariantMeta, ParseSource, SourceEnhancers } from "../CodeHighlighter/types.mjs";
3
3
  import { DemoGlobalData } from "../createDemoData/types.mjs";
4
4
  type CreateDemoMeta = {
5
5
  name?: string;
@@ -32,6 +32,7 @@ type AbstractCreateDemoOptions<T extends {}> = {
32
32
  loadVariantMeta?: LoadVariantMeta;
33
33
  loadSource?: LoadSource;
34
34
  sourceParser?: Promise<ParseSource>;
35
+ sourceEnhancers?: SourceEnhancers;
35
36
  };
36
37
  export declare function abstractCreateDemo<T extends {}>(options: AbstractCreateDemoOptions<T>, url: string, variants: {
37
38
  [key: string]: React.ComponentType;
@@ -31,6 +31,7 @@ export function abstractCreateDemo(options, url, variants, meta) {
31
31
  loadVariantMeta: options.loadVariantMeta,
32
32
  loadSource: options.loadSource,
33
33
  sourceParser: options.sourceParser,
34
+ sourceEnhancers: options.sourceEnhancers,
34
35
  highlightAfter: meta?.highlightAfter || options.highlightAfter,
35
36
  enhanceAfter: meta?.enhanceAfter || options.enhanceAfter,
36
37
  controlled: options.controlled,
package/cli/index.mjs CHANGED
@@ -7,4 +7,4 @@ function getVersion() {
7
7
  }
8
8
  yargs().scriptName('docs-infra').usage('$0 <command> [args]').command(runValidate).demandCommand(1, 'You need at least one command before moving on').strict().help()
9
9
  // MUI_VERSION is set through the code-infra build command.
10
- .version("0.9.0" || getVersion()).parse(hideBin(process.argv));
10
+ .version("0.10.0" || getVersion()).parse(hideBin(process.argv));
@@ -4,6 +4,7 @@ export type ExtractedNextConfigOptions = {
4
4
  ordering?: OrderingConfig;
5
5
  descriptionReplacements?: DescriptionReplacement[];
6
6
  useVisibleDescription?: boolean;
7
+ socketDir?: string;
7
8
  };
8
9
  /**
9
10
  * Dynamically imports the next config from the given directory and extracts
@@ -29,7 +29,8 @@ function extractUseVisibleDescriptionFromRemarkPlugins(remarkPlugins) {
29
29
  }
30
30
 
31
31
  /**
32
- * Extracts ordering and useVisibleDescription from loader options in a single pass.
32
+ * Extracts docs-infra options (ordering, descriptionReplacements, socketDir,
33
+ * useVisibleDescription) from loader options in a single pass.
33
34
  */
34
35
  function extractOptionsFromLoaderEntries(loaders) {
35
36
  const result = {};
@@ -43,6 +44,9 @@ function extractOptionsFromLoaderEntries(loaders) {
43
44
  if (!result.descriptionReplacements && loader.loader === TYPES_LOADER && loader.options?.descriptionReplacements) {
44
45
  result.descriptionReplacements = loader.options.descriptionReplacements;
45
46
  }
47
+ if (!result.socketDir && loader.loader === TYPES_LOADER && typeof loader.options?.socketDir === 'string') {
48
+ result.socketDir = loader.options.socketDir;
49
+ }
46
50
  if (result.useVisibleDescription === undefined && loader.options?.remarkPlugins) {
47
51
  const extracted = extractUseVisibleDescriptionFromRemarkPlugins(loader.options.remarkPlugins);
48
52
  if (typeof extracted === 'boolean') {
@@ -54,7 +58,8 @@ function extractOptionsFromLoaderEntries(loaders) {
54
58
  }
55
59
 
56
60
  /**
57
- * Searches turbopack rules for docs-infra options (ordering + useVisibleDescription).
61
+ * Searches turbopack rules for docs-infra options (ordering,
62
+ * descriptionReplacements, socketDir, useVisibleDescription).
58
63
  */
59
64
  function extractOptionsFromTurbopack(config) {
60
65
  const rules = config?.turbopack?.rules;
@@ -71,13 +76,15 @@ function extractOptionsFromTurbopack(config) {
71
76
  merged.ordering ??= extracted.ordering;
72
77
  merged.descriptionReplacements ??= extracted.descriptionReplacements;
73
78
  merged.useVisibleDescription ??= extracted.useVisibleDescription;
79
+ merged.socketDir ??= extracted.socketDir;
74
80
  }
75
81
  return merged;
76
82
  }
77
83
 
78
84
  /**
79
85
  * Calls the webpack function with a minimal config and extracts docs-infra
80
- * options (ordering + useVisibleDescription) from the resulting rules.
86
+ * options (ordering, descriptionReplacements, socketDir, useVisibleDescription)
87
+ * from the resulting rules.
81
88
  */
82
89
  function extractOptionsFromWebpack(config) {
83
90
  if (typeof config?.webpack !== 'function') {
@@ -105,6 +112,7 @@ function extractOptionsFromWebpack(config) {
105
112
  merged.ordering ??= extracted.ordering;
106
113
  merged.descriptionReplacements ??= extracted.descriptionReplacements;
107
114
  merged.useVisibleDescription ??= extracted.useVisibleDescription;
115
+ merged.socketDir ??= extracted.socketDir;
108
116
  }
109
117
  return merged;
110
118
  } catch {
@@ -131,7 +139,8 @@ export async function extractDocsInfraOptionsFromNextConfig(dir) {
131
139
  return {
132
140
  ordering: turbopack.ordering ?? webpack.ordering,
133
141
  descriptionReplacements: turbopack.descriptionReplacements ?? webpack.descriptionReplacements,
134
- useVisibleDescription: turbopack.useVisibleDescription ?? webpack.useVisibleDescription
142
+ useVisibleDescription: turbopack.useVisibleDescription ?? webpack.useVisibleDescription,
143
+ socketDir: turbopack.socketDir ?? webpack.socketDir
135
144
  };
136
145
  } catch {
137
146
  // Config not importable — use defaults
@@ -85,8 +85,10 @@ const runValidate = {
85
85
  const {
86
86
  ordering,
87
87
  descriptionReplacements,
88
- useVisibleDescription = false
88
+ useVisibleDescription = false,
89
+ socketDir: configSocketDir
89
90
  } = await extractDocsInfraOptionsFromNextConfig(cwd);
91
+ const socketDir = configSocketDir ? path.resolve(cwd, configSocketDir) : undefined;
90
92
 
91
93
  // If neither flag is set, run both. If one is set, run only that one.
92
94
  const runIndexes = !typesOnly || indexesOnly;
@@ -282,7 +284,8 @@ const runValidate = {
282
284
  markerDir: typesMarkerDir
283
285
  },
284
286
  ordering,
285
- descriptionReplacements
287
+ descriptionReplacements,
288
+ socketDir
286
289
  }
287
290
  });
288
291
  }));
@@ -73,7 +73,8 @@ if (parentPort) {
73
73
  watchSourceDirectly: Boolean(typesMetaCall.structuredOptions?.watchSourceDirectly),
74
74
  updateParentIndex: excludeFromIndex ? undefined : task.syncTypesOptions.updateParentIndex,
75
75
  ordering: task.syncTypesOptions.ordering,
76
- descriptionReplacements: task.syncTypesOptions.descriptionReplacements
76
+ descriptionReplacements: task.syncTypesOptions.descriptionReplacements,
77
+ socketDir: task.syncTypesOptions.socketDir
77
78
  });
78
79
  parentPort.postMessage({
79
80
  type: 'types',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.9.1-canary.0",
3
+ "version": "0.10.1-canary.1",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "license": "MIT",
@@ -429,6 +429,16 @@
429
429
  "default": "./pipeline/hastUtils/index.mjs"
430
430
  }
431
431
  },
432
+ "./pipeline/lintJavascriptDemoFocus": {
433
+ "import": {
434
+ "types": "./pipeline/lintJavascriptDemoFocus/index.d.mts",
435
+ "default": "./pipeline/lintJavascriptDemoFocus/index.mjs"
436
+ },
437
+ "default": {
438
+ "types": "./pipeline/lintJavascriptDemoFocus/index.d.mts",
439
+ "default": "./pipeline/lintJavascriptDemoFocus/index.mjs"
440
+ }
441
+ },
432
442
  "./pipeline/loadCodeVariant": {
433
443
  "import": {
434
444
  "types": "./pipeline/loadCodeVariant/index.d.mts",
@@ -633,5 +643,5 @@
633
643
  "bin": {
634
644
  "docs-infra": "./cli/index.mjs"
635
645
  },
636
- "gitSha": "3feee347096f50b441cad3087743bd1c5aef8651"
646
+ "gitSha": "eb63c846936de0d8b339188c5191c2c524357cc7"
637
647
  }
@@ -6,6 +6,23 @@ export type { EmphasisMeta, EnhanceCodeEmphasisOptions, FrameRange } from "../pa
6
6
  * Comments starting with this prefix will be processed for emphasis.
7
7
  */
8
8
  export declare const EMPHASIS_COMMENT_PREFIX = "@highlight";
9
+ /**
10
+ * The prefix used to identify focus-only comments in source code.
11
+ * Comments starting with this prefix will mark the region as focused without highlighting.
12
+ */
13
+ export declare const FOCUS_COMMENT_PREFIX = "@focus";
14
+ /**
15
+ * Modifier token used inside `@highlight` / `@focus` comments
16
+ * to override padding for that directive.
17
+ * Example: @highlight @padding 2.
18
+ */
19
+ export declare const PADDING_COMMENT_PREFIX = "@padding";
20
+ /**
21
+ * Modifier token used inside `@highlight` / `@focus` comments
22
+ * to override focus max size for that directive.
23
+ * Example: @highlight @min 6.
24
+ */
25
+ export declare const MIN_COMMENT_PREFIX = "@min";
9
26
  /**
10
27
  * Creates a source enhancer that adds emphasis to code lines based on `@highlight` comments
11
28
  * and restructures frames around highlighted regions.