@mui/internal-docs-infra 0.1.1-alpha.1 → 0.1.1-alpha.10

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.
Files changed (286) hide show
  1. package/CodeControllerContext/CodeControllerContext.d.ts +1 -1
  2. package/CodeControllerContext/CodeControllerContext.d.ts.map +1 -1
  3. package/CodeControllerContext/index.d.ts.map +1 -1
  4. package/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
  5. package/CodeExternalsContext/CodeExternalsContext.d.ts.map +1 -0
  6. package/CodeExternalsContext/CodeExternalsContext.js +7 -0
  7. package/CodeExternalsContext/index.d.ts +1 -0
  8. package/CodeExternalsContext/index.d.ts.map +1 -0
  9. package/CodeExternalsContext/index.js +1 -0
  10. package/CodeHighlighter/CodeHighlighter.d.ts +1 -1
  11. package/CodeHighlighter/CodeHighlighter.d.ts.map +1 -1
  12. package/CodeHighlighter/CodeHighlighter.js +235 -86
  13. package/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -1
  14. package/CodeHighlighter/CodeHighlighterClient.js +500 -62
  15. package/CodeHighlighter/CodeHighlighterContext.d.ts +2 -0
  16. package/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -1
  17. package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +1 -1
  18. package/CodeHighlighter/CodeHighlighterFallbackContext.js +3 -1
  19. package/CodeHighlighter/applyTransform.d.ts.map +1 -1
  20. package/CodeHighlighter/codeToFallbackProps.d.ts +2 -2
  21. package/CodeHighlighter/codeToFallbackProps.d.ts.map +1 -1
  22. package/CodeHighlighter/codeToFallbackProps.js +8 -5
  23. package/CodeHighlighter/errors.d.ts.map +1 -1
  24. package/CodeHighlighter/hasAllVariants.d.ts.map +1 -1
  25. package/CodeHighlighter/index.d.ts.map +1 -1
  26. package/CodeHighlighter/loadFallbackCode.d.ts +3 -2
  27. package/CodeHighlighter/loadFallbackCode.d.ts.map +1 -1
  28. package/CodeHighlighter/loadFallbackCode.js +325 -161
  29. package/CodeHighlighter/loadVariant.d.ts +3 -2
  30. package/CodeHighlighter/loadVariant.d.ts.map +1 -1
  31. package/CodeHighlighter/loadVariant.js +604 -229
  32. package/CodeHighlighter/maybeInitialData.d.ts +1 -1
  33. package/CodeHighlighter/maybeInitialData.d.ts.map +1 -1
  34. package/CodeHighlighter/parseCode.d.ts.map +1 -1
  35. package/CodeHighlighter/parseCode.js +14 -2
  36. package/CodeHighlighter/parseControlledCode.d.ts.map +1 -1
  37. package/CodeHighlighter/parseControlledCode.js +12 -1
  38. package/CodeHighlighter/transformCode.d.ts +1 -0
  39. package/CodeHighlighter/transformCode.d.ts.map +1 -1
  40. package/CodeHighlighter/transformCode.js +43 -3
  41. package/CodeHighlighter/transformParsedSource.d.ts.map +1 -1
  42. package/CodeHighlighter/transformSource.d.ts.map +1 -1
  43. package/CodeHighlighter/types.d.ts +39 -17
  44. package/CodeHighlighter/types.d.ts.map +1 -1
  45. package/CodeProvider/CodeContext.d.ts.map +1 -1
  46. package/CodeProvider/CodeProvider.d.ts.map +1 -1
  47. package/CodeProvider/CodeProvider.js +21 -6
  48. package/CodeProvider/index.d.ts +1 -2
  49. package/CodeProvider/index.d.ts.map +1 -1
  50. package/CodeProvider/index.js +1 -2
  51. package/abstractCreateDemo/abstractCreateDemo.d.ts +35 -0
  52. package/abstractCreateDemo/abstractCreateDemo.d.ts.map +1 -0
  53. package/abstractCreateDemo/abstractCreateDemo.js +91 -0
  54. package/abstractCreateDemo/index.d.ts +1 -0
  55. package/abstractCreateDemo/index.d.ts.map +1 -0
  56. package/abstractCreateDemo/index.js +1 -0
  57. package/createDemoData/createDemoData.d.ts +44 -0
  58. package/createDemoData/createDemoData.d.ts.map +1 -0
  59. package/createDemoData/createDemoData.js +75 -0
  60. package/createDemoData/index.d.ts +1 -0
  61. package/createDemoData/index.d.ts.map +1 -0
  62. package/createDemoData/index.js +1 -0
  63. package/createDemoData/types.d.ts +28 -0
  64. package/createDemoData/types.d.ts.map +1 -0
  65. package/createDemoData/types.js +1 -0
  66. package/package.json +15 -9
  67. package/pipeline/hastUtils/hastUtils.d.ts.map +1 -0
  68. package/{hast/hast.js → pipeline/hastUtils/hastUtils.js} +2 -1
  69. package/pipeline/hastUtils/index.d.ts +1 -0
  70. package/pipeline/hastUtils/index.d.ts.map +1 -0
  71. package/pipeline/hastUtils/index.js +1 -0
  72. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +54 -0
  73. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +1 -0
  74. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +465 -0
  75. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +15 -0
  76. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +1 -0
  77. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +253 -0
  78. package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +1 -0
  79. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +20 -0
  80. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -0
  81. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/loadPrecomputedCodeHighlighter.js +105 -75
  82. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseCreateFactoryCall.d.ts +12 -1
  83. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +1 -0
  84. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +433 -0
  85. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.d.ts +5 -1
  86. package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +1 -0
  87. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.js +1 -1
  88. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +25 -0
  89. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +1 -0
  90. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
  91. package/pipeline/loadServerCodeMeta/index.d.ts +1 -0
  92. package/pipeline/loadServerCodeMeta/index.d.ts.map +1 -0
  93. package/pipeline/loadServerCodeMeta/index.js +1 -0
  94. package/{loadServerCodeMeta/serverLoadCodeMeta.d.ts → pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts} +4 -4
  95. package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +1 -0
  96. package/{loadServerCodeMeta/serverLoadCodeMeta.js → pipeline/loadServerCodeMeta/loadServerCodeMeta.js} +18 -3
  97. package/pipeline/loadServerSource/index.d.ts +1 -0
  98. package/pipeline/loadServerSource/index.d.ts.map +1 -0
  99. package/pipeline/loadServerSource/index.js +1 -0
  100. package/{loadServerSource/serverLoadSource.d.ts → pipeline/loadServerSource/loadServerSource.d.ts} +5 -5
  101. package/pipeline/loadServerSource/loadServerSource.d.ts.map +1 -0
  102. package/pipeline/loadServerSource/loadServerSource.js +135 -0
  103. package/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
  104. package/pipeline/loaderUtils/externalsToPackages.d.ts.map +1 -0
  105. package/pipeline/loaderUtils/externalsToPackages.js +46 -0
  106. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
  107. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +1 -0
  108. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
  109. package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
  110. package/pipeline/loaderUtils/index.d.ts +7 -0
  111. package/pipeline/loaderUtils/index.d.ts.map +1 -0
  112. package/pipeline/loaderUtils/index.js +7 -0
  113. package/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
  114. package/pipeline/loaderUtils/mergeExternals.d.ts.map +1 -0
  115. package/pipeline/loaderUtils/mergeExternals.js +72 -0
  116. package/pipeline/loaderUtils/parseImports.d.ts +20 -0
  117. package/pipeline/loaderUtils/parseImports.d.ts.map +1 -0
  118. package/pipeline/loaderUtils/parseImports.js +307 -0
  119. package/{loaderUtils/processImports.d.ts → pipeline/loaderUtils/processRelativeImports.d.ts} +2 -2
  120. package/pipeline/loaderUtils/processRelativeImports.d.ts.map +1 -0
  121. package/pipeline/loaderUtils/processRelativeImports.js +329 -0
  122. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePath.d.ts +19 -6
  123. package/pipeline/loaderUtils/resolveModulePath.d.ts.map +1 -0
  124. package/pipeline/loaderUtils/resolveModulePath.js +1449 -0
  125. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.d.ts +6 -3
  126. package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
  127. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.js +8 -4
  128. package/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
  129. package/pipeline/loaderUtils/rewriteImports.d.ts.map +1 -0
  130. package/pipeline/loaderUtils/rewriteImports.js +35 -0
  131. package/pipeline/parseSource/grammars.d.ts.map +1 -0
  132. package/pipeline/parseSource/index.d.ts.map +1 -0
  133. package/pipeline/parseSource/parseSource.d.ts +3 -0
  134. package/pipeline/parseSource/parseSource.d.ts.map +1 -0
  135. package/{parseSource → pipeline/parseSource}/parseSource.js +15 -5
  136. package/pipeline/transformHtmlCode/index.d.ts +2 -0
  137. package/pipeline/transformHtmlCode/index.d.ts.map +1 -0
  138. package/pipeline/transformHtmlCode/index.js +4 -0
  139. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
  140. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +1 -0
  141. package/pipeline/transformHtmlCode/transformHtmlCode.js +303 -0
  142. package/pipeline/transformMarkdownCode/index.d.ts +2 -0
  143. package/pipeline/transformMarkdownCode/index.d.ts.map +1 -0
  144. package/pipeline/transformMarkdownCode/index.js +4 -0
  145. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
  146. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +1 -0
  147. package/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
  148. package/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
  149. package/pipeline/transformTypescriptToJavascript/index.d.ts.map +1 -0
  150. package/pipeline/transformTypescriptToJavascript/index.js +1 -0
  151. package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +1 -0
  152. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
  153. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +1 -0
  154. package/{transformTsToJs/transformTsToJs.js → pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js} +4 -4
  155. package/useCode/index.d.ts.map +1 -1
  156. package/useCode/useCode.d.ts +13 -11
  157. package/useCode/useCode.d.ts.map +1 -1
  158. package/useCode/useCode.js +93 -364
  159. package/useCode/useCodeUtils.d.ts +45 -0
  160. package/useCode/useCodeUtils.d.ts.map +1 -0
  161. package/useCode/useCodeUtils.js +240 -0
  162. package/useCode/useCopyFunctionality.d.ts +17 -0
  163. package/useCode/useCopyFunctionality.d.ts.map +1 -0
  164. package/useCode/useCopyFunctionality.js +28 -0
  165. package/useCode/useFileNavigation.d.ts +48 -0
  166. package/useCode/useFileNavigation.d.ts.map +1 -0
  167. package/useCode/useFileNavigation.js +370 -0
  168. package/useCode/useSourceEditing.d.ts +19 -0
  169. package/useCode/useSourceEditing.d.ts.map +1 -0
  170. package/useCode/useSourceEditing.js +32 -0
  171. package/useCode/useTransformManagement.d.ts +28 -0
  172. package/useCode/useTransformManagement.d.ts.map +1 -0
  173. package/useCode/useTransformManagement.js +82 -0
  174. package/useCode/useUIState.d.ts +16 -0
  175. package/useCode/useUIState.d.ts.map +1 -0
  176. package/useCode/useUIState.js +21 -0
  177. package/useCode/useVariantSelection.d.ts +21 -0
  178. package/useCode/useVariantSelection.d.ts.map +1 -0
  179. package/useCode/useVariantSelection.js +84 -0
  180. package/useCopier/index.d.ts +1 -1
  181. package/useCopier/index.d.ts.map +1 -1
  182. package/useCopier/index.js +5 -5
  183. package/useDemo/createCodeSandbox.d.ts +18 -0
  184. package/useDemo/createCodeSandbox.d.ts.map +1 -0
  185. package/useDemo/createCodeSandbox.js +48 -0
  186. package/useDemo/createStackBlitz.d.ts +22 -0
  187. package/useDemo/createStackBlitz.d.ts.map +1 -0
  188. package/useDemo/createStackBlitz.js +38 -0
  189. package/useDemo/examineVariant.d.ts +25 -0
  190. package/useDemo/examineVariant.d.ts.map +1 -0
  191. package/useDemo/examineVariant.js +134 -0
  192. package/useDemo/exportVariant.d.ts +110 -0
  193. package/useDemo/exportVariant.d.ts.map +1 -0
  194. package/useDemo/exportVariant.js +320 -0
  195. package/useDemo/exportVariantAsCra.d.ts +15 -0
  196. package/useDemo/exportVariantAsCra.d.ts.map +1 -0
  197. package/useDemo/exportVariantAsCra.js +56 -0
  198. package/useDemo/flattenVariant.d.ts +17 -0
  199. package/useDemo/flattenVariant.d.ts.map +1 -0
  200. package/useDemo/flattenVariant.js +206 -0
  201. package/useDemo/index.d.ts +6 -39
  202. package/useDemo/index.d.ts.map +1 -1
  203. package/useDemo/index.js +6 -17
  204. package/useDemo/useDemo.d.ts +78 -0
  205. package/useDemo/useDemo.d.ts.map +1 -0
  206. package/useDemo/useDemo.js +174 -0
  207. package/useLocalStorageState/index.d.ts +2 -0
  208. package/useLocalStorageState/index.d.ts.map +1 -0
  209. package/useLocalStorageState/index.js +2 -0
  210. package/useLocalStorageState/useLocalStorageState.d.ts +14 -0
  211. package/useLocalStorageState/useLocalStorageState.d.ts.map +1 -0
  212. package/useLocalStorageState/useLocalStorageState.js +128 -0
  213. package/useOnHydrate/index.d.ts.map +1 -1
  214. package/useOnHydrate/useOnHydrate.d.ts.map +1 -1
  215. package/useOnIdle/index.d.ts.map +1 -1
  216. package/useOnIdle/useOnIdle.d.ts.map +1 -1
  217. package/useUrlHashState/index.d.ts +1 -0
  218. package/useUrlHashState/index.d.ts.map +1 -0
  219. package/useUrlHashState/index.js +1 -0
  220. package/useUrlHashState/useUrlHashState.d.ts +50 -0
  221. package/useUrlHashState/useUrlHashState.d.ts.map +1 -0
  222. package/useUrlHashState/useUrlHashState.js +113 -0
  223. package/hast/hast.d.ts.map +0 -1
  224. package/hast/index.d.ts +0 -1
  225. package/hast/index.d.ts.map +0 -1
  226. package/hast/index.js +0 -1
  227. package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
  228. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
  229. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
  230. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
  231. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
  232. package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
  233. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
  234. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
  235. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
  236. package/loadServerCodeMeta/index.d.ts +0 -1
  237. package/loadServerCodeMeta/index.d.ts.map +0 -1
  238. package/loadServerCodeMeta/index.js +0 -1
  239. package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
  240. package/loadServerSource/index.d.ts +0 -1
  241. package/loadServerSource/index.d.ts.map +0 -1
  242. package/loadServerSource/index.js +0 -1
  243. package/loadServerSource/serverLoadSource.d.ts.map +0 -1
  244. package/loadServerSource/serverLoadSource.js +0 -100
  245. package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
  246. package/loaderUtils/index.d.ts +0 -5
  247. package/loaderUtils/index.d.ts.map +0 -1
  248. package/loaderUtils/index.js +0 -5
  249. package/loaderUtils/processImports.d.ts.map +0 -1
  250. package/loaderUtils/processImports.js +0 -82
  251. package/loaderUtils/resolveImports.d.ts +0 -4
  252. package/loaderUtils/resolveImports.d.ts.map +0 -1
  253. package/loaderUtils/resolveImports.js +0 -71
  254. package/loaderUtils/resolveModulePath.d.ts.map +0 -1
  255. package/loaderUtils/resolveModulePath.js +0 -862
  256. package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
  257. package/loaderUtils/rewriteImports.d.ts +0 -9
  258. package/loaderUtils/rewriteImports.d.ts.map +0 -1
  259. package/loaderUtils/rewriteImports.js +0 -57
  260. package/parseSource/grammars.d.ts.map +0 -1
  261. package/parseSource/index.d.ts.map +0 -1
  262. package/parseSource/parseSource.d.ts +0 -3
  263. package/parseSource/parseSource.d.ts.map +0 -1
  264. package/transformRelativeMarkdownPaths/index.d.ts +0 -2
  265. package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
  266. package/transformRelativeMarkdownPaths/index.js +0 -4
  267. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
  268. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
  269. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
  270. package/transformTsToJs/index.d.ts +0 -1
  271. package/transformTsToJs/index.d.ts.map +0 -1
  272. package/transformTsToJs/index.js +0 -1
  273. package/transformTsToJs/removeTypes.d.ts.map +0 -1
  274. package/transformTsToJs/transformTsToJs.d.ts +0 -3
  275. package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
  276. /package/{hast/hast.d.ts → pipeline/hastUtils/hastUtils.d.ts} +0 -0
  277. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.d.ts +0 -0
  278. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.js +0 -0
  279. /package/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.d.ts +0 -0
  280. /package/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.js +0 -0
  281. /package/{parseSource → pipeline/parseSource}/grammars.d.ts +0 -0
  282. /package/{parseSource → pipeline/parseSource}/grammars.js +0 -0
  283. /package/{parseSource → pipeline/parseSource}/index.d.ts +0 -0
  284. /package/{parseSource → pipeline/parseSource}/index.js +0 -0
  285. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.d.ts +0 -0
  286. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.js +0 -0
