@mui/internal-docs-infra 0.3.1-canary.3 → 0.3.1-canary.5

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 (102) hide show
  1. package/esm/CodeControllerContext/CodeControllerContext.js +2 -2
  2. package/esm/CodeExternalsContext/CodeExternalsContext.js +1 -1
  3. package/esm/CodeHighlighter/CodeHighlighter.js +247 -329
  4. package/esm/CodeHighlighter/CodeHighlighterClient.js +447 -653
  5. package/esm/CodeHighlighter/CodeHighlighterContext.js +2 -2
  6. package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +2 -2
  7. package/esm/CodeHighlighter/codeToFallbackProps.js +21 -37
  8. package/esm/CodeHighlighter/errors.js +248 -400
  9. package/esm/CodeHighlighter/parseControlledCode.js +12 -20
  10. package/esm/CodeProvider/CodeContext.js +3 -3
  11. package/esm/CodeProvider/CodeProvider.js +31 -40
  12. package/esm/abstractCreateDemo/abstractCreateDemo.js +13 -17
  13. package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +12 -12
  14. package/esm/cli/index.js +1 -1
  15. package/esm/cli/runValidate.js +160 -264
  16. package/esm/createDemoData/createDemoData.js +11 -12
  17. package/esm/createSitemap/createSitemap.js +2 -2
  18. package/esm/pipeline/getFileConventions/fileConventions.js +1 -1
  19. package/esm/pipeline/getFileConventions/getFileConventions.js +2 -15
  20. package/esm/pipeline/hastUtils/hastUtils.js +16 -17
  21. package/esm/pipeline/loadCodeVariant/addCodeVariantPaths.js +24 -24
  22. package/esm/pipeline/loadCodeVariant/applyCodeTransform.js +12 -22
  23. package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +30 -37
  24. package/esm/pipeline/loadCodeVariant/computeHastDeltas.js +107 -185
  25. package/esm/pipeline/loadCodeVariant/diffHast.js +18 -53
  26. package/esm/pipeline/loadCodeVariant/examineCodeVariant.js +24 -27
  27. package/esm/pipeline/loadCodeVariant/flattenCodeVariant.js +9 -10
  28. package/esm/pipeline/loadCodeVariant/hasAllCodeVariants.js +5 -5
  29. package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +516 -731
  30. package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +679 -1079
  31. package/esm/pipeline/loadCodeVariant/maybeCodeInitialData.js +14 -20
  32. package/esm/pipeline/loadCodeVariant/mergeCodeMetadata.js +53 -63
  33. package/esm/pipeline/loadCodeVariant/parseCode.js +40 -48
  34. package/esm/pipeline/loadCodeVariant/pathUtils.js +43 -64
  35. package/esm/pipeline/loadCodeVariant/transformSource.js +55 -125
  36. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +160 -221
  37. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +377 -479
  38. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +171 -173
  39. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +14 -30
  40. package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +19 -21
  41. package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +37 -71
  42. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +3 -9
  43. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +54 -80
  44. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +71 -98
  45. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +5 -5
  46. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +161 -211
  47. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +159 -207
  48. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +42 -64
  49. package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +20 -96
  50. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +66 -85
  51. package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +71 -118
  52. package/esm/pipeline/loadServerSource/loadServerSource.js +121 -148
  53. package/esm/pipeline/loaderUtils/externalsToPackages.js +7 -7
  54. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +8 -12
  55. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +5 -5
  56. package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +19 -29
  57. package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +3 -4
  58. package/esm/pipeline/loaderUtils/mergeExternals.js +15 -35
  59. package/esm/pipeline/loaderUtils/parseImportsAndComments.js +413 -433
  60. package/esm/pipeline/loaderUtils/processRelativeImports.js +153 -239
  61. package/esm/pipeline/loaderUtils/resolveModulePath.js +544 -1303
  62. package/esm/pipeline/loaderUtils/rewriteImports.js +73 -111
  63. package/esm/pipeline/parseSource/addLineGutters.js +33 -45
  64. package/esm/pipeline/parseSource/grammars.js +3 -3
  65. package/esm/pipeline/parseSource/parseSource.js +13 -31
  66. package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +32 -55
  67. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +107 -160
  68. package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +846 -1033
  69. package/esm/pipeline/syncPageIndex/syncPageIndex.js +291 -438
  70. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +213 -311
  71. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
  72. package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +133 -193
  73. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +25 -27
  74. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +572 -717
  75. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +8 -8
  76. package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +84 -113
  77. package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +10 -26
  78. package/esm/useCode/Pre.js +58 -62
  79. package/esm/useCode/useCode.js +59 -61
  80. package/esm/useCode/useCodeUtils.js +54 -63
  81. package/esm/useCode/useCopyFunctionality.js +10 -9
  82. package/esm/useCode/useFileNavigation.js +150 -212
  83. package/esm/useCode/useSourceEditing.js +17 -14
  84. package/esm/useCode/useTransformManagement.js +23 -26
  85. package/esm/useCode/useUIState.js +12 -20
  86. package/esm/useCode/useVariantSelection.js +62 -79
  87. package/esm/useCopier/index.js +29 -56
  88. package/esm/useDemo/createCodeSandbox.js +12 -15
  89. package/esm/useDemo/createStackBlitz.js +14 -20
  90. package/esm/useDemo/exportVariant.js +200 -180
  91. package/esm/useDemo/exportVariantAsCra.js +22 -25
  92. package/esm/useDemo/useDemo.js +80 -84
  93. package/esm/useErrors/ErrorsContext.js +1 -1
  94. package/esm/useErrors/useErrors.js +3 -3
  95. package/esm/useLocalStorageState/useLocalStorageState.js +23 -39
  96. package/esm/usePreference/PreferencesProvider.js +1 -1
  97. package/esm/usePreference/usePreference.js +9 -11
  98. package/esm/useSearch/useSearch.js +290 -387
  99. package/esm/useUrlHashState/useUrlHashState.js +11 -14
  100. package/esm/withDocsInfra/withDeploymentConfig.js +26 -21
  101. package/esm/withDocsInfra/withDocsInfra.js +99 -101
  102. package/package.json +7 -4
