@mui/internal-docs-infra 0.3.1-canary.0 → 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.
- 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/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +7 -4
- package/esm/withDocsInfra/withDocsInfra.js +16 -8
- package/package.json +2 -2
|
@@ -85,15 +85,28 @@ function convertKeyBasedOnDirectory(nestedKey, sourceFileKey) {
|
|
|
85
85
|
processedNestedKey = "./".concat(nestedKey);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
//
|
|
88
|
+
// Get the directory of the source file
|
|
89
89
|
var sourceDir = path.dirname(sourceFileKey);
|
|
90
|
-
var resolvedPath = path.resolve(sourceDir, processedNestedKey);
|
|
91
90
|
|
|
92
|
-
//
|
|
93
|
-
|
|
91
|
+
// If sourceDir is '.' (current directory), just return the processed nested key
|
|
92
|
+
// This avoids path.resolve which can produce absolute paths on Windows
|
|
93
|
+
if (sourceDir === '.') {
|
|
94
|
+
// Remove leading './' if present for consistency
|
|
95
|
+
return processedNestedKey.startsWith('./') ? processedNestedKey.slice(2) : processedNestedKey;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Use path.join instead of path.resolve to avoid producing absolute paths
|
|
99
|
+
// path.join keeps paths relative, while path.resolve can make them absolute
|
|
100
|
+
var joinedPath = path.join(sourceDir, processedNestedKey);
|
|
94
101
|
|
|
95
|
-
//
|
|
96
|
-
|
|
102
|
+
// Normalize the path to clean up any ../ or ./ segments
|
|
103
|
+
var normalizedPath = path.normalize(joinedPath);
|
|
104
|
+
|
|
105
|
+
// Ensure we return a clean relative path (remove leading './' if present after normalization)
|
|
106
|
+
if (normalizedPath.startsWith('./')) {
|
|
107
|
+
return normalizedPath.slice(2);
|
|
108
|
+
}
|
|
109
|
+
return normalizedPath === '.' ? '' : normalizedPath;
|
|
97
110
|
}
|
|
98
111
|
|
|
99
112
|
/**
|
|
@@ -5,6 +5,8 @@ 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 path from 'path';
|
|
8
|
+
// eslint-disable-next-line n/prefer-node-protocol
|
|
9
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
8
10
|
import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
|
|
9
11
|
import { createParseSource } from "../parseSource/index.js";
|
|
10
12
|
// TODO: re-enable following benchmarking
|
|
@@ -40,7 +42,7 @@ function _loadPrecomputedCodeHighlighter() {
|
|
|
40
42
|
_options$performance2,
|
|
41
43
|
_options$performance3,
|
|
42
44
|
_this = this;
|
|
43
|
-
var callback, options, performanceNotableMs, performanceShowWrapperMeasures, relativePath, observer, currentMark, _observer, _observer2, demoCall, variantData, allDependencies, resolvedVariantMap, loadSource, sourceTransformers, sourceParser, functionsInitMark, variantPromises, variantResults, _iterator, _step, result, modifiedSource, _observer3, _observer4, _t2;
|
|
45
|
+
var callback, options, performanceNotableMs, performanceShowWrapperMeasures, relativePath, observer, currentMark, resourceFileUrl, _observer, _observer2, demoCall, variantData, allDependencies, resolvedVariantMap, loadSource, sourceTransformers, sourceParser, functionsInitMark, variantPromises, variantResults, _iterator, _step, result, modifiedSource, _observer3, _observer4, _t2;
|
|
44
46
|
return _regenerator().w(function (_context2) {
|
|
45
47
|
while (1) switch (_context2.p = _context2.n) {
|
|
46
48
|
case 0:
|
|
@@ -60,10 +62,12 @@ function _loadPrecomputedCodeHighlighter() {
|
|
|
60
62
|
currentMark = performanceMeasure(undefined, {
|
|
61
63
|
mark: 'Start',
|
|
62
64
|
measure: 'Start'
|
|
63
|
-
}, [functionName, relativePath], true);
|
|
65
|
+
}, [functionName, relativePath], true); // Convert the filesystem path to a file:// URL for cross-platform compatibility
|
|
66
|
+
// pathToFileURL handles Windows drive letters correctly (e.g., C:\... → file:///C:/...)
|
|
67
|
+
resourceFileUrl = pathToFileURL(this.resourcePath).toString();
|
|
64
68
|
_context2.p = 1;
|
|
65
69
|
_context2.n = 2;
|
|
66
|
-
return parseCreateFactoryCall(source,
|
|
70
|
+
return parseCreateFactoryCall(source, resourceFileUrl);
|
|
67
71
|
case 2:
|
|
68
72
|
demoCall = _context2.v;
|
|
69
73
|
currentMark = performanceMeasure(currentMark, {
|
|
@@ -222,8 +226,9 @@ function _loadPrecomputedCodeHighlighter() {
|
|
|
222
226
|
|
|
223
227
|
// Add all dependencies to webpack's watch list
|
|
224
228
|
allDependencies.forEach(function (dep) {
|
|
225
|
-
//
|
|
226
|
-
|
|
229
|
+
// Convert file:// URLs to proper file system paths for webpack's dependency tracking
|
|
230
|
+
// Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... → C:\...)
|
|
231
|
+
_this.addDependency(dep.startsWith('file://') ? fileURLToPath(dep) : dep);
|
|
227
232
|
});
|
|
228
233
|
|
|
229
234
|
// log any pending performance entries before completing
|
|
@@ -254,19 +254,19 @@ function parseVariantsObjectFromObject(obj, importMap, namedExportsMap, function
|
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
256
|
* Helper function to convert the new parseImportsAndComments format to a Map
|
|
257
|
-
* that maps import names to their resolved
|
|
257
|
+
* that maps import names to their resolved URLs
|
|
258
258
|
*/
|
|
259
259
|
function buildImportMap(importResult, allowExternalVariants) {
|
|
260
260
|
var importMap = new Map();
|
|
261
261
|
Object.values(importResult.relative).forEach(function (_ref) {
|
|
262
|
-
var
|
|
262
|
+
var url = _ref.url,
|
|
263
263
|
names = _ref.names;
|
|
264
264
|
names.forEach(function (_ref2) {
|
|
265
265
|
var name = _ref2.name,
|
|
266
266
|
alias = _ref2.alias;
|
|
267
267
|
// Use alias if available, otherwise use the original name
|
|
268
268
|
var nameToUse = alias || name;
|
|
269
|
-
importMap.set(nameToUse,
|
|
269
|
+
importMap.set(nameToUse, url);
|
|
270
270
|
});
|
|
271
271
|
});
|
|
272
272
|
|
package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js
CHANGED
|
@@ -5,6 +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 path from 'path';
|
|
10
|
+
// eslint-disable-next-line n/prefer-node-protocol
|
|
11
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
8
12
|
import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
|
|
9
13
|
import { generateResolvedExternals } from "./generateResolvedExternals.js";
|
|
10
14
|
import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
|
|
@@ -34,15 +38,19 @@ export function loadPrecomputedCodeHighlighterClient(_x) {
|
|
|
34
38
|
function _loadPrecomputedCodeHighlighterClient() {
|
|
35
39
|
_loadPrecomputedCodeHighlighterClient = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(source) {
|
|
36
40
|
var _this = this;
|
|
37
|
-
var callback, demoCall, allDependencies, allExternalsArray, clientDir, indexPath, indexDemoCall, indexSource, resolvedVariantMap, loadSource, variantPromises, variantResults, _iterator, _step, result, allExternals, runtimeExternals, _generateResolvedExte, importLines, resolvedExternals, precomputeData, modifiedSource, _t2, _t3;
|
|
41
|
+
var callback, resourceFileUrl, demoCall, allDependencies, allExternalsArray, clientDir, indexPath, indexFileUrl, indexDemoCall, indexSource, resolvedVariantMap, loadSource, variantPromises, variantResults, _iterator, _step, result, allExternals, runtimeExternals, _generateResolvedExte, importLines, resolvedExternals, precomputeData, modifiedSource, _t2, _t3;
|
|
38
42
|
return _regenerator().w(function (_context2) {
|
|
39
43
|
while (1) switch (_context2.p = _context2.n) {
|
|
40
44
|
case 0:
|
|
41
45
|
callback = this.async();
|
|
42
46
|
this.cacheable();
|
|
43
47
|
_context2.p = 1;
|
|
48
|
+
// Convert the filesystem path to a file:// URL for cross-platform compatibility
|
|
49
|
+
// pathToFileURL handles Windows drive letters correctly (e.g., C:\... → file:///C:/...)
|
|
50
|
+
resourceFileUrl = pathToFileURL(this.resourcePath).toString(); // Parse the source to find a single createDemoClient call
|
|
51
|
+
// Use metadataOnly mode since client calls only have (url, options?) arguments
|
|
44
52
|
_context2.n = 2;
|
|
45
|
-
return parseCreateFactoryCall(source,
|
|
53
|
+
return parseCreateFactoryCall(source, resourceFileUrl, {
|
|
46
54
|
metadataOnly: true
|
|
47
55
|
});
|
|
48
56
|
case 2:
|
|
@@ -72,8 +80,9 @@ function _loadPrecomputedCodeHighlighterClient() {
|
|
|
72
80
|
allDependencies = [];
|
|
73
81
|
allExternalsArray = []; // For client files, we need to read the corresponding index.ts to get variants
|
|
74
82
|
// The client.ts and index.ts should be in the same directory
|
|
75
|
-
clientDir =
|
|
76
|
-
indexPath =
|
|
83
|
+
clientDir = path.dirname(this.resourcePath);
|
|
84
|
+
indexPath = path.join(clientDir, 'index.ts'); // Convert to file:// URL for parseCreateFactoryCall
|
|
85
|
+
indexFileUrl = pathToFileURL(indexPath).toString(); // Read and parse the index.ts file to get variant information
|
|
77
86
|
indexDemoCall = null;
|
|
78
87
|
_context2.p = 6;
|
|
79
88
|
_context2.n = 7;
|
|
@@ -83,7 +92,7 @@ function _loadPrecomputedCodeHighlighterClient() {
|
|
|
83
92
|
// Add index.ts as a dependency for hot reloading
|
|
84
93
|
this.addDependency(indexPath);
|
|
85
94
|
_context2.n = 8;
|
|
86
|
-
return parseCreateFactoryCall(indexSource,
|
|
95
|
+
return parseCreateFactoryCall(indexSource, indexFileUrl);
|
|
87
96
|
case 8:
|
|
88
97
|
indexDemoCall = _context2.v;
|
|
89
98
|
_context2.n = 10;
|
|
@@ -213,8 +222,9 @@ function _loadPrecomputedCodeHighlighterClient() {
|
|
|
213
222
|
|
|
214
223
|
// Add all dependencies to webpack's watch list
|
|
215
224
|
allDependencies.forEach(function (dep) {
|
|
216
|
-
//
|
|
217
|
-
|
|
225
|
+
// Convert file:// URLs to proper file system paths for webpack's dependency tracking
|
|
226
|
+
// Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... → C:\...)
|
|
227
|
+
_this.addDependency(dep.startsWith('file://') ? fileURLToPath(dep) : dep);
|
|
218
228
|
});
|
|
219
229
|
callback(null, modifiedSource);
|
|
220
230
|
_context2.n = 15;
|
|
@@ -5,6 +5,8 @@ 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 path from 'path';
|
|
8
|
+
// eslint-disable-next-line n/prefer-node-protocol
|
|
9
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
8
10
|
import { createPerformanceLogger, logPerformance, nameMark, performanceMeasure } from "../loadPrecomputedCodeHighlighter/performanceLogger.js";
|
|
9
11
|
import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
|
|
10
12
|
import { replacePrecomputeValue } from "../loadPrecomputedCodeHighlighter/replacePrecomputeValue.js";
|
|
@@ -18,7 +20,7 @@ export function loadPrecomputedSitemap(_x) {
|
|
|
18
20
|
function _loadPrecomputedSitemap() {
|
|
19
21
|
_loadPrecomputedSitemap = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(source) {
|
|
20
22
|
var _options$performance$, _options$performance, _options$performance$2, _options$performance2, _options$performance3;
|
|
21
|
-
var callback, options, performanceNotableMs, performanceShowWrapperMeasures, relativePath, observer, currentMark, _observer, _observer2, sitemapCall, variants, sitemapData, rootContext, loadPageIndex, entries, results, _iterator, _step, result, precomputeData, modifiedSource, relative, importPathsToRewrite, importResult, _i, _Object$entries, _Object$entries$_i, importPath, importData, _observer3, _observer4, _t2;
|
|
23
|
+
var callback, options, performanceNotableMs, performanceShowWrapperMeasures, relativePath, observer, currentMark, _observer, _observer2, resourceFileUrl, sitemapCall, variants, sitemapData, rootContext, loadPageIndex, entries, results, _iterator, _step, result, precomputeData, modifiedSource, relative, importPathsToRewrite, importResult, _i, _Object$entries, _Object$entries$_i, importPath, importData, _observer3, _observer4, _t2;
|
|
22
24
|
return _regenerator().w(function (_context2) {
|
|
23
25
|
while (1) switch (_context2.p = _context2.n) {
|
|
24
26
|
case 0:
|
|
@@ -40,8 +42,11 @@ function _loadPrecomputedSitemap() {
|
|
|
40
42
|
currentMark = nameMark(functionName, 'Start Loading', [relativePath]);
|
|
41
43
|
performance.mark(currentMark);
|
|
42
44
|
_context2.p = 1;
|
|
45
|
+
// Convert the filesystem path to a file:// URL for cross-platform compatibility
|
|
46
|
+
// pathToFileURL handles Windows drive letters correctly (e.g., C:\... → file:///C:/...)
|
|
47
|
+
resourceFileUrl = pathToFileURL(this.resourcePath).toString(); // Parse the source to find a single createSitemap call
|
|
43
48
|
_context2.n = 2;
|
|
44
|
-
return parseCreateFactoryCall(source,
|
|
49
|
+
return parseCreateFactoryCall(source, resourceFileUrl);
|
|
45
50
|
case 2:
|
|
46
51
|
sitemapCall = _context2.v;
|
|
47
52
|
currentMark = performanceMeasure(currentMark, {
|
|
@@ -93,7 +98,9 @@ function _loadPrecomputedSitemap() {
|
|
|
93
98
|
while (1) switch (_context.p = _context.n) {
|
|
94
99
|
case 0:
|
|
95
100
|
_ref3 = _slicedToArray(_ref, 2), key = _ref3[0], importPath = _ref3[1];
|
|
96
|
-
|
|
101
|
+
// Convert file:// URLs to proper file system paths for webpack's dependency tracking
|
|
102
|
+
// Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... → C:\...)
|
|
103
|
+
absolutePath = importPath.startsWith('file://') ? fileURLToPath(importPath) : importPath;
|
|
97
104
|
_context.p = 1;
|
|
98
105
|
_context.n = 2;
|
|
99
106
|
return loadPageIndex(importPath);
|
|
@@ -2,6 +2,7 @@ import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { resolveVariantPathsWithFs } from "./resolveModulePathWithFs.js";
|
|
6
7
|
import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
|
|
7
8
|
import { getFileNameFromUrl } from "../loaderUtils/index.js";
|
|
@@ -35,14 +36,15 @@ export function createLoadServerCodeMeta() {
|
|
|
35
36
|
return _regenerator().w(function (_context) {
|
|
36
37
|
while (1) switch (_context.n) {
|
|
37
38
|
case 0:
|
|
38
|
-
//
|
|
39
|
-
|
|
39
|
+
// Convert file:// URL to proper file system path for reading the file
|
|
40
|
+
// Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... → C:\...)
|
|
41
|
+
filePath = url.startsWith('file://') ? fileURLToPath(url) : url; // Read the source file to find createDemo calls
|
|
40
42
|
_context.n = 1;
|
|
41
43
|
return readFile(filePath, 'utf-8');
|
|
42
44
|
case 1:
|
|
43
45
|
source = _context.v;
|
|
44
46
|
_context.n = 2;
|
|
45
|
-
return parseCreateFactoryCall(source,
|
|
47
|
+
return parseCreateFactoryCall(source, url);
|
|
46
48
|
case 2:
|
|
47
49
|
demoCall = _context.v;
|
|
48
50
|
if (!(!demoCall || !demoCall.variants)) {
|
|
@@ -18,7 +18,7 @@ export declare function resolveModulePathWithFs(modulePath: string, options: Res
|
|
|
18
18
|
* @param options - Configuration options
|
|
19
19
|
* @returns Promise<Map<string, string>> - Map from input path to resolved file path
|
|
20
20
|
*/
|
|
21
|
-
export declare function resolveModulePathsWithFs(
|
|
21
|
+
export declare function resolveModulePathsWithFs(moduleUrls: string[], options?: ResolveModulePathOptions): Promise<Map<string, string>>;
|
|
22
22
|
/**
|
|
23
23
|
* Resolves import result by separating JavaScript modules from static assets,
|
|
24
24
|
* only resolving JavaScript modules and returning a combined map.
|
|
@@ -30,7 +30,7 @@ export declare function resolveModulePathsWithFs(modulePaths: string[], options?
|
|
|
30
30
|
* @returns Promise<Map<string, string>> - Map from import path to resolved file path
|
|
31
31
|
*/
|
|
32
32
|
export declare function resolveImportResultWithFs(importResult: Record<string, {
|
|
33
|
-
|
|
33
|
+
url: string;
|
|
34
34
|
names: string[];
|
|
35
35
|
includeTypeDefs?: true;
|
|
36
36
|
positions?: Array<{
|
|
@@ -3,20 +3,26 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
3
3
|
// webpack does not like node: imports
|
|
4
4
|
// eslint-disable-next-line n/prefer-node-protocol
|
|
5
5
|
import { readdir } from 'fs/promises';
|
|
6
|
+
// eslint-disable-next-line n/prefer-node-protocol
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
6
8
|
import { resolveModulePath, resolveModulePaths, resolveImportResult, resolveVariantPaths } from "../loaderUtils/resolveModulePath.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Node.js filesystem-based directory reader that converts Dirent objects
|
|
10
12
|
* to the DirectoryEntry interface expected by the resolver functions.
|
|
13
|
+
*
|
|
14
|
+
* The input is a file:// URL. We convert it to a filesystem path using fileURLToPath.
|
|
11
15
|
*/
|
|
12
16
|
var nodeDirectoryReader = /*#__PURE__*/function () {
|
|
13
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(
|
|
14
|
-
var entries;
|
|
17
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fileUrl) {
|
|
18
|
+
var fsPath, entries;
|
|
15
19
|
return _regenerator().w(function (_context) {
|
|
16
20
|
while (1) switch (_context.n) {
|
|
17
21
|
case 0:
|
|
22
|
+
// Convert file:// URL to filesystem path for Node.js fs APIs
|
|
23
|
+
fsPath = fileURLToPath(fileUrl);
|
|
18
24
|
_context.n = 1;
|
|
19
|
-
return readdir(
|
|
25
|
+
return readdir(fsPath, {
|
|
20
26
|
withFileTypes: true
|
|
21
27
|
});
|
|
22
28
|
case 1:
|
|
@@ -59,7 +65,7 @@ export function resolveModulePathWithFs(_x2) {
|
|
|
59
65
|
* @returns Promise<Map<string, string>> - Map from input path to resolved file path
|
|
60
66
|
*/
|
|
61
67
|
function _resolveModulePathWithFs() {
|
|
62
|
-
_resolveModulePathWithFs = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(
|
|
68
|
+
_resolveModulePathWithFs = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(moduleUrl) {
|
|
63
69
|
var options,
|
|
64
70
|
includeTypeDefs,
|
|
65
71
|
_args2 = arguments;
|
|
@@ -68,7 +74,7 @@ function _resolveModulePathWithFs() {
|
|
|
68
74
|
case 0:
|
|
69
75
|
options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
70
76
|
includeTypeDefs = _args2.length > 2 ? _args2[2] : undefined;
|
|
71
|
-
return _context2.a(2, resolveModulePath(
|
|
77
|
+
return _context2.a(2, resolveModulePath(moduleUrl, nodeDirectoryReader, options, includeTypeDefs));
|
|
72
78
|
}
|
|
73
79
|
}, _callee2);
|
|
74
80
|
}));
|
|
@@ -89,14 +95,14 @@ export function resolveModulePathsWithFs(_x3) {
|
|
|
89
95
|
* @returns Promise<Map<string, string>> - Map from import path to resolved file path
|
|
90
96
|
*/
|
|
91
97
|
function _resolveModulePathsWithFs() {
|
|
92
|
-
_resolveModulePathsWithFs = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(
|
|
98
|
+
_resolveModulePathsWithFs = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(moduleUrls) {
|
|
93
99
|
var options,
|
|
94
100
|
_args3 = arguments;
|
|
95
101
|
return _regenerator().w(function (_context3) {
|
|
96
102
|
while (1) switch (_context3.n) {
|
|
97
103
|
case 0:
|
|
98
104
|
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
99
|
-
return _context3.a(2, resolveModulePaths(
|
|
105
|
+
return _context3.a(2, resolveModulePaths(moduleUrls, nodeDirectoryReader, options));
|
|
100
106
|
}
|
|
101
107
|
}, _callee3);
|
|
102
108
|
}));
|
|
@@ -8,6 +8,7 @@ var _excluded = ["titleMarkdown", "children"],
|
|
|
8
8
|
_excluded2 = ["descriptionMarkdown", "sections"];
|
|
9
9
|
import fs from 'node:fs/promises';
|
|
10
10
|
import path from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
11
12
|
import { markdownToMetadata } from "../syncPageIndex/metadataToMarkdown.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -128,8 +129,9 @@ export function createLoadServerPageIndex() {
|
|
|
128
129
|
return _regenerator().w(function (_context) {
|
|
129
130
|
while (1) switch (_context.n) {
|
|
130
131
|
case 0:
|
|
131
|
-
//
|
|
132
|
-
|
|
132
|
+
// Convert file:// URLs to proper file system paths for reading the file
|
|
133
|
+
// Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... → C:\...)
|
|
134
|
+
absolutePath = filePath.startsWith('file://') ? fileURLToPath(filePath) : filePath; // Extract prefix and title from the import path
|
|
133
135
|
_extractPrefixAndTitl = extractPrefixAndTitle(absolutePath, rootContext), prefix = _extractPrefixAndTitl.prefix, generatedTitle = _extractPrefixAndTitl.title; // Read the markdown file
|
|
134
136
|
_context.n = 1;
|
|
135
137
|
return fs.readFile(absolutePath, 'utf-8');
|
|
@@ -4,6 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
5
|
import { readFile } from 'node:fs/promises';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
7
8
|
import { createLoadServerPageIndex } from "../loadServerPageIndex/loadServerPageIndex.js";
|
|
8
9
|
import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
|
|
9
10
|
|
|
@@ -59,8 +60,9 @@ export function createLoadServerSitemap() {
|
|
|
59
60
|
return _regenerator().w(function (_context2) {
|
|
60
61
|
while (1) switch (_context2.n) {
|
|
61
62
|
case 0:
|
|
62
|
-
//
|
|
63
|
-
|
|
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
|
|
64
66
|
rootContext = (_options$rootContext = options.rootContext) != null ? _options$rootContext : path.dirname(filePath); // Create page index loader with root context
|
|
65
67
|
loadPageIndex = createLoadServerPageIndex({
|
|
66
68
|
rootContext: rootContext
|
|
@@ -5,6 +5,8 @@ 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
11
|
import { resolveImportResultWithFs } from "../loadServerCodeMeta/resolveModulePathWithFs.js";
|
|
10
12
|
import { processRelativeImports } from "../loaderUtils/processRelativeImports.js";
|
|
@@ -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$,
|
|
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
|
-
//
|
|
41
|
-
|
|
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,
|
|
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],
|
|
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
|
-
|
|
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
|
|
119
|
-
return
|
|
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],
|
|
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
|
-
|
|
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
|
|
155
|
-
return resolvedPathsMap.get(
|
|
156
|
-
}).filter(function (
|
|
157
|
-
return
|
|
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, {
|
|
@@ -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
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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 =
|
|
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";
|