@mui/internal-docs-infra 0.2.3-canary.9 → 0.3.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 (156) hide show
  1. package/README.md +3 -2
  2. package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
  3. package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
  4. package/esm/CodeHighlighter/errors.js +3 -3
  5. package/esm/CodeHighlighter/types.d.ts +1 -1
  6. package/esm/CodeProvider/CodeContext.d.ts +4 -4
  7. package/esm/CodeProvider/CodeProvider.js +7 -7
  8. package/esm/cli/index.d.ts +1 -0
  9. package/esm/cli/index.js +6 -0
  10. package/esm/cli/runValidate.d.ts +8 -0
  11. package/esm/cli/runValidate.js +297 -0
  12. package/esm/createSitemap/createSitemap.d.ts +23 -0
  13. package/esm/createSitemap/createSitemap.js +45 -0
  14. package/esm/createSitemap/index.d.ts +1 -0
  15. package/esm/createSitemap/index.js +1 -0
  16. package/esm/createSitemap/types.d.ts +68 -0
  17. package/esm/createSitemap/types.js +1 -0
  18. package/esm/pipeline/getFileConventions/fileConventions.d.ts +4 -0
  19. package/esm/pipeline/getFileConventions/fileConventions.js +4 -0
  20. package/esm/pipeline/getFileConventions/getFileConventions.d.ts +4 -0
  21. package/esm/pipeline/getFileConventions/getFileConventions.js +17 -0
  22. package/esm/pipeline/getFileConventions/index.d.ts +1 -0
  23. package/esm/pipeline/getFileConventions/index.js +1 -0
  24. package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
  25. package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
  26. package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
  27. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +1 -1
  28. package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
  29. package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
  30. package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
  31. package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
  32. package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
  33. package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
  34. package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
  35. package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
  36. package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
  37. package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
  38. package/esm/pipeline/loadCodeVariant/index.js +17 -0
  39. package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
  40. package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +180 -106
  41. package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
  42. package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +141 -55
  43. package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
  44. package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
  45. package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
  46. package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
  47. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
  48. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
  49. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +5 -0
  50. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +94 -16
  51. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +3 -3
  52. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
  53. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
  54. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +24 -14
  55. package/esm/pipeline/loadPrecomputedSitemap/index.d.ts +2 -0
  56. package/esm/pipeline/loadPrecomputedSitemap/index.js +4 -0
  57. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.ts +10 -0
  58. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +220 -0
  59. package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
  60. package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
  61. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
  62. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +7 -5
  63. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +3 -3
  64. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +14 -8
  65. package/esm/pipeline/loadServerPageIndex/index.d.ts +2 -0
  66. package/esm/pipeline/loadServerPageIndex/index.js +1 -0
  67. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.d.ts +51 -0
  68. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +176 -0
  69. package/esm/pipeline/loadServerSitemap/index.d.ts +2 -0
  70. package/esm/pipeline/loadServerSitemap/index.js +1 -0
  71. package/esm/pipeline/loadServerSitemap/loadServerSitemap.d.ts +39 -0
  72. package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +170 -0
  73. package/esm/pipeline/loadServerSource/loadServerSource.js +18 -15
  74. package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
  75. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -9
  76. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +7 -7
  77. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.d.ts +44 -0
  78. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +80 -0
  79. package/esm/pipeline/loaderUtils/index.d.ts +2 -1
  80. package/esm/pipeline/loaderUtils/index.js +2 -1
  81. package/esm/pipeline/loaderUtils/parseImportsAndComments.d.ts +10 -6
  82. package/esm/pipeline/loaderUtils/parseImportsAndComments.js +17 -12
  83. package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +1 -1
  84. package/esm/pipeline/loaderUtils/processRelativeImports.js +44 -27
  85. package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +5 -5
  86. package/esm/pipeline/loaderUtils/resolveModulePath.js +40 -37
  87. package/esm/pipeline/loaderUtils/rewriteImports.d.ts +36 -0
  88. package/esm/pipeline/loaderUtils/rewriteImports.js +139 -8
  89. package/esm/pipeline/syncPageIndex/createMarkdownNodes.d.ts +76 -0
  90. package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +305 -0
  91. package/esm/pipeline/syncPageIndex/index.d.ts +1 -0
  92. package/esm/pipeline/syncPageIndex/index.js +1 -0
  93. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.d.ts +58 -0
  94. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +214 -0
  95. package/esm/pipeline/syncPageIndex/metadataToMarkdown.d.ts +67 -0
  96. package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +1486 -0
  97. package/esm/pipeline/syncPageIndex/syncPageIndex.d.ts +108 -0
  98. package/esm/pipeline/syncPageIndex/syncPageIndex.js +540 -0
  99. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
  100. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
  101. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
  102. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
  103. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
  104. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
  105. package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
  106. package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
  107. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
  108. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
  109. package/esm/pipeline/transformMarkdownMetadata/index.d.ts +2 -0
  110. package/esm/pipeline/transformMarkdownMetadata/index.js +4 -0
  111. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.d.ts +3 -0
  112. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +1010 -0
  113. package/esm/pipeline/transformMarkdownMetadata/types.d.ts +110 -0
  114. package/esm/pipeline/transformMarkdownMetadata/types.js +1 -0
  115. package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
  116. package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
  117. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +15 -0
  118. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +43 -0
  119. package/esm/useCode/Pre.js +15 -2
  120. package/esm/useCode/useCode.d.ts +15 -2
  121. package/esm/useCode/useCode.js +15 -6
  122. package/esm/useCode/useCodeUtils.js +3 -3
  123. package/esm/useCode/useFileNavigation.d.ts +9 -3
  124. package/esm/useCode/useFileNavigation.js +124 -81
  125. package/esm/useCode/useUIState.d.ts +4 -1
  126. package/esm/useCode/useUIState.js +17 -2
  127. package/esm/useCode/useVariantSelection.d.ts +8 -3
  128. package/esm/useCode/useVariantSelection.js +144 -52
  129. package/esm/useCopier/index.js +5 -4
  130. package/esm/useDemo/createCodeSandbox.d.ts +1 -1
  131. package/esm/useDemo/createStackBlitz.d.ts +1 -1
  132. package/esm/useDemo/exportVariant.js +13 -11
  133. package/esm/useDemo/index.d.ts +1 -1
  134. package/esm/useDemo/index.js +1 -1
  135. package/esm/useDemo/useDemo.d.ts +5 -5
  136. package/esm/useDemo/useDemo.js +6 -6
  137. package/esm/useErrors/useErrors.d.ts +1 -1
  138. package/esm/useErrors/useErrors.js +6 -2
  139. package/esm/useSearch/index.d.ts +1 -0
  140. package/esm/useSearch/index.js +1 -0
  141. package/esm/useSearch/types.d.ts +165 -0
  142. package/esm/useSearch/types.js +1 -0
  143. package/esm/useSearch/useSearch.d.ts +56 -0
  144. package/esm/useSearch/useSearch.js +647 -0
  145. package/esm/withDocsInfra/withDeploymentConfig.js +4 -2
  146. package/esm/withDocsInfra/withDocsInfra.d.ts +39 -0
  147. package/esm/withDocsInfra/withDocsInfra.js +94 -14
  148. package/package.json +105 -5
  149. package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
  150. /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
  151. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
  152. /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
  153. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
  154. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
  155. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
  156. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