@@ -1,6 +1,3 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _regenerator from "@babel/runtime/helpers/esm/regenerator";
3
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
1
  /* eslint-disable no-console */
5
2
  import chalk from 'chalk';
6
3
  import { readdir, readFile, rm } from 'node:fs/promises';
@@ -10,288 +7,187 @@ import remarkParse from 'remark-parse';
10
7
  import remarkMdx from 'remark-mdx';
11
8
  import { nameMark, performanceMeasure } from "../pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js";
12
9
  import { transformMarkdownMetadata } from "../pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js";
13
- var completeMessage = function completeMessage(message) {
14
- return "\u2713 ".concat(chalk.green(message));
15
- };
16
- var functionName = 'Run Validate';
10
+ const completeMessage = message => `✓ ${chalk.green(message)}`;
11
+ const functionName = 'Run Validate';
17
12
 
18
13
  /**
19
14
  * Recursively find all files matching a specific name in a directory
20
15
  */
21
- function findFiles(_x, _x2) {
22
- return _findFiles.apply(this, arguments);
23
- }
24
- function _findFiles() {
25
- _findFiles = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(dir, fileName) {
26
- var results, entries, _t3;
27
- return _regenerator().w(function (_context5) {
28
- while (1) switch (_context5.p = _context5.n) {
29
- case 0:
30
- results = [];
31
- _context5.p = 1;
32
- _context5.n = 2;
33
- return readdir(dir, {
34
- withFileTypes: true
35
- });
36
- case 2:
37
- entries = _context5.v;
38
- _context5.n = 3;
39
- return Promise.all(entries.map(/*#__PURE__*/function () {
40
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(entry) {
41
- var fullPath, subResults;
42
- return _regenerator().w(function (_context4) {
43
- while (1) switch (_context4.n) {
44
- case 0:
45
- fullPath = path.join(dir, entry.name);
46
- if (!entry.isDirectory()) {
47
- _context4.n = 2;
48
- break;
49
- }
50
- _context4.n = 1;
51
- return findFiles(fullPath, fileName);
52
- case 1:
53
- subResults = _context4.v;
54
- results.push.apply(results, _toConsumableArray(subResults));
55
- _context4.n = 3;
56
- break;
57
- case 2:
58
- if (entry.isFile() && entry.name === fileName) {
59
- results.push(fullPath);
60
- }
61
- case 3:
62
- return _context4.a(2);
63
- }
64
- }, _callee4);
65
- }));
66
- return function (_x5) {
67
- return _ref3.apply(this, arguments);
68
- };
69
- }()));
70
- case 3:
71
- _context5.n = 5;
72
- break;
73
- case 4:
74
- _context5.p = 4;
75
- _t3 = _context5.v;
76
- if (!(_t3.code !== 'ENOENT')) {
77
- _context5.n = 5;
78
- break;
79
- }
80
- throw _t3;
81
- case 5:
82
- return _context5.a(2, results);
16
+ async function findFiles(dir, fileName) {
17
+ const results = [];
18
+ try {
19
+ const entries = await readdir(dir, {
20
+ withFileTypes: true
21
+ });
22
+ await Promise.all(entries.map(async entry => {
23
+ const fullPath = path.join(dir, entry.name);
24
+ if (entry.isDirectory()) {
25
+ const subResults = await findFiles(fullPath, fileName);
26
+ results.push(...subResults);
27
+ } else if (entry.isFile() && entry.name === fileName) {
28
+ results.push(fullPath);
83
29
  }
84
- }, _callee5, null, [[1, 4]]);
85
- }));
86
- return _findFiles.apply(this, arguments);
30
+ }));
31
+ } catch (error) {
32
+ // Skip if directory doesn't exist
33
+ if (error.code !== 'ENOENT') {
34
+ throw error;
35
+ }
36
+ }
37
+ return results;
87
38
  }
