@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,827 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import { join, extname } from 'node:path';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Default file extensions for JavaScript/TypeScript modules that can be resolved
|
|
9
|
+
*/
|
|
10
|
+
export var JAVASCRIPT_MODULE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a file path or import path represents a JavaScript/TypeScript module
|
|
14
|
+
* @param path - The file path or import path to check
|
|
15
|
+
* @returns true if it's a JS/TS module, false otherwise
|
|
16
|
+
*/
|
|
17
|
+
export function isJavaScriptModule(path) {
|
|
18
|
+
// If the path has an extension, check if it's one of the JS/TS extensions
|
|
19
|
+
if (/\.[^/]+$/.test(path)) {
|
|
20
|
+
return JAVASCRIPT_MODULE_EXTENSIONS.some(function (ext) {
|
|
21
|
+
return path.endsWith(ext);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// If no extension, assume it's a JS/TS module (will be resolved to one)
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a module path by reading directory contents to find matching files.
|
|
29
|
+
* This is more efficient than checking each file individually with stat calls.
|
|
30
|
+
*
|
|
31
|
+
* Given a path like `/Code/mui-public/packages/docs-infra/docs/app/components/code-highlighter/demos/code/BasicCode`,
|
|
32
|
+
* this function will try to find the actual file by checking for:
|
|
33
|
+
* - `BasicCode.ts`, `BasicCode.tsx`, `BasicCode.js`, `BasicCode.jsx`
|
|
34
|
+
* - `BasicCode/index.ts`, `BasicCode/index.tsx`, `BasicCode/index.js`, `BasicCode/index.jsx`
|
|
35
|
+
*
|
|
36
|
+
* @param modulePath - The module path to resolve (without file extension)
|
|
37
|
+
* @param readDirectory - Function to read directory contents
|
|
38
|
+
* @param options - Configuration options
|
|
39
|
+
* @returns Promise<string> - The resolved file path, or throws if not found
|
|
40
|
+
*/
|
|
41
|
+
export function resolveModulePath(_x, _x2) {
|
|
42
|
+
return _resolveModulePath.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Resolves multiple module paths efficiently by grouping them by directory
|
|
47
|
+
* and performing batch directory lookups.
|
|
48
|
+
*
|
|
49
|
+
* @param modulePaths - Array of module paths to resolve (without file extensions)
|
|
50
|
+
* @param readDirectory - Function to read directory contents
|
|
51
|
+
* @param options - Configuration options
|
|
52
|
+
* @returns Promise<Map<string, string>> - Map from input path to resolved file path
|
|
53
|
+
*/
|
|
54
|
+
function _resolveModulePath() {
|
|
55
|
+
_resolveModulePath = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(modulePath, readDirectory) {
|
|
56
|
+
var options,
|
|
57
|
+
_options$extensions,
|
|
58
|
+
extensions,
|
|
59
|
+
lastSlashIndex,
|
|
60
|
+
parentDir,
|
|
61
|
+
moduleName,
|
|
62
|
+
dirContents,
|
|
63
|
+
filesByBaseName,
|
|
64
|
+
_iterator,
|
|
65
|
+
_step,
|
|
66
|
+
_entry2,
|
|
67
|
+
_fileName,
|
|
68
|
+
_fileExt,
|
|
69
|
+
_fileBaseName,
|
|
70
|
+
matchingFiles,
|
|
71
|
+
_iterator2,
|
|
72
|
+
_step2,
|
|
73
|
+
ext,
|
|
74
|
+
_iterator3,
|
|
75
|
+
_step3,
|
|
76
|
+
entry,
|
|
77
|
+
directoryMatches,
|
|
78
|
+
moduleDir,
|
|
79
|
+
moduleDirContents,
|
|
80
|
+
indexFilesByBaseName,
|
|
81
|
+
_iterator4,
|
|
82
|
+
_step4,
|
|
83
|
+
moduleFile,
|
|
84
|
+
fileName,
|
|
85
|
+
fileExt,
|
|
86
|
+
fileBaseName,
|
|
87
|
+
indexFiles,
|
|
88
|
+
_iterator5,
|
|
89
|
+
_step5,
|
|
90
|
+
_ext,
|
|
91
|
+
_iterator6,
|
|
92
|
+
_step6,
|
|
93
|
+
_entry,
|
|
94
|
+
_args = arguments;
|
|
95
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
96
|
+
while (1) switch (_context.prev = _context.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
99
|
+
_options$extensions = options.extensions, extensions = _options$extensions === void 0 ? JAVASCRIPT_MODULE_EXTENSIONS : _options$extensions; // Extract the parent directory and the module name
|
|
100
|
+
lastSlashIndex = modulePath.lastIndexOf('/');
|
|
101
|
+
parentDir = modulePath.substring(0, lastSlashIndex);
|
|
102
|
+
moduleName = modulePath.substring(lastSlashIndex + 1);
|
|
103
|
+
_context.prev = 5;
|
|
104
|
+
_context.next = 8;
|
|
105
|
+
return readDirectory(parentDir);
|
|
106
|
+
case 8:
|
|
107
|
+
dirContents = _context.sent;
|
|
108
|
+
// Look for direct file matches in extension priority order
|
|
109
|
+
// Create a map of baseName -> files with that basename for efficient lookup
|
|
110
|
+
filesByBaseName = new Map();
|
|
111
|
+
_iterator = _createForOfIteratorHelper(dirContents);
|
|
112
|
+
try {
|
|
113
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
114
|
+
_entry2 = _step.value;
|
|
115
|
+
if (_entry2.isFile) {
|
|
116
|
+
_fileName = _entry2.name;
|
|
117
|
+
_fileExt = extname(_fileName);
|
|
118
|
+
_fileBaseName = _fileName.substring(0, _fileName.length - _fileExt.length);
|
|
119
|
+
if (!filesByBaseName.has(_fileBaseName)) {
|
|
120
|
+
filesByBaseName.set(_fileBaseName, []);
|
|
121
|
+
}
|
|
122
|
+
filesByBaseName.get(_fileBaseName).push(_entry2);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Check for the module in extension priority order
|
|
127
|
+
} catch (err) {
|
|
128
|
+
_iterator.e(err);
|
|
129
|
+
} finally {
|
|
130
|
+
_iterator.f();
|
|
131
|
+
}
|
|
132
|
+
matchingFiles = filesByBaseName.get(moduleName);
|
|
133
|
+
if (!matchingFiles) {
|
|
134
|
+
_context.next = 46;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
_iterator2 = _createForOfIteratorHelper(extensions);
|
|
138
|
+
_context.prev = 15;
|
|
139
|
+
_iterator2.s();
|
|
140
|
+
case 17:
|
|
141
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
142
|
+
_context.next = 38;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
ext = _step2.value;
|
|
146
|
+
_iterator3 = _createForOfIteratorHelper(matchingFiles);
|
|
147
|
+
_context.prev = 20;
|
|
148
|
+
_iterator3.s();
|
|
149
|
+
case 22:
|
|
150
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
151
|
+
_context.next = 28;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
entry = _step3.value;
|
|
155
|
+
if (!(extname(entry.name) === ext)) {
|
|
156
|
+
_context.next = 26;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
return _context.abrupt("return", join(parentDir, entry.name));
|
|
160
|
+
case 26:
|
|
161
|
+
_context.next = 22;
|
|
162
|
+
break;
|
|
163
|
+
case 28:
|
|
164
|
+
_context.next = 33;
|
|
165
|
+
break;
|
|
166
|
+
case 30:
|
|
167
|
+
_context.prev = 30;
|
|
168
|
+
_context.t0 = _context["catch"](20);
|
|
169
|
+
_iterator3.e(_context.t0);
|
|
170
|
+
case 33:
|
|
171
|
+
_context.prev = 33;
|
|
172
|
+
_iterator3.f();
|
|
173
|
+
return _context.finish(33);
|
|
174
|
+
case 36:
|
|
175
|
+
_context.next = 17;
|
|
176
|
+
break;
|
|
177
|
+
case 38:
|
|
178
|
+
_context.next = 43;
|
|
179
|
+
break;
|
|
180
|
+
case 40:
|
|
181
|
+
_context.prev = 40;
|
|
182
|
+
_context.t1 = _context["catch"](15);
|
|
183
|
+
_iterator2.e(_context.t1);
|
|
184
|
+
case 43:
|
|
185
|
+
_context.prev = 43;
|
|
186
|
+
_iterator2.f();
|
|
187
|
+
return _context.finish(43);
|
|
188
|
+
case 46:
|
|
189
|
+
// Look for directory with index files
|
|
190
|
+
directoryMatches = dirContents.filter(function (entry) {
|
|
191
|
+
return entry.isDirectory && entry.name === moduleName;
|
|
192
|
+
});
|
|
193
|
+
if (!(directoryMatches.length > 0)) {
|
|
194
|
+
_context.next = 94;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
moduleDir = join(parentDir, directoryMatches[0].name);
|
|
198
|
+
_context.prev = 49;
|
|
199
|
+
_context.next = 52;
|
|
200
|
+
return readDirectory(moduleDir);
|
|
201
|
+
case 52:
|
|
202
|
+
moduleDirContents = _context.sent;
|
|
203
|
+
// Look for index files in extension priority order
|
|
204
|
+
// Create a map of baseName -> files for efficient lookup
|
|
205
|
+
indexFilesByBaseName = new Map();
|
|
206
|
+
_iterator4 = _createForOfIteratorHelper(moduleDirContents);
|
|
207
|
+
try {
|
|
208
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
209
|
+
moduleFile = _step4.value;
|
|
210
|
+
if (moduleFile.isFile) {
|
|
211
|
+
fileName = moduleFile.name;
|
|
212
|
+
fileExt = extname(fileName);
|
|
213
|
+
fileBaseName = fileName.substring(0, fileName.length - fileExt.length);
|
|
214
|
+
if (!indexFilesByBaseName.has(fileBaseName)) {
|
|
215
|
+
indexFilesByBaseName.set(fileBaseName, []);
|
|
216
|
+
}
|
|
217
|
+
indexFilesByBaseName.get(fileBaseName).push(moduleFile);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Check for index files in extension priority order
|
|
222
|
+
} catch (err) {
|
|
223
|
+
_iterator4.e(err);
|
|
224
|
+
} finally {
|
|
225
|
+
_iterator4.f();
|
|
226
|
+
}
|
|
227
|
+
indexFiles = indexFilesByBaseName.get('index');
|
|
228
|
+
if (!indexFiles) {
|
|
229
|
+
_context.next = 90;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
_iterator5 = _createForOfIteratorHelper(extensions);
|
|
233
|
+
_context.prev = 59;
|
|
234
|
+
_iterator5.s();
|
|
235
|
+
case 61:
|
|
236
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
237
|
+
_context.next = 82;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
_ext = _step5.value;
|
|
241
|
+
_iterator6 = _createForOfIteratorHelper(indexFiles);
|
|
242
|
+
_context.prev = 64;
|
|
243
|
+
_iterator6.s();
|
|
244
|
+
case 66:
|
|
245
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
246
|
+
_context.next = 72;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
_entry = _step6.value;
|
|
250
|
+
if (!(extname(_entry.name) === _ext)) {
|
|
251
|
+
_context.next = 70;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return _context.abrupt("return", join(moduleDir, _entry.name));
|
|
255
|
+
case 70:
|
|
256
|
+
_context.next = 66;
|
|
257
|
+
break;
|
|
258
|
+
case 72:
|
|
259
|
+
_context.next = 77;
|
|
260
|
+
break;
|
|
261
|
+
case 74:
|
|
262
|
+
_context.prev = 74;
|
|
263
|
+
_context.t2 = _context["catch"](64);
|
|
264
|
+
_iterator6.e(_context.t2);
|
|
265
|
+
case 77:
|
|
266
|
+
_context.prev = 77;
|
|
267
|
+
_iterator6.f();
|
|
268
|
+
return _context.finish(77);
|
|
269
|
+
case 80:
|
|
270
|
+
_context.next = 61;
|
|
271
|
+
break;
|
|
272
|
+
case 82:
|
|
273
|
+
_context.next = 87;
|
|
274
|
+
break;
|
|
275
|
+
case 84:
|
|
276
|
+
_context.prev = 84;
|
|
277
|
+
_context.t3 = _context["catch"](59);
|
|
278
|
+
_iterator5.e(_context.t3);
|
|
279
|
+
case 87:
|
|
280
|
+
_context.prev = 87;
|
|
281
|
+
_iterator5.f();
|
|
282
|
+
return _context.finish(87);
|
|
283
|
+
case 90:
|
|
284
|
+
_context.next = 94;
|
|
285
|
+
break;
|
|
286
|
+
case 92:
|
|
287
|
+
_context.prev = 92;
|
|
288
|
+
_context.t4 = _context["catch"](49);
|
|
289
|
+
case 94:
|
|
290
|
+
_context.next = 98;
|
|
291
|
+
break;
|
|
292
|
+
case 96:
|
|
293
|
+
_context.prev = 96;
|
|
294
|
+
_context.t5 = _context["catch"](5);
|
|
295
|
+
case 98:
|
|
296
|
+
throw new Error("Could not resolve module at path \"".concat(modulePath, "\". Tried extensions: ").concat(extensions.join(', ')));
|
|
297
|
+
case 99:
|
|
298
|
+
case "end":
|
|
299
|
+
return _context.stop();
|
|
300
|
+
}
|
|
301
|
+
}, _callee, null, [[5, 96], [15, 40, 43, 46], [20, 30, 33, 36], [49, 92], [59, 84, 87, 90], [64, 74, 77, 80]]);
|
|
302
|
+
}));
|
|
303
|
+
return _resolveModulePath.apply(this, arguments);
|
|
304
|
+
}
|
|
305
|
+
export function resolveModulePaths(_x3, _x4) {
|
|
306
|
+
return _resolveModulePaths.apply(this, arguments);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Resolves import result by separating JavaScript modules from static assets,
|
|
311
|
+
* only resolving JavaScript modules and returning a combined map.
|
|
312
|
+
* This function uses the resolveModulePaths function internally but requires
|
|
313
|
+
* a DirectoryReader to be provided.
|
|
314
|
+
*
|
|
315
|
+
* @param importResult - The result from resolveImports containing all imports
|
|
316
|
+
* @param readDirectory - Function to read directory contents
|
|
317
|
+
* @param options - Configuration options for module resolution
|
|
318
|
+
* @returns Promise<Map<string, string>> - Map from import path to resolved file path
|
|
319
|
+
*/
|
|
320
|
+
function _resolveModulePaths() {
|
|
321
|
+
_resolveModulePaths = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(modulePaths, readDirectory) {
|
|
322
|
+
var options,
|
|
323
|
+
_options$extensions2,
|
|
324
|
+
extensions,
|
|
325
|
+
results,
|
|
326
|
+
pathsByDirectory,
|
|
327
|
+
_iterator7,
|
|
328
|
+
_step7,
|
|
329
|
+
modulePath,
|
|
330
|
+
lastSlashIndex,
|
|
331
|
+
parentDir,
|
|
332
|
+
moduleName,
|
|
333
|
+
directoryEntries,
|
|
334
|
+
directoryResults,
|
|
335
|
+
_iterator14,
|
|
336
|
+
_step14,
|
|
337
|
+
directoryResult,
|
|
338
|
+
_iterator15,
|
|
339
|
+
_step15,
|
|
340
|
+
_step15$value,
|
|
341
|
+
fullPath,
|
|
342
|
+
resolvedPath,
|
|
343
|
+
_args4 = arguments;
|
|
344
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
345
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
|
348
|
+
_options$extensions2 = options.extensions, extensions = _options$extensions2 === void 0 ? ['.ts', '.tsx', '.js', '.jsx'] : _options$extensions2;
|
|
349
|
+
results = new Map(); // Group paths by their parent directory
|
|
350
|
+
pathsByDirectory = new Map();
|
|
351
|
+
_iterator7 = _createForOfIteratorHelper(modulePaths);
|
|
352
|
+
try {
|
|
353
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
354
|
+
modulePath = _step7.value;
|
|
355
|
+
lastSlashIndex = modulePath.lastIndexOf('/');
|
|
356
|
+
parentDir = modulePath.substring(0, lastSlashIndex);
|
|
357
|
+
moduleName = modulePath.substring(lastSlashIndex + 1);
|
|
358
|
+
if (!pathsByDirectory.has(parentDir)) {
|
|
359
|
+
pathsByDirectory.set(parentDir, []);
|
|
360
|
+
}
|
|
361
|
+
pathsByDirectory.get(parentDir).push({
|
|
362
|
+
fullPath: modulePath,
|
|
363
|
+
moduleName: moduleName
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Process each directory group
|
|
368
|
+
} catch (err) {
|
|
369
|
+
_iterator7.e(err);
|
|
370
|
+
} finally {
|
|
371
|
+
_iterator7.f();
|
|
372
|
+
}
|
|
373
|
+
directoryEntries = Array.from(pathsByDirectory.entries());
|
|
374
|
+
_context4.next = 9;
|
|
375
|
+
return Promise.all(directoryEntries.map(/*#__PURE__*/function () {
|
|
376
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
377
|
+
var _ref3, parentDir, pathGroup, dirContents, unresolved, resolved, filesByBaseName, _iterator8, _step8, entry, fileName, fileExt, fileBaseName, _iterator9, _step9, _step9$value, _fullPath, moduleName, foundMatch, matchingFiles, _iterator12, _step12, ext, _iterator13, _step13, _entry3, directories, indexResults, _iterator11, _step11, _step11$value, fullPath, resolvedPath;
|
|
378
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
379
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
380
|
+
case 0:
|
|
381
|
+
_ref3 = _slicedToArray(_ref, 2), parentDir = _ref3[0], pathGroup = _ref3[1];
|
|
382
|
+
_context3.prev = 1;
|
|
383
|
+
_context3.next = 4;
|
|
384
|
+
return readDirectory(parentDir);
|
|
385
|
+
case 4:
|
|
386
|
+
dirContents = _context3.sent;
|
|
387
|
+
unresolved = [];
|
|
388
|
+
resolved = []; // Look for direct file matches in extension priority order
|
|
389
|
+
// Create a map of baseName -> files for efficient lookup
|
|
390
|
+
filesByBaseName = new Map();
|
|
391
|
+
_iterator8 = _createForOfIteratorHelper(dirContents);
|
|
392
|
+
try {
|
|
393
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
394
|
+
entry = _step8.value;
|
|
395
|
+
if (entry.isFile) {
|
|
396
|
+
fileName = entry.name;
|
|
397
|
+
fileExt = extname(fileName);
|
|
398
|
+
fileBaseName = fileName.substring(0, fileName.length - fileExt.length);
|
|
399
|
+
if (!filesByBaseName.has(fileBaseName)) {
|
|
400
|
+
filesByBaseName.set(fileBaseName, []);
|
|
401
|
+
}
|
|
402
|
+
filesByBaseName.get(fileBaseName).push(entry);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Check each module path against the file map
|
|
407
|
+
} catch (err) {
|
|
408
|
+
_iterator8.e(err);
|
|
409
|
+
} finally {
|
|
410
|
+
_iterator8.f();
|
|
411
|
+
}
|
|
412
|
+
_iterator9 = _createForOfIteratorHelper(pathGroup);
|
|
413
|
+
_context3.prev = 11;
|
|
414
|
+
_iterator9.s();
|
|
415
|
+
case 13:
|
|
416
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
417
|
+
_context3.next = 57;
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
_step9$value = _step9.value, _fullPath = _step9$value.fullPath, moduleName = _step9$value.moduleName;
|
|
421
|
+
foundMatch = false;
|
|
422
|
+
matchingFiles = filesByBaseName.get(moduleName);
|
|
423
|
+
if (!matchingFiles) {
|
|
424
|
+
_context3.next = 54;
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
_iterator12 = _createForOfIteratorHelper(extensions);
|
|
428
|
+
_context3.prev = 19;
|
|
429
|
+
_iterator12.s();
|
|
430
|
+
case 21:
|
|
431
|
+
if ((_step12 = _iterator12.n()).done) {
|
|
432
|
+
_context3.next = 46;
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
ext = _step12.value;
|
|
436
|
+
_iterator13 = _createForOfIteratorHelper(matchingFiles);
|
|
437
|
+
_context3.prev = 24;
|
|
438
|
+
_iterator13.s();
|
|
439
|
+
case 26:
|
|
440
|
+
if ((_step13 = _iterator13.n()).done) {
|
|
441
|
+
_context3.next = 34;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
_entry3 = _step13.value;
|
|
445
|
+
if (!(extname(_entry3.name) === ext)) {
|
|
446
|
+
_context3.next = 32;
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
resolved.push({
|
|
450
|
+
fullPath: _fullPath,
|
|
451
|
+
resolvedPath: join(parentDir, _entry3.name)
|
|
452
|
+
});
|
|
453
|
+
foundMatch = true;
|
|
454
|
+
return _context3.abrupt("break", 34);
|
|
455
|
+
case 32:
|
|
456
|
+
_context3.next = 26;
|
|
457
|
+
break;
|
|
458
|
+
case 34:
|
|
459
|
+
_context3.next = 39;
|
|
460
|
+
break;
|
|
461
|
+
case 36:
|
|
462
|
+
_context3.prev = 36;
|
|
463
|
+
_context3.t0 = _context3["catch"](24);
|
|
464
|
+
_iterator13.e(_context3.t0);
|
|
465
|
+
case 39:
|
|
466
|
+
_context3.prev = 39;
|
|
467
|
+
_iterator13.f();
|
|
468
|
+
return _context3.finish(39);
|
|
469
|
+
case 42:
|
|
470
|
+
if (!foundMatch) {
|
|
471
|
+
_context3.next = 44;
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
return _context3.abrupt("break", 46);
|
|
475
|
+
case 44:
|
|
476
|
+
_context3.next = 21;
|
|
477
|
+
break;
|
|
478
|
+
case 46:
|
|
479
|
+
_context3.next = 51;
|
|
480
|
+
break;
|
|
481
|
+
case 48:
|
|
482
|
+
_context3.prev = 48;
|
|
483
|
+
_context3.t1 = _context3["catch"](19);
|
|
484
|
+
_iterator12.e(_context3.t1);
|
|
485
|
+
case 51:
|
|
486
|
+
_context3.prev = 51;
|
|
487
|
+
_iterator12.f();
|
|
488
|
+
return _context3.finish(51);
|
|
489
|
+
case 54:
|
|
490
|
+
if (!foundMatch) {
|
|
491
|
+
unresolved.push({
|
|
492
|
+
fullPath: _fullPath,
|
|
493
|
+
moduleName: moduleName
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
case 55:
|
|
497
|
+
_context3.next = 13;
|
|
498
|
+
break;
|
|
499
|
+
case 57:
|
|
500
|
+
_context3.next = 62;
|
|
501
|
+
break;
|
|
502
|
+
case 59:
|
|
503
|
+
_context3.prev = 59;
|
|
504
|
+
_context3.t2 = _context3["catch"](11);
|
|
505
|
+
_iterator9.e(_context3.t2);
|
|
506
|
+
case 62:
|
|
507
|
+
_context3.prev = 62;
|
|
508
|
+
_iterator9.f();
|
|
509
|
+
return _context3.finish(62);
|
|
510
|
+
case 65:
|
|
511
|
+
if (!(unresolved.length > 0)) {
|
|
512
|
+
_context3.next = 72;
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
directories = new Set(dirContents.filter(function (entry) {
|
|
516
|
+
return entry.isDirectory;
|
|
517
|
+
}).map(function (entry) {
|
|
518
|
+
return entry.name;
|
|
519
|
+
}));
|
|
520
|
+
_context3.next = 69;
|
|
521
|
+
return Promise.all(unresolved.map(/*#__PURE__*/function () {
|
|
522
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref4) {
|
|
523
|
+
var fullPath, moduleName, moduleDir, moduleDirContents, indexFilesByBaseName, _iterator0, _step0, moduleFile, fileName, fileExt, fileBaseName, indexFiles, _iterator1, _step1, ext, _iterator10, _step10, entry;
|
|
524
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
525
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
526
|
+
case 0:
|
|
527
|
+
fullPath = _ref4.fullPath, moduleName = _ref4.moduleName;
|
|
528
|
+
if (!directories.has(moduleName)) {
|
|
529
|
+
_context2.next = 48;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
moduleDir = join(parentDir, moduleName);
|
|
533
|
+
_context2.prev = 3;
|
|
534
|
+
_context2.next = 6;
|
|
535
|
+
return readDirectory(moduleDir);
|
|
536
|
+
case 6:
|
|
537
|
+
moduleDirContents = _context2.sent;
|
|
538
|
+
// Look for index files in extension priority order
|
|
539
|
+
// Create a map of baseName -> files for efficient lookup
|
|
540
|
+
indexFilesByBaseName = new Map();
|
|
541
|
+
_iterator0 = _createForOfIteratorHelper(moduleDirContents);
|
|
542
|
+
try {
|
|
543
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
544
|
+
moduleFile = _step0.value;
|
|
545
|
+
if (moduleFile.isFile) {
|
|
546
|
+
fileName = moduleFile.name;
|
|
547
|
+
fileExt = extname(fileName);
|
|
548
|
+
fileBaseName = fileName.substring(0, fileName.length - fileExt.length);
|
|
549
|
+
if (!indexFilesByBaseName.has(fileBaseName)) {
|
|
550
|
+
indexFilesByBaseName.set(fileBaseName, []);
|
|
551
|
+
}
|
|
552
|
+
indexFilesByBaseName.get(fileBaseName).push(moduleFile);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// Check for index files in extension priority order
|
|
557
|
+
} catch (err) {
|
|
558
|
+
_iterator0.e(err);
|
|
559
|
+
} finally {
|
|
560
|
+
_iterator0.f();
|
|
561
|
+
}
|
|
562
|
+
indexFiles = indexFilesByBaseName.get('index');
|
|
563
|
+
if (!indexFiles) {
|
|
564
|
+
_context2.next = 44;
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
_iterator1 = _createForOfIteratorHelper(extensions);
|
|
568
|
+
_context2.prev = 13;
|
|
569
|
+
_iterator1.s();
|
|
570
|
+
case 15:
|
|
571
|
+
if ((_step1 = _iterator1.n()).done) {
|
|
572
|
+
_context2.next = 36;
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
ext = _step1.value;
|
|
576
|
+
_iterator10 = _createForOfIteratorHelper(indexFiles);
|
|
577
|
+
_context2.prev = 18;
|
|
578
|
+
_iterator10.s();
|
|
579
|
+
case 20:
|
|
580
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
581
|
+
_context2.next = 26;
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
entry = _step10.value;
|
|
585
|
+
if (!(extname(entry.name) === ext)) {
|
|
586
|
+
_context2.next = 24;
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
589
|
+
return _context2.abrupt("return", {
|
|
590
|
+
fullPath: fullPath,
|
|
591
|
+
resolvedPath: join(moduleDir, entry.name)
|
|
592
|
+
});
|
|
593
|
+
case 24:
|
|
594
|
+
_context2.next = 20;
|
|
595
|
+
break;
|
|
596
|
+
case 26:
|
|
597
|
+
_context2.next = 31;
|
|
598
|
+
break;
|
|
599
|
+
case 28:
|
|
600
|
+
_context2.prev = 28;
|
|
601
|
+
_context2.t0 = _context2["catch"](18);
|
|
602
|
+
_iterator10.e(_context2.t0);
|
|
603
|
+
case 31:
|
|
604
|
+
_context2.prev = 31;
|
|
605
|
+
_iterator10.f();
|
|
606
|
+
return _context2.finish(31);
|
|
607
|
+
case 34:
|
|
608
|
+
_context2.next = 15;
|
|
609
|
+
break;
|
|
610
|
+
case 36:
|
|
611
|
+
_context2.next = 41;
|
|
612
|
+
break;
|
|
613
|
+
case 38:
|
|
614
|
+
_context2.prev = 38;
|
|
615
|
+
_context2.t1 = _context2["catch"](13);
|
|
616
|
+
_iterator1.e(_context2.t1);
|
|
617
|
+
case 41:
|
|
618
|
+
_context2.prev = 41;
|
|
619
|
+
_iterator1.f();
|
|
620
|
+
return _context2.finish(41);
|
|
621
|
+
case 44:
|
|
622
|
+
_context2.next = 48;
|
|
623
|
+
break;
|
|
624
|
+
case 46:
|
|
625
|
+
_context2.prev = 46;
|
|
626
|
+
_context2.t2 = _context2["catch"](3);
|
|
627
|
+
case 48:
|
|
628
|
+
return _context2.abrupt("return", {
|
|
629
|
+
fullPath: fullPath,
|
|
630
|
+
resolvedPath: null
|
|
631
|
+
});
|
|
632
|
+
case 49:
|
|
633
|
+
case "end":
|
|
634
|
+
return _context2.stop();
|
|
635
|
+
}
|
|
636
|
+
}, _callee2, null, [[3, 46], [13, 38, 41, 44], [18, 28, 31, 34]]);
|
|
637
|
+
}));
|
|
638
|
+
return function (_x0) {
|
|
639
|
+
return _ref5.apply(this, arguments);
|
|
640
|
+
};
|
|
641
|
+
}()));
|
|
642
|
+
case 69:
|
|
643
|
+
indexResults = _context3.sent;
|
|
644
|
+
_iterator11 = _createForOfIteratorHelper(indexResults);
|
|
645
|
+
try {
|
|
646
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
647
|
+
_step11$value = _step11.value, fullPath = _step11$value.fullPath, resolvedPath = _step11$value.resolvedPath;
|
|
648
|
+
if (resolvedPath) {
|
|
649
|
+
resolved.push({
|
|
650
|
+
fullPath: fullPath,
|
|
651
|
+
resolvedPath: resolvedPath
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
} catch (err) {
|
|
656
|
+
_iterator11.e(err);
|
|
657
|
+
} finally {
|
|
658
|
+
_iterator11.f();
|
|
659
|
+
}
|
|
660
|
+
case 72:
|
|
661
|
+
return _context3.abrupt("return", resolved);
|
|
662
|
+
case 75:
|
|
663
|
+
_context3.prev = 75;
|
|
664
|
+
_context3.t3 = _context3["catch"](1);
|
|
665
|
+
return _context3.abrupt("return", []);
|
|
666
|
+
case 78:
|
|
667
|
+
case "end":
|
|
668
|
+
return _context3.stop();
|
|
669
|
+
}
|
|
670
|
+
}, _callee3, null, [[1, 75], [11, 59, 62, 65], [19, 48, 51, 54], [24, 36, 39, 42]]);
|
|
671
|
+
}));
|
|
672
|
+
return function (_x9) {
|
|
673
|
+
return _ref2.apply(this, arguments);
|
|
674
|
+
};
|
|
675
|
+
}()));
|
|
676
|
+
case 9:
|
|
677
|
+
directoryResults = _context4.sent;
|
|
678
|
+
// Collect all resolved paths
|
|
679
|
+
_iterator14 = _createForOfIteratorHelper(directoryResults);
|
|
680
|
+
try {
|
|
681
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
682
|
+
directoryResult = _step14.value;
|
|
683
|
+
_iterator15 = _createForOfIteratorHelper(directoryResult);
|
|
684
|
+
try {
|
|
685
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
686
|
+
_step15$value = _step15.value, fullPath = _step15$value.fullPath, resolvedPath = _step15$value.resolvedPath;
|
|
687
|
+
results.set(fullPath, resolvedPath);
|
|
688
|
+
}
|
|
689
|
+
} catch (err) {
|
|
690
|
+
_iterator15.e(err);
|
|
691
|
+
} finally {
|
|
692
|
+
_iterator15.f();
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
} catch (err) {
|
|
696
|
+
_iterator14.e(err);
|
|
697
|
+
} finally {
|
|
698
|
+
_iterator14.f();
|
|
699
|
+
}
|
|
700
|
+
return _context4.abrupt("return", results);
|
|
701
|
+
case 13:
|
|
702
|
+
case "end":
|
|
703
|
+
return _context4.stop();
|
|
704
|
+
}
|
|
705
|
+
}, _callee4);
|
|
706
|
+
}));
|
|
707
|
+
return _resolveModulePaths.apply(this, arguments);
|
|
708
|
+
}
|
|
709
|
+
export function resolveImportResult(_x5, _x6) {
|
|
710
|
+
return _resolveImportResult.apply(this, arguments);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Resolves variant paths from a variants object mapping variant names to their file paths.
|
|
715
|
+
* This function extracts the paths, resolves them using resolveModulePaths, and returns
|
|
716
|
+
* a map from variant name to resolved file URL.
|
|
717
|
+
*
|
|
718
|
+
* @param variants - Object mapping variant names to their file paths
|
|
719
|
+
* @param readDirectory - Function to read directory contents
|
|
720
|
+
* @param options - Configuration options for module resolution
|
|
721
|
+
* @returns Promise<Map<string, string>> - Map from variant name to resolved file URL
|
|
722
|
+
*/
|
|
723
|
+
function _resolveImportResult() {
|
|
724
|
+
_resolveImportResult = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(importResult, readDirectory) {
|
|
725
|
+
var options,
|
|
726
|
+
resolvedPathsMap,
|
|
727
|
+
jsImportPaths,
|
|
728
|
+
staticAssetPaths,
|
|
729
|
+
resolvedJsMap,
|
|
730
|
+
_args5 = arguments;
|
|
731
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
732
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
733
|
+
case 0:
|
|
734
|
+
options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
|
735
|
+
resolvedPathsMap = new Map(); // Separate JS/TS imports from static asset imports
|
|
736
|
+
jsImportPaths = [];
|
|
737
|
+
staticAssetPaths = [];
|
|
738
|
+
Object.entries(importResult).forEach(function (_ref6) {
|
|
739
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
740
|
+
importPath = _ref7[0],
|
|
741
|
+
path = _ref7[1].path;
|
|
742
|
+
if (isJavaScriptModule(importPath)) {
|
|
743
|
+
// If the import path already has a JS/TS extension, use it as-is
|
|
744
|
+
if (JAVASCRIPT_MODULE_EXTENSIONS.some(function (ext) {
|
|
745
|
+
return importPath.endsWith(ext);
|
|
746
|
+
})) {
|
|
747
|
+
resolvedPathsMap.set(path, path);
|
|
748
|
+
} else {
|
|
749
|
+
// Otherwise, it needs to be resolved (extensionless import)
|
|
750
|
+
jsImportPaths.push(path);
|
|
751
|
+
}
|
|
752
|
+
} else {
|
|
753
|
+
staticAssetPaths.push(path);
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
// Resolve JS/TS import paths using the provided directory reader
|
|
758
|
+
if (!(jsImportPaths.length > 0)) {
|
|
759
|
+
_context5.next = 10;
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
_context5.next = 8;
|
|
763
|
+
return resolveModulePaths(jsImportPaths, readDirectory, options);
|
|
764
|
+
case 8:
|
|
765
|
+
resolvedJsMap = _context5.sent;
|
|
766
|
+
resolvedJsMap.forEach(function (resolvedPath, importPath) {
|
|
767
|
+
resolvedPathsMap.set(importPath, resolvedPath);
|
|
768
|
+
});
|
|
769
|
+
case 10:
|
|
770
|
+
// For static assets, use the path as-is since they already have extensions
|
|
771
|
+
staticAssetPaths.forEach(function (path) {
|
|
772
|
+
resolvedPathsMap.set(path, path);
|
|
773
|
+
});
|
|
774
|
+
return _context5.abrupt("return", resolvedPathsMap);
|
|
775
|
+
case 12:
|
|
776
|
+
case "end":
|
|
777
|
+
return _context5.stop();
|
|
778
|
+
}
|
|
779
|
+
}, _callee5);
|
|
780
|
+
}));
|
|
781
|
+
return _resolveImportResult.apply(this, arguments);
|
|
782
|
+
}
|
|
783
|
+
export function resolveVariantPaths(_x7, _x8) {
|
|
784
|
+
return _resolveVariantPaths.apply(this, arguments);
|
|
785
|
+
}
|
|
786
|
+
function _resolveVariantPaths() {
|
|
787
|
+
_resolveVariantPaths = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(variants, readDirectory) {
|
|
788
|
+
var options,
|
|
789
|
+
variantPaths,
|
|
790
|
+
resolvedVariantPaths,
|
|
791
|
+
variantMap,
|
|
792
|
+
_i,
|
|
793
|
+
_Object$entries,
|
|
794
|
+
_Object$entries$_i,
|
|
795
|
+
variantName,
|
|
796
|
+
variantPath,
|
|
797
|
+
resolvedVariantPath,
|
|
798
|
+
_args6 = arguments;
|
|
799
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
800
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
801
|
+
case 0:
|
|
802
|
+
options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
|
|
803
|
+
// Extract the variant paths and resolve them
|
|
804
|
+
variantPaths = Object.values(variants);
|
|
805
|
+
_context6.next = 4;
|
|
806
|
+
return resolveModulePaths(variantPaths, readDirectory, options);
|
|
807
|
+
case 4:
|
|
808
|
+
resolvedVariantPaths = _context6.sent;
|
|
809
|
+
// Build a map from variant name to resolved file URL
|
|
810
|
+
variantMap = new Map();
|
|
811
|
+
for (_i = 0, _Object$entries = Object.entries(variants); _i < _Object$entries.length; _i++) {
|
|
812
|
+
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), variantName = _Object$entries$_i[0], variantPath = _Object$entries$_i[1];
|
|
813
|
+
resolvedVariantPath = resolvedVariantPaths.get(variantPath);
|
|
814
|
+
if (resolvedVariantPath) {
|
|
815
|
+
// Store as a file URL
|
|
816
|
+
variantMap.set(variantName, "file://".concat(resolvedVariantPath));
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return _context6.abrupt("return", variantMap);
|
|
820
|
+
case 8:
|
|
821
|
+
case "end":
|
|
822
|
+
return _context6.stop();
|
|
823
|
+
}
|
|
824
|
+
}, _callee6);
|
|
825
|
+
}));
|
|
826
|
+
return _resolveVariantPaths.apply(this, arguments);
|
|
827
|
+
}
|