@@ -0,0 +1,297 @@
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
+ /* eslint-disable no-console */
5
+ import chalk from 'chalk';
6
+ import { readdir, readFile, rm } from 'node:fs/promises';
7
+ import path from 'node:path';
8
+ import { unified } from 'unified';
9
+ import remarkParse from 'remark-parse';
10
+ import remarkMdx from 'remark-mdx';
11
+ import { nameMark, performanceMeasure } from "../pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js";
12
+ 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';
17
+
18
+ /**
19
+ * Recursively find all files matching a specific name in a directory
20
+ */
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);
83
+ }
84
+ }, _callee5, null, [[1, 4]]);
85
+ }));
86
+ return _findFiles.apply(this, arguments);
87
+ }
88
+ var runValidate = {
89
+ command: 'validate [paths...]',
90
+ describe: 'Ensures that committed files match expected output',
91
+ builder: function builder(yargs) {
92
+ return yargs.option('command', {
93
+ type: 'string',
94
+ description: 'Command to suggest when indexes are out of date',
95
+ "default": 'pnpm docs-infra validate'
96
+ }).option('useVisibleDescription', {
97
+ type: 'boolean',
98
+ description: 'Use the first visible paragraph as description in extracted index instead of meta tag',
99
+ "default": false
100
+ }).positional('paths', {
101
+ type: 'string',
102
+ array: true,
103
+ description: 'Optional paths to validate (e.g., docs-infra/components docs-infra/functions)',
104
+ "default": []
105
+ });
106
+ },
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")));
158
+
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);
288
+ }
289
+ }, _callee3);
290
+ }));
291
+ function handler(_x3) {
292
+ return _handler.apply(this, arguments);
293
+ }
294
+ return handler;
295
+ }()
296
+ };
297
+ export default runValidate;
@@ -0,0 +1,23 @@
1
+ import type * as React from 'react';
2
+ import type { Sitemap } from "./types.js";
3
+ type CreateSitemapMeta = {
4
+ name?: string;
5
+ slug?: string;
6
+ displayName?: string;
7
+ precompute?: Sitemap;
8
+ skipPrecompute?: boolean;
9
+ [key: string]: any;
10
+ };
11
+ /**
12
+ * Creates sitemap data from page components with optional precomputed data.
13
+ * Returns a sitemap data object containing schema and page data.
14
+ *
15
+ * In Next.js builds, the webpack loader precomputes the sitemap data.
16
+ * Outside Next.js (e.g., tests or scripts), use `loadServerSitemap()` for runtime loading.
17
+ *
18
+ * @param sourceUrl Depends on `import.meta.url` to determine the source file location.
19
+ * @param pages Record of page components indexed by path.
20
+ * @param meta Additional meta and precomputed sitemap configuration.
21
+ */
22
+ export declare function createSitemap(sourceUrl: string, pages: Record<string, React.ComponentType<any> | null>, meta?: CreateSitemapMeta): Sitemap | undefined;
23
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Detects if code is running within a Next.js build or runtime context.
3
+ * Returns true if Next.js environment variables are present.
4
+ */
5
+ function isNextJsContext() {
6
+ return typeof process !== 'undefined' && (typeof process.env.NEXT_RUNTIME === 'string' ||
7
+ // Next.js runtime (edge/nodejs)
8
+ // eslint-disable-next-line no-underscore-dangle
9
+ typeof process.env.__NEXT_PROCESSED_ENV === 'string' ||
10
+ // Next.js build
11
+ typeof process.env.NEXT_PHASE === 'string') // Next.js build phase
12
+ ;
13
+ }
14
+
15
+ /**
16
+ * Creates sitemap data from page components with optional precomputed data.
17
+ * Returns a sitemap data object containing schema and page data.
18
+ *
19
+ * In Next.js builds, the webpack loader precomputes the sitemap data.
20
+ * Outside Next.js (e.g., tests or scripts), use `loadServerSitemap()` for runtime loading.
21
+ *
22
+ * @param sourceUrl Depends on `import.meta.url` to determine the source file location.
23
+ * @param pages Record of page components indexed by path.
24
+ * @param meta Additional meta and precomputed sitemap configuration.
25
+ */
26
+ export function createSitemap(sourceUrl, pages, meta) {
27
+ if (!sourceUrl.startsWith('file:')) {
28
+ throw new Error('createSitemap() requires the `sourceUrl` argument to be a file URL. Use `import.meta.url` to get the current file URL.');
29
+ }
30
+
31
+ // If precompute data exists or skipPrecompute is set, use the precomputed data
32
+ if (meta != null && meta.precompute || meta != null && meta.skipPrecompute) {
33
+ return meta.precompute;
34
+ }
35
+
36
+ // In Next.js context, precomputation should have happened via webpack loader
37
+ // If it didn't, throw an error to help developers fix their configuration
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"));
40
+ }
41
+
42
+ // Outside Next.js, return undefined (sync function can't do async loading)
43
+ // Use loadServerSitemap() for runtime loading
44
+ return undefined;
45
+ }
@@ -0,0 +1 @@
1
+ export * from "./createSitemap.js";
@@ -0,0 +1 @@
1
+ export * from "./createSitemap.js";
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Section data structure from sitemap
3
+ */
4
+ export interface SitemapSection {
5
+ title: string;
6
+ children?: Record<string, SitemapSection>;
7
+ }
8
+ /**
9
+ * Part data structure from sitemap (for component parts)
10
+ */
11
+ export interface SitemapPart {
12
+ props?: string[];
13
+ dataAttributes?: string[];
14
+ cssVariables?: string[];
15
+ }
16
+ /**
17
+ * Export data structure from sitemap (for exported functions/components)
18
+ */
19
+ export interface SitemapExport {
20
+ props?: string[];
21
+ dataAttributes?: string[];
22
+ cssVariables?: string[];
23
+ }
24
+ /**
25
+ * Page data structure from sitemap
26
+ */
27
+ export interface SitemapPage {
28
+ title?: string;
29
+ slug: string;
30
+ path: string;
31
+ description?: string;
32
+ keywords?: string[];
33
+ sections?: Record<string, SitemapSection>;
34
+ parts?: Record<string, SitemapPart>;
35
+ exports?: Record<string, SitemapExport>;
36
+ tags?: string[];
37
+ skipDetailSection?: boolean;
38
+ openGraph?: {
39
+ title?: string;
40
+ description?: string;
41
+ images?: Array<{
42
+ url: string;
43
+ width: number;
44
+ height: number;
45
+ alt: string;
46
+ }>;
47
+ };
48
+ }
49
+ /**
50
+ * Section data from sitemap
51
+ */
52
+ export interface SitemapSectionData {
53
+ title: string;
54
+ prefix: string;
55
+ pages: SitemapPage[];
56
+ }
57
+ /**
58
+ * Orama schema property types
59
+ * See: https://docs.orama.com/docs/orama-js/usage/create#schema-properties-and-types
60
+ */
61
+ export type OramaSchemaType = 'string' | 'number' | 'boolean' | 'string[]' | 'number[]' | 'boolean[]' | `vector[${number}]`;
62
+ /**
63
+ * Sitemap structure
64
+ */
65
+ export interface Sitemap {
66
+ schema: Record<string, OramaSchemaType>;
67
+ data: Record<string, SitemapSectionData>;
68
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const fileConventions: {
2
+ rule: string;
3
+ loader: string;
4
+ }[];
@@ -0,0 +1,4 @@
1
+ export var fileConventions = [{
2
+ rule: './app/**/demos/*/index.ts',
3
+ loader: 'loadPrecomputedCodeHighlighter'
4
+ }];
@@ -0,0 +1,4 @@
1
+ export declare function getFileConventions(): Promise<{
2
+ rule: string;
3
+ loader: string;
4
+ }[]>;
@@ -0,0 +1,17 @@
1
+ import _regenerator from "@babel/runtime/helpers/esm/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ 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);
17
+ }
@@ -0,0 +1 @@
1
+ export * from "./getFileConventions.js";
@@ -0,0 +1 @@
1
+ export * from "./getFileConventions.js";
@@ -2,7 +2,7 @@
2
2
  * Add path utility to add path property to each file in a variant
