@mui/internal-docs-infra 0.1.1-alpha.9 → 0.1.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/README.md +1 -3
- package/esm/package.json +1 -0
- package/esm/useCopier/index.d.ts +15 -0
- package/esm/useCopier/index.d.ts.map +1 -0
- package/esm/useCopier/index.js +62 -0
- package/esm/useDemo/index.d.ts +51 -0
- package/esm/useDemo/index.d.ts.map +1 -0
- package/esm/useDemo/index.js +104 -0
- package/package.json +31 -32
- package/useCopier/index.d.ts +1 -1
- package/useCopier/index.js +23 -15
- package/useDemo/index.d.ts +51 -6
- package/useDemo/index.js +112 -6
- package/CodeControllerContext/CodeControllerContext.d.ts +0 -22
- package/CodeControllerContext/CodeControllerContext.d.ts.map +0 -1
- package/CodeControllerContext/CodeControllerContext.js +0 -14
- package/CodeControllerContext/index.d.ts +0 -1
- package/CodeControllerContext/index.d.ts.map +0 -1
- package/CodeControllerContext/index.js +0 -1
- package/CodeExternalsContext/CodeExternalsContext.d.ts +0 -8
- package/CodeExternalsContext/CodeExternalsContext.d.ts.map +0 -1
- package/CodeExternalsContext/CodeExternalsContext.js +0 -7
- package/CodeExternalsContext/index.d.ts +0 -1
- package/CodeExternalsContext/index.d.ts.map +0 -1
- package/CodeExternalsContext/index.js +0 -1
- package/CodeHighlighter/CodeHighlighter.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighter.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighter.js +0 -470
- package/CodeHighlighter/CodeHighlighterClient.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighterClient.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterClient.js +0 -837
- package/CodeHighlighter/CodeHighlighterContext.d.ts +0 -16
- package/CodeHighlighter/CodeHighlighterContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterContext.js +0 -14
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +0 -7
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterFallbackContext.js +0 -13
- package/CodeHighlighter/applyTransform.d.ts +0 -19
- package/CodeHighlighter/applyTransform.d.ts.map +0 -1
- package/CodeHighlighter/applyTransform.js +0 -75
- package/CodeHighlighter/codeToFallbackProps.d.ts +0 -2
- package/CodeHighlighter/codeToFallbackProps.d.ts.map +0 -1
- package/CodeHighlighter/codeToFallbackProps.js +0 -73
- package/CodeHighlighter/errors.d.ts +0 -0
- package/CodeHighlighter/errors.d.ts.map +0 -1
- package/CodeHighlighter/errors.js +0 -1
- package/CodeHighlighter/hasAllVariants.d.ts +0 -2
- package/CodeHighlighter/hasAllVariants.d.ts.map +0 -1
- package/CodeHighlighter/hasAllVariants.js +0 -31
- package/CodeHighlighter/index.d.ts +0 -4
- package/CodeHighlighter/index.d.ts.map +0 -1
- package/CodeHighlighter/index.js +0 -4
- package/CodeHighlighter/loadFallbackCode.d.ts +0 -10
- package/CodeHighlighter/loadFallbackCode.d.ts.map +0 -1
- package/CodeHighlighter/loadFallbackCode.js +0 -632
- package/CodeHighlighter/loadVariant.d.ts +0 -12
- package/CodeHighlighter/loadVariant.d.ts.map +0 -1
- package/CodeHighlighter/loadVariant.js +0 -1083
- package/CodeHighlighter/maybeInitialData.d.ts +0 -10
- package/CodeHighlighter/maybeInitialData.d.ts.map +0 -1
- package/CodeHighlighter/maybeInitialData.js +0 -94
- package/CodeHighlighter/parseCode.d.ts +0 -6
- package/CodeHighlighter/parseCode.d.ts.map +0 -1
- package/CodeHighlighter/parseCode.js +0 -134
- package/CodeHighlighter/parseControlledCode.d.ts +0 -6
- package/CodeHighlighter/parseControlledCode.d.ts.map +0 -1
- package/CodeHighlighter/parseControlledCode.js +0 -87
- package/CodeHighlighter/transformCode.d.ts +0 -21
- package/CodeHighlighter/transformCode.d.ts.map +0 -1
- package/CodeHighlighter/transformCode.js +0 -263
- package/CodeHighlighter/transformParsedSource.d.ts +0 -3
- package/CodeHighlighter/transformParsedSource.d.ts.map +0 -1
- package/CodeHighlighter/transformParsedSource.js +0 -66
- package/CodeHighlighter/transformSource.d.ts +0 -2
- package/CodeHighlighter/transformSource.d.ts.map +0 -1
- package/CodeHighlighter/transformSource.js +0 -107
- package/CodeHighlighter/types.d.ts +0 -160
- package/CodeHighlighter/types.d.ts.map +0 -1
- package/CodeHighlighter/types.js +0 -1
- package/CodeProvider/CodeContext.d.ts +0 -12
- package/CodeProvider/CodeContext.d.ts.map +0 -1
- package/CodeProvider/CodeContext.js +0 -8
- package/CodeProvider/CodeProvider.d.ts +0 -13
- package/CodeProvider/CodeProvider.d.ts.map +0 -1
- package/CodeProvider/CodeProvider.js +0 -65
- package/CodeProvider/index.d.ts +0 -1
- package/CodeProvider/index.d.ts.map +0 -1
- package/CodeProvider/index.js +0 -1
- package/abstractCreateDemo/abstractCreateDemo.d.ts +0 -35
- package/abstractCreateDemo/abstractCreateDemo.d.ts.map +0 -1
- package/abstractCreateDemo/abstractCreateDemo.js +0 -91
- package/abstractCreateDemo/index.d.ts +0 -1
- package/abstractCreateDemo/index.d.ts.map +0 -1
- package/abstractCreateDemo/index.js +0 -1
- package/createDemoData/createDemoData.d.ts +0 -44
- package/createDemoData/createDemoData.d.ts.map +0 -1
- package/createDemoData/createDemoData.js +0 -75
- package/createDemoData/index.d.ts +0 -1
- package/createDemoData/index.d.ts.map +0 -1
- package/createDemoData/index.js +0 -1
- package/createDemoData/types.d.ts +0 -28
- package/createDemoData/types.d.ts.map +0 -1
- package/createDemoData/types.js +0 -1
- package/pipeline/hastUtils/hastUtils.d.ts +0 -11
- package/pipeline/hastUtils/hastUtils.d.ts.map +0 -1
- package/pipeline/hastUtils/hastUtils.js +0 -67
- package/pipeline/hastUtils/index.d.ts +0 -1
- package/pipeline/hastUtils/index.d.ts.map +0 -1
- package/pipeline/hastUtils/index.js +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +0 -54
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +0 -465
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +0 -15
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +0 -253
- package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts +0 -2
- package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/index.js +0 -4
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -20
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -224
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +0 -31
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -433
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +0 -19
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +0 -168
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -25
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -73
- package/pipeline/loadServerCodeMeta/index.d.ts +0 -1
- package/pipeline/loadServerCodeMeta/index.d.ts.map +0 -1
- package/pipeline/loadServerCodeMeta/index.js +0 -1
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +0 -24
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +0 -1
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +0 -92
- package/pipeline/loadServerSource/index.d.ts +0 -1
- package/pipeline/loadServerSource/index.d.ts.map +0 -1
- package/pipeline/loadServerSource/index.js +0 -1
- package/pipeline/loadServerSource/loadServerSource.d.ts +0 -25
- package/pipeline/loadServerSource/loadServerSource.d.ts.map +0 -1
- package/pipeline/loadServerSource/loadServerSource.js +0 -135
- package/pipeline/loaderUtils/externalsToPackages.d.ts +0 -1
- package/pipeline/loaderUtils/externalsToPackages.d.ts.map +0 -1
- package/pipeline/loaderUtils/externalsToPackages.js +0 -46
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -34
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +0 -1
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +0 -161
- package/pipeline/loaderUtils/getFileNameFromUrl.d.ts +0 -11
- package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
- package/pipeline/loaderUtils/getFileNameFromUrl.js +0 -32
- package/pipeline/loaderUtils/index.d.ts +0 -7
- package/pipeline/loaderUtils/index.d.ts.map +0 -1
- package/pipeline/loaderUtils/index.js +0 -7
- package/pipeline/loaderUtils/mergeExternals.d.ts +0 -32
- package/pipeline/loaderUtils/mergeExternals.d.ts.map +0 -1
- package/pipeline/loaderUtils/mergeExternals.js +0 -72
- package/pipeline/loaderUtils/parseImports.d.ts +0 -20
- package/pipeline/loaderUtils/parseImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/parseImports.js +0 -307
- package/pipeline/loaderUtils/processRelativeImports.d.ts +0 -19
- package/pipeline/loaderUtils/processRelativeImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/processRelativeImports.js +0 -329
- package/pipeline/loaderUtils/resolveModulePath.d.ts +0 -87
- package/pipeline/loaderUtils/resolveModulePath.d.ts.map +0 -1
- package/pipeline/loaderUtils/resolveModulePath.js +0 -1449
- package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +0 -47
- package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
- package/pipeline/loaderUtils/resolveModulePathWithFs.js +0 -163
- package/pipeline/loaderUtils/rewriteImports.d.ts +0 -9
- package/pipeline/loaderUtils/rewriteImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/rewriteImports.js +0 -35
- package/pipeline/parseSource/grammars.d.ts +0 -2
- package/pipeline/parseSource/grammars.d.ts.map +0 -1
- package/pipeline/parseSource/grammars.js +0 -27
- package/pipeline/parseSource/index.d.ts +0 -1
- package/pipeline/parseSource/index.d.ts.map +0 -1
- package/pipeline/parseSource/index.js +0 -1
- package/pipeline/parseSource/parseSource.d.ts +0 -3
- package/pipeline/parseSource/parseSource.d.ts.map +0 -1
- package/pipeline/parseSource/parseSource.js +0 -47
- package/pipeline/transformHtmlCode/index.d.ts +0 -2
- package/pipeline/transformHtmlCode/index.d.ts.map +0 -1
- package/pipeline/transformHtmlCode/index.js +0 -4
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +0 -13
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +0 -1
- package/pipeline/transformHtmlCode/transformHtmlCode.js +0 -303
- package/pipeline/transformMarkdownCode/index.d.ts +0 -2
- package/pipeline/transformMarkdownCode/index.d.ts.map +0 -1
- package/pipeline/transformMarkdownCode/index.js +0 -4
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +0 -2
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +0 -1
- package/pipeline/transformMarkdownCode/transformMarkdownCode.js +0 -514
- package/pipeline/transformTypescriptToJavascript/index.d.ts +0 -1
- package/pipeline/transformTypescriptToJavascript/index.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/index.js +0 -1
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts +0 -13
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/removeTypes.js +0 -134
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +0 -3
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +0 -34
- package/useCode/index.d.ts +0 -1
- package/useCode/index.d.ts.map +0 -1
- package/useCode/index.js +0 -1
- package/useCode/useCode.d.ts +0 -39
- package/useCode/useCode.d.ts.map +0 -1
- package/useCode/useCode.js +0 -122
- package/useCode/useCodeUtils.d.ts +0 -45
- package/useCode/useCodeUtils.d.ts.map +0 -1
- package/useCode/useCodeUtils.js +0 -240
- package/useCode/useCopyFunctionality.d.ts +0 -17
- package/useCode/useCopyFunctionality.d.ts.map +0 -1
- package/useCode/useCopyFunctionality.js +0 -28
- package/useCode/useFileNavigation.d.ts +0 -48
- package/useCode/useFileNavigation.d.ts.map +0 -1
- package/useCode/useFileNavigation.js +0 -370
- package/useCode/useSourceEditing.d.ts +0 -19
- package/useCode/useSourceEditing.d.ts.map +0 -1
- package/useCode/useSourceEditing.js +0 -32
- package/useCode/useTransformManagement.d.ts +0 -28
- package/useCode/useTransformManagement.d.ts.map +0 -1
- package/useCode/useTransformManagement.js +0 -82
- package/useCode/useUIState.d.ts +0 -16
- package/useCode/useUIState.d.ts.map +0 -1
- package/useCode/useUIState.js +0 -21
- package/useCode/useVariantSelection.d.ts +0 -21
- package/useCode/useVariantSelection.d.ts.map +0 -1
- package/useCode/useVariantSelection.js +0 -84
- package/useCopier/index.d.ts.map +0 -1
- package/useDemo/createCodeSandbox.d.ts +0 -18
- package/useDemo/createCodeSandbox.d.ts.map +0 -1
- package/useDemo/createCodeSandbox.js +0 -48
- package/useDemo/createStackBlitz.d.ts +0 -22
- package/useDemo/createStackBlitz.d.ts.map +0 -1
- package/useDemo/createStackBlitz.js +0 -38
- package/useDemo/examineVariant.d.ts +0 -25
- package/useDemo/examineVariant.d.ts.map +0 -1
- package/useDemo/examineVariant.js +0 -134
- package/useDemo/exportVariant.d.ts +0 -110
- package/useDemo/exportVariant.d.ts.map +0 -1
- package/useDemo/exportVariant.js +0 -320
- package/useDemo/exportVariantAsCra.d.ts +0 -15
- package/useDemo/exportVariantAsCra.d.ts.map +0 -1
- package/useDemo/exportVariantAsCra.js +0 -56
- package/useDemo/flattenVariant.d.ts +0 -17
- package/useDemo/flattenVariant.d.ts.map +0 -1
- package/useDemo/flattenVariant.js +0 -206
- package/useDemo/index.d.ts.map +0 -1
- package/useDemo/useDemo.d.ts +0 -78
- package/useDemo/useDemo.d.ts.map +0 -1
- package/useDemo/useDemo.js +0 -174
- package/useLocalStorageState/index.d.ts +0 -2
- package/useLocalStorageState/index.d.ts.map +0 -1
- package/useLocalStorageState/index.js +0 -2
- package/useLocalStorageState/useLocalStorageState.d.ts +0 -14
- package/useLocalStorageState/useLocalStorageState.d.ts.map +0 -1
- package/useLocalStorageState/useLocalStorageState.js +0 -128
- package/useOnHydrate/index.d.ts +0 -1
- package/useOnHydrate/index.d.ts.map +0 -1
- package/useOnHydrate/index.js +0 -1
- package/useOnHydrate/useOnHydrate.d.ts +0 -1
- package/useOnHydrate/useOnHydrate.d.ts.map +0 -1
- package/useOnHydrate/useOnHydrate.js +0 -18
- package/useOnIdle/index.d.ts +0 -1
- package/useOnIdle/index.d.ts.map +0 -1
- package/useOnIdle/index.js +0 -1
- package/useOnIdle/useOnIdle.d.ts +0 -1
- package/useOnIdle/useOnIdle.d.ts.map +0 -1
- package/useOnIdle/useOnIdle.js +0 -39
- package/useUrlHashState/index.d.ts +0 -1
- package/useUrlHashState/index.d.ts.map +0 -1
- package/useUrlHashState/index.js +0 -1
- package/useUrlHashState/useUrlHashState.d.ts +0 -50
- package/useUrlHashState/useUrlHashState.d.ts.map +0 -1
- package/useUrlHashState/useUrlHashState.js +0 -113
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import { rewriteImportsToSameDirectory } from "./rewriteImports.js";
|
|
5
|
-
import { isJavaScriptModule } from "./resolveModulePath.js";
|
|
6
|
-
import { getFileNameFromUrl } from "./getFileNameFromUrl.js";
|
|
7
|
-
/**
|
|
8
|
-
* Processes imports based on the specified storage mode, automatically handling
|
|
9
|
-
* source rewriting when needed (e.g., for 'flat' mode).
|
|
10
|
-
*
|
|
11
|
-
* @param source - The original source code
|
|
12
|
-
* @param importResult - The result from parseImports
|
|
13
|
-
* @param resolvedPathsMap - Map from import paths to resolved file paths
|
|
14
|
-
* @param storeAt - How to process the imports
|
|
15
|
-
* @returns Object with processed source and extraFiles mapping
|
|
16
|
-
*/
|
|
17
|
-
export function processRelativeImports(source, importResult, resolvedPathsMap, storeAt) {
|
|
18
|
-
var extraFiles = {};
|
|
19
|
-
|
|
20
|
-
// For flat mode, we need to handle naming conflicts intelligently
|
|
21
|
-
if (storeAt === 'flat') {
|
|
22
|
-
var result = processFlatMode(importResult, resolvedPathsMap);
|
|
23
|
-
|
|
24
|
-
// Create import path mapping for rewriting
|
|
25
|
-
var importPathMapping = new Map();
|
|
26
|
-
|
|
27
|
-
// Build a reverse mapping from resolved paths to extraFiles keys
|
|
28
|
-
var resolvedToExtraFile = new Map();
|
|
29
|
-
Object.entries(result.extraFiles).forEach(function (_ref) {
|
|
30
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
31
|
-
extraFileKey = _ref2[0],
|
|
32
|
-
fileUrl = _ref2[1];
|
|
33
|
-
var resolvedPath = fileUrl.replace('file://', '');
|
|
34
|
-
resolvedToExtraFile.set(resolvedPath, extraFileKey);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// For each import, find its resolved path and map to the corresponding extraFile key
|
|
38
|
-
Object.entries(importResult).forEach(function (_ref3) {
|
|
39
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
40
|
-
relativePath = _ref4[0],
|
|
41
|
-
importInfo = _ref4[1];
|
|
42
|
-
var resolvedPath = resolvedPathsMap.get(importInfo.path);
|
|
43
|
-
if (resolvedPath) {
|
|
44
|
-
var extraFileKey = resolvedToExtraFile.get(resolvedPath);
|
|
45
|
-
if (extraFileKey) {
|
|
46
|
-
// For JavaScript modules, remove the extension; for other files (CSS, JSON, etc.), keep it
|
|
47
|
-
var isJavascriptModule = isJavaScriptModule(relativePath);
|
|
48
|
-
var newPath = extraFileKey;
|
|
49
|
-
if (isJavascriptModule) {
|
|
50
|
-
// Handle TypeScript declaration files (.d.ts) properly
|
|
51
|
-
if (newPath.endsWith('.d.ts')) {
|
|
52
|
-
newPath = newPath.replace(/\.d\.ts$/, '');
|
|
53
|
-
} else {
|
|
54
|
-
newPath = newPath.replace(/\.[^/.]+$/, '');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// For non-JS modules (CSS, JSON, etc.), keep the full path with extension
|
|
58
|
-
|
|
59
|
-
importPathMapping.set(relativePath, newPath);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Rewrite the source with the mapping
|
|
65
|
-
var rewrittenSource = rewriteImportsToSameDirectory(source, importPathMapping);
|
|
66
|
-
return {
|
|
67
|
-
processedSource: rewrittenSource,
|
|
68
|
-
extraFiles: result.extraFiles
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Process each import and generate extraFiles for non-flat modes
|
|
73
|
-
Object.entries(importResult).forEach(function (_ref5) {
|
|
74
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
75
|
-
relativePath = _ref6[0],
|
|
76
|
-
importInfo = _ref6[1];
|
|
77
|
-
var resolvedPath = resolvedPathsMap.get(importInfo.path);
|
|
78
|
-
if (resolvedPath) {
|
|
79
|
-
var fileExtension = getFileNameFromUrl(resolvedPath).extension;
|
|
80
|
-
var isJavascriptModule = isJavaScriptModule(relativePath);
|
|
81
|
-
var keyPath;
|
|
82
|
-
if (!isJavascriptModule) {
|
|
83
|
-
// For static assets (CSS, JSON, etc.), use the original import path as-is since it already has the extension
|
|
84
|
-
switch (storeAt) {
|
|
85
|
-
case 'canonical':
|
|
86
|
-
case 'import':
|
|
87
|
-
keyPath = relativePath;
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
keyPath = relativePath;
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
// For JS/TS modules, apply the existing logic
|
|
94
|
-
switch (storeAt) {
|
|
95
|
-
case 'canonical':
|
|
96
|
-
// Show the full resolved path including index files when they exist
|
|
97
|
-
// e.g., import '../Component' resolved to '/src/Component/index.js'
|
|
98
|
-
// becomes extraFiles: { '../Component/index.js': 'file:///src/Component/index.js' }
|
|
99
|
-
keyPath = "".concat(relativePath).concat(resolvedPath.endsWith("/index".concat(fileExtension)) ? "/index".concat(fileExtension) : fileExtension);
|
|
100
|
-
break;
|
|
101
|
-
case 'import':
|
|
102
|
-
// Use the original import path with the actual file extension
|
|
103
|
-
// e.g., import '../Component' with '/src/Component/index.js'
|
|
104
|
-
// becomes extraFiles: { '../Component.js': 'file:///src/Component/index.js' }
|
|
105
|
-
keyPath = "".concat(relativePath).concat(fileExtension);
|
|
106
|
-
break;
|
|
107
|
-
default:
|
|
108
|
-
keyPath = "".concat(relativePath).concat(fileExtension);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
extraFiles[keyPath] = "file://".concat(resolvedPath);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
return {
|
|
115
|
-
processedSource: source,
|
|
116
|
-
extraFiles: extraFiles
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Processes flat mode with intelligent conflict resolution
|
|
122
|
-
*/
|
|
123
|
-
function processFlatMode(importResult, resolvedPathsMap) {
|
|
124
|
-
var extraFiles = {};
|
|
125
|
-
var fileMapping = [];
|
|
126
|
-
|
|
127
|
-
// First pass: collect all files and their path segments
|
|
128
|
-
Object.entries(importResult).forEach(function (_ref7) {
|
|
129
|
-
var _ref8 = _slicedToArray(_ref7, 2),
|
|
130
|
-
_relativePath = _ref8[0],
|
|
131
|
-
importInfo = _ref8[1];
|
|
132
|
-
var resolvedPath = resolvedPathsMap.get(importInfo.path);
|
|
133
|
-
if (resolvedPath) {
|
|
134
|
-
var fileExtension = getFileNameFromUrl(resolvedPath).extension;
|
|
135
|
-
var pathSegments = resolvedPath.split('/').filter(Boolean);
|
|
136
|
-
fileMapping.push({
|
|
137
|
-
resolvedPath: resolvedPath,
|
|
138
|
-
extension: fileExtension,
|
|
139
|
-
segments: pathSegments
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// Second pass: determine candidate names and group by conflicts
|
|
145
|
-
var candidateNames = new Map();
|
|
146
|
-
var nameGroups = new Map();
|
|
147
|
-
for (var _i = 0, _fileMapping = fileMapping; _i < _fileMapping.length; _i++) {
|
|
148
|
-
var file = _fileMapping[_i];
|
|
149
|
-
var fileName = file.segments[file.segments.length - 1];
|
|
150
|
-
var isIndexFile = fileName.startsWith('index.');
|
|
151
|
-
var candidateName = void 0;
|
|
152
|
-
if (isIndexFile) {
|
|
153
|
-
// For index files, use the parent directory name + extension
|
|
154
|
-
var parentDir = file.segments[file.segments.length - 2];
|
|
155
|
-
candidateName = "".concat(parentDir).concat(file.extension);
|
|
156
|
-
} else {
|
|
157
|
-
candidateName = fileName;
|
|
158
|
-
}
|
|
159
|
-
candidateNames.set(file.resolvedPath, candidateName);
|
|
160
|
-
if (!nameGroups.has(candidateName)) {
|
|
161
|
-
nameGroups.set(candidateName, []);
|
|
162
|
-
}
|
|
163
|
-
nameGroups.get(candidateName).push(file.resolvedPath);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Third pass: resolve conflicts for all files in conflicting groups
|
|
167
|
-
var finalNames = new Map();
|
|
168
|
-
nameGroups.forEach(function (paths, candidateName) {
|
|
169
|
-
if (paths.length === 1) {
|
|
170
|
-
// No conflict, use the candidate name
|
|
171
|
-
finalNames.set(paths[0], candidateName);
|
|
172
|
-
} else {
|
|
173
|
-
// Conflict detected, find optimal minimal distinguishing paths for all files
|
|
174
|
-
var conflictingFiles = paths.map(function (resolvedPath) {
|
|
175
|
-
return fileMapping.find(function (f) {
|
|
176
|
-
return f.resolvedPath === resolvedPath;
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// Check if we can resolve conflicts by treating some files differently
|
|
181
|
-
// This specifically handles cases like:
|
|
182
|
-
// - /path/to/a/Component.js and /path/to/Component.js (parent-child relationship)
|
|
183
|
-
|
|
184
|
-
// Find files that are "shorter" (parent level) compared to others
|
|
185
|
-
var minLength = Math.min.apply(Math, _toConsumableArray(conflictingFiles.map(function (f) {
|
|
186
|
-
return f.segments.length;
|
|
187
|
-
})));
|
|
188
|
-
var maxLengthForSmart = Math.max.apply(Math, _toConsumableArray(conflictingFiles.map(function (f) {
|
|
189
|
-
return f.segments.length;
|
|
190
|
-
})));
|
|
191
|
-
if (maxLengthForSmart > minLength) {
|
|
192
|
-
// We have files at different depths, check if it's a parent-child scenario
|
|
193
|
-
var shorterFiles = conflictingFiles.filter(function (file) {
|
|
194
|
-
return file.segments.length === minLength;
|
|
195
|
-
});
|
|
196
|
-
var longerFiles = conflictingFiles.filter(function (file) {
|
|
197
|
-
return file.segments.length > minLength;
|
|
198
|
-
});
|
|
199
|
-
if (shorterFiles.length === 1 && longerFiles.length >= 1) {
|
|
200
|
-
// Check if the shorter file is truly a "parent" of the longer files
|
|
201
|
-
var shorterFile = shorterFiles[0];
|
|
202
|
-
var shorterPath = shorterFile.segments.slice(0, -1).join('/'); // Remove filename
|
|
203
|
-
|
|
204
|
-
// Check if all longer files share the same prefix as the shorter file
|
|
205
|
-
var allLongerFilesAreChildren = longerFiles.every(function (longerFile) {
|
|
206
|
-
var longerPath = longerFile.segments.slice(0, shorterFile.segments.length - 1).join('/');
|
|
207
|
-
return longerPath === shorterPath;
|
|
208
|
-
});
|
|
209
|
-
if (allLongerFilesAreChildren) {
|
|
210
|
-
// This is a true parent-child scenario, apply smart resolution
|
|
211
|
-
|
|
212
|
-
// For longer files, find distinguishing index
|
|
213
|
-
var _distinguishingIndex = -1;
|
|
214
|
-
var maxLongerLength = Math.max.apply(Math, _toConsumableArray(longerFiles.map(function (f) {
|
|
215
|
-
return f.segments.length;
|
|
216
|
-
})));
|
|
217
|
-
var _loop = function _loop(i) {
|
|
218
|
-
var segmentsAtIndex = new Set(longerFiles.map(function (f) {
|
|
219
|
-
return f.segments[i];
|
|
220
|
-
}).filter(Boolean));
|
|
221
|
-
if (segmentsAtIndex.size === longerFiles.length) {
|
|
222
|
-
_distinguishingIndex = i;
|
|
223
|
-
return 1; // break
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
for (var i = 0; i < maxLongerLength; i += 1) {
|
|
227
|
-
if (_loop(i)) break;
|
|
228
|
-
}
|
|
229
|
-
if (_distinguishingIndex !== -1) {
|
|
230
|
-
// Generate names for longer files using distinguishing segment
|
|
231
|
-
var _iterator = _createForOfIteratorHelper(longerFiles),
|
|
232
|
-
_step;
|
|
233
|
-
try {
|
|
234
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
235
|
-
var _file = _step.value;
|
|
236
|
-
var _fileName = _file.segments[_file.segments.length - 1];
|
|
237
|
-
var _isIndexFile = _fileName.startsWith('index.');
|
|
238
|
-
var distinguishingSegment = _file.segments[_distinguishingIndex];
|
|
239
|
-
var finalName = void 0;
|
|
240
|
-
if (_isIndexFile) {
|
|
241
|
-
var _parentDir = _file.segments[_file.segments.length - 2];
|
|
242
|
-
finalName = "".concat(distinguishingSegment, "/").concat(_parentDir).concat(_file.extension);
|
|
243
|
-
} else {
|
|
244
|
-
finalName = "".concat(distinguishingSegment, "/").concat(_fileName);
|
|
245
|
-
}
|
|
246
|
-
finalNames.set(_file.resolvedPath, finalName);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// For shorter files, use the candidate name as-is (no conflicts after disambiguation)
|
|
250
|
-
} catch (err) {
|
|
251
|
-
_iterator.e(err);
|
|
252
|
-
} finally {
|
|
253
|
-
_iterator.f();
|
|
254
|
-
}
|
|
255
|
-
var _iterator2 = _createForOfIteratorHelper(shorterFiles),
|
|
256
|
-
_step2;
|
|
257
|
-
try {
|
|
258
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
259
|
-
var shortFile = _step2.value;
|
|
260
|
-
finalNames.set(shortFile.resolvedPath, candidateName);
|
|
261
|
-
}
|
|
262
|
-
} catch (err) {
|
|
263
|
-
_iterator2.e(err);
|
|
264
|
-
} finally {
|
|
265
|
-
_iterator2.f();
|
|
266
|
-
}
|
|
267
|
-
return; // Successfully resolved
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Fallback to original algorithm if smart resolution fails
|
|
274
|
-
var distinguishingIndex = -1;
|
|
275
|
-
var maxLength = Math.max.apply(Math, _toConsumableArray(conflictingFiles.map(function (f) {
|
|
276
|
-
return f.segments.length;
|
|
277
|
-
})));
|
|
278
|
-
var _loop2 = function _loop2(_i2) {
|
|
279
|
-
var segmentsAtIndex = new Set(conflictingFiles.map(function (f) {
|
|
280
|
-
return f.segments[_i2];
|
|
281
|
-
}).filter(Boolean));
|
|
282
|
-
if (segmentsAtIndex.size === conflictingFiles.length) {
|
|
283
|
-
distinguishingIndex = _i2;
|
|
284
|
-
return 1; // break
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
for (var _i2 = 0; _i2 < maxLength; _i2 += 1) {
|
|
288
|
-
if (_loop2(_i2)) break;
|
|
289
|
-
}
|
|
290
|
-
if (distinguishingIndex === -1) {
|
|
291
|
-
throw new Error("Cannot find distinguishing segment for files: ".concat(paths.join(', ')));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Generate names using the distinguishing segment
|
|
295
|
-
var _iterator3 = _createForOfIteratorHelper(conflictingFiles),
|
|
296
|
-
_step3;
|
|
297
|
-
try {
|
|
298
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
299
|
-
var _file2 = _step3.value;
|
|
300
|
-
var _fileName2 = _file2.segments[_file2.segments.length - 1];
|
|
301
|
-
var _isIndexFile2 = _fileName2.startsWith('index.');
|
|
302
|
-
var _distinguishingSegment = _file2.segments[distinguishingIndex];
|
|
303
|
-
var _finalName = void 0;
|
|
304
|
-
if (_isIndexFile2) {
|
|
305
|
-
var _parentDir2 = _file2.segments[_file2.segments.length - 2];
|
|
306
|
-
_finalName = "".concat(_distinguishingSegment, "/").concat(_parentDir2).concat(_file2.extension);
|
|
307
|
-
} else {
|
|
308
|
-
_finalName = "".concat(_distinguishingSegment, "/").concat(_fileName2);
|
|
309
|
-
}
|
|
310
|
-
finalNames.set(_file2.resolvedPath, _finalName);
|
|
311
|
-
}
|
|
312
|
-
} catch (err) {
|
|
313
|
-
_iterator3.e(err);
|
|
314
|
-
} finally {
|
|
315
|
-
_iterator3.f();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// Fourth pass: build the extraFiles mapping
|
|
321
|
-
finalNames.forEach(function (finalName, resolvedPath) {
|
|
322
|
-
extraFiles["./".concat(finalName)] = "file://".concat(resolvedPath);
|
|
323
|
-
});
|
|
324
|
-
return {
|
|
325
|
-
processedSource: '',
|
|
326
|
-
// Will be set by caller after rewriting
|
|
327
|
-
extraFiles: extraFiles
|
|
328
|
-
};
|
|
329
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default file extensions for JavaScript/TypeScript modules that can be resolved
|
|
3
|
-
*/
|
|
4
|
-
export declare const JAVASCRIPT_MODULE_EXTENSIONS: readonly [".ts", ".tsx", ".js", ".jsx", ".d.ts"];
|
|
5
|
-
/**
|
|
6
|
-
* Extension priority for type-only imports - prioritize .d.ts first
|
|
7
|
-
*/
|
|
8
|
-
export declare const TYPE_IMPORT_EXTENSIONS: readonly [".d.ts", ".ts", ".tsx", ".js", ".jsx"];
|
|
9
|
-
/**
|
|
10
|
-
* Extension priority for value imports - standard priority with .d.ts last
|
|
11
|
-
*/
|
|
12
|
-
export declare const VALUE_IMPORT_EXTENSIONS: readonly [".ts", ".tsx", ".js", ".jsx", ".d.ts"];
|
|
13
|
-
/**
|
|
14
|
-
* Checks if a file path or import path represents a JavaScript/TypeScript module
|
|
15
|
-
* @param path - The file path or import path to check
|
|
16
|
-
* @returns true if it's a JS/TS module, false otherwise
|
|
17
|
-
*/
|
|
18
|
-
export declare function isJavaScriptModule(path: string): boolean;
|
|
19
|
-
export interface DirectoryEntry {
|
|
20
|
-
name: string;
|
|
21
|
-
isFile: boolean;
|
|
22
|
-
isDirectory: boolean;
|
|
23
|
-
}
|
|
24
|
-
export type DirectoryReader = (path: string) => Promise<DirectoryEntry[]>;
|
|
25
|
-
export interface ResolveModulePathOptions {
|
|
26
|
-
/**
|
|
27
|
-
* Array of file extensions to try when resolving modules.
|
|
28
|
-
* Default: ['.ts', '.tsx', '.js', '.jsx']
|
|
29
|
-
*/
|
|
30
|
-
extensions?: string[];
|
|
31
|
-
}
|
|
32
|
-
export interface TypeAwareResolveResult {
|
|
33
|
-
import: string;
|
|
34
|
-
typeImport?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Resolves a module path by reading directory contents to find matching files.
|
|
38
|
-
* This is more efficient than checking each file individually with stat calls.
|
|
39
|
-
*
|
|
40
|
-
* Given a path like `/Code/mui-public/packages/docs-infra/docs/app/components/code-highlighter/demos/code/BasicCode`,
|
|
41
|
-
* this function will try to find the actual file by checking for:
|
|
42
|
-
* - `BasicCode.ts`, `BasicCode.tsx`, `BasicCode.js`, `BasicCode.jsx`
|
|
43
|
-
* - `BasicCode/index.ts`, `BasicCode/index.tsx`, `BasicCode/index.js`, `BasicCode/index.jsx`
|
|
44
|
-
*
|
|
45
|
-
* @param modulePath - The module path to resolve (without file extension)
|
|
46
|
-
* @param readDirectory - Function to read directory contents
|
|
47
|
-
* @param options - Configuration options
|
|
48
|
-
* @param includeTypeDefs - If true, returns both import and typeImport paths with different extension priorities
|
|
49
|
-
* @returns Promise<string | TypeAwareResolveResult> - The resolved file path(s)
|
|
50
|
-
*/
|
|
51
|
-
export declare function resolveModulePath(modulePath: string, readDirectory: DirectoryReader, options?: ResolveModulePathOptions, includeTypeDefs?: boolean): Promise<string | TypeAwareResolveResult>;
|
|
52
|
-
/**
|
|
53
|
-
* Resolves multiple module paths efficiently by grouping them by directory
|
|
54
|
-
* and performing batch directory lookups.
|
|
55
|
-
*
|
|
56
|
-
* @param modulePaths - Array of module paths to resolve (without file extensions)
|
|
57
|
-
* @param readDirectory - Function to read directory contents
|
|
58
|
-
* @param options - Configuration options
|
|
59
|
-
* @returns Promise<Map<string, string>> - Map from input path to resolved file path
|
|
60
|
-
*/
|
|
61
|
-
export declare function resolveModulePaths(modulePaths: string[], readDirectory: DirectoryReader, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
|
|
62
|
-
/**
|
|
63
|
-
* Resolves import result by separating JavaScript modules from static assets,
|
|
64
|
-
* only resolving JavaScript modules and returning a combined map.
|
|
65
|
-
* This function uses the new type-aware resolveModulePath function internally.
|
|
66
|
-
*
|
|
67
|
-
* @param importResult - The result from parseImports containing all imports
|
|
68
|
-
* @param readDirectory - Function to read directory contents
|
|
69
|
-
* @param options - Configuration options for module resolution
|
|
70
|
-
* @returns Promise<Map<string, string>> - Map from import path to resolved file path
|
|
71
|
-
*/
|
|
72
|
-
export declare function resolveImportResult(importResult: Record<string, {
|
|
73
|
-
path: string;
|
|
74
|
-
names: string[];
|
|
75
|
-
includeTypeDefs?: true;
|
|
76
|
-
}>, readDirectory: DirectoryReader, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
|
|
77
|
-
/**
|
|
78
|
-
* Resolves variant paths from a variants object mapping variant names to their file paths.
|
|
79
|
-
* This function extracts the paths, resolves them using resolveModulePaths, and returns
|
|
80
|
-
* a map from variant name to resolved file URL.
|
|
81
|
-
*
|
|
82
|
-
* @param variants - Object mapping variant names to their file paths
|
|
83
|
-
* @param readDirectory - Function to read directory contents
|
|
84
|
-
* @param options - Configuration options for module resolution
|
|
85
|
-
* @returns Promise<Map<string, string>> - Map from variant name to resolved file URL
|
|
86
|
-
*/
|
|
87
|
-
export declare function resolveVariantPaths(variants: Record<string, string>, readDirectory: DirectoryReader, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveModulePath.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loaderUtils/resolveModulePath.ts"],"names":[],"mappings":"AA4BA;;GAEG;AACH,eAAO,MAAM,4BAA4B,kDAAmD,CAAC;AAE7F;;GAEG;AACH,eAAO,MAAM,sBAAsB,kDAAmD,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,uBAAuB,kDAAmD,CAAC;AAExF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOxD;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;AAE1E,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,eAAe,EAC9B,OAAO,GAAE,wBAA6B,EACtC,eAAe,CAAC,EAAE,OAAO,GACxB,OAAO,CAAC,MAAM,GAAG,sBAAsB,CAAC,CAqB1C;AAqTD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EAAE,EACrB,aAAa,EAAE,eAAe,EAC9B,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiJ9B;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC,EACvF,aAAa,EAAE,eAAe,EAC9B,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA8D9B;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,aAAa,EAAE,eAAe,EAC9B,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgB9B"}
|