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

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 (288) 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/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +228 -0
  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/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.d.ts +1 -0
  110. package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
  111. package/pipeline/loaderUtils/getFileNameFromUrl.js +66 -0
  112. package/pipeline/loaderUtils/index.d.ts +7 -0
  113. package/pipeline/loaderUtils/index.d.ts.map +1 -0
  114. package/pipeline/loaderUtils/index.js +7 -0
  115. package/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
  116. package/pipeline/loaderUtils/mergeExternals.d.ts.map +1 -0
  117. package/pipeline/loaderUtils/mergeExternals.js +72 -0
  118. package/pipeline/loaderUtils/parseImports.d.ts +20 -0
  119. package/pipeline/loaderUtils/parseImports.d.ts.map +1 -0
  120. package/pipeline/loaderUtils/parseImports.js +307 -0
  121. package/{loaderUtils/processImports.d.ts → pipeline/loaderUtils/processRelativeImports.d.ts} +2 -2
  122. package/pipeline/loaderUtils/processRelativeImports.d.ts.map +1 -0
  123. package/pipeline/loaderUtils/processRelativeImports.js +352 -0
  124. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePath.d.ts +19 -6
  125. package/pipeline/loaderUtils/resolveModulePath.d.ts.map +1 -0
  126. package/pipeline/loaderUtils/resolveModulePath.js +1449 -0
  127. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.d.ts +6 -3
  128. package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
  129. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.js +8 -4
  130. package/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
  131. package/pipeline/loaderUtils/rewriteImports.d.ts.map +1 -0
  132. package/pipeline/loaderUtils/rewriteImports.js +35 -0
  133. package/pipeline/parseSource/grammars.d.ts.map +1 -0
  134. package/pipeline/parseSource/index.d.ts.map +1 -0
  135. package/pipeline/parseSource/parseSource.d.ts +3 -0
  136. package/pipeline/parseSource/parseSource.d.ts.map +1 -0
  137. package/{parseSource → pipeline/parseSource}/parseSource.js +15 -5
  138. package/pipeline/transformHtmlCode/index.d.ts +2 -0
  139. package/pipeline/transformHtmlCode/index.d.ts.map +1 -0
  140. package/pipeline/transformHtmlCode/index.js +4 -0
  141. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
  142. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +1 -0
  143. package/pipeline/transformHtmlCode/transformHtmlCode.js +303 -0
  144. package/pipeline/transformMarkdownCode/index.d.ts +2 -0
  145. package/pipeline/transformMarkdownCode/index.d.ts.map +1 -0
  146. package/pipeline/transformMarkdownCode/index.js +4 -0
  147. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
  148. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +1 -0
  149. package/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
  150. package/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
  151. package/pipeline/transformTypescriptToJavascript/index.d.ts.map +1 -0
  152. package/pipeline/transformTypescriptToJavascript/index.js +1 -0
  153. package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +1 -0
  154. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
  155. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +1 -0
  156. package/{transformTsToJs/transformTsToJs.js → pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js} +4 -4
  157. package/useCode/index.d.ts.map +1 -1
  158. package/useCode/useCode.d.ts +14 -11
  159. package/useCode/useCode.d.ts.map +1 -1
  160. package/useCode/useCode.js +94 -364
  161. package/useCode/useCodeUtils.d.ts +45 -0
  162. package/useCode/useCodeUtils.d.ts.map +1 -0
  163. package/useCode/useCodeUtils.js +240 -0
  164. package/useCode/useCopyFunctionality.d.ts +17 -0
  165. package/useCode/useCopyFunctionality.d.ts.map +1 -0
  166. package/useCode/useCopyFunctionality.js +28 -0
  167. package/useCode/useFileNavigation.d.ts +49 -0
  168. package/useCode/useFileNavigation.d.ts.map +1 -0
  169. package/useCode/useFileNavigation.js +398 -0
  170. package/useCode/useSourceEditing.d.ts +19 -0
  171. package/useCode/useSourceEditing.d.ts.map +1 -0
  172. package/useCode/useSourceEditing.js +32 -0
  173. package/useCode/useTransformManagement.d.ts +28 -0
  174. package/useCode/useTransformManagement.d.ts.map +1 -0
  175. package/useCode/useTransformManagement.js +82 -0
  176. package/useCode/useUIState.d.ts +16 -0
  177. package/useCode/useUIState.d.ts.map +1 -0
  178. package/useCode/useUIState.js +21 -0
  179. package/useCode/useVariantSelection.d.ts +21 -0
  180. package/useCode/useVariantSelection.d.ts.map +1 -0
  181. package/useCode/useVariantSelection.js +84 -0
  182. package/useCopier/index.d.ts +1 -1
  183. package/useCopier/index.d.ts.map +1 -1
  184. package/useCopier/index.js +5 -5
  185. package/useDemo/createCodeSandbox.d.ts +18 -0
  186. package/useDemo/createCodeSandbox.d.ts.map +1 -0
  187. package/useDemo/createCodeSandbox.js +48 -0
  188. package/useDemo/createStackBlitz.d.ts +22 -0
  189. package/useDemo/createStackBlitz.d.ts.map +1 -0
  190. package/useDemo/createStackBlitz.js +38 -0
  191. package/useDemo/examineVariant.d.ts +25 -0
  192. package/useDemo/examineVariant.d.ts.map +1 -0
  193. package/useDemo/examineVariant.js +134 -0
  194. package/useDemo/exportVariant.d.ts +110 -0
  195. package/useDemo/exportVariant.d.ts.map +1 -0
  196. package/useDemo/exportVariant.js +320 -0
  197. package/useDemo/exportVariantAsCra.d.ts +15 -0
  198. package/useDemo/exportVariantAsCra.d.ts.map +1 -0
  199. package/useDemo/exportVariantAsCra.js +56 -0
  200. package/useDemo/flattenVariant.d.ts +17 -0
  201. package/useDemo/flattenVariant.d.ts.map +1 -0
  202. package/useDemo/flattenVariant.js +206 -0
  203. package/useDemo/index.d.ts +6 -39
  204. package/useDemo/index.d.ts.map +1 -1
  205. package/useDemo/index.js +6 -17
  206. package/useDemo/useDemo.d.ts +79 -0
  207. package/useDemo/useDemo.d.ts.map +1 -0
  208. package/useDemo/useDemo.js +174 -0
  209. package/useLocalStorageState/index.d.ts +2 -0
  210. package/useLocalStorageState/index.d.ts.map +1 -0
  211. package/useLocalStorageState/index.js +2 -0
  212. package/useLocalStorageState/useLocalStorageState.d.ts +14 -0
  213. package/useLocalStorageState/useLocalStorageState.d.ts.map +1 -0
  214. package/useLocalStorageState/useLocalStorageState.js +128 -0
  215. package/useOnHydrate/index.d.ts.map +1 -1
  216. package/useOnHydrate/useOnHydrate.d.ts.map +1 -1
  217. package/useOnIdle/index.d.ts.map +1 -1
  218. package/useOnIdle/useOnIdle.d.ts.map +1 -1
  219. package/useUrlHashState/index.d.ts +1 -0
  220. package/useUrlHashState/index.d.ts.map +1 -0
  221. package/useUrlHashState/index.js +1 -0
  222. package/useUrlHashState/useUrlHashState.d.ts +50 -0
  223. package/useUrlHashState/useUrlHashState.d.ts.map +1 -0
  224. package/useUrlHashState/useUrlHashState.js +113 -0
  225. package/hast/hast.d.ts.map +0 -1
  226. package/hast/index.d.ts +0 -1
  227. package/hast/index.d.ts.map +0 -1
  228. package/hast/index.js +0 -1
  229. package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
  230. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
  231. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
  232. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -194
  233. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
  234. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
  235. package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
  236. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
  237. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
  238. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
  239. package/loadServerCodeMeta/index.d.ts +0 -1
  240. package/loadServerCodeMeta/index.d.ts.map +0 -1
  241. package/loadServerCodeMeta/index.js +0 -1
  242. package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
  243. package/loadServerSource/index.d.ts +0 -1
  244. package/loadServerSource/index.d.ts.map +0 -1
  245. package/loadServerSource/index.js +0 -1
  246. package/loadServerSource/serverLoadSource.d.ts.map +0 -1
  247. package/loadServerSource/serverLoadSource.js +0 -100
  248. package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
  249. package/loaderUtils/getFileNameFromUrl.js +0 -32
  250. package/loaderUtils/index.d.ts +0 -5
  251. package/loaderUtils/index.d.ts.map +0 -1
  252. package/loaderUtils/index.js +0 -5
  253. package/loaderUtils/processImports.d.ts.map +0 -1
  254. package/loaderUtils/processImports.js +0 -82
  255. package/loaderUtils/resolveImports.d.ts +0 -4
  256. package/loaderUtils/resolveImports.d.ts.map +0 -1
  257. package/loaderUtils/resolveImports.js +0 -71
  258. package/loaderUtils/resolveModulePath.d.ts.map +0 -1
  259. package/loaderUtils/resolveModulePath.js +0 -862
  260. package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
  261. package/loaderUtils/rewriteImports.d.ts +0 -9
  262. package/loaderUtils/rewriteImports.d.ts.map +0 -1
  263. package/loaderUtils/rewriteImports.js +0 -57
  264. package/parseSource/grammars.d.ts.map +0 -1
  265. package/parseSource/index.d.ts.map +0 -1
  266. package/parseSource/parseSource.d.ts +0 -3
  267. package/parseSource/parseSource.d.ts.map +0 -1
  268. package/transformRelativeMarkdownPaths/index.d.ts +0 -2
  269. package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
  270. package/transformRelativeMarkdownPaths/index.js +0 -4
  271. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
  272. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
  273. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
  274. package/transformTsToJs/index.d.ts +0 -1
  275. package/transformTsToJs/index.d.ts.map +0 -1
  276. package/transformTsToJs/index.js +0 -1
  277. package/transformTsToJs/removeTypes.d.ts.map +0 -1
  278. package/transformTsToJs/transformTsToJs.d.ts +0 -3
  279. package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
  280. /package/{hast/hast.d.ts → pipeline/hastUtils/hastUtils.d.ts} +0 -0
  281. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.d.ts +0 -0
  282. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.js +0 -0
  283. /package/{parseSource → pipeline/parseSource}/grammars.d.ts +0 -0
  284. /package/{parseSource → pipeline/parseSource}/grammars.js +0 -0
  285. /package/{parseSource → pipeline/parseSource}/index.d.ts +0 -0
  286. /package/{parseSource → pipeline/parseSource}/index.js +0 -0
  287. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.d.ts +0 -0
  288. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.js +0 -0