3
3
  * Uses calculateMainFilePath utility and URL resolution for simplified path calculation
4
4
  */
5
- import type { VariantCode, VariantSource } from "./types.js";
5
+ import type { VariantCode, VariantSource } from "../../CodeHighlighter/types.js";
6
6
  export interface FileWithPath {
7
7
  source?: VariantSource;
8
8
  metadata?: boolean;
@@ -1,4 +1,4 @@
1
- import type { VariantSource, Transforms } from "./types.js";
1
+ import type { VariantSource, Transforms } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Applies a specific transform to a variant source and returns the transformed source
4
4
  * @param source - The original variant source (string, HastNodes, or hastJson object)
@@ -7,7 +7,7 @@ import type { VariantSource, Transforms } from "./types.js";
7
7
  * @returns The transformed variant source in the same format as the input
8
8
  * @throws Error if the transform key doesn't exist or patching fails
9
9
  */
10
- export declare function applyTransform(source: VariantSource, transforms: Transforms, transformKey: string): VariantSource;
10
+ export declare function applyCodeTransform(source: VariantSource, transforms: Transforms, transformKey: string): VariantSource;
11
11
  /**
12
12
  * Applies multiple transforms to a variant source in sequence
13
13
  * @param source - The original variant source
@@ -16,4 +16,4 @@ export declare function applyTransform(source: VariantSource, transforms: Transf
16
16
  * @returns The transformed variant source in the same format as the input
17
17
  * @throws Error if any transform key doesn't exist or patching fails
18
18
  */
19
- export declare function applyTransforms(source: VariantSource, transforms: Transforms, transformKeys: string[]): VariantSource;
19
+ export declare function applyCodeTransforms(source: VariantSource, transforms: Transforms, transformKeys: string[]): VariantSource;
@@ -8,7 +8,7 @@ import { patch, clone } from 'jsondiffpatch';
8
8
  * @returns The transformed variant source in the same format as the input
9
9
  * @throws Error if the transform key doesn't exist or patching fails
10
10
  */
11
- export function applyTransform(source, transforms, transformKey) {
11
+ export function applyCodeTransform(source, transforms, transformKey) {
12
12
  var transform = transforms[transformKey];
13
13
  if (!transform) {
14
14
  throw new Error("Transform \"".concat(transformKey, "\" not found in transforms"));
@@ -25,7 +25,7 @@ export function applyTransform(source, transforms, transformKey) {
25
25
  return patched.join('\n');
26
26
  }
27
27
 
28
- // For Hast node sources, deltas are typically node-based (from transformParsedSource)
28
+ // For Hast node sources, deltas are typically node-based (from diffHast)
29
29
  var sourceRoot;
30
30
  var isHastJson = 'hastJson' in source;
31
31
  if (isHastJson) {
@@ -57,14 +57,14 @@ export function applyTransform(source, transforms, transformKey) {
57
57
  * @returns The transformed variant source in the same format as the input
58
58
  * @throws Error if any transform key doesn't exist or patching fails
59
59
  */
60
- export function applyTransforms(source, transforms, transformKeys) {
60
+ export function applyCodeTransforms(source, transforms, transformKeys) {
61
61
  var currentSource = source;
62
62
  var _iterator = _createForOfIteratorHelper(transformKeys),
63
63
  _step;
64
64
  try {
65
65
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
66
66
  var transformKey = _step.value;
67
- currentSource = applyTransform(currentSource, transforms, transformKey);
67
+ currentSource = applyCodeTransform(currentSource, transforms, transformKey);
68
68
  }
69
69
  } catch (err) {
70
70
  _iterator.e(err);
@@ -1,5 +1,5 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import { createSyntheticDirectories, buildPath } from './pathUtils.js';
2
+ import { createSyntheticDirectories, buildPath } from "./pathUtils.js";
3
3
  export function calculateMainFilePath(url, maxBackNav, maxSourceBackNav, metadataPrefix, fileName) {
4
4
  // Handle optional parameters with defaults
5
5
  var actualMaxSourceBackNav = maxSourceBackNav != null ? maxSourceBackNav : maxBackNav;
@@ -1,4 +1,4 @@
1
- import type { Code, ParseSource } from "./types.js";
1
+ import type { Code, ParseSource } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Pure function to identify which variants need transformation.
4
4
  * Returns entries of variants that have transforms requiring processing.
@@ -13,9 +13,13 @@ export declare function getAvailableTransforms(parsedCode: Code | undefined, var
13
13
  * Pure async function to transform a single variant's code and extraFiles.
14
14
  * Returns the transformed variant or the original if transformation fails.
15
15
  */
16
- export declare function transformVariant(variant: string, variantCode: any, parseSource: ParseSource): Promise<any>;
16
+ export declare function computeVariantDeltas(variant: string, variantCode: any, parseSource: ParseSource): Promise<any>;
17
17
  /**
18
- * Pure async function to apply transformations to all variants that need them.
19
- * Returns the enhanced code with computed transforms.
18
+ * Computes transform deltas for all variants in the parsed code.
19
+ * This function generates the transformation data that can be applied later.
20
+ *
21
+ * @param parsedCode - The parsed code object containing variants
22
+ * @param parseSource - The parser function to parse source strings
23
+ * @returns A promise that resolves to the code with computed transforms
20
24
  */
21
- export declare function applyTransforms(parsedCode: Code, parseSource: ParseSource): Promise<Code>;
25
+ export declare function computeHastDeltas(parsedCode: Code, parseSource: ParseSource): Promise<Code>;