88
- var runValidate = {
39
+ const runValidate = {
89
40
  command: 'validate [paths...]',
90
41
  describe: 'Ensures that committed files match expected output',
91
- builder: function builder(yargs) {
42
+ builder: yargs => {
92
43
  return yargs.option('command', {
93
44
  type: 'string',
94
45
  description: 'Command to suggest when indexes are out of date',
95
- "default": 'pnpm docs-infra validate'
46
+ default: 'pnpm docs-infra validate'
96
47
  }).option('useVisibleDescription', {
97
48
  type: 'boolean',
98
49
  description: 'Use the first visible paragraph as description in extracted index instead of meta tag',
99
- "default": false
50
+ default: false
100
51
  }).positional('paths', {
101
52
  type: 'string',
102
53
  array: true,
103
54
  description: 'Optional paths to validate (e.g., docs-infra/components docs-infra/functions)',
104
- "default": []
55
+ default: []
105
56
  });
106
57
  },
107
- handler: function () {
108
- var _handler = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(args) {
109
- var cwd, _args$paths, paths, _args$command, command, _args$useVisibleDescr, useVisibleDescription, ci;
110
- return _regenerator().w(function (_context3) {
111
- while (1) switch (_context3.n) {
112
- case 0:
113
- cwd = process.cwd();
114
- _args$paths = args.paths, paths = _args$paths === void 0 ? [] : _args$paths, _args$command = args.command, command = _args$command === void 0 ? 'pnpm docs-infra validate' : _args$command, _args$useVisibleDescr = args.useVisibleDescription, useVisibleDescription = _args$useVisibleDescr === void 0 ? false : _args$useVisibleDescr;
115
- ci = Boolean(process.env.CI);
116
- _context3.n = 1;
117
- return Promise.all([_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
118
- var startMark, currentMark, markerDir, markerDirPath, searchDirs, pageMdxFilesPerDir, pageMdxFiles, hasSrcAppFiles, hasAppFiles, includePatterns, processor, hasErrors, updatedIndexes, generatedFiles, pathsArg, updatedPaths, _t2;
119
- return _regenerator().w(function (_context2) {
120
- while (1) switch (_context2.p = _context2.n) {
121
- case 0:
122
- console.log(chalk.cyan('Validating committed files match expected output...'));
123
- startMark = nameMark(functionName, 'Start Validation', []);
124
- currentMark = startMark;
125
- performance.mark(currentMark);
126
- markerDir = '.next/cache/docs-infra/index-updates';
127
- markerDirPath = path.join(cwd, markerDir); // Remove the marker directory if it exists
128
- _context2.p = 1;
129
- _context2.n = 2;
130
- return rm(markerDirPath, {
131
- recursive: true,
132
- force: true
133
- });
134
- case 2:
135
- _context2.n = 4;
136
- break;
137
- case 3:
138
- _context2.p = 3;
139
- _t2 = _context2.v;
140
- case 4:
141
- if (paths.length > 0) {
142
- // If paths are provided, search in those specific paths
143
- searchDirs = paths.flatMap(function (p) {
144
- return [path.join(cwd, 'src/app', p), path.join(cwd, 'app', p)];
145
- });
146
- } else {
147
- // Otherwise search all app directories
148
- searchDirs = [path.join(cwd, 'src/app'), path.join(cwd, 'app')];
149
- }
150
- _context2.n = 5;
151
- return Promise.all(searchDirs.map(function (dir) {
152
- return findFiles(dir, 'page.mdx');
153
- }));
154
- case 5:
155
- pageMdxFilesPerDir = _context2.v;
156
- pageMdxFiles = pageMdxFilesPerDir.flat();
157
- console.log(chalk.yellow("\nProcessing ".concat(pageMdxFiles.length, " page.mdx files...\n")));
58
+ handler: async args => {
59
+ const cwd = process.cwd();
60
+ const {
61
+ paths = [],
62
+ command = 'pnpm docs-infra validate',
63
+ useVisibleDescription = false
64
+ } = args;
65
+ const ci = Boolean(process.env.CI);
66
+ await Promise.all([(async () => {
67
+ console.log(chalk.cyan('Validating committed files match expected output...'));
68
+ const startMark = nameMark(functionName, 'Start Validation', []);
69
+ let currentMark = startMark;
70
+ performance.mark(currentMark);
71
+ const markerDir = '.next/cache/docs-infra/index-updates';
72
+ const markerDirPath = path.join(cwd, markerDir);
73
+
74
+ // Remove the marker directory if it exists
75
+ try {
76
+ await rm(markerDirPath, {
77
+ recursive: true,
78
+ force: true
79
+ });
80
+ } catch (error) {
81
+ // Ignore errors if directory doesn't exist
82
+ }
83
+
84
+ // Find all page.mdx files in src/app/ or app/ directories
85
+ let searchDirs;
86
+ if (paths.length > 0) {
87
+ // If paths are provided, search in those specific paths
88
+ searchDirs = paths.flatMap(p => [path.join(cwd, 'src/app', p), path.join(cwd, 'app', p)]);
89
+ } else {
90
+ // Otherwise search all app directories
91
+ searchDirs = [path.join(cwd, 'src/app'), path.join(cwd, 'app')];
92
+ }
93
+ const pageMdxFilesPerDir = await Promise.all(searchDirs.map(dir => findFiles(dir, 'page.mdx')));
94
+ const pageMdxFiles = pageMdxFilesPerDir.flat();
95
+ console.log(chalk.yellow(`\nProcessing ${pageMdxFiles.length} page.mdx files...\n`));
96
+
97
+ // Process each file through the unified pipeline
98
+ // Auto-detect include paths based on which directories actually contain files
99
+ const hasSrcAppFiles = pageMdxFilesPerDir.slice(0, Math.ceil(searchDirs.length / 2)) // First half are src/app paths
100
+ .some(files => files.length > 0);
101
+ const hasAppFiles = pageMdxFilesPerDir.slice(Math.ceil(searchDirs.length / 2)) // Second half are app paths
102
+ .some(files => files.length > 0);
103
+ const includePatterns = [];
104
+ if (hasSrcAppFiles) {
105
+ includePatterns.push('src/app');
106
+ }
107
+ if (hasAppFiles) {
108
+ includePatterns.push('app');
109
+ }
110
+ // Fallback to 'app' if neither has files (shouldn't happen but be safe)
111
+ if (includePatterns.length === 0) {
112
+ includePatterns.push('app');
113
+ }
114
+ const processor = unified().use(remarkParse).use(remarkMdx).use(transformMarkdownMetadata, {
115
+ extractToIndex: {
116
+ include: includePatterns,
117
+ exclude: [],
118
+ baseDir: cwd,
119
+ onlyUpdateIndexes: true,
120
+ markerDir,
121
+ useVisibleDescription
122
+ }
123
+ });
124
+ let hasErrors = false;
125
+ await Promise.all(pageMdxFiles.map(async filePath => {
126
+ try {
127
+ const content = await readFile(filePath, 'utf-8');
128
+ const vfile = {
129
+ path: filePath,
130
+ value: content
131
+ };
132
+ // Use run() instead of process() since we don't need HTML output
133
+ await processor.run(processor.parse(vfile), vfile);
134
+ } catch (error) {
135
+ hasErrors = true;
136
+ console.error(chalk.red(`Error processing ${filePath}:`), error);
137
+ }
138
+ }));
158
139
 
159
- // Process each file through the unified pipeline
160
- // Auto-detect include paths based on which directories actually contain files
161
- hasSrcAppFiles = pageMdxFilesPerDir.slice(0, Math.ceil(searchDirs.length / 2)) // First half are src/app paths
162
- .some(function (files) {
163
- return files.length > 0;
164
- });
165
- hasAppFiles = pageMdxFilesPerDir.slice(Math.ceil(searchDirs.length / 2)) // Second half are app paths
166
- .some(function (files) {
167
- return files.length > 0;
168
- });
169
- includePatterns = [];
170
- if (hasSrcAppFiles) {
171
- includePatterns.push('src/app');
172
- }
173
- if (hasAppFiles) {
174
- includePatterns.push('app');
175
- }
176
- // Fallback to 'app' if neither has files (shouldn't happen but be safe)
177
- if (includePatterns.length === 0) {
178
- includePatterns.push('app');
179
- }
180
- processor = unified().use(remarkParse).use(remarkMdx).use(transformMarkdownMetadata, {
181
- extractToIndex: {
182
- include: includePatterns,
183
- exclude: [],
184
- baseDir: cwd,
185
- onlyUpdateIndexes: true,
186
- markerDir: markerDir,
187
- useVisibleDescription: useVisibleDescription
188
- }
189
- });
190
- hasErrors = false;
191
- _context2.n = 6;
192
- return Promise.all(pageMdxFiles.map(/*#__PURE__*/function () {
193
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(filePath) {
194
- var content, vfile, _t;
195
- return _regenerator().w(function (_context) {
196
- while (1) switch (_context.p = _context.n) {
197
- case 0:
198
- _context.p = 0;
199
- _context.n = 1;
200
- return readFile(filePath, 'utf-8');
201
- case 1:
202
- content = _context.v;
203
- vfile = {
204
- path: filePath,
205
- value: content
206
- }; // Use run() instead of process() since we don't need HTML output
207
- _context.n = 2;
208
- return processor.run(processor.parse(vfile), vfile);
209
- case 2:
210
- _context.n = 4;
211
- break;
212
- case 3:
213
- _context.p = 3;
214
- _t = _context.v;
215
- hasErrors = true;
216
- console.error(chalk.red("Error processing ".concat(filePath, ":")), _t);
217
- case 4:
218
- return _context.a(2);
219
- }
220
- }, _callee, null, [[0, 3]]);
221
- }));
222
- return function (_x4) {
223
- return _ref2.apply(this, arguments);
224
- };
225
- }()));
226
- case 6:
227
- _context2.n = 7;
228
- return findFiles(markerDirPath, 'page.mdx');
229
- case 7:
230
- updatedIndexes = _context2.v;
231
- if (updatedIndexes.length > 0) {
232
- console.log(chalk.yellow('\nUpdated index files:'));
233
- updatedIndexes.forEach(function (markerPath) {
234
- // Convert marker path back to actual index path
235
- var relativePath = path.relative(markerDirPath, markerPath);
236
- console.log(chalk.gray(" ".concat(relativePath)));
237
- });
238
- console.log(chalk.yellow("\nTotal: ".concat(updatedIndexes.length, " indexes updated\n")));
239
- } else {
240
- console.log(chalk.green('\nNo indexes needed updating\n'));
241
- }
242
- generatedFiles = updatedIndexes.length;
243
- currentMark = performanceMeasure(currentMark, {
244
- mark: 'Validated Files',
245
- measure: 'Validating Files'
246
- }, [functionName], true);
247
- console.log(completeMessage("".concat(generatedFiles, " index files updated in ").concat((performance.measure(nameMark(functionName, 'Validation', []), startMark, currentMark).duration / 1000).toPrecision(3), "s")));
248
- if (hasErrors) {
249
- console.error(chalk.red('\n✗ Validation failed with errors\n'));
250
- process.exit(1);
251
- }
252
- if (ci && generatedFiles > 0) {
253
- pathsArg = '';
254
- if (paths.length > 0) {
255
- // Use the paths that were provided
256
- pathsArg = " ".concat(paths.join(' '));
257
- } else {
258
- // Derive paths from the updated indexes
259
- updatedPaths = new Set();
260
- updatedIndexes.forEach(function (markerPath) {
261
- var relativePath = path.relative(markerDirPath, markerPath);
262
- // Extract the directory path (e.g., 'app/docs-infra/components/page.mdx' -> 'docs-infra/components')
263
- var dir = path.dirname(relativePath);
264
- // Remove 'app/' or 'src/app/' prefix if present
265
- var cleanDir = dir.replace(/^(src\/)?app\//, '');
266
- if (cleanDir) {
267
- updatedPaths.add(cleanDir);
268
- }
269
- });
270
- if (updatedPaths.size > 0) {
271
- pathsArg = " ".concat(Array.from(updatedPaths).map(function (p) {
272
- return /^[a-zA-Z0-9/_.-]+$/.test(p) ? p : "\"".concat(p, "\"");
273
- }).join(' '));
274
- }
275
- }
276
- console.error(chalk.red('\n✗ Index files are out of date. Run this command locally:\n'));
277
- console.error(chalk.cyan(" ".concat(command).concat(pathsArg)));
278
- console.error(chalk.red('\nThen commit the results.\n'));
279
- process.exit(1);
280
- }
281
- case 8:
282
- return _context2.a(2);
283
- }
284
- }, _callee2, null, [[1, 3]]);
285
- }))()]);
286
- case 1:
287
- return _context3.a(2);
140
+ // Find all marker files to see which indexes were updated
141
+ const updatedIndexes = await findFiles(markerDirPath, 'page.mdx');
142
+ if (updatedIndexes.length > 0) {
143
+ console.log(chalk.yellow('\nUpdated index files:'));
144
+ updatedIndexes.forEach(markerPath => {
145
+ // Convert marker path back to actual index path
146
+ const relativePath = path.relative(markerDirPath, markerPath);
147
+ console.log(chalk.gray(` ${relativePath}`));
148
+ });
149
+ console.log(chalk.yellow(`\nTotal: ${updatedIndexes.length} indexes updated\n`));
150
+ } else {
151
+ console.log(chalk.green('\nNo indexes needed updating\n'));
152
+ }
153
+ const generatedFiles = updatedIndexes.length;
154
+ currentMark = performanceMeasure(currentMark, {
155
+ mark: 'Validated Files',
156
+ measure: 'Validating Files'
157
+ }, [functionName], true);
158
+ console.log(completeMessage(`${generatedFiles} index files updated in ${(performance.measure(nameMark(functionName, 'Validation', []), startMark, currentMark).duration / 1000).toPrecision(3)}s`));
159
+ if (hasErrors) {
160
+ console.error(chalk.red('\n✗ Validation failed with errors\n'));
161
+ process.exit(1);
162
+ }
163
+ if (ci && generatedFiles > 0) {
164
+ let pathsArg = '';
165
+ if (paths.length > 0) {
166
+ // Use the paths that were provided
167
+ pathsArg = ` ${paths.join(' ')}`;
168
+ } else {
169
+ // Derive paths from the updated indexes
170
+ const updatedPaths = new Set();
171
+ updatedIndexes.forEach(markerPath => {
172
+ const relativePath = path.relative(markerDirPath, markerPath);
173
+ // Extract the directory path (e.g., 'app/docs-infra/components/page.mdx' -> 'docs-infra/components')
174
+ const dir = path.dirname(relativePath);
175
+ // Remove 'app/' or 'src/app/' prefix if present
176
+ const cleanDir = dir.replace(/^(src\/)?app\//, '');
177
+ if (cleanDir) {
178
+ updatedPaths.add(cleanDir);
179
+ }
180
+ });
181
+ if (updatedPaths.size > 0) {
182
+ pathsArg = ` ${Array.from(updatedPaths).map(p => /^[a-zA-Z0-9/_.-]+$/.test(p) ? p : `"${p}"`).join(' ')}`;
183
+ }
288
184
  }
289
- }, _callee3);
290
- }));
291
- function handler(_x3) {
292
- return _handler.apply(this, arguments);
293
- }
294
- return handler;
295
- }()
185
+ console.error(chalk.red('\n✗ Index files are out of date. Run this command locally:\n'));
186
+ console.error(chalk.cyan(` ${command}${pathsArg}`));
187
+ console.error(chalk.red('\nThen commit the results.\n'));
188
+ process.exit(1);
189
+ }
190
+ })()]);
191
+ }
296
192
  };