@@ -0,0 +1,307 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
+ import path from 'path';
6
+ export function parseImports(_x, _x2) {
7
+ return _parseImports.apply(this, arguments);
8
+ }
9
+ function _parseImports() {
10
+ _parseImports = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(code, _filePath) {
11
+ var result, externals, importRegex, sideEffectImportRegex, match, _loop, _ret, sideEffectMatch, _sideEffectMatch, _sideEffectMatch2, modulePathRaw, modulePath, isRelative, resolvedPath;
12
+ return _regeneratorRuntime().wrap(function _callee$(_context2) {
13
+ while (1) switch (_context2.prev = _context2.next) {
14
+ case 0:
15
+ result = {};
16
+ externals = {}; // Regex to extract regular import statements with 'from' clause
17
+ importRegex = /import(?:\s+type)?\s*([^'"]*)\s*from\s*['"]([^'"]+)['"][;]?/g; // Regex to extract side-effect imports (without 'from' clause)
18
+ sideEffectImportRegex = /import\s*['"]([^'"]+)['"][;]?/g;
19
+ // eslint-disable-next-line no-cond-assign
20
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
21
+ var _match, _match2, fullMatch, importSpecifierRaw, modulePathRaw, includeTypeDefs, importSpecifier, modulePath, isRelative, _resolvedPath, _resolvedPath2, defaultImportMatch, namespaceImportMatch, namedImportsMatch, defaultImport, namespaceImport, namedImportsStr, existing, _existing, cleanedImportsStr, namedImports, _defaultImportMatch, _namespaceImportMatch, _namedImportsMatch, _defaultImport, _namespaceImport, _namedImportsStr, _existing3, _existing4, _cleanedImportsStr, _namedImports;
22
+ return _regeneratorRuntime().wrap(function _loop$(_context) {
23
+ while (1) switch (_context.prev = _context.next) {
24
+ case 0:
25
+ _match = match, _match2 = _slicedToArray(_match, 3), fullMatch = _match2[0], importSpecifierRaw = _match2[1], modulePathRaw = _match2[2]; // Determine if this is a type import by checking if the full match contains "import type"
26
+ includeTypeDefs = fullMatch.includes('import type');
27
+ importSpecifier = importSpecifierRaw == null ? void 0 : importSpecifierRaw.trim();
28
+ modulePath = modulePathRaw == null ? void 0 : modulePathRaw.trim();
29
+ if (modulePath) {
30
+ _context.next = 6;
31
+ break;
32
+ }
33
+ return _context.abrupt("return", 0);
34
+ case 6:
35
+ // Check if this is a relative import
36
+ isRelative = modulePath.startsWith('./') || modulePath.startsWith('../'); // Handle side-effect imports (no import specifier)
37
+ if (importSpecifier) {
38
+ _context.next = 10;
39
+ break;
40
+ }
41
+ if (isRelative) {
42
+ // Resolve the relative import to an absolute path
43
+ _resolvedPath = path.resolve(path.dirname(_filePath), modulePath);
44
+ if (!result[modulePath]) {
45
+ result[modulePath] = {
46
+ path: _resolvedPath,
47
+ names: [] // Empty names array for side-effect imports
48
+ };
49
+ }
50
+ } else if (!externals[modulePath]) {
51
+ // External side-effect import
52
+ externals[modulePath] = {
53
+ names: []
54
+ };
55
+ }
56
+ return _context.abrupt("return", 0);
57
+ case 10:
58
+ if (isRelative) {
59
+ // Resolve the relative import to an absolute path
60
+ _resolvedPath2 = path.resolve(path.dirname(_filePath), modulePath);
61
+ if (!result[modulePath]) {
62
+ result[modulePath] = _objectSpread({
63
+ path: _resolvedPath2,
64
+ names: []
65
+ }, includeTypeDefs && {
66
+ includeTypeDefs: true
67
+ });
68
+ } else if (includeTypeDefs && !result[modulePath].includeTypeDefs) {
69
+ result[modulePath].includeTypeDefs = true;
70
+ }
71
+
72
+ // Parse the import specifier to determine the type of import
73
+ defaultImportMatch = importSpecifier.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:,|$)/);
74
+ namespaceImportMatch = importSpecifier.match(/\*\s+as\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/);
75
+ namedImportsMatch = importSpecifier.match(/\{([^}]+)\}/);
76
+ defaultImport = defaultImportMatch == null ? void 0 : defaultImportMatch[1];
77
+ namespaceImport = namespaceImportMatch == null ? void 0 : namespaceImportMatch[1];
78
+ namedImportsStr = namedImportsMatch == null ? void 0 : namedImportsMatch[1];
79
+ if (defaultImport) {
80
+ // Check if we already have this default import
81
+ existing = result[modulePath].names.find(function (n) {
82
+ return n.name === defaultImport && n.type === 'default';
83
+ });
84
+ if (!existing) {
85
+ result[modulePath].names.push(_objectSpread({
86
+ name: defaultImport,
87
+ type: 'default'
88
+ }, includeTypeDefs && {
89
+ isType: true
90
+ }));
91
+ }
92
+ }
93
+ if (namespaceImport) {
94
+ // Check if we already have this namespace import
95
+ _existing = result[modulePath].names.find(function (n) {
96
+ return n.name === namespaceImport && n.type === 'namespace';
97
+ });
98
+ if (!_existing) {
99
+ result[modulePath].names.push(_objectSpread({
100
+ name: namespaceImport,
101
+ type: 'namespace'
102
+ }, includeTypeDefs && {
103
+ isType: true
104
+ }));
105
+ }
106
+ }
107
+ if (namedImportsStr) {
108
+ // Handle named imports like { ComponentName, Component2 as Alias, type TypeName }
109
+ // Clean up the string by removing comments and extra whitespace
110
+ cleanedImportsStr = namedImportsStr.replace(/\/\*[\s\S]*?\*\//g, '') // Remove /* comment */ blocks
111
+ .replace(/\/\/.*$/gm, '') // Remove // line comments
112
+ .trim();
113
+ if (cleanedImportsStr) {
114
+ namedImports = cleanedImportsStr.split(',').map(function (s) {
115
+ return s.trim();
116
+ }).filter(function (s) {
117
+ return s.length > 0;
118
+ });
119
+ namedImports.forEach(function (namedImport) {
120
+ // Check if this specific import is a type import
121
+ var isTypeImport = namedImport.trim().startsWith('type ');
122
+
123
+ // Clean up the import name (remove 'type' keyword and handle aliases)
124
+ var cleanImport = namedImport.replace(/^type\s+/, ''); // Remove leading 'type'
125
+
126
+ // Parse original name and alias
127
+ var aliasMatch = cleanImport.match(/(.+?)\s+as\s+(.+)/);
128
+ var originalName = aliasMatch ? aliasMatch[1].trim() : cleanImport.trim();
129
+ var alias = aliasMatch ? aliasMatch[2].trim() : undefined;
130
+
131
+ // Only add if we have a valid name
132
+ if (originalName && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(originalName)) {
133
+ // Check if we already have this named import
134
+ var _existing2 = result[modulePath].names.find(function (n) {
135
+ return n.name === originalName && n.type === 'named' && n.alias === alias;
136
+ });
137
+ if (!_existing2) {
138
+ result[modulePath].names.push(_objectSpread(_objectSpread({
139
+ name: originalName
140
+ }, alias && {
141
+ alias: alias
142
+ }), {}, {
143
+ type: 'named'
144
+ }, (includeTypeDefs || isTypeImport) && {
145
+ isType: true
146
+ }));
147
+ }
148
+ }
149
+ });
150
+ }
151
+ }
152
+ } else {
153
+ // This is an external import
154
+ if (!externals[modulePath]) {
155
+ externals[modulePath] = {
156
+ names: []
157
+ };
158
+ }
159
+
160
+ // Parse the import specifier to determine the type of import
161
+ _defaultImportMatch = importSpecifier.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:,|$)/);
162
+ _namespaceImportMatch = importSpecifier.match(/\*\s+as\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/);
163
+ _namedImportsMatch = importSpecifier.match(/\{([^}]+)\}/);
164
+ _defaultImport = _defaultImportMatch == null ? void 0 : _defaultImportMatch[1];
165
+ _namespaceImport = _namespaceImportMatch == null ? void 0 : _namespaceImportMatch[1];
166
+ _namedImportsStr = _namedImportsMatch == null ? void 0 : _namedImportsMatch[1];
167
+ if (_defaultImport) {
168
+ // Check if we already have this default import
169
+ _existing3 = externals[modulePath].names.find(function (n) {
170
+ return n.name === _defaultImport && n.type === 'default';
171
+ });
172
+ if (!_existing3) {
173
+ externals[modulePath].names.push(_objectSpread({
174
+ name: _defaultImport,
175
+ type: 'default'
176
+ }, includeTypeDefs && {
177
+ isType: true
178
+ }));
179
+ }
180
+ }
181
+ if (_namespaceImport) {
182
+ // Check if we already have this namespace import
183
+ _existing4 = externals[modulePath].names.find(function (n) {
184
+ return n.name === _namespaceImport && n.type === 'namespace';
185
+ });
186
+ if (!_existing4) {
187
+ externals[modulePath].names.push(_objectSpread({
188
+ name: _namespaceImport,
189
+ type: 'namespace'
190
+ }, includeTypeDefs && {
191
+ isType: true
192
+ }));
193
+ }
194
+ }
195
+ if (_namedImportsStr) {
196
+ // Handle named imports like { ComponentName, Component2 as Alias, type TypeName }
197
+ // Clean up the string by removing comments and extra whitespace
198
+ _cleanedImportsStr = _namedImportsStr.replace(/\/\*[\s\S]*?\*\//g, '') // Remove /* comment */ blocks
199
+ .replace(/\/\/.*$/gm, '') // Remove // line comments
200
+ .trim();
201
+ if (_cleanedImportsStr) {
202
+ _namedImports = _cleanedImportsStr.split(',').map(function (s) {
203
+ return s.trim();
204
+ }).filter(function (s) {
205
+ return s.length > 0;
206
+ });
207
+ _namedImports.forEach(function (namedImport) {
208
+ // Check if this specific import is a type import
209
+ var isTypeImport = namedImport.trim().startsWith('type ');
210
+
211
+ // Clean up the import name (remove 'type' keyword and handle aliases)
212
+ var cleanImport = namedImport.replace(/^type\s+/, ''); // Remove leading 'type'
213
+
214
+ // Parse original name and alias - for externals we track both
215
+ var aliasMatch = cleanImport.match(/(.+?)\s+as\s+(.+)/);
216
+ var originalName = aliasMatch ? aliasMatch[1].trim() : cleanImport.trim();
217
+ var alias = aliasMatch ? aliasMatch[2].trim() : undefined;
218
+
219
+ // Only add if we have a valid name
220
+ if (originalName && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(originalName)) {
221
+ // Check if we already have this named import
222
+ var _existing5 = externals[modulePath].names.find(function (n) {
223
+ return n.name === originalName && n.type === 'named' && n.alias === alias;
224
+ });
225
+ if (!_existing5) {
226
+ externals[modulePath].names.push(_objectSpread(_objectSpread({
227
+ name: originalName
228
+ }, alias && {
229
+ alias: alias
230
+ }), {}, {
231
+ type: 'named'
232
+ }, (includeTypeDefs || isTypeImport) && {
233
+ isType: true
234
+ }));
235
+ }
236
+ }
237
+ });
238
+ }
239
+ }
240
+ }
241
+ case 11:
242
+ case "end":
243
+ return _context.stop();
244
+ }
245
+ }, _loop);
246
+ });
247
+ case 5:
248
+ if (!((match = importRegex.exec(code)) !== null)) {
249
+ _context2.next = 12;
250
+ break;
251
+ }
252
+ return _context2.delegateYield(_loop(), "t0", 7);
253
+ case 7:
254
+ _ret = _context2.t0;
255
+ if (!(_ret === 0)) {
256
+ _context2.next = 10;
257
+ break;
258
+ }
259
+ return _context2.abrupt("continue", 5);
260
+ case 10:
261
+ _context2.next = 5;
262
+ break;
263
+ case 12:
264
+ if (!((sideEffectMatch = sideEffectImportRegex.exec(code)) !== null)) {
265
+ _context2.next = 21;
266
+ break;
267
+ }
268
+ _sideEffectMatch = sideEffectMatch, _sideEffectMatch2 = _slicedToArray(_sideEffectMatch, 2), modulePathRaw = _sideEffectMatch2[1];
269
+ modulePath = modulePathRaw == null ? void 0 : modulePathRaw.trim();
270
+ if (modulePath) {
271
+ _context2.next = 17;
272
+ break;
273
+ }
274
+ return _context2.abrupt("continue", 12);
275
+ case 17:
276
+ // Check if this is a relative import
277
+ isRelative = modulePath.startsWith('./') || modulePath.startsWith('../');
278
+ if (isRelative) {
279
+ // Resolve the relative import to an absolute path
280
+ resolvedPath = path.resolve(path.dirname(_filePath), modulePath);
281
+ if (!result[modulePath]) {
282
+ result[modulePath] = {
283
+ path: resolvedPath,
284
+ names: [] // Empty names array for side-effect imports
285
+ };
286
+ }
287
+ } else if (!externals[modulePath]) {
288
+ // External side-effect import
289
+ externals[modulePath] = {
290
+ names: []
291
+ };
292
+ }
293
+ _context2.next = 12;
294
+ break;
295
+ case 21:
296
+ return _context2.abrupt("return", {
297
+ relative: result,
298
+ externals: externals
299
+ });
300
+ case 22:
301
+ case "end":
302
+ return _context2.stop();
303
+ }
304
+ }, _callee);
305
+ }));
306
+ return _parseImports.apply(this, arguments);
307
+ }
@@ -8,12 +8,12 @@ export interface ProcessImportsResult {
8
8
  * source rewriting when needed (e.g., for 'flat' mode).
9
9
  *
10
10
  * @param source - The original source code
11
- * @param importResult - The result from resolveImports
11
+ * @param importResult - The result from parseImports
12
12
  * @param resolvedPathsMap - Map from import paths to resolved file paths
13
13
  * @param storeAt - How to process the imports
14
14
  * @returns Object with processed source and extraFiles mapping
15
15
  */
16
- export declare function processImportsWithStoreAt(source: string, importResult: Record<string, {
16
+ export declare function processRelativeImports(source: string, importResult: Record<string, {
17
17
  path: string;
18
18
  names: string[];
19
19
  }>, resolvedPathsMap: Map<string, string>, storeAt: StoreAtMode): ProcessImportsResult;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processRelativeImports.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loaderUtils/processRelativeImports.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,EAC/D,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,OAAO,EAAE,WAAW,GACnB,oBAAoB,CAmGtB"}
@@ -0,0 +1,352 @@
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import { rewriteImportsToSameDirectory } from "./rewriteImports.js";
5
+ import { isJavaScriptModule } from "./resolveModulePath.js";
6
+ import { getFileNameFromUrl } from "./getFileNameFromUrl.js";
7
+ /**
8
+ * Processes imports based on the specified storage mode, automatically handling
9
+ * source rewriting when needed (e.g., for 'flat' mode).
10
+ *
11
+ * @param source - The original source code
12
+ * @param importResult - The result from parseImports
13
+ * @param resolvedPathsMap - Map from import paths to resolved file paths
14
+ * @param storeAt - How to process the imports
15
+ * @returns Object with processed source and extraFiles mapping
16
+ */
17
+ export function processRelativeImports(source, importResult, resolvedPathsMap, storeAt) {
18
+ var extraFiles = {};
19
+
20
+ // For flat mode, we need to handle naming conflicts intelligently
21
+ if (storeAt === 'flat') {
22
+ var result = processFlatMode(importResult, resolvedPathsMap);
23
+
24
+ // Create import path mapping for rewriting
25
+ var importPathMapping = new Map();
26
+
27
+ // Build a reverse mapping from resolved paths to extraFiles keys
28
+ var resolvedToExtraFile = new Map();
29
+ Object.entries(result.extraFiles).forEach(function (_ref) {
30
+ var _ref2 = _slicedToArray(_ref, 2),
31
+ extraFileKey = _ref2[0],
32
+ fileUrl = _ref2[1];
33
+ var resolvedPath = fileUrl.replace('file://', '');
34
+ resolvedToExtraFile.set(resolvedPath, extraFileKey);
35
+ });
36
+
37
+ // For each import, find its resolved path and map to the corresponding extraFile key
38
+ Object.entries(importResult).forEach(function (_ref3) {
39
+ var _ref4 = _slicedToArray(_ref3, 2),
40
+ relativePath = _ref4[0],
41
+ importInfo = _ref4[1];
42
+ var resolvedPath = resolvedPathsMap.get(importInfo.path);
43
+ if (resolvedPath) {
44
+ var extraFileKey = resolvedToExtraFile.get(resolvedPath);
45
+ if (extraFileKey) {
46
+ // For JavaScript modules, remove the extension; for other files (CSS, JSON, etc.), keep it
47
+ var isJavascriptModule = isJavaScriptModule(relativePath);
48
+ var newPath = extraFileKey;
49
+ if (isJavascriptModule) {
50
+ // Handle TypeScript declaration files (.d.ts) properly
51
+ if (newPath.endsWith('.d.ts')) {
52
+ newPath = newPath.replace(/\.d\.ts$/, '');
53
+ } else {
54
+ newPath = newPath.replace(/\.[^/.]+$/, '');
55
+ }
56
+ }
57
+ // For non-JS modules (CSS, JSON, etc.), keep the full path with extension
58
+
59
+ importPathMapping.set(relativePath, newPath);
60
+ }
61
+ }
62
+ });
63
+
64
+ // Rewrite the source with the mapping
65
+ var rewrittenSource = rewriteImportsToSameDirectory(source, importPathMapping);
66
+ return {
67
+ processedSource: rewrittenSource,
68
+ extraFiles: result.extraFiles
69
+ };
70
+ }
71
+
72
+ // Process each import and generate extraFiles for non-flat modes
73
+ Object.entries(importResult).forEach(function (_ref5) {
74
+ var _ref6 = _slicedToArray(_ref5, 2),
75
+ relativePath = _ref6[0],
76
+ importInfo = _ref6[1];
77
+ var resolvedPath = resolvedPathsMap.get(importInfo.path);
78
+ if (resolvedPath) {
79
+ var fileExtension = getFileNameFromUrl(resolvedPath).extension;
80
+ var isJavascriptModule = isJavaScriptModule(relativePath);
81
+ var keyPath;
82
+ if (!isJavascriptModule) {
83
+ // For static assets (CSS, JSON, etc.), use the original import path as-is since it already has the extension
84
+ switch (storeAt) {
85
+ case 'canonical':
86
+ case 'import':
87
+ keyPath = relativePath;
88
+ break;
89
+ default:
90
+ keyPath = relativePath;
91
+ }
92
+ } else {
93
+ // For JS/TS modules, apply the existing logic
94
+ switch (storeAt) {
95
+ case 'canonical':
96
+ // Show the full resolved path including index files when they exist
97
+ // e.g., import '../Component' resolved to '/src/Component/index.js'
98
+ // becomes extraFiles: { '../Component/index.js': 'file:///src/Component/index.js' }
99
+ keyPath = "".concat(relativePath).concat(resolvedPath.endsWith("/index".concat(fileExtension)) ? "/index".concat(fileExtension) : fileExtension);
100
+ break;
101
+ case 'import':
102
+ // Use the original import path with the actual file extension
103
+ // e.g., import '../Component' with '/src/Component/index.js'
104
+ // becomes extraFiles: { '../Component.js': 'file:///src/Component/index.js' }
105
+ keyPath = "".concat(relativePath).concat(fileExtension);
106
+ break;
107
+ default:
108
+ keyPath = "".concat(relativePath).concat(fileExtension);
109
+ }
110
+ }
111
+ extraFiles[keyPath] = "file://".concat(resolvedPath);
112
+ }
113
+ });
114
+ return {
115
+ processedSource: source,
116
+ extraFiles: extraFiles
117
+ };
118
+ }
119
+
120
+ /**
121
+ * Processes flat mode with intelligent conflict resolution
122
+ */
123
+ function processFlatMode(importResult, resolvedPathsMap) {
124
+ var extraFiles = {};
125
+ var fileMapping = [];
126
+
127
+ // First pass: collect all files and their path segments
128
+ Object.entries(importResult).forEach(function (_ref7) {
129
+ var _ref8 = _slicedToArray(_ref7, 2),
130
+ relativePath = _ref8[0],
131
+ importInfo = _ref8[1];
132
+ var resolvedPath = resolvedPathsMap.get(importInfo.path);
133
+ if (resolvedPath) {
134
+ var fileExtension = getFileNameFromUrl(resolvedPath).extension;
135
+ var pathSegments = resolvedPath.split('/').filter(Boolean);
136
+ fileMapping.push({
137
+ resolvedPath: resolvedPath,
138
+ extension: fileExtension,
139
+ segments: pathSegments,
140
+ originalImportPath: relativePath
141
+ });
142
+ }
143
+ });
144
+
145
+ // Second pass: determine candidate names and group by conflicts
146
+ var candidateNames = new Map();
147
+ var nameGroups = new Map();
148
+ for (var _i = 0, _fileMapping = fileMapping; _i < _fileMapping.length; _i++) {
149
+ var file = _fileMapping[_i];
150
+ var fileName = file.segments[file.segments.length - 1];
151
+ var isIndexFile = fileName.startsWith('index.');
152
+ var candidateName = void 0;
153
+ if (isIndexFile) {
154
+ // Check if the original import was a direct index file (e.g., "./index.ext")
155
+ var originalImportParts = file.originalImportPath.split('/');
156
+ var isDirectIndexImport = originalImportParts.length === 2 && originalImportParts[0] === '.' && originalImportParts[1].startsWith('index.');
157
+ if (isDirectIndexImport) {
158
+ // For direct index imports like "./index.ext", keep the original name
159
+ candidateName = "index".concat(file.extension);
160
+ } else {
161
+ // For nested index files like "./test/index.ext", use parent directory + extension
162
+ var parentDir = file.segments[file.segments.length - 2];
163
+ candidateName = "".concat(parentDir).concat(file.extension);
164
+ }
165
+ } else {
166
+ candidateName = fileName;
167
+ }
168
+ candidateNames.set(file.resolvedPath, candidateName);
169
+ if (!nameGroups.has(candidateName)) {
170
+ nameGroups.set(candidateName, []);
171
+ }
172
+ nameGroups.get(candidateName).push(file.resolvedPath);
173
+ }
174
+
175
+ // Third pass: resolve conflicts for all files in conflicting groups
176
+ var finalNames = new Map();
177
+ nameGroups.forEach(function (paths, candidateName) {
178
+ if (paths.length === 1) {
179
+ // No conflict, use the candidate name
180
+ finalNames.set(paths[0], candidateName);
181
+ } else {
182
+ // Conflict detected, find optimal minimal distinguishing paths for all files
183
+ var conflictingFiles = paths.map(function (resolvedPath) {
184
+ return fileMapping.find(function (f) {
185
+ return f.resolvedPath === resolvedPath;
186
+ });
187
+ });
188
+
189
+ // Check if we can resolve conflicts by treating some files differently
190
+ // This specifically handles cases like:
191
+ // - /path/to/a/Component.js and /path/to/Component.js (parent-child relationship)
192
+
193
+ // Find files that are "shorter" (parent level) compared to others
194
+ var minLength = Math.min.apply(Math, _toConsumableArray(conflictingFiles.map(function (f) {
195
+ return f.segments.length;
196
+ })));
197
+ var maxLengthForSmart = Math.max.apply(Math, _toConsumableArray(conflictingFiles.map(function (f) {
198
+ return f.segments.length;
199
+ })));
200
+ if (maxLengthForSmart > minLength) {
201
+ // We have files at different depths, check if it's a parent-child scenario
202
+ var shorterFiles = conflictingFiles.filter(function (file) {
203
+ return file.segments.length === minLength;
204
+ });
205
+ var longerFiles = conflictingFiles.filter(function (file) {
206
+ return file.segments.length > minLength;
207
+ });
208
+ if (shorterFiles.length === 1 && longerFiles.length >= 1) {
209
+ // Check if the shorter file is truly a "parent" of the longer files
210
+ var shorterFile = shorterFiles[0];
211
+ var shorterPath = shorterFile.segments.slice(0, -1).join('/'); // Remove filename
212
+
213
+ // Check if all longer files share the same prefix as the shorter file
214
+ var allLongerFilesAreChildren = longerFiles.every(function (longerFile) {
215
+ var longerPath = longerFile.segments.slice(0, shorterFile.segments.length - 1).join('/');
216
+ return longerPath === shorterPath;
217
+ });
218
+ if (allLongerFilesAreChildren) {
219
+ // This is a true parent-child scenario, apply smart resolution
220
+
221
+ // For longer files, find distinguishing index
222
+ var _distinguishingIndex = -1;
223
+ var maxLongerLength = Math.max.apply(Math, _toConsumableArray(longerFiles.map(function (f) {
224
+ return f.segments.length;
225
+ })));
226
+ var _loop = function _loop(i) {
227
+ var segmentsAtIndex = new Set(longerFiles.map(function (f) {
228
+ return f.segments[i];
229
+ }).filter(Boolean));
230
+ if (segmentsAtIndex.size === longerFiles.length) {
231
+ _distinguishingIndex = i;
232
+ return 1; // break
233
+ }
234
+ };
235
+ for (var i = 0; i < maxLongerLength; i += 1) {
236
+ if (_loop(i)) break;
237
+ }
238
+ if (_distinguishingIndex !== -1) {
239
+ // Generate names for longer files using distinguishing segment
240
+ var _iterator = _createForOfIteratorHelper(longerFiles),
241
+ _step;
242
+ try {
243
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
244
+ var _file = _step.value;
245
+ var _fileName = _file.segments[_file.segments.length - 1];
246
+ var _isIndexFile = _fileName.startsWith('index.');
247
+ var distinguishingSegment = _file.segments[_distinguishingIndex];
248
+ var finalName = void 0;
249
+ if (_isIndexFile) {
250
+ // Check if this was a direct index import
251
+ var _originalImportParts = _file.originalImportPath.split('/');
252
+ var _isDirectIndexImport = _originalImportParts.length === 2 && _originalImportParts[0] === '.' && _originalImportParts[1].startsWith('index.');
253
+ if (_isDirectIndexImport) {
254
+ finalName = "".concat(distinguishingSegment, "/index").concat(_file.extension);
255
+ } else {
256
+ var _parentDir = _file.segments[_file.segments.length - 2];
257
+ finalName = "".concat(distinguishingSegment, "/").concat(_parentDir).concat(_file.extension);
258
+ }
259
+ } else {
260
+ finalName = "".concat(distinguishingSegment, "/").concat(_fileName);
261
+ }
262
+ finalNames.set(_file.resolvedPath, finalName);
263
+ }
264
+
265
+ // For shorter files, use the candidate name as-is (no conflicts after disambiguation)
266
+ } catch (err) {
267
+ _iterator.e(err);
268
+ } finally {
269
+ _iterator.f();
270
+ }
271
+ var _iterator2 = _createForOfIteratorHelper(shorterFiles),
272
+ _step2;
273
+ try {
274
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
275
+ var shortFile = _step2.value;
276
+ finalNames.set(shortFile.resolvedPath, candidateName);
277
+ }
278
+ } catch (err) {
279
+ _iterator2.e(err);
280
+ } finally {
281
+ _iterator2.f();
282
+ }
283
+ return; // Successfully resolved
284
+ }
285
+ }
286
+ }
287
+ }
288
+
289
+ // Fallback to original algorithm if smart resolution fails
290
+ var distinguishingIndex = -1;
291
+ var maxLength = Math.max.apply(Math, _toConsumableArray(conflictingFiles.map(function (f) {
292
+ return f.segments.length;
293
+ })));
294
+ var _loop2 = function _loop2(_i2) {
295
+ var segmentsAtIndex = new Set(conflictingFiles.map(function (f) {
296
+ return f.segments[_i2];
297
+ }).filter(Boolean));
298
+ if (segmentsAtIndex.size === conflictingFiles.length) {
299
+ distinguishingIndex = _i2;
300
+ return 1; // break
301
+ }
302
+ };
303
+ for (var _i2 = 0; _i2 < maxLength; _i2 += 1) {
304
+ if (_loop2(_i2)) break;
305
+ }
306
+ if (distinguishingIndex === -1) {
307
+ throw new Error("Cannot find distinguishing segment for files: ".concat(paths.join(', ')));
308
+ }
309
+
310
+ // Generate names using the distinguishing segment
311
+ var _iterator3 = _createForOfIteratorHelper(conflictingFiles),
312
+ _step3;
313
+ try {
314
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
315
+ var _file2 = _step3.value;
316
+ var _fileName2 = _file2.segments[_file2.segments.length - 1];
317
+ var _isIndexFile2 = _fileName2.startsWith('index.');
318
+ var _distinguishingSegment = _file2.segments[distinguishingIndex];
319
+ var _finalName = void 0;
320
+ if (_isIndexFile2) {
321
+ // Check if this was a direct index import
322
+ var _originalImportParts2 = _file2.originalImportPath.split('/');
323
+ var _isDirectIndexImport2 = _originalImportParts2.length === 2 && _originalImportParts2[0] === '.' && _originalImportParts2[1].startsWith('index.');
324
+ if (_isDirectIndexImport2) {
325
+ _finalName = "".concat(_distinguishingSegment, "/index").concat(_file2.extension);
326
+ } else {
327
+ var _parentDir2 = _file2.segments[_file2.segments.length - 2];
328
+ _finalName = "".concat(_distinguishingSegment, "/").concat(_parentDir2).concat(_file2.extension);
329
+ }
330
+ } else {
331
+ _finalName = "".concat(_distinguishingSegment, "/").concat(_fileName2);
332
+ }
333
+ finalNames.set(_file2.resolvedPath, _finalName);
334
+ }
335
+ } catch (err) {
336
+ _iterator3.e(err);
337
+ } finally {
338
+ _iterator3.f();
339
+ }
340
+ }
341
+ });
342
+
343
+ // Fourth pass: build the extraFiles mapping
344
+ finalNames.forEach(function (finalName, resolvedPath) {
345
+ extraFiles["./".concat(finalName)] = "file://".concat(resolvedPath);
346
+ });
347
+ return {
348
+ processedSource: '',
349
+ // Will be set by caller after rewriting
350
+ extraFiles: extraFiles
351
+ };
352
+ }