@@ -0,0 +1,1449 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
5
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
+ import { getFileNameFromUrl } from "./getFileNameFromUrl.js";
7
+
8
+ /**
9
+ * Isomorphic path joining function that works in both Node.js and browser environments.
10
+ * Uses string concatenation to handle path joining consistently across platforms.
11
+ */
12
+ function joinPath(basePath) {
13
+ // Start with the base path, ensuring it has a trailing slash for URL construction
14
+ var result = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
15
+
16
+ // Handle each segment
17
+ for (var i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i += 1) {
18
+ var segment = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
19
+ if (segment) {
20
+ // Remove leading slash from segment to avoid double slashes
21
+ var cleanSegment = segment.startsWith('/') ? segment.slice(1) : segment;
22
+ // Append segment
23
+ result += cleanSegment;
24
+ // Add trailing slash for intermediate segments
25
+ if (i < (arguments.length <= 1 ? 0 : arguments.length - 1) - 1) {
26
+ result += '/';
27
+ }
28
+ }
29
+ }
30
+ return result;
31
+ }
32
+
33
+ /**
34
+ * Default file extensions for JavaScript/TypeScript modules that can be resolved
35
+ */
36
+ export var JAVASCRIPT_MODULE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.d.ts'];
37
+
38
+ /**
39
+ * Extension priority for type-only imports - prioritize .d.ts first
40
+ */
41
+ export var TYPE_IMPORT_EXTENSIONS = ['.d.ts', '.ts', '.tsx', '.js', '.jsx'];
42
+
43
+ /**
44
+ * Extension priority for value imports - standard priority with .d.ts last
45
+ */
46
+ export var VALUE_IMPORT_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.d.ts'];
47
+
48
+ /**
49
+ * Checks if a file path or import path represents a JavaScript/TypeScript module
50
+ * @param path - The file path or import path to check
51
+ * @returns true if it's a JS/TS module, false otherwise
52
+ */
53
+ export function isJavaScriptModule(path) {
54
+ // If the path has an extension, check if it's one of the JS/TS extensions
55
+ if (/\.[^/]+$/.test(path)) {
56
+ return JAVASCRIPT_MODULE_EXTENSIONS.some(function (ext) {
57
+ return path.endsWith(ext);
58
+ });
59
+ }
60
+ // If no extension, assume it's a JS/TS module (will be resolved to one)
61
+ return true;
62
+ }
63
+ /**
64
+ * Resolves a module path by reading directory contents to find matching files.
65
+ * This is more efficient than checking each file individually with stat calls.
66
+ *
67
+ * Given a path like `/Code/mui-public/packages/docs-infra/docs/app/components/code-highlighter/demos/code/BasicCode`,
68
+ * this function will try to find the actual file by checking for:
69
+ * - `BasicCode.ts`, `BasicCode.tsx`, `BasicCode.js`, `BasicCode.jsx`
70
+ * - `BasicCode/index.ts`, `BasicCode/index.tsx`, `BasicCode/index.js`, `BasicCode/index.jsx`
71
+ *
72
+ * @param modulePath - The module path to resolve (without file extension)
73
+ * @param readDirectory - Function to read directory contents
74
+ * @param options - Configuration options
75
+ * @param includeTypeDefs - If true, returns both import and typeImport paths with different extension priorities
76
+ * @returns Promise<string | TypeAwareResolveResult> - The resolved file path(s)
77
+ */
78
+ export function resolveModulePath(_x, _x2) {
79
+ return _resolveModulePath.apply(this, arguments);
80
+ }
81
+
82
+ /**
83
+ * Resolves a module path with type-aware resolution, returning both import and typeImport paths
84
+ * This function is optimized to do only a single directory read instead of two separate reads.
85
+ */
86
+ function _resolveModulePath() {
87
+ _resolveModulePath = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(modulePath, readDirectory) {
88
+ var options,
89
+ includeTypeDefs,
90
+ _options$extensions,
91
+ extensions,
92
+ lastSlashIndex,
93
+ parentDir,
94
+ moduleName,
95
+ resolvedPath,
96
+ _args = arguments;
97
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
98
+ while (1) switch (_context.prev = _context.next) {
99
+ case 0:
100
+ options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
101
+ includeTypeDefs = _args.length > 3 ? _args[3] : undefined;
102
+ _options$extensions = options.extensions, extensions = _options$extensions === void 0 ? JAVASCRIPT_MODULE_EXTENSIONS : _options$extensions; // If includeTypeDefs is true, we need to resolve with both type and value extension priorities
103
+ if (!includeTypeDefs) {
104
+ _context.next = 5;
105
+ break;
106
+ }
107
+ return _context.abrupt("return", resolveWithTypeAwareness(modulePath, readDirectory, options));
108
+ case 5:
109
+ // Extract the parent directory and the module name
110
+ lastSlashIndex = modulePath.lastIndexOf('/');
111
+ parentDir = modulePath.substring(0, lastSlashIndex);
112
+ moduleName = modulePath.substring(lastSlashIndex + 1);
113
+ _context.next = 10;
114
+ return resolveSinglePath(modulePath, parentDir, moduleName, readDirectory, extensions);
115
+ case 10:
116
+ resolvedPath = _context.sent;
117
+ return _context.abrupt("return", resolvedPath);
118
+ case 12:
119
+ case "end":
120
+ return _context.stop();
121
+ }
122
+ }, _callee);
123
+ }));
124
+ return _resolveModulePath.apply(this, arguments);
125
+ }
126
+ function resolveWithTypeAwareness(_x3, _x4) {
127
+ return _resolveWithTypeAwareness.apply(this, arguments);
128
+ }
129
+ /**
130
+ * Internal function to resolve a single path with given extensions
131
+ */
132
+ function _resolveWithTypeAwareness() {
133
+ _resolveWithTypeAwareness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(modulePath, readDirectory) {
134
+ var _options,
135
+ lastSlashIndex,
136
+ parentDir,
137
+ moduleName,
138
+ dirContents,
139
+ filesByBaseName,
140
+ _iterator,
141
+ _step,
142
+ _entry4,
143
+ _fileName,
144
+ _fileBaseName,
145
+ _actualExtension,
146
+ _getFileNameFromUrl2,
147
+ _fileExt,
148
+ matchingFiles,
149
+ entryMap,
150
+ importPath,
151
+ _iterator2,
152
+ _step2,
153
+ ext,
154
+ _iterator4,
155
+ _step4,
156
+ entry,
157
+ typeImportPath,
158
+ _iterator3,
159
+ _step3,
160
+ _ext,
161
+ _iterator5,
162
+ _step5,
163
+ _entry,
164
+ directoryMatches,
165
+ moduleDir,
166
+ moduleDirContents,
167
+ indexFilesByBaseName,
168
+ _iterator6,
169
+ _step6,
170
+ moduleFile,
171
+ fileName,
172
+ fileBaseName,
173
+ actualExtension,
174
+ _getFileNameFromUrl,
175
+ fileExt,
176
+ indexFiles,
177
+ indexEntryMap,
178
+ _importPath,
179
+ _iterator7,
180
+ _step7,
181
+ _ext2,
182
+ _iterator9,
183
+ _step9,
184
+ _entry2,
185
+ _typeImportPath,
186
+ _iterator8,
187
+ _step8,
188
+ _ext3,
189
+ _iterator0,
190
+ _step0,
191
+ _entry3,
192
+ _args2 = arguments;
193
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
194
+ while (1) switch (_context2.prev = _context2.next) {
195
+ case 0:
196
+ _options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
197
+ lastSlashIndex = modulePath.lastIndexOf('/');
198
+ parentDir = modulePath.substring(0, lastSlashIndex);
199
+ moduleName = modulePath.substring(lastSlashIndex + 1); // Single filesystem read to get directory contents
200
+ _context2.next = 6;
201
+ return readDirectory(parentDir);
202
+ case 6:
203
+ dirContents = _context2.sent;
204
+ // Build a map of available files by basename
205
+ filesByBaseName = new Map();
206
+ _iterator = _createForOfIteratorHelper(dirContents);
207
+ try {
208
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
209
+ _entry4 = _step.value;
210
+ if (_entry4.isFile) {
211
+ _fileName = _entry4.name;
212
+ _fileBaseName = void 0;
213
+ _actualExtension = void 0; // Handle .d.ts files specially since getFileNameFromUrl returns .ts for types.d.ts
214
+ if (_fileName.endsWith('.d.ts')) {
215
+ _actualExtension = '.d.ts';
216
+ _fileBaseName = _fileName.substring(0, _fileName.length - 5); // Remove .d.ts
217
+ } else {
218
+ _getFileNameFromUrl2 = getFileNameFromUrl(_fileName), _fileExt = _getFileNameFromUrl2.extension;
219
+ _actualExtension = _fileExt;
220
+ _fileBaseName = _fileName.substring(0, _fileName.length - _fileExt.length);
221
+ }
222
+ if (!filesByBaseName.has(_fileBaseName)) {
223
+ filesByBaseName.set(_fileBaseName, []);
224
+ }
225
+ // Store the entry with its actual extension for later matching
226
+ filesByBaseName.get(_fileBaseName).push(_objectSpread(_objectSpread({}, _entry4), {}, {
227
+ actualExtension: _actualExtension
228
+ }));
229
+ }
230
+ }
231
+
232
+ // Check for the module in both priority orders
233
+ } catch (err) {
234
+ _iterator.e(err);
235
+ } finally {
236
+ _iterator.f();
237
+ }
238
+ matchingFiles = filesByBaseName.get(moduleName);
239
+ if (!matchingFiles) {
240
+ _context2.next = 91;
241
+ break;
242
+ }
243
+ entryMap = matchingFiles; // Find best match for value imports (VALUE_IMPORT_EXTENSIONS priority)
244
+ importPath = null;
245
+ _iterator2 = _createForOfIteratorHelper(VALUE_IMPORT_EXTENSIONS);
246
+ _context2.prev = 15;
247
+ _iterator2.s();
248
+ case 17:
249
+ if ((_step2 = _iterator2.n()).done) {
250
+ _context2.next = 41;
251
+ break;
252
+ }
253
+ ext = _step2.value;
254
+ _iterator4 = _createForOfIteratorHelper(entryMap);
255
+ _context2.prev = 20;
256
+ _iterator4.s();
257
+ case 22:
258
+ if ((_step4 = _iterator4.n()).done) {
259
+ _context2.next = 29;
260
+ break;
261
+ }
262
+ entry = _step4.value;
263
+ if (!(entry.actualExtension === ext)) {
264
+ _context2.next = 27;
265
+ break;
266
+ }
267
+ importPath = joinPath(parentDir, entry.name);
268
+ return _context2.abrupt("break", 29);
269
+ case 27:
270
+ _context2.next = 22;
271
+ break;
272
+ case 29:
273
+ _context2.next = 34;
274
+ break;
275
+ case 31:
276
+ _context2.prev = 31;
277
+ _context2.t0 = _context2["catch"](20);
278
+ _iterator4.e(_context2.t0);
279
+ case 34:
280
+ _context2.prev = 34;
281
+ _iterator4.f();
282
+ return _context2.finish(34);
283
+ case 37:
284
+ if (!importPath) {
285
+ _context2.next = 39;
286
+ break;
287
+ }
288
+ return _context2.abrupt("break", 41);
289
+ case 39:
290
+ _context2.next = 17;
291
+ break;
292
+ case 41:
293
+ _context2.next = 46;
294
+ break;
295
+ case 43:
296
+ _context2.prev = 43;
297
+ _context2.t1 = _context2["catch"](15);
298
+ _iterator2.e(_context2.t1);
299
+ case 46:
300
+ _context2.prev = 46;
301
+ _iterator2.f();
302
+ return _context2.finish(46);
303
+ case 49:
304
+ // Find best match for type imports (TYPE_IMPORT_EXTENSIONS priority)
305
+ typeImportPath = null;
306
+ _iterator3 = _createForOfIteratorHelper(TYPE_IMPORT_EXTENSIONS);
307
+ _context2.prev = 51;
308
+ _iterator3.s();
309
+ case 53:
310
+ if ((_step3 = _iterator3.n()).done) {
311
+ _context2.next = 77;
312
+ break;
313
+ }
314
+ _ext = _step3.value;
315
+ _iterator5 = _createForOfIteratorHelper(entryMap);
316
+ _context2.prev = 56;
317
+ _iterator5.s();
318
+ case 58:
319
+ if ((_step5 = _iterator5.n()).done) {
320
+ _context2.next = 65;
321
+ break;
322
+ }
323
+ _entry = _step5.value;
324
+ if (!(_entry.actualExtension === _ext)) {
325
+ _context2.next = 63;
326
+ break;
327
+ }
328
+ typeImportPath = joinPath(parentDir, _entry.name);
329
+ return _context2.abrupt("break", 65);
330
+ case 63:
331
+ _context2.next = 58;
332
+ break;
333
+ case 65:
334
+ _context2.next = 70;
335
+ break;
336
+ case 67:
337
+ _context2.prev = 67;
338
+ _context2.t2 = _context2["catch"](56);
339
+ _iterator5.e(_context2.t2);
340
+ case 70:
341
+ _context2.prev = 70;
342
+ _iterator5.f();
343
+ return _context2.finish(70);
344
+ case 73:
345
+ if (!typeImportPath) {
346
+ _context2.next = 75;
347
+ break;
348
+ }
349
+ return _context2.abrupt("break", 77);
350
+ case 75:
351
+ _context2.next = 53;
352
+ break;
353
+ case 77:
354
+ _context2.next = 82;
355
+ break;
356
+ case 79:
357
+ _context2.prev = 79;
358
+ _context2.t3 = _context2["catch"](51);
359
+ _iterator3.e(_context2.t3);
360
+ case 82:
361
+ _context2.prev = 82;
362
+ _iterator3.f();
363
+ return _context2.finish(82);
364
+ case 85:
365
+ if (!(importPath && typeImportPath && importPath !== typeImportPath)) {
366
+ _context2.next = 87;
367
+ break;
368
+ }
369
+ return _context2.abrupt("return", {
370
+ "import": importPath,
371
+ typeImport: typeImportPath
372
+ });
373
+ case 87:
374
+ if (!importPath) {
375
+ _context2.next = 89;
376
+ break;
377
+ }
378
+ return _context2.abrupt("return", {
379
+ "import": importPath
380
+ });
381
+ case 89:
382
+ if (!typeImportPath) {
383
+ _context2.next = 91;
384
+ break;
385
+ }
386
+ return _context2.abrupt("return", {
387
+ "import": typeImportPath
388
+ });
389
+ case 91:
390
+ // Try index files with the same single-pass approach
391
+ directoryMatches = dirContents.filter(function (entry) {
392
+ return entry.isDirectory && entry.name === moduleName;
393
+ });
394
+ if (!(directoryMatches.length > 0)) {
395
+ _context2.next = 186;
396
+ break;
397
+ }
398
+ moduleDir = joinPath(parentDir, directoryMatches[0].name);
399
+ _context2.prev = 94;
400
+ _context2.next = 97;
401
+ return readDirectory(moduleDir);
402
+ case 97:
403
+ moduleDirContents = _context2.sent;
404
+ // Build a map of available index files by basename
405
+ indexFilesByBaseName = new Map();
406
+ _iterator6 = _createForOfIteratorHelper(moduleDirContents);
407
+ try {
408
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
409
+ moduleFile = _step6.value;
410
+ if (moduleFile.isFile) {
411
+ fileName = moduleFile.name;
412
+ fileBaseName = void 0;
413
+ actualExtension = void 0; // Handle .d.ts files specially since getFileNameFromUrl returns .ts for index.d.ts
414
+ if (fileName.endsWith('.d.ts')) {
415
+ actualExtension = '.d.ts';
416
+ fileBaseName = fileName.substring(0, fileName.length - 5); // Remove .d.ts
417
+ } else {
418
+ _getFileNameFromUrl = getFileNameFromUrl(fileName), fileExt = _getFileNameFromUrl.extension;
419
+ actualExtension = fileExt;
420
+ fileBaseName = fileName.substring(0, fileName.length - fileExt.length);
421
+ }
422
+ if (!indexFilesByBaseName.has(fileBaseName)) {
423
+ indexFilesByBaseName.set(fileBaseName, []);
424
+ }
425
+ // Store the entry with its actual extension for later matching
426
+ indexFilesByBaseName.get(fileBaseName).push(_objectSpread(_objectSpread({}, moduleFile), {}, {
427
+ actualExtension: actualExtension
428
+ }));
429
+ }
430
+ }
431
+
432
+ // Check for index files in both priority orders
433
+ } catch (err) {
434
+ _iterator6.e(err);
435
+ } finally {
436
+ _iterator6.f();
437
+ }
438
+ indexFiles = indexFilesByBaseName.get('index');
439
+ if (!indexFiles) {
440
+ _context2.next = 182;
441
+ break;
442
+ }
443
+ indexEntryMap = indexFiles; // Find best match for value imports
444
+ _importPath = null;
445
+ _iterator7 = _createForOfIteratorHelper(VALUE_IMPORT_EXTENSIONS);
446
+ _context2.prev = 106;
447
+ _iterator7.s();
448
+ case 108:
449
+ if ((_step7 = _iterator7.n()).done) {
450
+ _context2.next = 132;
451
+ break;
452
+ }
453
+ _ext2 = _step7.value;
454
+ _iterator9 = _createForOfIteratorHelper(indexEntryMap);
455
+ _context2.prev = 111;
456
+ _iterator9.s();
457
+ case 113:
458
+ if ((_step9 = _iterator9.n()).done) {
459
+ _context2.next = 120;
460
+ break;
461
+ }
462
+ _entry2 = _step9.value;
463
+ if (!(_entry2.actualExtension === _ext2)) {
464
+ _context2.next = 118;
465
+ break;
466
+ }
467
+ _importPath = joinPath(moduleDir, _entry2.name);
468
+ return _context2.abrupt("break", 120);
469
+ case 118:
470
+ _context2.next = 113;
471
+ break;
472
+ case 120:
473
+ _context2.next = 125;
474
+ break;
475
+ case 122:
476
+ _context2.prev = 122;
477
+ _context2.t4 = _context2["catch"](111);
478
+ _iterator9.e(_context2.t4);
479
+ case 125:
480
+ _context2.prev = 125;
481
+ _iterator9.f();
482
+ return _context2.finish(125);
483
+ case 128:
484
+ if (!_importPath) {
485
+ _context2.next = 130;
486
+ break;
487
+ }
488
+ return _context2.abrupt("break", 132);
489
+ case 130:
490
+ _context2.next = 108;
491
+ break;
492
+ case 132:
493
+ _context2.next = 137;
494
+ break;
495
+ case 134:
496
+ _context2.prev = 134;
497
+ _context2.t5 = _context2["catch"](106);
498
+ _iterator7.e(_context2.t5);
499
+ case 137:
500
+ _context2.prev = 137;
501
+ _iterator7.f();
502
+ return _context2.finish(137);
503
+ case 140:
504
+ // Find best match for type imports
505
+ _typeImportPath = null;
506
+ _iterator8 = _createForOfIteratorHelper(TYPE_IMPORT_EXTENSIONS);
507
+ _context2.prev = 142;
508
+ _iterator8.s();
509
+ case 144:
510
+ if ((_step8 = _iterator8.n()).done) {
511
+ _context2.next = 168;
512
+ break;
513
+ }
514
+ _ext3 = _step8.value;
515
+ _iterator0 = _createForOfIteratorHelper(indexEntryMap);
516
+ _context2.prev = 147;
517
+ _iterator0.s();
518
+ case 149:
519
+ if ((_step0 = _iterator0.n()).done) {
520
+ _context2.next = 156;
521
+ break;
522
+ }
523
+ _entry3 = _step0.value;
524
+ if (!(_entry3.actualExtension === _ext3)) {
525
+ _context2.next = 154;
526
+ break;
527
+ }
528
+ _typeImportPath = joinPath(moduleDir, _entry3.name);
529
+ return _context2.abrupt("break", 156);
530
+ case 154:
531
+ _context2.next = 149;
532
+ break;
533
+ case 156:
534
+ _context2.next = 161;
535
+ break;
536
+ case 158:
537
+ _context2.prev = 158;
538
+ _context2.t6 = _context2["catch"](147);
539
+ _iterator0.e(_context2.t6);
540
+ case 161:
541
+ _context2.prev = 161;
542
+ _iterator0.f();
543
+ return _context2.finish(161);
544
+ case 164:
545
+ if (!_typeImportPath) {
546
+ _context2.next = 166;
547
+ break;
548
+ }
549
+ return _context2.abrupt("break", 168);
550
+ case 166:
551
+ _context2.next = 144;
552
+ break;
553
+ case 168:
554
+ _context2.next = 173;
555
+ break;
556
+ case 170:
557
+ _context2.prev = 170;
558
+ _context2.t7 = _context2["catch"](142);
559
+ _iterator8.e(_context2.t7);
560
+ case 173:
561
+ _context2.prev = 173;
562
+ _iterator8.f();
563
+ return _context2.finish(173);
564
+ case 176:
565
+ if (!(_importPath && _typeImportPath && _importPath !== _typeImportPath)) {
566
+ _context2.next = 178;
567
+ break;
568
+ }
569
+ return _context2.abrupt("return", {
570
+ "import": _importPath,
571
+ typeImport: _typeImportPath
572
+ });
573
+ case 178:
574
+ if (!_importPath) {
575
+ _context2.next = 180;
576
+ break;
577
+ }
578
+ return _context2.abrupt("return", {
579
+ "import": _importPath
580
+ });
581
+ case 180:
582
+ if (!_typeImportPath) {
583
+ _context2.next = 182;
584
+ break;
585
+ }
586
+ return _context2.abrupt("return", {
587
+ "import": _typeImportPath
588
+ });
589
+ case 182:
590
+ _context2.next = 186;
591
+ break;
592
+ case 184:
593
+ _context2.prev = 184;
594
+ _context2.t8 = _context2["catch"](94);
595
+ case 186:
596
+ throw new Error("Could not resolve module at path \"".concat(modulePath, "\". Tried extensions: ").concat(VALUE_IMPORT_EXTENSIONS.join(', '), ", ").concat(TYPE_IMPORT_EXTENSIONS.join(', ')));
597
+ case 187:
598
+ case "end":
599
+ return _context2.stop();
600
+ }
601
+ }, _callee2, null, [[15, 43, 46, 49], [20, 31, 34, 37], [51, 79, 82, 85], [56, 67, 70, 73], [94, 184], [106, 134, 137, 140], [111, 122, 125, 128], [142, 170, 173, 176], [147, 158, 161, 164]]);
602
+ }));
603
+ return _resolveWithTypeAwareness.apply(this, arguments);
604
+ }
605
+ function resolveSinglePath(_x5, _x6, _x7, _x8, _x9) {
606
+ return _resolveSinglePath.apply(this, arguments);
607
+ }
608
+ /**
609
+ * Resolves multiple module paths efficiently by grouping them by directory
610
+ * and performing batch directory lookups.
611
+ *
612
+ * @param modulePaths - Array of module paths to resolve (without file extensions)
613
+ * @param readDirectory - Function to read directory contents
614
+ * @param options - Configuration options
615
+ * @returns Promise<Map<string, string>> - Map from input path to resolved file path
616
+ */
617
+ function _resolveSinglePath() {
618
+ _resolveSinglePath = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(modulePath, parentDir, moduleName, readDirectory, extensions) {
619
+ var dirContents, filesByBaseName, _iterator1, _step1, _entry6, _fileName2, _fileBaseName2, _actualExtension2, _getFileNameFromUrl4, _fileExt2, matchingFiles, _iterator10, _step10, ext, _iterator11, _step11, entry, entryWithExt, resolvedPath, directoryMatches, moduleDir, moduleDirContents, indexFilesByBaseName, _iterator12, _step12, moduleFile, fileName, fileBaseName, actualExtension, _getFileNameFromUrl3, fileExt, indexFiles, _iterator13, _step13, _ext4, _iterator14, _step14, _entry5, _entryWithExt;
620
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
621
+ while (1) switch (_context3.prev = _context3.next) {
622
+ case 0:
623
+ _context3.prev = 0;
624
+ _context3.next = 3;
625
+ return readDirectory(parentDir);
626
+ case 3:
627
+ dirContents = _context3.sent;
628
+ // Look for direct file matches in extension priority order
629
+ // Create a map of baseName -> files with that basename for efficient lookup
630
+ filesByBaseName = new Map();
631
+ _iterator1 = _createForOfIteratorHelper(dirContents);
632
+ try {
633
+ for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
634
+ _entry6 = _step1.value;
635
+ if (_entry6.isFile) {
636
+ _fileName2 = _entry6.name;
637
+ _fileBaseName2 = void 0;
638
+ _actualExtension2 = void 0; // Handle .d.ts files specially since getFileNameFromUrl returns .ts for types.d.ts
639
+ if (_fileName2.endsWith('.d.ts')) {
640
+ _actualExtension2 = '.d.ts';
641
+ _fileBaseName2 = _fileName2.substring(0, _fileName2.length - 5); // Remove .d.ts
642
+ } else {
643
+ _getFileNameFromUrl4 = getFileNameFromUrl(_fileName2), _fileExt2 = _getFileNameFromUrl4.extension;
644
+ _actualExtension2 = _fileExt2;
645
+ _fileBaseName2 = _fileName2.substring(0, _fileName2.length - _fileExt2.length);
646
+ }
647
+ if (!filesByBaseName.has(_fileBaseName2)) {
648
+ filesByBaseName.set(_fileBaseName2, []);
649
+ }
650
+ // Store the entry with its actual extension for later matching
651
+ filesByBaseName.get(_fileBaseName2).push(_objectSpread(_objectSpread({}, _entry6), {}, {
652
+ // Add a custom property to track the actual extension
653
+ actualExtension: _actualExtension2
654
+ }));
655
+ }
656
+ }
657
+
658
+ // Check for the module in extension priority order
659
+ } catch (err) {
660
+ _iterator1.e(err);
661
+ } finally {
662
+ _iterator1.f();
663
+ }
664
+ matchingFiles = filesByBaseName.get(moduleName);
665
+ if (!matchingFiles) {
666
+ _context3.next = 43;
667
+ break;
668
+ }
669
+ _iterator10 = _createForOfIteratorHelper(extensions);
670
+ _context3.prev = 10;
671
+ _iterator10.s();
672
+ case 12:
673
+ if ((_step10 = _iterator10.n()).done) {
674
+ _context3.next = 35;
675
+ break;
676
+ }
677
+ ext = _step10.value;
678
+ _iterator11 = _createForOfIteratorHelper(matchingFiles);
679
+ _context3.prev = 15;
680
+ _iterator11.s();
681
+ case 17:
682
+ if ((_step11 = _iterator11.n()).done) {
683
+ _context3.next = 25;
684
+ break;
685
+ }
686
+ entry = _step11.value;
687
+ entryWithExt = entry;
688
+ if (!(entryWithExt.actualExtension === ext)) {
689
+ _context3.next = 23;
690
+ break;
691
+ }
692
+ resolvedPath = joinPath(parentDir, entry.name);
693
+ return _context3.abrupt("return", resolvedPath);
694
+ case 23:
695
+ _context3.next = 17;
696
+ break;
697
+ case 25:
698
+ _context3.next = 30;
699
+ break;
700
+ case 27:
701
+ _context3.prev = 27;
702
+ _context3.t0 = _context3["catch"](15);
703
+ _iterator11.e(_context3.t0);
704
+ case 30:
705
+ _context3.prev = 30;
706
+ _iterator11.f();
707
+ return _context3.finish(30);
708
+ case 33:
709
+ _context3.next = 12;
710
+ break;
711
+ case 35:
712
+ _context3.next = 40;
713
+ break;
714
+ case 37:
715
+ _context3.prev = 37;
716
+ _context3.t1 = _context3["catch"](10);
717
+ _iterator10.e(_context3.t1);
718
+ case 40:
719
+ _context3.prev = 40;
720
+ _iterator10.f();
721
+ return _context3.finish(40);
722
+ case 43:
723
+ // Look for directory with index files
724
+ directoryMatches = dirContents.filter(function (entry) {
725
+ return entry.isDirectory && entry.name === moduleName;
726
+ });
727
+ if (!(directoryMatches.length > 0)) {
728
+ _context3.next = 92;
729
+ break;
730
+ }
731
+ moduleDir = joinPath(parentDir, directoryMatches[0].name);
732
+ _context3.prev = 46;
733
+ _context3.next = 49;
734
+ return readDirectory(moduleDir);
735
+ case 49:
736
+ moduleDirContents = _context3.sent;
737
+ // Look for index files in extension priority order
738
+ // Create a map of baseName -> files for efficient lookup
739
+ indexFilesByBaseName = new Map();
740
+ _iterator12 = _createForOfIteratorHelper(moduleDirContents);
741
+ try {
742
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
743
+ moduleFile = _step12.value;
744
+ if (moduleFile.isFile) {
745
+ fileName = moduleFile.name;
746
+ fileBaseName = void 0;
747
+ actualExtension = void 0; // Handle .d.ts files specially since getFileNameFromUrl returns .ts for index.d.ts
748
+ if (fileName.endsWith('.d.ts')) {
749
+ actualExtension = '.d.ts';
750
+ fileBaseName = fileName.substring(0, fileName.length - 5); // Remove .d.ts
751
+ } else {
752
+ _getFileNameFromUrl3 = getFileNameFromUrl(fileName), fileExt = _getFileNameFromUrl3.extension;
753
+ actualExtension = fileExt;
754
+ fileBaseName = fileName.substring(0, fileName.length - fileExt.length);
755
+ }
756
+ if (!indexFilesByBaseName.has(fileBaseName)) {
757
+ indexFilesByBaseName.set(fileBaseName, []);
758
+ }
759
+ // Store the entry with its actual extension for later matching
760
+ indexFilesByBaseName.get(fileBaseName).push(_objectSpread(_objectSpread({}, moduleFile), {}, {
761
+ actualExtension: actualExtension
762
+ }));
763
+ }
764
+ }
765
+
766
+ // Check for index files in extension priority order
767
+ } catch (err) {
768
+ _iterator12.e(err);
769
+ } finally {
770
+ _iterator12.f();
771
+ }
772
+ indexFiles = indexFilesByBaseName.get('index');
773
+ if (!indexFiles) {
774
+ _context3.next = 88;
775
+ break;
776
+ }
777
+ _iterator13 = _createForOfIteratorHelper(extensions);
778
+ _context3.prev = 56;
779
+ _iterator13.s();
780
+ case 58:
781
+ if ((_step13 = _iterator13.n()).done) {
782
+ _context3.next = 80;
783
+ break;
784
+ }
785
+ _ext4 = _step13.value;
786
+ _iterator14 = _createForOfIteratorHelper(indexFiles);
787
+ _context3.prev = 61;
788
+ _iterator14.s();
789
+ case 63:
790
+ if ((_step14 = _iterator14.n()).done) {
791
+ _context3.next = 70;
792
+ break;
793
+ }
794
+ _entry5 = _step14.value;
795
+ _entryWithExt = _entry5;
796
+ if (!(_entryWithExt.actualExtension === _ext4)) {
797
+ _context3.next = 68;
798
+ break;
799
+ }
800
+ return _context3.abrupt("return", joinPath(moduleDir, _entry5.name));
801
+ case 68:
802
+ _context3.next = 63;
803
+ break;
804
+ case 70:
805
+ _context3.next = 75;
806
+ break;
807
+ case 72:
808
+ _context3.prev = 72;
809
+ _context3.t2 = _context3["catch"](61);
810
+ _iterator14.e(_context3.t2);
811
+ case 75:
812
+ _context3.prev = 75;
813
+ _iterator14.f();
814
+ return _context3.finish(75);
815
+ case 78:
816
+ _context3.next = 58;
817
+ break;
818
+ case 80:
819
+ _context3.next = 85;
820
+ break;
821
+ case 82:
822
+ _context3.prev = 82;
823
+ _context3.t3 = _context3["catch"](56);
824
+ _iterator13.e(_context3.t3);
825
+ case 85:
826
+ _context3.prev = 85;
827
+ _iterator13.f();
828
+ return _context3.finish(85);
829
+ case 88:
830
+ _context3.next = 92;
831
+ break;
832
+ case 90:
833
+ _context3.prev = 90;
834
+ _context3.t4 = _context3["catch"](46);
835
+ case 92:
836
+ _context3.next = 96;
837
+ break;
838
+ case 94:
839
+ _context3.prev = 94;
840
+ _context3.t5 = _context3["catch"](0);
841
+ case 96:
842
+ throw new Error("Could not resolve module at path \"".concat(modulePath, "\". Tried extensions: ").concat(extensions.join(', ')));
843
+ case 97:
844
+ case "end":
845
+ return _context3.stop();
846
+ }
847
+ }, _callee3, null, [[0, 94], [10, 37, 40, 43], [15, 27, 30, 33], [46, 90], [56, 82, 85, 88], [61, 72, 75, 78]]);
848
+ }));
849
+ return _resolveSinglePath.apply(this, arguments);
850
+ }
851
+ export function resolveModulePaths(_x0, _x1) {
852
+ return _resolveModulePaths.apply(this, arguments);
853
+ }
854
+
855
+ /**
856
+ * Resolves import result by separating JavaScript modules from static assets,
857
+ * only resolving JavaScript modules and returning a combined map.
858
+ * This function uses the new type-aware resolveModulePath function internally.
859
+ *
860
+ * @param importResult - The result from parseImports containing all imports
861
+ * @param readDirectory - Function to read directory contents
862
+ * @param options - Configuration options for module resolution
863
+ * @returns Promise<Map<string, string>> - Map from import path to resolved file path
864
+ */
865
+ function _resolveModulePaths() {
866
+ _resolveModulePaths = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(modulePaths, readDirectory) {
867
+ var options,
868
+ _options$extensions2,
869
+ extensions,
870
+ results,
871
+ pathsByDirectory,
872
+ _iterator15,
873
+ _step15,
874
+ modulePath,
875
+ lastSlashIndex,
876
+ parentDir,
877
+ moduleName,
878
+ directoryEntries,
879
+ directoryResults,
880
+ _iterator24,
881
+ _step24,
882
+ directoryResult,
883
+ _iterator25,
884
+ _step25,
885
+ _step25$value,
886
+ fullPath,
887
+ resolvedPath,
888
+ _args6 = arguments;
889
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
890
+ while (1) switch (_context6.prev = _context6.next) {
891
+ case 0:
892
+ options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
893
+ _options$extensions2 = options.extensions, extensions = _options$extensions2 === void 0 ? JAVASCRIPT_MODULE_EXTENSIONS : _options$extensions2;
894
+ results = new Map(); // Group paths by their parent directory
895
+ pathsByDirectory = new Map();
896
+ _iterator15 = _createForOfIteratorHelper(modulePaths);
897
+ try {
898
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
899
+ modulePath = _step15.value;
900
+ lastSlashIndex = modulePath.lastIndexOf('/');
901
+ parentDir = modulePath.substring(0, lastSlashIndex);
902
+ moduleName = modulePath.substring(lastSlashIndex + 1);
903
+ if (!pathsByDirectory.has(parentDir)) {
904
+ pathsByDirectory.set(parentDir, []);
905
+ }
906
+ pathsByDirectory.get(parentDir).push({
907
+ fullPath: modulePath,
908
+ moduleName: moduleName
909
+ });
910
+ }
911
+
912
+ // Process each directory group
913
+ } catch (err) {
914
+ _iterator15.e(err);
915
+ } finally {
916
+ _iterator15.f();
917
+ }
918
+ directoryEntries = Array.from(pathsByDirectory.entries());
919
+ _context6.next = 9;
920
+ return Promise.all(directoryEntries.map(/*#__PURE__*/function () {
921
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref) {
922
+ var _ref3, parentDir, pathGroup, dirContents, unresolved, resolved, filesByBaseName, _iterator16, _step16, entry, fileName, _getFileNameFromUrl7, fileExt, fileBaseName, _iterator17, _step17, _step17$value, _fullPath, moduleName, foundMatch, matchingFiles, _iterator22, _step22, ext, _iterator23, _step23, _entry7, _getFileNameFromUrl8, entryExt, directories, indexResults, _iterator21, _step21, _step21$value, fullPath, resolvedPath;
923
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
924
+ while (1) switch (_context5.prev = _context5.next) {
925
+ case 0:
926
+ _ref3 = _slicedToArray(_ref, 2), parentDir = _ref3[0], pathGroup = _ref3[1];
927
+ _context5.prev = 1;
928
+ _context5.next = 4;
929
+ return readDirectory(parentDir);
930
+ case 4:
931
+ dirContents = _context5.sent;
932
+ unresolved = [];
933
+ resolved = []; // Look for direct file matches in extension priority order
934
+ // Create a map of baseName -> files for efficient lookup
935
+ filesByBaseName = new Map();
936
+ _iterator16 = _createForOfIteratorHelper(dirContents);
937
+ try {
938
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
939
+ entry = _step16.value;
940
+ if (entry.isFile) {
941
+ fileName = entry.name;
942
+ _getFileNameFromUrl7 = getFileNameFromUrl(fileName), fileExt = _getFileNameFromUrl7.extension;
943
+ fileBaseName = fileName.substring(0, fileName.length - fileExt.length);
944
+ if (!filesByBaseName.has(fileBaseName)) {
945
+ filesByBaseName.set(fileBaseName, []);
946
+ }
947
+ filesByBaseName.get(fileBaseName).push(entry);
948
+ }
949
+ }
950
+
951
+ // Check each module path against the file map
952
+ } catch (err) {
953
+ _iterator16.e(err);
954
+ } finally {
955
+ _iterator16.f();
956
+ }
957
+ _iterator17 = _createForOfIteratorHelper(pathGroup);
958
+ _context5.prev = 11;
959
+ _iterator17.s();
960
+ case 13:
961
+ if ((_step17 = _iterator17.n()).done) {
962
+ _context5.next = 58;
963
+ break;
964
+ }
965
+ _step17$value = _step17.value, _fullPath = _step17$value.fullPath, moduleName = _step17$value.moduleName;
966
+ foundMatch = false;
967
+ matchingFiles = filesByBaseName.get(moduleName);
968
+ if (!matchingFiles) {
969
+ _context5.next = 55;
970
+ break;
971
+ }
972
+ _iterator22 = _createForOfIteratorHelper(extensions);
973
+ _context5.prev = 19;
974
+ _iterator22.s();
975
+ case 21:
976
+ if ((_step22 = _iterator22.n()).done) {
977
+ _context5.next = 47;
978
+ break;
979
+ }
980
+ ext = _step22.value;
981
+ _iterator23 = _createForOfIteratorHelper(matchingFiles);
982
+ _context5.prev = 24;
983
+ _iterator23.s();
984
+ case 26:
985
+ if ((_step23 = _iterator23.n()).done) {
986
+ _context5.next = 35;
987
+ break;
988
+ }
989
+ _entry7 = _step23.value;
990
+ _getFileNameFromUrl8 = getFileNameFromUrl(_entry7.name), entryExt = _getFileNameFromUrl8.extension;
991
+ if (!(entryExt === ext)) {
992
+ _context5.next = 33;
993
+ break;
994
+ }
995
+ resolved.push({
996
+ fullPath: _fullPath,
997
+ resolvedPath: joinPath(parentDir, _entry7.name)
998
+ });
999
+ foundMatch = true;
1000
+ return _context5.abrupt("break", 35);
1001
+ case 33:
1002
+ _context5.next = 26;
1003
+ break;
1004
+ case 35:
1005
+ _context5.next = 40;
1006
+ break;
1007
+ case 37:
1008
+ _context5.prev = 37;
1009
+ _context5.t0 = _context5["catch"](24);
1010
+ _iterator23.e(_context5.t0);
1011
+ case 40:
1012
+ _context5.prev = 40;
1013
+ _iterator23.f();
1014
+ return _context5.finish(40);
1015
+ case 43:
1016
+ if (!foundMatch) {
1017
+ _context5.next = 45;
1018
+ break;
1019
+ }
1020
+ return _context5.abrupt("break", 47);
1021
+ case 45:
1022
+ _context5.next = 21;
1023
+ break;
1024
+ case 47:
1025
+ _context5.next = 52;
1026
+ break;
1027
+ case 49:
1028
+ _context5.prev = 49;
1029
+ _context5.t1 = _context5["catch"](19);
1030
+ _iterator22.e(_context5.t1);
1031
+ case 52:
1032
+ _context5.prev = 52;
1033
+ _iterator22.f();
1034
+ return _context5.finish(52);
1035
+ case 55:
1036
+ if (!foundMatch) {
1037
+ unresolved.push({
1038
+ fullPath: _fullPath,
1039
+ moduleName: moduleName
1040
+ });
1041
+ }
1042
+ case 56:
1043
+ _context5.next = 13;
1044
+ break;
1045
+ case 58:
1046
+ _context5.next = 63;
1047
+ break;
1048
+ case 60:
1049
+ _context5.prev = 60;
1050
+ _context5.t2 = _context5["catch"](11);
1051
+ _iterator17.e(_context5.t2);
1052
+ case 63:
1053
+ _context5.prev = 63;
1054
+ _iterator17.f();
1055
+ return _context5.finish(63);
1056
+ case 66:
1057
+ if (!(unresolved.length > 0)) {
1058
+ _context5.next = 73;
1059
+ break;
1060
+ }
1061
+ directories = new Set(dirContents.filter(function (entry) {
1062
+ return entry.isDirectory;
1063
+ }).map(function (entry) {
1064
+ return entry.name;
1065
+ }));
1066
+ _context5.next = 70;
1067
+ return Promise.all(unresolved.map(/*#__PURE__*/function () {
1068
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref4) {
1069
+ var fullPath, moduleName, moduleDir, moduleDirContents, indexFilesByBaseName, _iterator18, _step18, moduleFile, fileName, _getFileNameFromUrl6, fileExt, fileBaseName, indexFiles, _iterator19, _step19, ext, _iterator20, _step20, entry, _getFileNameFromUrl5, entryExt;
1070
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1071
+ while (1) switch (_context4.prev = _context4.next) {
1072
+ case 0:
1073
+ fullPath = _ref4.fullPath, moduleName = _ref4.moduleName;
1074
+ if (!directories.has(moduleName)) {
1075
+ _context4.next = 49;
1076
+ break;
1077
+ }
1078
+ moduleDir = joinPath(parentDir, moduleName);
1079
+ _context4.prev = 3;
1080
+ _context4.next = 6;
1081
+ return readDirectory(moduleDir);
1082
+ case 6:
1083
+ moduleDirContents = _context4.sent;
1084
+ // Look for index files in extension priority order
1085
+ // Create a map of baseName -> files for efficient lookup
1086
+ indexFilesByBaseName = new Map();
1087
+ _iterator18 = _createForOfIteratorHelper(moduleDirContents);
1088
+ try {
1089
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
1090
+ moduleFile = _step18.value;
1091
+ if (moduleFile.isFile) {
1092
+ fileName = moduleFile.name;
1093
+ _getFileNameFromUrl6 = getFileNameFromUrl(fileName), fileExt = _getFileNameFromUrl6.extension;
1094
+ fileBaseName = fileName.substring(0, fileName.length - fileExt.length);
1095
+ if (!indexFilesByBaseName.has(fileBaseName)) {
1096
+ indexFilesByBaseName.set(fileBaseName, []);
1097
+ }
1098
+ indexFilesByBaseName.get(fileBaseName).push(moduleFile);
1099
+ }
1100
+ }
1101
+
1102
+ // Check for index files in extension priority order
1103
+ } catch (err) {
1104
+ _iterator18.e(err);
1105
+ } finally {
1106
+ _iterator18.f();
1107
+ }
1108
+ indexFiles = indexFilesByBaseName.get('index');
1109
+ if (!indexFiles) {
1110
+ _context4.next = 45;
1111
+ break;
1112
+ }
1113
+ _iterator19 = _createForOfIteratorHelper(extensions);
1114
+ _context4.prev = 13;
1115
+ _iterator19.s();
1116
+ case 15:
1117
+ if ((_step19 = _iterator19.n()).done) {
1118
+ _context4.next = 37;
1119
+ break;
1120
+ }
1121
+ ext = _step19.value;
1122
+ _iterator20 = _createForOfIteratorHelper(indexFiles);
1123
+ _context4.prev = 18;
1124
+ _iterator20.s();
1125
+ case 20:
1126
+ if ((_step20 = _iterator20.n()).done) {
1127
+ _context4.next = 27;
1128
+ break;
1129
+ }
1130
+ entry = _step20.value;
1131
+ _getFileNameFromUrl5 = getFileNameFromUrl(entry.name), entryExt = _getFileNameFromUrl5.extension;
1132
+ if (!(entryExt === ext)) {
1133
+ _context4.next = 25;
1134
+ break;
1135
+ }
1136
+ return _context4.abrupt("return", {
1137
+ fullPath: fullPath,
1138
+ resolvedPath: joinPath(moduleDir, entry.name)
1139
+ });
1140
+ case 25:
1141
+ _context4.next = 20;
1142
+ break;
1143
+ case 27:
1144
+ _context4.next = 32;
1145
+ break;
1146
+ case 29:
1147
+ _context4.prev = 29;
1148
+ _context4.t0 = _context4["catch"](18);
1149
+ _iterator20.e(_context4.t0);
1150
+ case 32:
1151
+ _context4.prev = 32;
1152
+ _iterator20.f();
1153
+ return _context4.finish(32);
1154
+ case 35:
1155
+ _context4.next = 15;
1156
+ break;
1157
+ case 37:
1158
+ _context4.next = 42;
1159
+ break;
1160
+ case 39:
1161
+ _context4.prev = 39;
1162
+ _context4.t1 = _context4["catch"](13);
1163
+ _iterator19.e(_context4.t1);
1164
+ case 42:
1165
+ _context4.prev = 42;
1166
+ _iterator19.f();
1167
+ return _context4.finish(42);
1168
+ case 45:
1169
+ _context4.next = 49;
1170
+ break;
1171
+ case 47:
1172
+ _context4.prev = 47;
1173
+ _context4.t2 = _context4["catch"](3);
1174
+ case 49:
1175
+ return _context4.abrupt("return", {
1176
+ fullPath: fullPath,
1177
+ resolvedPath: null
1178
+ });
1179
+ case 50:
1180
+ case "end":
1181
+ return _context4.stop();
1182
+ }
1183
+ }, _callee4, null, [[3, 47], [13, 39, 42, 45], [18, 29, 32, 35]]);
1184
+ }));
1185
+ return function (_x15) {
1186
+ return _ref5.apply(this, arguments);
1187
+ };
1188
+ }()));
1189
+ case 70:
1190
+ indexResults = _context5.sent;
1191
+ _iterator21 = _createForOfIteratorHelper(indexResults);
1192
+ try {
1193
+ for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
1194
+ _step21$value = _step21.value, fullPath = _step21$value.fullPath, resolvedPath = _step21$value.resolvedPath;
1195
+ if (resolvedPath) {
1196
+ resolved.push({
1197
+ fullPath: fullPath,
1198
+ resolvedPath: resolvedPath
1199
+ });
1200
+ }
1201
+ }
1202
+ } catch (err) {
1203
+ _iterator21.e(err);
1204
+ } finally {
1205
+ _iterator21.f();
1206
+ }
1207
+ case 73:
1208
+ return _context5.abrupt("return", resolved);
1209
+ case 76:
1210
+ _context5.prev = 76;
1211
+ _context5.t3 = _context5["catch"](1);
1212
+ return _context5.abrupt("return", []);
1213
+ case 79:
1214
+ case "end":
1215
+ return _context5.stop();
1216
+ }
1217
+ }, _callee5, null, [[1, 76], [11, 60, 63, 66], [19, 49, 52, 55], [24, 37, 40, 43]]);
1218
+ }));
1219
+ return function (_x14) {
1220
+ return _ref2.apply(this, arguments);
1221
+ };
1222
+ }()));
1223
+ case 9:
1224
+ directoryResults = _context6.sent;
1225
+ // Collect all resolved paths
1226
+ _iterator24 = _createForOfIteratorHelper(directoryResults);
1227
+ try {
1228
+ for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
1229
+ directoryResult = _step24.value;
1230
+ _iterator25 = _createForOfIteratorHelper(directoryResult);
1231
+ try {
1232
+ for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
1233
+ _step25$value = _step25.value, fullPath = _step25$value.fullPath, resolvedPath = _step25$value.resolvedPath;
1234
+ results.set(fullPath, resolvedPath);
1235
+ }
1236
+ } catch (err) {
1237
+ _iterator25.e(err);
1238
+ } finally {
1239
+ _iterator25.f();
1240
+ }
1241
+ }
1242
+ } catch (err) {
1243
+ _iterator24.e(err);
1244
+ } finally {
1245
+ _iterator24.f();
1246
+ }
1247
+ return _context6.abrupt("return", results);
1248
+ case 13:
1249
+ case "end":
1250
+ return _context6.stop();
1251
+ }
1252
+ }, _callee6);
1253
+ }));
1254
+ return _resolveModulePaths.apply(this, arguments);
1255
+ }
1256
+ export function resolveImportResult(_x10, _x11) {
1257
+ return _resolveImportResult.apply(this, arguments);
1258
+ }
1259
+
1260
+ /**
1261
+ * Resolves variant paths from a variants object mapping variant names to their file paths.
1262
+ * This function extracts the paths, resolves them using resolveModulePaths, and returns
1263
+ * a map from variant name to resolved file URL.
1264
+ *
1265
+ * @param variants - Object mapping variant names to their file paths
1266
+ * @param readDirectory - Function to read directory contents
1267
+ * @param options - Configuration options for module resolution
1268
+ * @returns Promise<Map<string, string>> - Map from variant name to resolved file URL
1269
+ */
1270
+ function _resolveImportResult() {
1271
+ _resolveImportResult = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(importResult, readDirectory) {
1272
+ var options,
1273
+ resolvedPathsMap,
1274
+ jsModulesToResolve,
1275
+ jsModulesWithExtensions,
1276
+ staticAssets,
1277
+ _loop,
1278
+ _i,
1279
+ _Object$entries,
1280
+ resolutionPromises,
1281
+ resolutionResults,
1282
+ _args9 = arguments;
1283
+ return _regeneratorRuntime().wrap(function _callee8$(_context9) {
1284
+ while (1) switch (_context9.prev = _context9.next) {
1285
+ case 0:
1286
+ options = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : {};
1287
+ resolvedPathsMap = new Map(); // Separate imports into categories for processing
1288
+ jsModulesToResolve = [];
1289
+ jsModulesWithExtensions = [];
1290
+ staticAssets = [];
1291
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
1292
+ var _Object$entries$_i, importPath, _Object$entries$_i$, path, includeTypeDefs;
1293
+ return _regeneratorRuntime().wrap(function _loop$(_context7) {
1294
+ while (1) switch (_context7.prev = _context7.next) {
1295
+ case 0:
1296
+ _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), importPath = _Object$entries$_i[0], _Object$entries$_i$ = _Object$entries$_i[1], path = _Object$entries$_i$.path, includeTypeDefs = _Object$entries$_i$.includeTypeDefs;
1297
+ if (isJavaScriptModule(importPath)) {
1298
+ // If the import path already has a JS/TS extension, use it as-is
1299
+ if (JAVASCRIPT_MODULE_EXTENSIONS.some(function (ext) {
1300
+ return importPath.endsWith(ext);
1301
+ })) {
1302
+ jsModulesWithExtensions.push(path);
1303
+ } else {
1304
+ jsModulesToResolve.push({
1305
+ path: path,
1306
+ includeTypeDefs: includeTypeDefs
1307
+ });
1308
+ }
1309
+ } else {
1310
+ // Static asset - use path as-is
1311
+ staticAssets.push(path);
1312
+ }
1313
+ case 2:
1314
+ case "end":
1315
+ return _context7.stop();
1316
+ }
1317
+ }, _loop);
1318
+ });
1319
+ _i = 0, _Object$entries = Object.entries(importResult);
1320
+ case 7:
1321
+ if (!(_i < _Object$entries.length)) {
1322
+ _context9.next = 12;
1323
+ break;
1324
+ }
1325
+ return _context9.delegateYield(_loop(), "t0", 9);
1326
+ case 9:
1327
+ _i++;
1328
+ _context9.next = 7;
1329
+ break;
1330
+ case 12:
1331
+ // Add modules with extensions as-is
1332
+ jsModulesWithExtensions.forEach(function (path) {
1333
+ resolvedPathsMap.set(path, path);
1334
+ });
1335
+
1336
+ // Add static assets as-is
1337
+ staticAssets.forEach(function (path) {
1338
+ resolvedPathsMap.set(path, path);
1339
+ });
1340
+
1341
+ // Resolve JS modules without extensions
1342
+ if (!(jsModulesToResolve.length > 0)) {
1343
+ _context9.next = 20;
1344
+ break;
1345
+ }
1346
+ resolutionPromises = jsModulesToResolve.map(/*#__PURE__*/function () {
1347
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref6) {
1348
+ var path, includeTypeDefs, resolved;
1349
+ return _regeneratorRuntime().wrap(function _callee7$(_context8) {
1350
+ while (1) switch (_context8.prev = _context8.next) {
1351
+ case 0:
1352
+ path = _ref6.path, includeTypeDefs = _ref6.includeTypeDefs;
1353
+ _context8.prev = 1;
1354
+ _context8.next = 4;
1355
+ return resolveModulePath(path, readDirectory, options, includeTypeDefs);
1356
+ case 4:
1357
+ resolved = _context8.sent;
1358
+ if (!(typeof resolved === 'string')) {
1359
+ _context8.next = 7;
1360
+ break;
1361
+ }
1362
+ return _context8.abrupt("return", {
1363
+ path: path,
1364
+ resolved: resolved
1365
+ });
1366
+ case 7:
1367
+ return _context8.abrupt("return", {
1368
+ path: path,
1369
+ resolved: resolved["import"]
1370
+ });
1371
+ case 10:
1372
+ _context8.prev = 10;
1373
+ _context8.t0 = _context8["catch"](1);
1374
+ return _context8.abrupt("return", null);
1375
+ case 13:
1376
+ case "end":
1377
+ return _context8.stop();
1378
+ }
1379
+ }, _callee7, null, [[1, 10]]);
1380
+ }));
1381
+ return function (_x16) {
1382
+ return _ref7.apply(this, arguments);
1383
+ };
1384
+ }());
1385
+ _context9.next = 18;
1386
+ return Promise.all(resolutionPromises);
1387
+ case 18:
1388
+ resolutionResults = _context9.sent;
1389
+ // Add successful resolutions to the map
1390
+ resolutionResults.forEach(function (result) {
1391
+ if (result) {
1392
+ resolvedPathsMap.set(result.path, result.resolved);
1393
+ }
1394
+ });
1395
+ case 20:
1396
+ return _context9.abrupt("return", resolvedPathsMap);
1397
+ case 21:
1398
+ case "end":
1399
+ return _context9.stop();
1400
+ }
1401
+ }, _callee8);
1402
+ }));
1403
+ return _resolveImportResult.apply(this, arguments);
1404
+ }
1405
+ export function resolveVariantPaths(_x12, _x13) {
1406
+ return _resolveVariantPaths.apply(this, arguments);
1407
+ }
1408
+ function _resolveVariantPaths() {
1409
+ _resolveVariantPaths = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(variants, readDirectory) {
1410
+ var options,
1411
+ variantPaths,
1412
+ resolvedVariantPaths,
1413
+ variantMap,
1414
+ _i2,
1415
+ _Object$entries2,
1416
+ _Object$entries2$_i,
1417
+ variantName,
1418
+ variantPath,
1419
+ resolvedVariantPath,
1420
+ _args0 = arguments;
1421
+ return _regeneratorRuntime().wrap(function _callee9$(_context0) {
1422
+ while (1) switch (_context0.prev = _context0.next) {
1423
+ case 0:
1424
+ options = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : {};
1425
+ // Extract the variant paths and resolve them
1426
+ variantPaths = Object.values(variants);
1427
+ _context0.next = 4;
1428
+ return resolveModulePaths(variantPaths, readDirectory, options);
1429
+ case 4:
1430
+ resolvedVariantPaths = _context0.sent;
1431
+ // Build a map from variant name to resolved file URL
1432
+ variantMap = new Map();
1433
+ for (_i2 = 0, _Object$entries2 = Object.entries(variants); _i2 < _Object$entries2.length; _i2++) {
1434
+ _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2), variantName = _Object$entries2$_i[0], variantPath = _Object$entries2$_i[1];
1435
+ resolvedVariantPath = resolvedVariantPaths.get(variantPath);
1436
+ if (resolvedVariantPath) {
1437
+ // Store as a file URL
1438
+ variantMap.set(variantName, "file://".concat(resolvedVariantPath));
1439
+ }
1440
+ }
1441
+ return _context0.abrupt("return", variantMap);
1442
+ case 8:
1443
+ case "end":
1444
+ return _context0.stop();
1445
+ }
1446
+ }, _callee9);
1447
+ }));
1448
+ return _resolveVariantPaths.apply(this, arguments);
1449
+ }