@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,170 @@
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
+ import _regenerator from "@babel/runtime/helpers/esm/regenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
+ import { readFile } from 'node:fs/promises';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { createLoadServerPageIndex } from "../loadServerPageIndex/loadServerPageIndex.js";
9
+ import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
10
+
11
+ /**
12
+ * Options for creating a loadServerSitemap function
13
+ */
14
+
15
+ /**
16
+ * Function type for loading sitemap data from a sitemap index file URL
17
+ */
18
+
19
+ /**
20
+ * Creates the default Orama schema for search indexing.
21
+ * See: https://docs.orama.com/docs/orama-js/usage/create#schema-properties-and-types
22
+ */
23
+ export function createSitemapSchema() {
24
+ return {
25
+ slug: 'string',
26
+ path: 'string',
27
+ title: 'string',
28
+ description: 'string',
29
+ sections: 'string[]',
30
+ subsections: 'string[]',
31
+ keywords: 'string[]'
32
+ };
33
+ }
34
+
35
+ /**
36
+ * Default loadServerSitemap function that loads sitemap data from a sitemap index file.
37
+ * This function parses the sitemap index file to find createSitemap calls and resolves
38
+ * the page index paths from the imports.
39
+ */
40
+ export var loadServerSitemap = createLoadServerSitemap();
41
+
42
+ /**
43
+ * Creates a loadServerSitemap function with custom options.
44
+ *
45
+ * This factory function creates a LoadServerSitemap implementation that:
46
+ * 1. Parses the sitemap index file to find createSitemap calls with page imports
47
+ * 2. Resolves all page index paths from the imports
48
+ * 3. Loads each page index using loadServerPageIndex
49
+ * 4. Returns a Sitemap object with schema and page data
50
+ *
51
+ * @param options - Configuration options for the loader
52
+ * @returns LoadServerSitemap function that takes a file URL and returns Promise<Sitemap>
53
+ */
54
+ export function createLoadServerSitemap() {
55
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
56
+ return /*#__PURE__*/function () {
57
+ var _loadSitemap = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(url) {
58
+ var _options$rootContext;
59
+ var filePath, rootContext, loadPageIndex, source, sitemapCall, entries, results, sitemapData, errors, _iterator, _step, result, errorMessages;
60
+ return _regenerator().w(function (_context2) {
61
+ while (1) switch (_context2.n) {
62
+ case 0:
63
+ // Convert file:// URL to proper file system path for reading the file
64
+ // Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... → C:\...)
65
+ filePath = url.startsWith('file://') ? fileURLToPath(url) : url; // Determine root context from file path if not provided
66
+ rootContext = (_options$rootContext = options.rootContext) != null ? _options$rootContext : path.dirname(filePath); // Create page index loader with root context
67
+ loadPageIndex = createLoadServerPageIndex({
68
+ rootContext: rootContext
69
+ }); // Read the source file to find createSitemap calls
70
+ _context2.n = 1;
71
+ return readFile(filePath, 'utf-8');
72
+ case 1:
73
+ source = _context2.v;
74
+ _context2.n = 2;
75
+ return parseCreateFactoryCall(source, filePath);
76
+ case 2:
77
+ sitemapCall = _context2.v;
78
+ if (!(!sitemapCall || !sitemapCall.variants)) {
79
+ _context2.n = 3;
80
+ break;
81
+ }
82
+ return _context2.a(2, {
83
+ schema: createSitemapSchema(),
84
+ data: {}
85
+ });
86
+ case 3:
87
+ // Process all page index files in parallel
88
+ entries = Object.entries(sitemapCall.variants);
89
+ _context2.n = 4;
90
+ return Promise.all(entries.map(/*#__PURE__*/function () {
91
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
92
+ var _ref3, key, importPath, metadata, _t;
93
+ return _regenerator().w(function (_context) {
94
+ while (1) switch (_context.p = _context.n) {
95
+ case 0:
96
+ _ref3 = _slicedToArray(_ref, 2), key = _ref3[0], importPath = _ref3[1];
97
+ _context.p = 1;
98
+ _context.n = 2;
99
+ return loadPageIndex(importPath);
100
+ case 2:
101
+ metadata = _context.v;
102
+ return _context.a(2, {
103
+ key: key,
104
+ metadata: metadata,
105
+ error: null
106
+ });
107
+ case 3:
108
+ _context.p = 3;
109
+ _t = _context.v;
110
+ return _context.a(2, {
111
+ key: key,
112
+ metadata: null,
113
+ error: _t instanceof Error ? _t : new Error(String(_t))
114
+ });
115
+ }
116
+ }, _callee, null, [[1, 3]]);
117
+ }));
118
+ return function (_x2) {
119
+ return _ref2.apply(this, arguments);
120
+ };
121
+ }()));
122
+ case 4:
123
+ results = _context2.v;
124
+ // Collect results and errors
125
+ sitemapData = {};
126
+ errors = [];
127
+ _iterator = _createForOfIteratorHelper(results);
128
+ try {
129
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
130
+ result = _step.value;
131
+ if (result.error) {
132
+ errors.push({
133
+ key: result.key,
134
+ error: result.error
135
+ });
136
+ } else if (result.metadata) {
137
+ sitemapData[result.key] = result.metadata;
138
+ }
139
+ }
140
+
141
+ // Throw if any pages failed to load
142
+ } catch (err) {
143
+ _iterator.e(err);
144
+ } finally {
145
+ _iterator.f();
146
+ }
147
+ if (!(errors.length > 0)) {
148
+ _context2.n = 5;
149
+ break;
150
+ }
151
+ errorMessages = errors.map(function (_ref4) {
152
+ var key = _ref4.key,
153
+ error = _ref4.error;
154
+ return " ".concat(key, ": ").concat(error.message);
155
+ }).join('\n');
156
+ throw new Error("Failed to load ".concat(errors.length, " page index(es):\n").concat(errorMessages));
157
+ case 5:
158
+ return _context2.a(2, {
159
+ schema: createSitemapSchema(),
160
+ data: sitemapData
161
+ });
162
+ }
163
+ }, _callee2);
164
+ }));
165
+ function loadSitemap(_x) {
166
+ return _loadSitemap.apply(this, arguments);
167
+ }
168
+ return loadSitemap;
169
+ }();
170
+ }
@@ -5,8 +5,10 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
5
  // webpack does not like node: imports
