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

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