297
193
  export default runValidate;
@@ -9,26 +9,25 @@ import { extractNameAndSlugFromUrl } from "../pipeline/loaderUtils/index.js";
9
9
  * @param meta Additional meta for the demo.
10
10
  */
11
11
  export function createDemoDataWithVariants(url, variants, meta) {
12
- var _meta$name, _meta$slug;
13
12
  if (!url.startsWith('file:')) {
14
13
  throw new Error('createDemoData() requires the `url` argument to be a file URL. Use `import.meta.url` to get the current file URL.');
15
14
  }
16
15
  if (!meta || !meta.precompute && !meta.skipPrecompute) {
17
- throw new Error("createDemoData() was unable to precompute the code in ".concat(url, ". Ensure the createDemoData() function is called within a path used for demo indexes. This is typically app/**/demos/*/index.ts but may be overridden in next.config.js"));
16
+ throw new Error(`createDemoData() was unable to precompute the code in ${url}. Ensure the createDemoData() function is called within a path used for demo indexes. This is typically app/**/demos/*/index.ts but may be overridden in next.config.js`);
18
17
  }
19
- var precompute = meta.precompute;
18
+ const precompute = meta.precompute;
20
19
 
21
20
  // Generate name and slug from URL if not provided in meta
22
- var generatedMeta = extractNameAndSlugFromUrl(url);
23
- var name = (_meta$name = meta.name) != null ? _meta$name : generatedMeta.name;
24
- var slug = (_meta$slug = meta.slug) != null ? _meta$slug : generatedMeta.slug;
25
- var displayName = (meta == null ? void 0 : meta.displayName) || "".concat(name.replace(/ /g, ''), "Demo");
21
+ const generatedMeta = extractNameAndSlugFromUrl(url);
22
+ const name = meta.name ?? generatedMeta.name;
23
+ const slug = meta.slug ?? generatedMeta.slug;
24
+ const displayName = meta?.displayName || `${name.replace(/ /g, '')}Demo`;
26
25
  return {
27
- name: name,
28
- slug: slug,
29
- displayName: displayName,
30
- precompute: precompute,
31
- url: url,
26
+ name,
27
+ slug,
28
+ displayName,
29
+ precompute,
30
+ url,
32
31
  components: variants
33
32
  };
34
33
  }
