@mui/internal-docs-infra 0.3.1-canary.0 → 0.3.1-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/createSitemap/types.d.ts +3 -9
- package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +19 -6
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +10 -5
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +3 -3
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +17 -7
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +10 -3
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +5 -3
- package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.d.ts +2 -2
- package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +13 -7
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +4 -2
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +4 -2
- package/esm/pipeline/loadServerSource/loadServerSource.js +17 -14
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -9
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +7 -7
- package/esm/pipeline/loaderUtils/fileUrlToPortablePath.d.ts +44 -0
- package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +80 -0
- package/esm/pipeline/loaderUtils/index.d.ts +2 -1
- package/esm/pipeline/loaderUtils/index.js +2 -1
- package/esm/pipeline/loaderUtils/parseImportsAndComments.d.ts +10 -6
- package/esm/pipeline/loaderUtils/parseImportsAndComments.js +17 -12
- package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +1 -1
- package/esm/pipeline/loaderUtils/processRelativeImports.js +28 -24
- package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +5 -5
- package/esm/pipeline/loaderUtils/resolveModulePath.js +40 -37
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +1 -6
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +12 -35
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +4 -28
- package/esm/pipeline/transformMarkdownMetadata/types.d.ts +3 -9
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +7 -4
- package/esm/withDocsInfra/withDocsInfra.js +16 -8
- package/package.json +2 -2
|
@@ -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
|
|
28
|
-
|
|
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
|
|
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
|
-
* '
|
|
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,
|
|
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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
* '
|
|
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,
|
|
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 = {}; //
|
|
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
|
-
|
|
18
|
+
url: string;
|
|
19
19
|
names: string[];
|
|
20
20
|
positions?: Array<{
|
|
21
21
|
start: number;
|
|
@@ -4,6 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
4
4
|
import { rewriteImports } from "./rewriteImports.js";
|
|
5
5
|
import { isJavaScriptModule } from "./resolveModulePath.js";
|
|
6
6
|
import { getFileNameFromUrl } from "./getFileNameFromUrl.js";
|
|
7
|
+
import { fileUrlToPortablePath, portablePathToFileUrl } from "./fileUrlToPortablePath.js";
|
|
7
8
|
/**
|
|
8
9
|
* Processes flat mode with intelligent conflict resolution
|
|
9
10
|
*/
|
|
@@ -16,9 +17,11 @@ function processFlatMode(importResult, resolvedPathsMap) {
|
|
|
16
17
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
17
18
|
relativePath = _ref2[0],
|
|
18
19
|
importInfo = _ref2[1];
|
|
19
|
-
var
|
|
20
|
-
if (
|
|
21
|
-
|
|
20
|
+
var resolvedUrl = resolvedPathsMap.get(importInfo.url);
|
|
21
|
+
if (resolvedUrl) {
|
|
22
|
+
// Convert file URL to portable path for path manipulation
|
|
23
|
+
var resolvedPath = resolvedUrl.startsWith('file://') ? fileUrlToPortablePath(resolvedUrl) : resolvedUrl;
|
|
24
|
+
var fileExtension = getFileNameFromUrl(resolvedUrl).extension;
|
|
22
25
|
var pathSegments = resolvedPath.split('/').filter(Boolean);
|
|
23
26
|
fileMapping.push({
|
|
24
27
|
resolvedPath: resolvedPath,
|
|
@@ -242,7 +245,7 @@ function processFlatMode(importResult, resolvedPathsMap) {
|
|
|
242
245
|
|
|
243
246
|
// Fourth pass: build the extraFiles mapping
|
|
244
247
|
finalNames.forEach(function (finalName, resolvedPath) {
|
|
245
|
-
extraFiles["./".concat(finalName)] =
|
|
248
|
+
extraFiles["./".concat(finalName)] = portablePathToFileUrl(resolvedPath);
|
|
246
249
|
});
|
|
247
250
|
return {
|
|
248
251
|
processedSource: '',
|
|
@@ -266,8 +269,8 @@ function processBasicImports(source, importResult, storeAt) {
|
|
|
266
269
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
267
270
|
_relativePath = _ref4[0],
|
|
268
271
|
importInfo = _ref4[1];
|
|
269
|
-
var resolvedPath = importInfo.
|
|
270
|
-
var fileUrl =
|
|
272
|
+
var resolvedPath = importInfo.url; // For CSS, this is already resolved by parseImports
|
|
273
|
+
var fileUrl = portablePathToFileUrl(resolvedPath);
|
|
271
274
|
var _getFileNameFromUrl = getFileNameFromUrl(fileUrl),
|
|
272
275
|
fileName = _getFileNameFromUrl.fileName,
|
|
273
276
|
extension = _getFileNameFromUrl.extension;
|
|
@@ -290,7 +293,7 @@ function processBasicImports(source, importResult, storeAt) {
|
|
|
290
293
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
291
294
|
relativePath = _ref6[0],
|
|
292
295
|
importInfo = _ref6[1];
|
|
293
|
-
var resolvedPath = importInfo.
|
|
296
|
+
var resolvedPath = importInfo.url;
|
|
294
297
|
var finalName = finalNames.get(resolvedPath);
|
|
295
298
|
if (finalName) {
|
|
296
299
|
importPathMapping.set(relativePath, finalName);
|
|
@@ -299,8 +302,7 @@ function processBasicImports(source, importResult, storeAt) {
|
|
|
299
302
|
|
|
300
303
|
// Create extraFiles entries
|
|
301
304
|
finalNames.forEach(function (finalName, resolvedPath) {
|
|
302
|
-
|
|
303
|
-
extraFiles["./".concat(finalName)] = fileUrl;
|
|
305
|
+
extraFiles["./".concat(finalName)] = portablePathToFileUrl(resolvedPath);
|
|
304
306
|
});
|
|
305
307
|
|
|
306
308
|
// Apply import path replacements using position-based rewriting
|
|
@@ -329,9 +331,8 @@ function processBasicImports(source, importResult, storeAt) {
|
|
|
329
331
|
var _ref8 = _slicedToArray(_ref7, 2),
|
|
330
332
|
relativePath = _ref8[0],
|
|
331
333
|
importInfo = _ref8[1];
|
|
332
|
-
var resolvedPath = importInfo.
|
|
333
|
-
|
|
334
|
-
extraFiles[relativePath] = fileUrl; // Always use original path for extraFiles
|
|
334
|
+
var resolvedPath = importInfo.url;
|
|
335
|
+
extraFiles[relativePath] = portablePathToFileUrl(resolvedPath); // Always use original path for extraFiles
|
|
335
336
|
});
|
|
336
337
|
|
|
337
338
|
// Apply import path replacements using position-based rewriting
|
|
@@ -351,9 +352,8 @@ function processBasicImports(source, importResult, storeAt) {
|
|
|
351
352
|
var _ref0 = _slicedToArray(_ref9, 2),
|
|
352
353
|
relativePath = _ref0[0],
|
|
353
354
|
importInfo = _ref0[1];
|
|
354
|
-
var resolvedPath = importInfo.
|
|
355
|
-
|
|
356
|
-
extraFiles[relativePath] = fileUrl; // Use original import path
|
|
355
|
+
var resolvedPath = importInfo.url;
|
|
356
|
+
extraFiles[relativePath] = portablePathToFileUrl(resolvedPath); // Use original import path
|
|
357
357
|
});
|
|
358
358
|
return {
|
|
359
359
|
processedSource: source,
|
|
@@ -376,7 +376,8 @@ function processJsImports(source, importResult, storeAt, resolvedPathsMap) {
|
|
|
376
376
|
var _ref10 = _slicedToArray(_ref1, 2),
|
|
377
377
|
extraFileKey = _ref10[0],
|
|
378
378
|
fileUrl = _ref10[1];
|
|
379
|
-
|
|
379
|
+
// Convert file URL to portable path for lookup
|
|
380
|
+
var resolvedPath = fileUrl.startsWith('file://') ? fileUrlToPortablePath(fileUrl) : fileUrl;
|
|
380
381
|
resolvedToExtraFile.set(resolvedPath, extraFileKey);
|
|
381
382
|
});
|
|
382
383
|
|
|
@@ -386,8 +387,10 @@ function processJsImports(source, importResult, storeAt, resolvedPathsMap) {
|
|
|
386
387
|
var _ref12 = _slicedToArray(_ref11, 2),
|
|
387
388
|
relativePath = _ref12[0],
|
|
388
389
|
importInfo = _ref12[1];
|
|
389
|
-
var
|
|
390
|
-
if (
|
|
390
|
+
var resolvedUrl = resolvedPathsMap.get(importInfo.url);
|
|
391
|
+
if (resolvedUrl) {
|
|
392
|
+
// Convert file URL to portable path for lookup
|
|
393
|
+
var resolvedPath = resolvedUrl.startsWith('file://') ? fileUrlToPortablePath(resolvedUrl) : resolvedUrl;
|
|
391
394
|
var extraFileKey = resolvedToExtraFile.get(resolvedPath);
|
|
392
395
|
if (extraFileKey) {
|
|
393
396
|
// For JavaScript modules, remove the extension; for other files (CSS, JSON, etc.), keep it
|
|
@@ -421,12 +424,14 @@ function processJsImports(source, importResult, storeAt, resolvedPathsMap) {
|
|
|
421
424
|
var _ref14 = _slicedToArray(_ref13, 2),
|
|
422
425
|
relativePath = _ref14[0],
|
|
423
426
|
importInfo = _ref14[1];
|
|
424
|
-
var
|
|
425
|
-
if (!
|
|
427
|
+
var resolvedUrl = resolvedPathsMap.get(importInfo.url);
|
|
428
|
+
if (!resolvedUrl) {
|
|
426
429
|
return;
|
|
427
430
|
}
|
|
428
|
-
|
|
429
|
-
|
|
431
|
+
|
|
432
|
+
// Convert file URL to portable path for path manipulation
|
|
433
|
+
var resolvedPath = resolvedUrl.startsWith('file://') ? fileUrlToPortablePath(resolvedUrl) : resolvedUrl;
|
|
434
|
+
var fileExtension = getFileNameFromUrl(resolvedUrl).extension;
|
|
430
435
|
var isJavascriptModule = isJavaScriptModule(relativePath);
|
|
431
436
|
var keyPath;
|
|
432
437
|
if (!isJavascriptModule) {
|
|
@@ -447,8 +452,7 @@ function processJsImports(source, importResult, storeAt, resolvedPathsMap) {
|
|
|
447
452
|
keyPath = "".concat(relativePath).concat(fileExtension);
|
|
448
453
|
}
|
|
449
454
|
}
|
|
450
|
-
|
|
451
|
-
extraFiles[keyPath] = fileUrl;
|
|
455
|
+
extraFiles[keyPath] = portablePathToFileUrl(resolvedPath);
|
|
452
456
|
});
|
|
453
457
|
return {
|
|
454
458
|
processedSource: source,
|
|
@@ -37,18 +37,18 @@ export interface TypeAwareResolveResult {
|
|
|
37
37
|
* Resolves a module path by reading directory contents to find matching files.
|
|
38
38
|
* This is more efficient than checking each file individually with stat calls.
|
|
39
39
|
*
|
|
40
|
-
* Given a path like
|
|
40
|
+
* Given a path like `file:///Code/mui-public/packages/docs-infra/docs/app/components/code-highlighter/demos/code/BasicCode`,
|
|
41
41
|
* this function will try to find the actual file by checking for:
|
|
42
42
|
* - `BasicCode.ts`, `BasicCode.tsx`, `BasicCode.js`, `BasicCode.jsx`
|
|
43
43
|
* - `BasicCode/index.ts`, `BasicCode/index.tsx`, `BasicCode/index.js`, `BasicCode/index.jsx`
|
|
44
44
|
*
|
|
45
|
-
* @param
|
|
45
|
+
* @param moduleUrl - The module URL to resolve (file:// URL or portable path, without file extension)
|
|
46
46
|
* @param readDirectory - Function to read directory contents
|
|
47
47
|
* @param options - Configuration options
|
|
48
48
|
* @param includeTypeDefs - If true, returns both import and typeImport paths with different extension priorities
|
|
49
|
-
* @returns Promise<string | TypeAwareResolveResult> - The resolved file
|
|
49
|
+
* @returns Promise<string | TypeAwareResolveResult> - The resolved file:// URL(s)
|
|
50
50
|
*/
|
|
51
|
-
export declare function resolveModulePath(
|
|
51
|
+
export declare function resolveModulePath(moduleUrl: string, readDirectory: DirectoryReader, options?: ResolveModulePathOptions, includeTypeDefs?: boolean): Promise<string | TypeAwareResolveResult>;
|
|
52
52
|
/**
|
|
53
53
|
* Resolves multiple module paths efficiently by grouping them by directory
|
|
54
54
|
* and performing batch directory lookups.
|
|
@@ -70,7 +70,7 @@ export declare function resolveModulePaths(modulePaths: string[], readDirectory:
|
|
|
70
70
|
* @returns Promise<Map<string, string>> - Map from import path to resolved file path
|
|
71
71
|
*/
|
|
72
72
|
export declare function resolveImportResult(importResult: Record<string, {
|
|
73
|
-
|
|
73
|
+
url: string;
|
|
74
74
|
names: string[];
|
|
75
75
|
includeTypeDefs?: true;
|
|
76
76
|
positions?: Array<{
|