6
6
  // eslint-disable-next-line n/prefer-node-protocol
7
7
  import { readFile } from 'fs/promises';
8
+ // eslint-disable-next-line n/prefer-node-protocol
9
+ import { fileURLToPath } from 'url';
8
10
  import { parseImportsAndComments } from "../loaderUtils/index.js";
9
- import { resolveImportResultWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
11
+ import { resolveImportResultWithFs } from "../loadServerCodeMeta/resolveModulePathWithFs.js";
10
12
  import { processRelativeImports } from "../loaderUtils/processRelativeImports.js";
11
13
  import { isJavaScriptModule } from "../loaderUtils/resolveModulePath.js";
12
14
  /**
@@ -33,12 +35,13 @@ export function createLoadServerSource() {
33
35
  storeAt = _options$storeAt === void 0 ? 'flat' : _options$storeAt;
34
36
  return /*#__PURE__*/function () {
35
37
  var _loadSource = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url) {
36
- var filePath, source, isJavascriptModuleFile, isCssFile, _yield$parseImportsAn, importResult, externals, transformedExternals, _i, _Object$entries, _Object$entries$_i, modulePath, externalImport, processedSource, extraFiles, extraDependencies, importsCompatible, _i2, _Object$entries2, _Object$entries2$_i, importPath, _Object$entries2$_i$, path, names, positions, result, relativeImportsCompatible, _i3, _Object$entries3, _Object$entries3$_i, _importPath, _Object$entries3$_i$, _path, _names, includeTypeDefs, _positions, resolvedPathsMap, _result;
38
+ var filePath, source, isJavascriptModuleFile, isCssFile, _yield$parseImportsAn, importResult, externals, transformedExternals, _i, _Object$entries, _Object$entries$_i, modulePath, externalImport, processedSource, extraFiles, extraDependencies, importsCompatible, _i2, _Object$entries2, _Object$entries2$_i, importPath, _Object$entries2$_i$, importUrl, names, positions, result, relativeImportsCompatible, _i3, _Object$entries3, _Object$entries3$_i, _importPath, _Object$entries3$_i$, _importUrl, _names, includeTypeDefs, _positions, resolvedPathsMap, _result;
37
39
  return _regenerator().w(function (_context) {
38
40
  while (1) switch (_context.n) {
39
41
  case 0:
40
- // Remove file:// prefix if present
41
- filePath = url.replace('file://', ''); // Read the file
42
+ // Convert file:// URL to proper file system path for reading the file
43
+ // Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... → C:\...)
44
+ filePath = url.startsWith('file://') ? fileURLToPath(url) : url; // Read the file
42
45
  _context.n = 1;
43
46
  return readFile(filePath, 'utf8');
44
47
  case 1:
@@ -63,7 +66,7 @@ export function createLoadServerSource() {
63
66
  });
64
67
  case 3:
65
68
  _context.n = 4;
66
- return parseImportsAndComments(source, filePath);
69
+ return parseImportsAndComments(source, url);
67
70
  case 4:
68
71
  _yield$parseImportsAn = _context.v;
69
72
  importResult = _yield$parseImportsAn.relative;
@@ -92,9 +95,9 @@ export function createLoadServerSource() {
92
95
  // Convert import result to the format expected by processImports, preserving position data
93
96
  importsCompatible = {};
94
97
  for (_i2 = 0, _Object$entries2 = Object.entries(importResult); _i2 < _Object$entries2.length; _i2++) {
95
- _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2), importPath = _Object$entries2$_i[0], _Object$entries2$_i$ = _Object$entries2$_i[1], path = _Object$entries2$_i$.path, names = _Object$entries2$_i$.names, positions = _Object$entries2$_i$.positions;
98
+ _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2), importPath = _Object$entries2$_i[0], _Object$entries2$_i$ = _Object$entries2$_i[1], importUrl = _Object$entries2$_i$.url, names = _Object$entries2$_i$.names, positions = _Object$entries2$_i$.positions;
96
99
  importsCompatible[importPath] = {
97
- path: path,
100
+ url: importUrl,
98
101
  names: names.map(function (_ref) {
99
102
  var name = _ref.name,
100
103
  alias = _ref.alias;
@@ -115,8 +118,8 @@ export function createLoadServerSource() {
115
118
 
116
119
  // Build dependencies list for recursive loading (CSS files use direct paths)
117
120
  extraDependencies = Object.values(importResult).map(function (_ref2) {
118
- var path = _ref2.path;
119
- return path;
121
+ var importUrl = _ref2.url;
122
+ return importUrl;
120
123
  });
121
124
  _context.n = 8;
122
125
  break;
@@ -124,9 +127,9 @@ export function createLoadServerSource() {
124
127
  // For JavaScript/TypeScript files, resolve paths first
125
128
  relativeImportsCompatible = {};
126
129
  for (_i3 = 0, _Object$entries3 = Object.entries(importResult); _i3 < _Object$entries3.length; _i3++) {
127
- _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2), _importPath = _Object$entries3$_i[0], _Object$entries3$_i$ = _Object$entries3$_i[1], _path = _Object$entries3$_i$.path, _names = _Object$entries3$_i$.names, includeTypeDefs = _Object$entries3$_i$.includeTypeDefs, _positions = _Object$entries3$_i$.positions;
130
+ _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2), _importPath = _Object$entries3$_i[0], _Object$entries3$_i$ = _Object$entries3$_i[1], _importUrl = _Object$entries3$_i$.url, _names = _Object$entries3$_i$.names, includeTypeDefs = _Object$entries3$_i$.includeTypeDefs, _positions = _Object$entries3$_i$.positions;
128
131
  relativeImportsCompatible[_importPath] = _extends({
129
- path: _path,
132
+ url: _importUrl,
130
133
  names: _names.map(function (_ref3) {
131
134
  var name = _ref3.name,
132
135
  alias = _ref3.alias;
@@ -151,10 +154,10 @@ export function createLoadServerSource() {
151
154
 
152
155
  // Build dependencies list for recursive loading
153
156
  extraDependencies = Object.values(importResult).map(function (_ref4) {
154
- var path = _ref4.path;
155
- return resolvedPathsMap.get(path);
156
- }).filter(function (path) {
157
- return path !== undefined;
157
+ var importUrl = _ref4.url;
158
+ return resolvedPathsMap.get(importUrl);
159
+ }).filter(function (resolved) {
160
+ return resolved !== undefined;
158
161
  });
159
162
  case 8:
160
163
  return _context.a(2, {
@@ -21,7 +21,7 @@ export function externalsToPackages(externals) {
21
21
  * - 'react' -> 'react'
22
22
  * - 'react-dom' -> 'react-dom'
23
23
  * - '@mui/internal-docs-infra/CodeHighlighter' -> '@mui/internal-docs-infra'
24
- * - '@mui/internal-docs-infra/parseSource' -> '@mui/internal-docs-infra'
24
+ * - '@mui/internal-docs-infra/pipeline/parseSource' -> '@mui/internal-docs-infra'
25
25
  * - 'lodash/get' -> 'lodash'
26
26
  * - 'some-package/submodule/deep' -> 'some-package'
27
27
  */
@@ -1,12 +1,3 @@
1
- /**
2
- * Extracts and formats a name and slug from a URL path.
3
- * This utility takes the last meaningful segment of a URL path and formats it
4
- * into both a human-readable title and a URL-friendly slug.
5
- *
6
- * - Strips common file extensions (index.js, index.ts, index.tsx, etc.)
7
- * - Converts kebab-case to Title Case for names
8
- * - Ensures slugs are in kebab-case format
9
- */
10
1
  /**
11
2
  * Extracts and formats a name and slug from a URL path
12
3
  * @param url - The URL to extract from (can be file:// URL or regular path)
@@ -1,3 +1,5 @@
1
+ import { fileUrlToPortablePath } from "./fileUrlToPortablePath.js";
2
+
1
3
  /**
2
4
  * Extracts and formats a name and slug from a URL path.
3
5
  * This utility takes the last meaningful segment of a URL path and formats it
@@ -82,17 +84,15 @@ function toKebabCase(str) {
82
84
  * @returns The last meaningful path segment
83
85
  */
84
86
  function extractLastSegment(url) {
85
- // Handle file: URLs by removing the protocol
86
- var path = url;
87
- if (url.startsWith('file:')) {
88
- path = url.replace(/^file:\/\//, '');
89
- }
87
+ // Convert to portable path format for consistent handling across platforms
88
+ // This handles file:// URLs, Windows paths with backslashes, and regular paths
89
+ var path = fileUrlToPortablePath(url);
90
90
 
91
91
  // Strip query parameters and hash fragments before processing
92
- path = path.split('?')[0].split('#')[0];
92
+ var cleanPath = path.split('?')[0].split('#')[0];
93
93
 
94
94
  // Split the path into segments and filter out empty ones
95
- var segments = path.split('/').filter(Boolean);
95
+ var segments = cleanPath.split('/').filter(Boolean);
96
96
  if (segments.length === 0) {
97
97
  throw new Error('Could not extract meaningful segment from URL');
98
98
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Converts a file:// URL to a portable path format that can be used with path-module (POSIX-only).
3
+ *
4
+ * This function is designed to work with isomorphic code that uses path-module,
5
+ * which only supports POSIX paths. The key insight is that by stripping the `file://`
6
+ * prefix and normalizing backslashes to forward slashes, we get a path that:
7
+ * - On Unix: `/home/user/file.ts` - works directly with path-module
8
+ * - On Windows: `/C:/Users/file.ts` - also works with path-module because it starts with `/`
9
+ *
10
+ * The resulting path is NOT a valid filesystem path on Windows, but it's a valid
11
+ * POSIX-style path for path manipulation. Use `fileURLToPath` from the `url` module
12
+ * when you need to access the actual filesystem.
13
+ *
14
+ * @param fileUrl - A file:// URL or absolute path (with forward slashes)
15
+ * @returns A portable path starting with `/` that works with path-module
16
+ *
17
+ * @example
18
+ * // Unix file URL
19
+ * fileUrlToPortablePath('file:///home/user/file.ts') // => '/home/user/file.ts'
20
+ *
21
+ * // Windows file URL
22
+ * fileUrlToPortablePath('file:///C:/Users/file.ts') // => '/C:/Users/file.ts'
23
+ *
24
+ * // Already a portable path (passthrough)
25
+ * fileUrlToPortablePath('/home/user/file.ts') // => '/home/user/file.ts'
26
+ */
27
+ export declare function fileUrlToPortablePath(fileUrl: string): string;
28
+ /**
29
+ * Converts a portable path back to a file:// URL.
30
+ *
31
+ * This is the inverse of `fileUrlToPortablePath`. It takes a portable path
32
+ * (which always starts with `/`) and converts it back to a proper file:// URL.
33
+ *
34
+ * @param portablePath - A portable path starting with `/`
35
+ * @returns A file:// URL
36
+ *
37
+ * @example
38
+ * // Unix path
39
+ * portablePathToFileUrl('/home/user/file.ts') // => 'file:///home/user/file.ts'
40
+ *
41
+ * // Windows path (portable format)
42
+ * portablePathToFileUrl('/C:/Users/file.ts') // => 'file:///C:/Users/file.ts'
43
+ */
44
+ export declare function portablePathToFileUrl(portablePath: string): string;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Converts a file:// URL to a portable path format that can be used with path-module (POSIX-only).
3
+ *
4
+ * This function is designed to work with isomorphic code that uses path-module,
5
+ * which only supports POSIX paths. The key insight is that by stripping the `file://`
6
+ * prefix and normalizing backslashes to forward slashes, we get a path that:
7
+ * - On Unix: `/home/user/file.ts` - works directly with path-module
8
+ * - On Windows: `/C:/Users/file.ts` - also works with path-module because it starts with `/`
9
+ *
10
+ * The resulting path is NOT a valid filesystem path on Windows, but it's a valid
11
+ * POSIX-style path for path manipulation. Use `fileURLToPath` from the `url` module
12
+ * when you need to access the actual filesystem.
13
+ *
14
+ * @param fileUrl - A file:// URL or absolute path (with forward slashes)
15
+ * @returns A portable path starting with `/` that works with path-module
16
+ *
17
+ * @example
18
+ * // Unix file URL
19
+ * fileUrlToPortablePath('file:///home/user/file.ts') // => '/home/user/file.ts'
20
+ *
21
+ * // Windows file URL
22
+ * fileUrlToPortablePath('file:///C:/Users/file.ts') // => '/C:/Users/file.ts'
23
+ *
24
+ * // Already a portable path (passthrough)
25
+ * fileUrlToPortablePath('/home/user/file.ts') // => '/home/user/file.ts'
26
+ */
27
+ export function fileUrlToPortablePath(fileUrl) {
28
+ // If it's not a file:// URL, check if it's already a portable path
29
+ if (!fileUrl.startsWith('file://')) {
30
+ // Normalize backslashes to forward slashes
31
+ var normalized = fileUrl.replace(/\\/g, '/');
32
+ // If it doesn't start with /, it's likely a Windows path - add leading slash
33
+ if (!normalized.startsWith('/') && /^[a-zA-Z]:\//.test(normalized)) {
34
+ return "/".concat(normalized);
35
+ }
36
+ return normalized;
37
+ }
38
+
39
+ // Strip the file:// prefix
40
+ // file:///home/user/file.ts => /home/user/file.ts (Unix)
41
+ // file:///C:/Users/file.ts => /C:/Users/file.ts (Windows - keep the leading slash)
42
+ var path = fileUrl.slice(7); // Remove 'file://'
43
+
44
+ // Normalize any backslashes that might have snuck in
45
+ path = path.replace(/\\/g, '/');
46
+
47
+ // If it doesn't start with /, add one (should already have one for valid file:// URLs)
48
+ if (!path.startsWith('/')) {
49
+ path = "/".concat(path);
50
+ }
51
+ return path;
52
+ }
53
+
54
+ /**
55
+ * Converts a portable path back to a file:// URL.
56
+ *
57
+ * This is the inverse of `fileUrlToPortablePath`. It takes a portable path
58
+ * (which always starts with `/`) and converts it back to a proper file:// URL.
59
+ *
60
+ * @param portablePath - A portable path starting with `/`
61
+ * @returns A file:// URL
62
+ *
63
+ * @example
64
+ * // Unix path
65
+ * portablePathToFileUrl('/home/user/file.ts') // => 'file:///home/user/file.ts'
66
+ *
67
+ * // Windows path (portable format)
68
+ * portablePathToFileUrl('/C:/Users/file.ts') // => 'file:///C:/Users/file.ts'
69
+ */
70
+ export function portablePathToFileUrl(portablePath) {
71
+ // If it's already a URL (file://, http://, https://), return as-is
72
+ if (portablePath.startsWith('file://') || portablePath.startsWith('http://') || portablePath.startsWith('https://')) {
73
+ return portablePath;
74
+ }
75
+
76
+ // For Windows portable paths like /C:/Users/..., we need file:// + path
77
+ // For Unix paths like /home/user/..., we need file:// + path
78
+ // Both cases: file:// + /path = file:///path
79
+ return "file://".concat(portablePath);
80
+ }
@@ -4,4 +4,5 @@ export * from "./rewriteImports.js";
4
4
  export * from "./processRelativeImports.js";
5
5
  export * from "./getFileNameFromUrl.js";
6
6
  export * from "./extractNameAndSlugFromUrl.js";
7
- export * from "./externalsToPackages.js";
7
+ export * from "./externalsToPackages.js";
8
+ export * from "./fileUrlToPortablePath.js";
@@ -4,4 +4,5 @@ export * from "./rewriteImports.js";
4
4
  export * from "./processRelativeImports.js";
5
5
  export * from "./getFileNameFromUrl.js";
6
6
  export * from "./extractNameAndSlugFromUrl.js";
7
- export * from "./externalsToPackages.js";
7
+ export * from "./externalsToPackages.js";
8
+ export * from "./fileUrlToPortablePath.js";
@@ -24,8 +24,8 @@ export interface ImportPathPosition {
24
24
  * Represents an import from a relative path (starts with ./ or ../).
25
25
  */
26
26
  export interface RelativeImport {
27
- /** The resolved absolute path to the imported file */
28
- path: string;
27
+ /** The resolved absolute URL to the imported file (file:// URL) */
28
+ url: string;
29
29
  /** Array of imported names from this module */
30
30
  names: ImportName[];
31
31
  /** Whether TypeScript type definitions should be included for this import */
@@ -68,8 +68,12 @@ export interface ImportsAndComments {
68
68
  * and template literals, it's most efficient to handle comment processing in this
69
69
  * same pass rather than requiring separate parsing steps.
70
70
  *
71
+ * The function accepts file:// URLs or file paths and converts them internally to a
72
+ * portable path format that works cross-platform. Resolved import paths are returned
73
+ * in the same portable format (forward slashes, starting with /).
74
+ *
71
75
  * @param code - The source code to parse
72
- * @param filePath - The file path, used to determine file type and resolve relative imports
76
+ * @param fileUrl - The file URL (file:// protocol) or path, used to determine file type and resolve relative imports
73
77
  * @param options - Optional configuration for comment processing
74
78
  * @param options.removeCommentsWithPrefix - Array of prefixes; comments starting with these will be stripped from output
75
79
  * @param options.notableCommentsPrefix - Array of prefixes; comments starting with these will be collected regardless of stripping
@@ -79,13 +83,13 @@ export interface ImportsAndComments {
79
83
  * ```typescript
80
84
  * const result = await parseImportsAndComments(
81
85
  * 'import React from "react";\nimport { Button } from "./Button";',
82
- * '/src/App.tsx'
86
+ * 'file:///src/App.tsx'
83
87
  * );
84
88
  * // result.externals['react'] contains the React import
85
- * // result.relative['./Button'] contains the Button import
89
+ * // result.relative['./Button'] contains the Button import with url: 'file:///src/Button'
86
90
  * ```
87
91
  */
88
- export declare function parseImportsAndComments(code: string, filePath: string, options?: {
92
+ export declare function parseImportsAndComments(code: string, fileUrl: string, options?: {
89
93
  removeCommentsWithPrefix?: string[];
90
94
  notableCommentsPrefix?: string[];
91
95
  }): Promise<ImportsAndComments>;
@@ -3,9 +3,8 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
6
- // webpack does not like node: imports
7
- // eslint-disable-next-line n/prefer-node-protocol
8
- import path from 'path';
6
+ import * as path from 'path-module';
7
+ import { fileUrlToPortablePath, portablePathToFileUrl } from "./fileUrlToPortablePath.js";
9
8
 
10
9
  /**
11
10
  * Represents a single import name with its properties.
@@ -845,7 +844,7 @@ function detectCssImport(sourceText, pos, cssResult, cssExternals, cssFilePath,
845
844
  var resolvedPath = path.resolve(path.dirname(cssFilePath), normalizedPath);
846
845
  if (!cssResult[importResult.modulePath]) {
847
846
  cssResult[importResult.modulePath] = {
848
- path: resolvedPath,
847
+ url: portablePathToFileUrl(resolvedPath),
849
848
  names: [],
850
849
  positions: []
851
850
  };
@@ -954,7 +953,7 @@ function parseJSImports(code, filePath, result, externals, isMdxFile, removeComm
954
953
  var resolvedPath = path.resolve(path.dirname(filePath), _modulePath);
955
954
  if (!result[_modulePath]) {
956
955
  result[_modulePath] = {
957
- path: resolvedPath,
956
+ url: portablePathToFileUrl(resolvedPath),
958
957
  names: [],
959
958
  positions: []
960
959
  };
@@ -1083,7 +1082,7 @@ function parseJSImports(code, filePath, result, externals, isMdxFile, removeComm
1083
1082
  var _resolvedPath = path.resolve(path.dirname(filePath), modulePath);
1084
1083
  if (!result[modulePath]) {
1085
1084
  result[modulePath] = _extends({
1086
- path: _resolvedPath,
1085
+ url: portablePathToFileUrl(_resolvedPath),
1087
1086
  names: [],
1088
1087
  positions: []
1089
1088
  }, isTypeImport && {
@@ -1285,8 +1284,12 @@ function detectJavaScriptImport(sourceText, pos, _positionMapper) {
1285
1284
  * and template literals, it's most efficient to handle comment processing in this
1286
1285
  * same pass rather than requiring separate parsing steps.
1287
1286
  *
1287
+ * The function accepts file:// URLs or file paths and converts them internally to a
1288
+ * portable path format that works cross-platform. Resolved import paths are returned
1289
+ * in the same portable format (forward slashes, starting with /).
1290
+ *
1288
1291
  * @param code - The source code to parse
1289
- * @param filePath - The file path, used to determine file type and resolve relative imports
1292
+ * @param fileUrl - The file URL (file:// protocol) or path, used to determine file type and resolve relative imports
1290
1293
  * @param options - Optional configuration for comment processing
1291
1294
  * @param options.removeCommentsWithPrefix - Array of prefixes; comments starting with these will be stripped from output
1292
1295
  * @param options.notableCommentsPrefix - Array of prefixes; comments starting with these will be collected regardless of stripping
@@ -1296,23 +1299,25 @@ function detectJavaScriptImport(sourceText, pos, _positionMapper) {
1296
1299
  * ```typescript
1297
1300
  * const result = await parseImportsAndComments(
1298
1301
  * 'import React from "react";\nimport { Button } from "./Button";',
1299
- * '/src/App.tsx'
1302
+ * 'file:///src/App.tsx'
1300
1303
  * );
1301
1304
  * // result.externals['react'] contains the React import
1302
- * // result.relative['./Button'] contains the Button import
1305
+ * // result.relative['./Button'] contains the Button import with url: 'file:///src/Button'
1303
1306
  * ```
1304
1307
  */
1305
1308
  export function parseImportsAndComments(_x, _x2, _x3) {
1306
1309
  return _parseImportsAndComments.apply(this, arguments);
1307
1310
  }
1308
1311
  function _parseImportsAndComments() {
1309
- _parseImportsAndComments = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(code, filePath, options) {
1310
- var result, externals, isCssFile, isMdxFile;
1312
+ _parseImportsAndComments = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(code, fileUrl, options) {
1313
+ var result, externals, filePath, isCssFile, isMdxFile;
1311
1314
  return _regenerator().w(function (_context) {
1312
1315
  while (1) switch (_context.n) {
1313
1316
  case 0:
1314
1317
  result = {};
1315
- externals = {}; // Check if this is a CSS file
1318
+ externals = {}; // Convert file:// URL or OS path to portable path format for cross-platform compatibility
1319
+ // Portable paths always use forward slashes and start with / (even on Windows: /C:/...)
1320
+ filePath = fileUrlToPortablePath(fileUrl); // Check if this is a CSS file
1316
1321
  isCssFile = filePath.toLowerCase().endsWith('.css'); // Check if this is an MDX file (which can contain code blocks with triple backticks)
1317
1322
  isMdxFile = filePath.toLowerCase().endsWith('.mdx'); // If this is a CSS file, parse CSS @import statements instead
1318
1323
  if (!isCssFile) {
@@ -15,7 +15,7 @@ export interface ProcessImportsResult {
15
15
  * @returns Object with processed source and extraFiles mapping
16
16
  */
17
17
  export declare function processRelativeImports(source: string, importResult: Record<string, {
18
- path: string;
18
+ url: string;
19
19
  names: string[];
20
20
  positions?: Array<{
21
21
  start: number;