@mui/internal-docs-infra 0.1.0 → 0.1.1-alpha.0
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 +3 -1
- package/build/CodeControllerContext/CodeControllerContext.d.ts +22 -0
- package/build/CodeControllerContext/CodeControllerContext.js +21 -0
- package/build/CodeControllerContext/index.d.ts +1 -0
- package/build/CodeControllerContext/index.js +16 -0
- package/build/CodeHighlighter/CodeHighlighter.d.ts +2 -0
- package/build/CodeHighlighter/CodeHighlighter.js +329 -0
- package/build/CodeHighlighter/CodeHighlighterClient.d.ts +2 -0
- package/build/CodeHighlighter/CodeHighlighterClient.js +406 -0
- package/build/CodeHighlighter/CodeHighlighterContext.d.ts +14 -0
- package/build/CodeHighlighter/CodeHighlighterContext.js +22 -0
- package/build/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +7 -0
- package/build/CodeHighlighter/CodeHighlighterFallbackContext.js +18 -0
- package/build/CodeHighlighter/applyTransform.d.ts +19 -0
- package/build/CodeHighlighter/applyTransform.js +83 -0
- package/build/CodeHighlighter/codeToFallbackProps.d.ts +2 -0
- package/build/CodeHighlighter/codeToFallbackProps.js +77 -0
- package/build/CodeHighlighter/errors.d.ts +0 -0
- package/build/CodeHighlighter/errors.js +2 -0
- package/build/CodeHighlighter/hasAllVariants.d.ts +2 -0
- package/build/CodeHighlighter/hasAllVariants.js +37 -0
- package/build/CodeHighlighter/index.d.ts +4 -0
- package/build/CodeHighlighter/index.js +49 -0
- package/build/CodeHighlighter/loadFallbackCode.d.ts +9 -0
- package/build/CodeHighlighter/loadFallbackCode.js +474 -0
- package/build/CodeHighlighter/loadVariant.d.ts +11 -0
- package/build/CodeHighlighter/loadVariant.js +715 -0
- package/build/CodeHighlighter/maybeInitialData.d.ts +10 -0
- package/build/CodeHighlighter/maybeInitialData.js +101 -0
- package/build/CodeHighlighter/parseCode.d.ts +6 -0
- package/build/CodeHighlighter/parseCode.js +129 -0
- package/build/CodeHighlighter/parseControlledCode.d.ts +6 -0
- package/build/CodeHighlighter/parseControlledCode.js +83 -0
- package/build/CodeHighlighter/transformCode.d.ts +20 -0
- package/build/CodeHighlighter/transformCode.js +231 -0
- package/build/CodeHighlighter/transformParsedSource.d.ts +3 -0
- package/build/CodeHighlighter/transformParsedSource.js +73 -0
- package/build/CodeHighlighter/transformSource.d.ts +2 -0
- package/build/CodeHighlighter/transformSource.js +114 -0
- package/build/CodeHighlighter/types.d.ts +138 -0
- package/build/CodeHighlighter/types.js +5 -0
- package/build/CodeProvider/CodeContext.d.ts +12 -0
- package/build/CodeProvider/CodeContext.js +14 -0
- package/build/CodeProvider/CodeProvider.d.ts +13 -0
- package/build/CodeProvider/CodeProvider.js +57 -0
- package/build/CodeProvider/index.d.ts +2 -0
- package/build/CodeProvider/index.js +27 -0
- package/build/README.md +19 -0
- package/build/esm/CodeControllerContext/CodeControllerContext.d.ts +22 -0
- package/build/esm/CodeControllerContext/CodeControllerContext.d.ts.map +1 -0
- package/build/esm/CodeControllerContext/CodeControllerContext.js +14 -0
- package/build/esm/CodeControllerContext/index.d.ts +1 -0
- package/build/esm/CodeControllerContext/index.d.ts.map +1 -0
- package/build/esm/CodeControllerContext/index.js +1 -0
- package/build/esm/CodeHighlighter/CodeHighlighter.d.ts +2 -0
- package/build/esm/CodeHighlighter/CodeHighlighter.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/CodeHighlighter.js +321 -0
- package/build/esm/CodeHighlighter/CodeHighlighterClient.d.ts +2 -0
- package/build/esm/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/CodeHighlighterClient.js +399 -0
- package/build/esm/CodeHighlighter/CodeHighlighterContext.d.ts +14 -0
- package/build/esm/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/CodeHighlighterContext.js +14 -0
- package/build/esm/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +7 -0
- package/build/esm/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +11 -0
- package/build/esm/CodeHighlighter/applyTransform.d.ts +19 -0
- package/build/esm/CodeHighlighter/applyTransform.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/applyTransform.js +75 -0
- package/build/esm/CodeHighlighter/codeToFallbackProps.d.ts +2 -0
- package/build/esm/CodeHighlighter/codeToFallbackProps.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/codeToFallbackProps.js +70 -0
- package/build/esm/CodeHighlighter/errors.d.ts +0 -0
- package/build/esm/CodeHighlighter/errors.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/errors.js +1 -0
- package/build/esm/CodeHighlighter/hasAllVariants.d.ts +2 -0
- package/build/esm/CodeHighlighter/hasAllVariants.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/hasAllVariants.js +31 -0
- package/build/esm/CodeHighlighter/index.d.ts +4 -0
- package/build/esm/CodeHighlighter/index.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/index.js +4 -0
- package/build/esm/CodeHighlighter/loadFallbackCode.d.ts +9 -0
- package/build/esm/CodeHighlighter/loadFallbackCode.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/loadFallbackCode.js +468 -0
- package/build/esm/CodeHighlighter/loadVariant.d.ts +11 -0
- package/build/esm/CodeHighlighter/loadVariant.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/loadVariant.js +708 -0
- package/build/esm/CodeHighlighter/maybeInitialData.d.ts +10 -0
- package/build/esm/CodeHighlighter/maybeInitialData.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/maybeInitialData.js +94 -0
- package/build/esm/CodeHighlighter/parseCode.d.ts +6 -0
- package/build/esm/CodeHighlighter/parseCode.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/parseCode.js +122 -0
- package/build/esm/CodeHighlighter/parseControlledCode.d.ts +6 -0
- package/build/esm/CodeHighlighter/parseControlledCode.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/parseControlledCode.js +76 -0
- package/build/esm/CodeHighlighter/transformCode.d.ts +20 -0
- package/build/esm/CodeHighlighter/transformCode.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/transformCode.js +223 -0
- package/build/esm/CodeHighlighter/transformParsedSource.d.ts +3 -0
- package/build/esm/CodeHighlighter/transformParsedSource.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/transformParsedSource.js +66 -0
- package/build/esm/CodeHighlighter/transformSource.d.ts +2 -0
- package/build/esm/CodeHighlighter/transformSource.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/transformSource.js +107 -0
- package/build/esm/CodeHighlighter/types.d.ts +138 -0
- package/build/esm/CodeHighlighter/types.d.ts.map +1 -0
- package/build/esm/CodeHighlighter/types.js +1 -0
- package/build/esm/CodeProvider/CodeContext.d.ts +12 -0
- package/build/esm/CodeProvider/CodeContext.d.ts.map +1 -0
- package/build/esm/CodeProvider/CodeContext.js +8 -0
- package/build/esm/CodeProvider/CodeProvider.d.ts +13 -0
- package/build/esm/CodeProvider/CodeProvider.d.ts.map +1 -0
- package/build/esm/CodeProvider/CodeProvider.js +50 -0
- package/build/esm/CodeProvider/index.d.ts +2 -0
- package/build/esm/CodeProvider/index.d.ts.map +1 -0
- package/build/esm/CodeProvider/index.js +2 -0
- package/build/esm/hast/hast.d.ts +11 -0
- package/build/esm/hast/hast.d.ts.map +1 -0
- package/build/esm/hast/hast.js +66 -0
- package/build/esm/hast/index.d.ts +1 -0
- package/build/esm/hast/index.d.ts.map +1 -0
- package/build/esm/hast/index.js +1 -0
- package/build/esm/loadPrecomputedCodeHighlighter/index.d.ts +2 -0
- package/build/esm/loadPrecomputedCodeHighlighter/index.d.ts.map +1 -0
- package/build/esm/loadPrecomputedCodeHighlighter/index.js +4 -0
- package/build/esm/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +57 -0
- package/build/esm/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -0
- package/build/esm/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +194 -0
- package/build/esm/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +20 -0
- package/build/esm/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +1 -0
- package/build/esm/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +243 -0
- package/build/esm/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +15 -0
- package/build/esm/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +1 -0
- package/build/esm/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +168 -0
- package/build/esm/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +27 -0
- package/build/esm/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +1 -0
- package/build/esm/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +37 -0
- package/build/esm/loadServerCodeMeta/index.d.ts +1 -0
- package/build/esm/loadServerCodeMeta/index.d.ts.map +1 -0
- package/build/esm/loadServerCodeMeta/index.js +1 -0
- package/build/esm/loadServerCodeMeta/serverLoadCodeMeta.d.ts +24 -0
- package/build/esm/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +1 -0
- package/build/esm/loadServerCodeMeta/serverLoadCodeMeta.js +77 -0
- package/build/esm/loadServerSource/index.d.ts +1 -0
- package/build/esm/loadServerSource/index.d.ts.map +1 -0
- package/build/esm/loadServerSource/index.js +1 -0
- package/build/esm/loadServerSource/serverLoadSource.d.ts +25 -0
- package/build/esm/loadServerSource/serverLoadSource.d.ts.map +1 -0
- package/build/esm/loadServerSource/serverLoadSource.js +100 -0
- package/build/esm/loaderUtils/getFileNameFromUrl.d.ts +11 -0
- package/build/esm/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
- package/build/esm/loaderUtils/getFileNameFromUrl.js +32 -0
- package/build/esm/loaderUtils/index.d.ts +5 -0
- package/build/esm/loaderUtils/index.d.ts.map +1 -0
- package/build/esm/loaderUtils/index.js +5 -0
- package/build/esm/loaderUtils/processImports.d.ts +19 -0
- package/build/esm/loaderUtils/processImports.d.ts.map +1 -0
- package/build/esm/loaderUtils/processImports.js +82 -0
- package/build/esm/loaderUtils/resolveImports.d.ts +4 -0
- package/build/esm/loaderUtils/resolveImports.d.ts.map +1 -0
- package/build/esm/loaderUtils/resolveImports.js +71 -0
- package/build/esm/loaderUtils/resolveModulePath.d.ts +74 -0
- package/build/esm/loaderUtils/resolveModulePath.d.ts.map +1 -0
- package/build/esm/loaderUtils/resolveModulePath.js +827 -0
- package/build/esm/loaderUtils/resolveModulePathWithFs.d.ts +44 -0
- package/build/esm/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
- package/build/esm/loaderUtils/resolveModulePathWithFs.js +159 -0
- package/build/esm/loaderUtils/rewriteImports.d.ts +9 -0
- package/build/esm/loaderUtils/rewriteImports.d.ts.map +1 -0
- package/build/esm/loaderUtils/rewriteImports.js +57 -0
- package/build/esm/parseSource/grammars.d.ts +2 -0
- package/build/esm/parseSource/grammars.d.ts.map +1 -0
- package/build/esm/parseSource/grammars.js +27 -0
- package/build/esm/parseSource/index.d.ts +1 -0
- package/build/esm/parseSource/index.d.ts.map +1 -0
- package/build/esm/parseSource/index.js +1 -0
- package/build/esm/parseSource/parseSource.d.ts +3 -0
- package/build/esm/parseSource/parseSource.d.ts.map +1 -0
- package/build/esm/parseSource/parseSource.js +37 -0
- package/build/esm/transformRelativeMarkdownPaths/index.d.ts +2 -0
- package/build/esm/transformRelativeMarkdownPaths/index.d.ts.map +1 -0
- package/build/esm/transformRelativeMarkdownPaths/index.js +4 -0
- package/build/esm/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +12 -0
- package/build/esm/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +1 -0
- package/build/esm/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +30 -0
- package/build/esm/transformTsToJs/index.d.ts +1 -0
- package/build/esm/transformTsToJs/index.d.ts.map +1 -0
- package/build/esm/transformTsToJs/index.js +1 -0
- package/build/esm/transformTsToJs/removeTypes.d.ts +13 -0
- package/build/esm/transformTsToJs/removeTypes.d.ts.map +1 -0
- package/build/esm/transformTsToJs/removeTypes.js +134 -0
- package/build/esm/transformTsToJs/transformTsToJs.d.ts +3 -0
- package/build/esm/transformTsToJs/transformTsToJs.d.ts.map +1 -0
- package/build/esm/transformTsToJs/transformTsToJs.js +34 -0
- package/build/esm/useCode/index.d.ts +1 -0
- package/build/esm/useCode/index.d.ts.map +1 -0
- package/build/esm/useCode/index.js +1 -0
- package/build/esm/useCode/useCode.d.ts +37 -0
- package/build/esm/useCode/useCode.d.ts.map +1 -0
- package/build/esm/useCode/useCode.js +393 -0
- package/{esm → build/esm}/useDemo/index.d.ts +12 -24
- package/build/esm/useDemo/index.d.ts.map +1 -0
- package/build/esm/useDemo/index.js +17 -0
- package/build/esm/useOnHydrate/index.d.ts +1 -0
- package/build/esm/useOnHydrate/index.d.ts.map +1 -0
- package/build/esm/useOnHydrate/index.js +1 -0
- package/build/esm/useOnHydrate/useOnHydrate.d.ts +1 -0
- package/build/esm/useOnHydrate/useOnHydrate.d.ts.map +1 -0
- package/build/esm/useOnHydrate/useOnHydrate.js +18 -0
- package/build/esm/useOnIdle/index.d.ts +1 -0
- package/build/esm/useOnIdle/index.d.ts.map +1 -0
- package/build/esm/useOnIdle/index.js +1 -0
- package/build/esm/useOnIdle/useOnIdle.d.ts +1 -0
- package/build/esm/useOnIdle/useOnIdle.d.ts.map +1 -0
- package/build/esm/useOnIdle/useOnIdle.js +39 -0
- package/build/hast/hast.d.ts +11 -0
- package/build/hast/hast.js +75 -0
- package/build/hast/index.d.ts +1 -0
- package/build/hast/index.js +16 -0
- package/build/loadPrecomputedCodeHighlighter/index.d.ts +2 -0
- package/build/loadPrecomputedCodeHighlighter/index.js +9 -0
- package/build/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +57 -0
- package/build/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +201 -0
- package/build/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +20 -0
- package/build/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +248 -0
- package/build/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +15 -0
- package/build/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +174 -0
- package/build/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +27 -0
- package/build/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +43 -0
- package/build/loadServerCodeMeta/index.d.ts +1 -0
- package/build/loadServerCodeMeta/index.js +16 -0
- package/build/loadServerCodeMeta/serverLoadCodeMeta.d.ts +24 -0
- package/build/loadServerCodeMeta/serverLoadCodeMeta.js +85 -0
- package/build/loadServerSource/index.d.ts +1 -0
- package/build/loadServerSource/index.js +16 -0
- package/build/loadServerSource/serverLoadSource.d.ts +25 -0
- package/build/loadServerSource/serverLoadSource.js +108 -0
- package/build/loaderUtils/getFileNameFromUrl.d.ts +11 -0
- package/build/loaderUtils/getFileNameFromUrl.js +38 -0
- package/build/loaderUtils/index.d.ts +5 -0
- package/build/loaderUtils/index.js +60 -0
- package/build/loaderUtils/processImports.d.ts +19 -0
- package/build/loaderUtils/processImports.js +89 -0
- package/build/loaderUtils/resolveImports.d.ts +4 -0
- package/build/loaderUtils/resolveImports.js +78 -0
- package/build/loaderUtils/resolveModulePath.d.ts +74 -0
- package/build/loaderUtils/resolveModulePath.js +835 -0
- package/build/loaderUtils/resolveModulePathWithFs.d.ts +44 -0
- package/build/loaderUtils/resolveModulePathWithFs.js +163 -0
- package/build/loaderUtils/rewriteImports.d.ts +9 -0
- package/build/loaderUtils/rewriteImports.js +62 -0
- package/build/package.json +101 -0
- package/build/parseSource/grammars.d.ts +2 -0
- package/build/parseSource/grammars.js +34 -0
- package/build/parseSource/index.d.ts +1 -0
- package/build/parseSource/index.js +16 -0
- package/build/parseSource/parseSource.d.ts +3 -0
- package/build/parseSource/parseSource.js +44 -0
- package/build/transformRelativeMarkdownPaths/index.d.ts +2 -0
- package/build/transformRelativeMarkdownPaths/index.js +9 -0
- package/build/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +12 -0
- package/build/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +36 -0
- package/build/transformTsToJs/index.d.ts +1 -0
- package/build/transformTsToJs/index.js +16 -0
- package/build/transformTsToJs/removeTypes.d.ts +13 -0
- package/build/transformTsToJs/removeTypes.js +141 -0
- package/build/transformTsToJs/transformTsToJs.d.ts +3 -0
- package/build/transformTsToJs/transformTsToJs.js +41 -0
- package/build/useCode/index.d.ts +1 -0
- package/build/useCode/index.js +16 -0
- package/build/useCode/useCode.d.ts +37 -0
- package/build/useCode/useCode.js +401 -0
- package/{useDemo → build/useDemo}/index.d.ts +12 -24
- package/build/useDemo/index.js +25 -0
- package/build/useOnHydrate/index.d.ts +1 -0
- package/build/useOnHydrate/index.js +16 -0
- package/build/useOnHydrate/useOnHydrate.d.ts +1 -0
- package/build/useOnHydrate/useOnHydrate.js +26 -0
- package/build/useOnIdle/index.d.ts +1 -0
- package/build/useOnIdle/index.js +16 -0
- package/build/useOnIdle/useOnIdle.d.ts +1 -0
- package/build/useOnIdle/useOnIdle.js +47 -0
- package/package.json +86 -14
- package/esm/useDemo/index.d.ts.map +0 -1
- package/esm/useDemo/index.js +0 -104
- package/useDemo/index.js +0 -112
- /package/{LICENSE → build/LICENSE} +0 -0
- /package/{esm → build/esm}/package.json +0 -0
- /package/{esm → build/esm}/useCopier/index.d.ts +0 -0
- /package/{esm → build/esm}/useCopier/index.d.ts.map +0 -0
- /package/{esm → build/esm}/useCopier/index.js +0 -0
- /package/{useCopier → build/useCopier}/index.d.ts +0 -0
- /package/{useCopier → build/useCopier}/index.js +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.processImportsWithStoreAt = processImportsWithStoreAt;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _rewriteImports = require("./rewriteImports");
|
|
10
|
+
var _resolveModulePath = require("./resolveModulePath");
|
|
11
|
+
var _getFileNameFromUrl = require("./getFileNameFromUrl");
|
|
12
|
+
/**
|
|
13
|
+
* Processes imports based on the specified storage mode, automatically handling
|
|
14
|
+
* source rewriting when needed (e.g., for 'flat' mode).
|
|
15
|
+
*
|
|
16
|
+
* @param source - The original source code
|
|
17
|
+
* @param importResult - The result from resolveImports
|
|
18
|
+
* @param resolvedPathsMap - Map from import paths to resolved file paths
|
|
19
|
+
* @param storeAt - How to process the imports
|
|
20
|
+
* @returns Object with processed source and extraFiles mapping
|
|
21
|
+
*/
|
|
22
|
+
function processImportsWithStoreAt(source, importResult, resolvedPathsMap, storeAt) {
|
|
23
|
+
var processedSource = source;
|
|
24
|
+
var extraFiles = {};
|
|
25
|
+
|
|
26
|
+
// For flat mode, automatically rewrite imports to same directory
|
|
27
|
+
if (storeAt === 'flat') {
|
|
28
|
+
var allResolvedPaths = new Set(resolvedPathsMap.values());
|
|
29
|
+
processedSource = (0, _rewriteImports.rewriteImportsToSameDirectory)(source, allResolvedPaths);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Process each import and generate extraFiles
|
|
33
|
+
Object.entries(importResult).forEach(function (_ref) {
|
|
34
|
+
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
|
|
35
|
+
relativePath = _ref2[0],
|
|
36
|
+
importInfo = _ref2[1];
|
|
37
|
+
var resolvedPath = resolvedPathsMap.get(importInfo.path);
|
|
38
|
+
if (resolvedPath) {
|
|
39
|
+
var fileExtension = (0, _getFileNameFromUrl.getFileNameFromUrl)(resolvedPath).extension;
|
|
40
|
+
var isJavascriptModule = (0, _resolveModulePath.isJavaScriptModule)(relativePath);
|
|
41
|
+
var keyPath;
|
|
42
|
+
if (!isJavascriptModule) {
|
|
43
|
+
// For static assets (CSS, JSON, etc.), use the original import path as-is since it already has the extension
|
|
44
|
+
switch (storeAt) {
|
|
45
|
+
case 'canonical':
|
|
46
|
+
case 'import':
|
|
47
|
+
keyPath = relativePath;
|
|
48
|
+
break;
|
|
49
|
+
case 'flat':
|
|
50
|
+
// For flat mode, use just the filename from the original import
|
|
51
|
+
keyPath = "./".concat((0, _getFileNameFromUrl.getFileNameFromUrl)(relativePath).fileName);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
keyPath = relativePath;
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
// For JS/TS modules, apply the existing logic
|
|
58
|
+
switch (storeAt) {
|
|
59
|
+
case 'canonical':
|
|
60
|
+
// Show the full resolved path including index files when they exist
|
|
61
|
+
// e.g., import '../Component' resolved to '/src/Component/index.js'
|
|
62
|
+
// becomes extraFiles: { '../Component/index.js': 'file:///src/Component/index.js' }
|
|
63
|
+
keyPath = "".concat(relativePath).concat(resolvedPath.endsWith("/index".concat(fileExtension)) ? "/index".concat(fileExtension) : fileExtension);
|
|
64
|
+
break;
|
|
65
|
+
case 'import':
|
|
66
|
+
// Use the original import path with the actual file extension
|
|
67
|
+
// e.g., import '../Component' with '/src/Component/index.js'
|
|
68
|
+
// becomes extraFiles: { '../Component.js': 'file:///src/Component/index.js' }
|
|
69
|
+
keyPath = "".concat(relativePath).concat(fileExtension);
|
|
70
|
+
break;
|
|
71
|
+
case 'flat':
|
|
72
|
+
// Flatten all files to current directory using just the filename
|
|
73
|
+
// e.g., import '../Component' with '/src/Component/index.js'
|
|
74
|
+
// becomes extraFiles: { './index.js': 'file:///src/Component/index.js' }
|
|
75
|
+
// Note: This mode also requires rewriting imports in the source code (handled above)
|
|
76
|
+
keyPath = "./".concat((0, _getFileNameFromUrl.getFileNameFromUrl)(resolvedPath).fileName);
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
keyPath = "".concat(relativePath).concat(fileExtension);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
extraFiles[keyPath] = "file://".concat(resolvedPath);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
processedSource: processedSource,
|
|
87
|
+
extraFiles: extraFiles
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.resolveImports = resolveImports;
|
|
8
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
function resolveImports(_x, _x2) {
|
|
12
|
+
return _resolveImports.apply(this, arguments);
|
|
13
|
+
}
|
|
14
|
+
function _resolveImports() {
|
|
15
|
+
_resolveImports = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee(code, filePath) {
|
|
16
|
+
var result, importRegex, importMatch, _loop;
|
|
17
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context2) {
|
|
18
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
result = {};
|
|
21
|
+
importRegex = /import\s+(?:(\w+)|\*\s+as\s+(\w+)|{([^}]+)})\s+from\s+['"]([^'"]+)['"]/g;
|
|
22
|
+
importMatch = importRegex.exec(code);
|
|
23
|
+
_loop = /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _loop() {
|
|
24
|
+
var _importMatch, _importMatch2, defaultImport, namespaceImport, namedImportsStr, modulePath, basePath, resolvedPath, namedImports;
|
|
25
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _loop$(_context) {
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
_importMatch = importMatch, _importMatch2 = (0, _slicedToArray2["default"])(_importMatch, 5), defaultImport = _importMatch2[1], namespaceImport = _importMatch2[2], namedImportsStr = _importMatch2[3], modulePath = _importMatch2[4]; // Only process relative imports
|
|
29
|
+
if (modulePath.startsWith('.')) {
|
|
30
|
+
basePath = filePath.substring(0, filePath.lastIndexOf('/'));
|
|
31
|
+
resolvedPath = new URL(modulePath, "file://".concat(basePath, "/")).pathname;
|
|
32
|
+
if (!result[modulePath]) {
|
|
33
|
+
result[modulePath] = {
|
|
34
|
+
path: resolvedPath,
|
|
35
|
+
names: []
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (defaultImport) {
|
|
39
|
+
result[modulePath].names.push(defaultImport);
|
|
40
|
+
} else if (namespaceImport) {
|
|
41
|
+
result[modulePath].names.push(namespaceImport);
|
|
42
|
+
} else if (namedImportsStr) {
|
|
43
|
+
// Handle named imports like { ComponentName, Component2 as Alias }
|
|
44
|
+
namedImports = namedImportsStr.split(',').map(function (s) {
|
|
45
|
+
return s.trim();
|
|
46
|
+
});
|
|
47
|
+
namedImports.forEach(function (namedImport) {
|
|
48
|
+
var cleanImport = namedImport.split(' as ')[0].trim();
|
|
49
|
+
result[modulePath].names.push(cleanImport);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
importMatch = importRegex.exec(code);
|
|
54
|
+
case 3:
|
|
55
|
+
case "end":
|
|
56
|
+
return _context.stop();
|
|
57
|
+
}
|
|
58
|
+
}, _loop);
|
|
59
|
+
});
|
|
60
|
+
case 4:
|
|
61
|
+
if (!(importMatch !== null)) {
|
|
62
|
+
_context2.next = 8;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
return _context2.delegateYield(_loop(), "t0", 6);
|
|
66
|
+
case 6:
|
|
67
|
+
_context2.next = 4;
|
|
68
|
+
break;
|
|
69
|
+
case 8:
|
|
70
|
+
return _context2.abrupt("return", result);
|
|
71
|
+
case 9:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context2.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee);
|
|
76
|
+
}));
|
|
77
|
+
return _resolveImports.apply(this, arguments);
|
|
78
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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"];
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a file path or import path represents a JavaScript/TypeScript module
|
|
7
|
+
* @param path - The file path or import path to check
|
|
8
|
+
* @returns true if it's a JS/TS module, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export declare function isJavaScriptModule(path: string): boolean;
|
|
11
|
+
export interface DirectoryEntry {
|
|
12
|
+
name: string;
|
|
13
|
+
isFile: boolean;
|
|
14
|
+
isDirectory: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type DirectoryReader = (path: string) => Promise<DirectoryEntry[]>;
|
|
17
|
+
export interface ResolveModulePathOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Array of file extensions to try when resolving modules.
|
|
20
|
+
* Default: ['.ts', '.tsx', '.js', '.jsx']
|
|
21
|
+
*/
|
|
22
|
+
extensions?: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolves a module path by reading directory contents to find matching files.
|
|
26
|
+
* This is more efficient than checking each file individually with stat calls.
|
|
27
|
+
*
|
|
28
|
+
* Given a path like `/Code/mui-public/packages/docs-infra/docs/app/components/code-highlighter/demos/code/BasicCode`,
|
|
29
|
+
* this function will try to find the actual file by checking for:
|
|
30
|
+
* - `BasicCode.ts`, `BasicCode.tsx`, `BasicCode.js`, `BasicCode.jsx`
|
|
31
|
+
* - `BasicCode/index.ts`, `BasicCode/index.tsx`, `BasicCode/index.js`, `BasicCode/index.jsx`
|
|
32
|
+
*
|
|
33
|
+
* @param modulePath - The module path to resolve (without file extension)
|
|
34
|
+
* @param readDirectory - Function to read directory contents
|
|
35
|
+
* @param options - Configuration options
|
|
36
|
+
* @returns Promise<string> - The resolved file path, or throws if not found
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveModulePath(modulePath: string, readDirectory: DirectoryReader, options?: ResolveModulePathOptions): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Resolves multiple module paths efficiently by grouping them by directory
|
|
41
|
+
* and performing batch directory lookups.
|
|
42
|
+
*
|
|
43
|
+
* @param modulePaths - Array of module paths to resolve (without file extensions)
|
|
44
|
+
* @param readDirectory - Function to read directory contents
|
|
45
|
+
* @param options - Configuration options
|
|
46
|
+
* @returns Promise<Map<string, string>> - Map from input path to resolved file path
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveModulePaths(modulePaths: string[], readDirectory: DirectoryReader, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
|
|
49
|
+
/**
|
|
50
|
+
* Resolves import result by separating JavaScript modules from static assets,
|
|
51
|
+
* only resolving JavaScript modules and returning a combined map.
|
|
52
|
+
* This function uses the resolveModulePaths function internally but requires
|
|
53
|
+
* a DirectoryReader to be provided.
|
|
54
|
+
*
|
|
55
|
+
* @param importResult - The result from resolveImports containing all imports
|
|
56
|
+
* @param readDirectory - Function to read directory contents
|
|
57
|
+
* @param options - Configuration options for module resolution
|
|
58
|
+
* @returns Promise<Map<string, string>> - Map from import path to resolved file path
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveImportResult(importResult: Record<string, {
|
|
61
|
+
path: string;
|
|
62
|
+
names: string[];
|
|
63
|
+
}>, readDirectory: DirectoryReader, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
|
|
64
|
+
/**
|
|
65
|
+
* Resolves variant paths from a variants object mapping variant names to their file paths.
|
|
66
|
+
* This function extracts the paths, resolves them using resolveModulePaths, and returns
|
|
67
|
+
* a map from variant name to resolved file URL.
|
|
68
|
+
*
|
|
69
|
+
* @param variants - Object mapping variant names to their file paths
|
|
70
|
+
* @param readDirectory - Function to read directory contents
|
|
71
|
+
* @param options - Configuration options for module resolution
|
|
72
|
+
* @returns Promise<Map<string, string>> - Map from variant name to resolved file URL
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveVariantPaths(variants: Record<string, string>, readDirectory: DirectoryReader, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
|