@@ -29,14 +29,14 @@ export function createSitemap(sourceUrl, pages, meta) {
29
29
  }
30
30
 
31
31
  // If precompute data exists or skipPrecompute is set, use the precomputed data
32
- if (meta != null && meta.precompute || meta != null && meta.skipPrecompute) {
32
+ if (meta?.precompute || meta?.skipPrecompute) {
33
33
  return meta.precompute;
34
34
  }
35
35
 
36
36
  // In Next.js context, precomputation should have happened via webpack loader
37
37
  // If it didn't, throw an error to help developers fix their configuration
38
38
  if (isNextJsContext()) {
39
- throw new Error("createSitemap() was unable to precompute the sitemap data in ".concat(sourceUrl, ". Ensure the createSitemap() function is called within a path used for sitemap indexes. This is typically app/sitemap/index.ts but may be overridden in next.config.js"));
39
+ throw new Error(`createSitemap() was unable to precompute the sitemap data in ${sourceUrl}. Ensure the createSitemap() function is called within a path used for sitemap indexes. This is typically app/sitemap/index.ts but may be overridden in next.config.js`);
40
40
  }
41
41
 
42
42
  // Outside Next.js, return undefined (sync function can't do async loading)
@@ -1,4 +1,4 @@
1
- export var fileConventions = [{
1
+ export const fileConventions = [{
2
2
  rule: './app/**/demos/*/index.ts',
3
3
  loader: 'loadPrecomputedCodeHighlighter'
4
4
  }];
@@ -1,17 +1,4 @@
1
- import _regenerator from "@babel/runtime/helpers/esm/regenerator";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
1
  import { fileConventions } from "./fileConventions.js";
4
- export function getFileConventions() {
5
- return _getFileConventions.apply(this, arguments);
6
- }
7
- function _getFileConventions() {
8
- _getFileConventions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
9
- return _regenerator().w(function (_context) {
10
- while (1) switch (_context.n) {
11
- case 0:
12
- return _context.a(2, fileConventions);
13
- }
14
- }, _callee);
15
- }));
16
- return _getFileConventions.apply(this, arguments);
2
+ export async function getFileConventions() {
3
+ return fileConventions; // TODO: Parse the next.config.js file to get convention overrides.
17
4
  }
@@ -1,4 +1,3 @@
1
- import _typeof from "@babel/runtime/helpers/esm/typeof";
2
1
  import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
3
2
  import { toText } from 'hast-util-to-text';
4
3
  import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
@@ -6,50 +5,50 @@ import { decompressSync, strFromU8 } from 'fflate';
6
5
  import { decode } from 'uint8-to-base64';
7
6
  export function hastToJsx(hast) {
8
7
  return toJsxRuntime(hast, {
9
- Fragment: Fragment,
10
- jsx: jsx,
11
- jsxs: jsxs
8
+ Fragment,
9
+ jsx,
10
+ jsxs
12
11
  });
13
12
  }
14
13
  export function hastOrJsonToJsx(hastOrJson) {
15
- var hast;
14
+ let hast;
16
15
  if ('hastJson' in hastOrJson) {
17
16
  try {
18
17
  hast = JSON.parse(hastOrJson.hastJson);
19
18
  } catch (error) {
20
- throw new Error("Failed to parse hastJson: ".concat(JSON.stringify(error)));
19
+ throw new Error(`Failed to parse hastJson: ${JSON.stringify(error)}`);
21
20
  }
22
21
  } else if ('hastGzip' in hastOrJson) {
23
22
  try {
24
23
  hast = JSON.parse(strFromU8(decompressSync(decode(hastOrJson.hastGzip))));
25
24
  } catch (error) {
26
- throw new Error("Failed to parse hastGzip: ".concat(JSON.stringify(error)));
25
+ throw new Error(`Failed to parse hastGzip: ${JSON.stringify(error)}`);
27
26
  }
28
27
  } else {
29
28
  hast = hastOrJson;
30
29
  }
31
30
  return toJsxRuntime(hast, {
32
- Fragment: Fragment,
33
- jsx: jsx,
34
- jsxs: jsxs
31
+ Fragment,
32
+ jsx,
33
+ jsxs
35
34
  });
36
35
  }
37
36
  export function stringOrHastToString(source) {
38
37
  if (typeof source === 'string') {
39
38
  return source;
40
39
  }
41
- var hast;
40
+ let hast;
42
41
  if ('hastJson' in source) {
43
42
  try {
44
43
  hast = JSON.parse(source.hastJson);
45
44
  } catch (error) {
46
- throw new Error("Failed to parse hastJson: ".concat(JSON.stringify(error)));
45
+ throw new Error(`Failed to parse hastJson: ${JSON.stringify(error)}`);
47
46
  }
48
47
  } else if ('hastGzip' in source) {
49
48
  try {
50
49
  hast = JSON.parse(strFromU8(decompressSync(decode(source.hastGzip))));
51
50
  } catch (error) {
52
- throw new Error("Failed to parse hastGzip: ".concat(JSON.stringify(error)));
51
+ throw new Error(`Failed to parse hastGzip: ${JSON.stringify(error)}`);
53
52
  }
54
53
  } else {
55
54
  hast = source;
@@ -62,23 +61,23 @@ export function stringOrHastToJsx(source, highlighted) {
62
61
  if (typeof source === 'string') {
63
62
  return source;
64
63
  }
65
- var hast;
64
+ let hast;
66
65
  if ('hastJson' in source) {
67
66
  try {
68
67
  hast = JSON.parse(source.hastJson);
69
68
  } catch (error) {
70
- throw new Error("Failed to parse hastJson: ".concat(JSON.stringify(error)));
69
+ throw new Error(`Failed to parse hastJson: ${JSON.stringify(error)}`);
71
70
  }
72
71
  } else if ('hastGzip' in source) {
73
72
  try {
74
73
  hast = JSON.parse(strFromU8(decompressSync(decode(source.hastGzip))));
75
74
  } catch (error) {
76
- throw new Error("Failed to parse hastGzip: ".concat(JSON.stringify(error)));
75
+ throw new Error(`Failed to parse hastGzip: ${JSON.stringify(error)}`);
77
76
  }
78
77
  } else {
79
78
  hast = source;
80
79
  }
81
- if (highlighted && _typeof(hast) === 'object') {
80
+ if (highlighted && typeof hast === 'object') {
82
81
  return hastToJsx(hast);
83
82
  }
84
83
  return toText(hast, {