@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
@@ -1,57 +0,0 @@
1
- interface LoaderContext {
2
- resourcePath: string;
3
- addDependency(dependency: string): void;
4
- async(): (err?: Error | null, content?: string) => void;
5
- cacheable(): void;
6
- }
7
- /**
8
- * Webpack loader that processes demo files and precomputes variant data.
9
- *
10
- * This loader:
11
- * 1. Parses demo files to find a single createDemo call with precompute: true
12
- * 2. Resolves all variant entry point paths using resolveModulePathsWithFs
13
- * 3. Uses loadVariant to handle all loading, parsing, and transformation:
14
- * - loadSource: Loads individual files and extracts dependencies
15
- * - loadVariantMeta: Creates basic variant structure
16
- * - parseSource: Applies syntax highlighting using Starry Night
17
- * - sourceTransformers: Handles TypeScript to JavaScript conversion
18
- * 4. loadVariant handles recursive dependency loading automatically
19
- * 5. Adds all dependencies to webpack's watch list
20
- * 6. Replaces precompute: true with the actual precomputed data using replacePrecomputeValue
21
- *
22
- * Note: Only supports one createDemo call per file. Will throw an error if multiple calls are found.
23
- *
24
- * Features:
25
- * - Proper variant entry point resolution using resolveModulePathsWithFs
26
- * - Complete dependency tree loading handled by loadVariant
27
- * - Syntax highlighting using Starry Night (via parseSource)
28
- * - TypeScript to JavaScript transformation (via transformTsToJs)
29
- * - Webpack dependency tracking for hot reloading
30
- * - Precise precompute value replacement (via replacePrecomputeValue)
31
- *
32
- * Example input:
33
- * ```typescript
34
- * import { createDemo } from '@/functions/createDemo';
35
- * import CssModules from './CssModules';
36
- * import Tailwind from './Tailwind';
37
- *
38
- * export const CodeDemo = createDemo(
39
- * import.meta.url,
40
- * { CssModules, Tailwind },
41
- * {
42
- * name: 'Basic Code Block',
43
- * slug: 'code',
44
- * precompute: true,
45
- * },
46
- * );
47
- * ```
48
- *
49
- * Example output (precompute: true replaced with processed data):
50
- * The precompute property is replaced with an object containing:
51
- * - fileName: The main file name
52
- * - source: HAST nodes with syntax highlighting applied
53
- * - extraFiles: Object containing additional dependency files
54
- * - transforms: Object with language variants (e.g., JavaScript version from TypeScript)
55
- */
56
- export declare function loadPrecomputedCodeHighlighter(this: LoaderContext, source: string): Promise<void>;
57
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadPrecomputedCodeHighlighter.d.ts","sourceRoot":"","sources":["../../../src/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.ts"],"names":[],"mappings":"AASA,UAAU,aAAa;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,SAAS,IAAI,IAAI,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA4Ff"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseCreateFactoryCall.d.ts","sourceRoot":"","sources":["../../../src/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAgFD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAiErC"}
@@ -1,243 +0,0 @@
1
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
- import { resolveImports } from "../loaderUtils/index.js";
5
- import { parseFunctionParameters } from "./parseFunctionParameters.js";
6
-
7
- /**
8
- * Helper function to convert the new resolveImports format to a Map
9
- * that maps import names to their resolved paths
10
- */
11
- function buildImportMap(importResult) {
12
- var importMap = new Map();
13
- Object.values(importResult).forEach(function (_ref) {
14
- var path = _ref.path,
15
- names = _ref.names;
16
- names.forEach(function (name) {
17
- importMap.set(name, path);
18
- });
19
- });
20
- return importMap;
21
- }
22
- /**
23
- * Parses a variants object string and maps variant names to their import paths
24
- */
25
- function parseVariantsObject(variantsObjectStr, importMap) {
26
- var demoImports = {};
27
-
28
- // Parse the demo object to extract key-value pairs
29
- // Handle both { Default: BasicCode } and { Default } syntax
30
- var objectContentRegex = /(\w+)(?:\s*:\s*(\w+))?/g;
31
- var objectMatch = objectContentRegex.exec(variantsObjectStr);
32
- while (objectMatch !== null) {
33
- var _objectMatch = objectMatch,
34
- _objectMatch2 = _slicedToArray(_objectMatch, 3),
35
- key = _objectMatch2[1],
36
- value = _objectMatch2[2];
37
- var importName = value || key; // Use value if provided, otherwise use key (shorthand syntax)
38
-
39
- if (importMap.has(importName)) {
40
- demoImports[key] = importMap.get(importName);
41
- }
42
- objectMatch = objectContentRegex.exec(variantsObjectStr);
43
- }
44
- return demoImports;
45
- }
46
-
47
- /**
48
- * Validates that a URL parameter follows the expected convention
49
- */
50
- function validateUrlParameter(url, functionName, filePath) {
51
- var trimmedUrl = url.trim();
52
-
53
- // Check for import.meta.url
54
- if (trimmedUrl === 'import.meta.url') {
55
- return;
56
- }
57
-
58
- // Check for CJS equivalent: require('url').pathToFileURL(__filename).toString()
59
- // https://github.com/javiertury/babel-plugin-transform-import-meta#importmetaurl
60
- var cjsPattern = /require\s*\(\s*['"`]url['"`]\s*\)\s*\.\s*pathToFileURL\s*\(\s*__filename\s*\)\s*\.\s*toString\s*\(\s*\)/;
61
- if (cjsPattern.test(trimmedUrl)) {
62
- return;
63
- }
64
- throw new Error("Invalid URL parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected 'import.meta.url' or 'require('url').pathToFileURL(__filename).toString()' but got: ".concat(trimmedUrl));
65
- }
66
-
67
- /**
68
- * Validates that a variants parameter is an object mapping to imports
69
- */
70
- function validateVariantsParameter(variantsObjectStr, functionName, filePath) {
71
- if (!variantsObjectStr || variantsObjectStr.trim() === '') {
72
- throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object mapping variant names to imports.");
73
- }
74
-
75
- // Basic validation that it looks like an object
76
- var trimmed = variantsObjectStr.trim();
77
- if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) {
78
- throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object but got: ".concat(trimmed));
79
- }
80
- }
81
-
82
- /**
83
- * Parses a file to extract a single create* factory call and its variants and options
84
- * Only supports one create* call per file - will throw an error if multiple are found
85
- * Returns null if no create* call is found
86
- */
87
- export function parseCreateFactoryCall(_x, _x2) {
88
- return _parseCreateFactoryCall.apply(this, arguments);
89
- }
90
-
91
- /**
92
- * Finds create* factory calls in code, handling multiline cases
93
- */
94
- function _parseCreateFactoryCall() {
95
- _parseCreateFactoryCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(code, filePath) {
96
- var importResult, importMap, createFactoryMatches, match, functionName, fullMatch, urlParam, variantsObjectStr, optionsObjectStr, url, variants, options, nameMatch, slugMatch, precomputeMatch;
97
- return _regeneratorRuntime().wrap(function _callee$(_context) {
98
- while (1) switch (_context.prev = _context.next) {
99
- case 0:
100
- _context.next = 2;
101
- return resolveImports(code, filePath);
102
- case 2:
103
- importResult = _context.sent;
104
- importMap = buildImportMap(importResult); // Find all create* calls in the code
105
- createFactoryMatches = findCreateFactoryCalls(code, filePath); // Enforce single create* call per file
106
- if (!(createFactoryMatches.length > 1)) {
107
- _context.next = 7;
108
- break;
109
- }
110
- throw new Error("Multiple create* factory calls found in ".concat(filePath, ". Only one create* call per file is supported. Found ").concat(createFactoryMatches.length, " calls."));
111
- case 7:
112
- if (!(createFactoryMatches.length === 0)) {
113
- _context.next = 9;
114
- break;
115
- }
116
- return _context.abrupt("return", null);
117
- case 9:
118
- match = createFactoryMatches[0];
119
- functionName = match.functionName, fullMatch = match.fullMatch, urlParam = match.urlParam, variantsObjectStr = match.variantsObjectStr, optionsObjectStr = match.optionsObjectStr; // Validate URL parameter
120
- validateUrlParameter(urlParam, functionName, filePath);
121
-
122
- // Validate variants parameter
123
- validateVariantsParameter(variantsObjectStr, functionName, filePath);
124
-
125
- // Extract URL (typically import.meta.url)
126
- url = urlParam.trim(); // Resolve variants for this specific create* call
127
- variants = parseVariantsObject(variantsObjectStr, importMap); // Parse options object
128
- options = {}; // Extract name
129
- nameMatch = optionsObjectStr.match(/name\s*:\s*['"`]([^'"`]+)['"`]/);
130
- if (nameMatch) {
131
- options.name = nameMatch[1];
132
- }
133
-
134
- // Extract slug
135
- slugMatch = optionsObjectStr.match(/slug\s*:\s*['"`]([^'"`]+)['"`]/);
136
- if (slugMatch) {
137
- options.slug = slugMatch[1];
138
- }
139
-
140
- // Extract precompute
141
- precomputeMatch = optionsObjectStr.match(/precompute\s*:\s*(true|false)/);
142
- if (precomputeMatch) {
143
- options.precompute = precomputeMatch[1] === 'true';
144
- }
145
- return _context.abrupt("return", {
146
- functionName: functionName,
147
- url: url,
148
- variants: variants,
149
- options: options,
150
- fullMatch: fullMatch,
151
- variantsObjectStr: variantsObjectStr,
152
- optionsObjectStr: optionsObjectStr
153
- });
154
- case 23:
155
- case "end":
156
- return _context.stop();
157
- }
158
- }, _callee);
159
- }));
160
- return _parseCreateFactoryCall.apply(this, arguments);
161
- }
162
- function findCreateFactoryCalls(code, filePath) {
163
- var results = [];
164
-
165
- // Find all create* function calls
166
- var createFactoryRegex = /\b(create\w*)\s*\(/g;
167
- var match = createFactoryRegex.exec(code);
168
- while (match !== null) {
169
- var functionName = match[1];
170
- var startIndex = match.index;
171
- var parenIndex = match.index + match[0].length - 1; // Position of opening parenthesis
172
-
173
- // Find the matching closing parenthesis
174
- var parenCount = 0;
175
- var endIndex = -1;
176
- for (var i = parenIndex; i < code.length; i += 1) {
177
- if (code[i] === '(') {
178
- parenCount += 1;
179
- } else if (code[i] === ')') {
180
- parenCount -= 1;
181
- if (parenCount === 0) {
182
- endIndex = i;
183
- break;
184
- }
185
- }
186
- }
187
- if (endIndex === -1) {
188
- match = createFactoryRegex.exec(code);
189
- continue;
190
- }
191
- var fullMatch = code.substring(startIndex, endIndex + 1);
192
- var content = code.substring(parenIndex + 1, endIndex);
193
-
194
- // Split by commas at the top level, handling nested structures and comments
195
- var _parseFunctionParamet = parseFunctionParameters(content),
196
- parts = _parseFunctionParamet.parts,
197
- objects = _parseFunctionParamet.objects;
198
-
199
- // Validate the function follows the convention
200
- if (parts.length < 2 || parts.length > 3) {
201
- throw new Error("Invalid ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected 2-3 parameters (url, variants, options?) but got ".concat(parts.length, " parameters. ") + "Functions starting with 'create' must follow the convention: create*(url, variants, options?)");
202
- }
203
- if (parts.length === 2) {
204
- var _parts = _slicedToArray(parts, 1),
205
- urlParam = _parts[0];
206
-
207
- // Extract the actual object string for variants
208
- var variantsObjectStr = objects[1];
209
- if (!variantsObjectStr) {
210
- throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object but could not parse: ".concat(parts[1].trim()));
211
- }
212
- results.push({
213
- functionName: functionName,
214
- fullMatch: fullMatch,
215
- urlParam: urlParam.trim(),
216
- variantsObjectStr: variantsObjectStr,
217
- optionsObjectStr: '{}' // Default empty options
218
- });
219
- } else if (parts.length === 3) {
220
- var _parts2 = _slicedToArray(parts, 1),
221
- _urlParam = _parts2[0];
222
-
223
- // Extract the actual object strings
224
- var _variantsObjectStr = objects[1];
225
- var optionsObjectStr = objects[2];
226
- if (!_variantsObjectStr) {
227
- throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object but could not parse: ".concat(parts[1].trim()));
228
- }
229
- if (!optionsObjectStr) {
230
- throw new Error("Invalid options parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object but could not parse: ".concat(parts[2].trim()));
231
- }
232
- results.push({
233
- functionName: functionName,
234
- fullMatch: fullMatch,
235
- urlParam: _urlParam.trim(),
236
- variantsObjectStr: _variantsObjectStr,
237
- optionsObjectStr: optionsObjectStr
238
- });
239
- }
240
- match = createFactoryRegex.exec(code);
241
- }
242
- return results;
243
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseFunctionParameters.d.ts","sourceRoot":"","sources":["../../../src/loadPrecomputedCodeHighlighter/parseFunctionParameters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,8EAA8E;IAC9E,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CA8FrE"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Replaces 'precompute: true' with the actual precomputed data in source code.
3
- *
4
- * This function performs a precise replacement of the boolean true value in
5
- * 'precompute: true' expressions with the provided data object, keeping the
6
- * rest of the source code unchanged.
7
- *
8
- * @param source - The source code string containing 'precompute: true'
9
- * @param precomputeData - The data object to replace the true value with
10
- * @returns The modified source code with precompute data injected
11
- *
12
- * @example
13
- * ```typescript
14
- * const source = `
15
- * export const demo = createDemo(
16
- * import.meta.url,
17
- * { Component },
18
- * { precompute: true }
19
- * );
20
- * `;
21
- *
22
- * const data = { variants: { default: { code: "..." } } };
23
- * const result = replacePrecomputeValue(source, data);
24
- * // Result will have 'precompute: true' replaced with 'precompute: { variants: { default: { code: "..." } } }'
25
- * ```
26
- */
27
- export declare function replacePrecomputeValue(source: string, precomputeData: Record<string, any>): string;
@@ -1 +0,0 @@
1
- {"version":3,"file":"replacePrecomputeValue.d.ts","sourceRoot":"","sources":["../../../src/loadPrecomputedCodeHighlighter/replacePrecomputeValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAClC,MAAM,CAUR"}
@@ -1,37 +0,0 @@
1
- /**
2
- * Replaces 'precompute: true' with the actual precomputed data in source code.
3
- *
4
- * This function performs a precise replacement of the boolean true value in
5
- * 'precompute: true' expressions with the provided data object, keeping the
6
- * rest of the source code unchanged.
7
- *
8
- * @param source - The source code string containing 'precompute: true'
9
- * @param precomputeData - The data object to replace the true value with
10
- * @returns The modified source code with precompute data injected
11
- *
12
- * @example
13
- * ```typescript
14
- * const source = `
15
- * export const demo = createDemo(
16
- * import.meta.url,
17
- * { Component },
18
- * { precompute: true }
19
- * );
20
- * `;
21
- *
22
- * const data = { variants: { default: { code: "..." } } };
23
- * const result = replacePrecomputeValue(source, data);
24
- * // Result will have 'precompute: true' replaced with 'precompute: { variants: { default: { code: "..." } } }'
25
- * ```
26
- */
27
- export function replacePrecomputeValue(source, precomputeData) {
28
- // Regex to match 'precompute: true' with optional whitespace
29
- var precomputeRegex = /precompute\s*:\s*true/g;
30
-
31
- // Convert the data to a properly formatted JSON string
32
- var precomputeDataString = JSON.stringify(precomputeData, null, 2);
33
-
34
- // Replace 'precompute: true' with 'precompute: {data}'
35
- // The regex will match the exact pattern and we replace just that part
36
- return source.replace(precomputeRegex, "precompute: ".concat(precomputeDataString));
37
- }
@@ -1 +0,0 @@
1
- export * from "./serverLoadCodeMeta.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/loadServerCodeMeta/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -1 +0,0 @@
1
- export * from "./serverLoadCodeMeta.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverLoadCodeMeta.d.ts","sourceRoot":"","sources":["../../../src/loadServerCodeMeta/serverLoadCodeMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAQ,MAAM,0BAA0B,CAAC;AAInE,MAAM,WAAW,yBAAyB;CAEzC;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAA6B,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,GAAE,yBAA8B,GAAG,YAAY,CA4B/F"}
@@ -1 +0,0 @@
1
- export * from "./serverLoadSource.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/loadServerSource/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -1 +0,0 @@
1
- export * from "./serverLoadSource.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverLoadSource.d.ts","sourceRoot":"","sources":["../../../src/loadServerSource/serverLoadSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5F,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,YAA2B,CAAC;AAEzD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CAmDlF"}
@@ -1,100 +0,0 @@
1
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import { readFile } from 'node:fs/promises';
4
- import { resolveImports } from "../loaderUtils/resolveImports.js";
5
- import { resolveImportResultWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
6
- import { processImportsWithStoreAt } from "../loaderUtils/processImports.js";
7
- import { isJavaScriptModule } from "../loaderUtils/resolveModulePath.js";
8
- /**
9
- * Default serverLoadSource function that reads a file and extracts its dependencies.
10
- * This function is used to load source files for demos, resolving their imports and dependencies.
11
- * It reads the source file, resolves its imports, and returns the processed source along with any
12
- * additional files and dependencies that were found.
13
- */
14
- export var serverLoadSource = createServerLoadSource();
15
-
16
- /**
17
- * Creates a loadSource function that reads a file and extracts its dependencies.
18
- *
19
- * @param options.storeAt - Controls how imports are stored in extraFiles:
20
- * - 'canonical': Full resolved path (e.g., '../Component/index.js')
21
- * - 'import': Import path with file extension (e.g., '../Component.js')
22
- * - 'flat': Flattened to current directory with rewritten imports (e.g., './Component.js')
23
- */
24
- export function createServerLoadSource() {
25
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
- var _options$includeDepen = options.includeDependencies,
27
- includeDependencies = _options$includeDepen === void 0 ? true : _options$includeDepen,
28
- _options$storeAt = options.storeAt,
29
- storeAt = _options$storeAt === void 0 ? 'flat' : _options$storeAt;
30
- return /*#__PURE__*/function () {
31
- var _loadSource = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
32
- var filePath, source, isJavascriptModuleFile, importResult, resolvedPathsMap, _processImportsWithSt, processedSource, extraFiles, extraDependencies;
33
- return _regeneratorRuntime().wrap(function _callee$(_context) {
34
- while (1) switch (_context.prev = _context.next) {
35
- case 0:
36
- // Remove file:// prefix if present
37
- filePath = url.replace('file://', ''); // Read the file
38
- _context.next = 3;
39
- return readFile(filePath, 'utf8');
40
- case 3:
41
- source = _context.sent;
42
- if (includeDependencies) {
43
- _context.next = 6;
44
- break;
45
- }
46
- return _context.abrupt("return", {
47
- source: source
48
- });
49
- case 6:
50
- // Check if this is a static asset file (non-JS/TS modules)
51
- isJavascriptModuleFile = isJavaScriptModule(filePath);
52
- if (isJavascriptModuleFile) {
53
- _context.next = 9;
54
- break;
55
- }
56
- return _context.abrupt("return", {
57
- source: source
58
- });
59
- case 9:
60
- _context.next = 11;
61
- return resolveImports(source, filePath);
62
- case 11:
63
- importResult = _context.sent;
64
- if (!(Object.keys(importResult).length === 0)) {
65
- _context.next = 14;
66
- break;
67
- }
68
- return _context.abrupt("return", {
69
- source: source
70
- });
71
- case 14:
72
- _context.next = 16;
73
- return resolveImportResultWithFs(importResult);
74
- case 16:
75
- resolvedPathsMap = _context.sent;
76
- // Process imports using the consolidated helper function
77
- _processImportsWithSt = processImportsWithStoreAt(source, importResult, resolvedPathsMap, storeAt), processedSource = _processImportsWithSt.processedSource, extraFiles = _processImportsWithSt.extraFiles; // Build dependencies list for recursive loading
78
- extraDependencies = Object.values(importResult).map(function (_ref) {
79
- var path = _ref.path;
80
- return resolvedPathsMap.get(path);
81
- }).filter(function (path) {
82
- return path !== undefined;
83
- });
84
- return _context.abrupt("return", {
85
- source: processedSource,
86
- extraFiles: Object.keys(extraFiles).length > 0 ? extraFiles : undefined,
87
- extraDependencies: extraDependencies.length > 0 ? extraDependencies : undefined
88
- });
89
- case 20:
90
- case "end":
91
- return _context.stop();
92
- }
93
- }, _callee);
94
- }));
95
- function loadSource(_x) {
96
- return _loadSource.apply(this, arguments);
97
- }
98
- return loadSource;
99
- }();
100
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFileNameFromUrl.d.ts","sourceRoot":"","sources":["../../../src/loaderUtils/getFileNameFromUrl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAoBvF"}
@@ -1,5 +0,0 @@
1
- export * from "./resolveImports.js";
2
- export * from "./resolveModulePath.js";
3
- export * from "./rewriteImports.js";
4
- export * from "./processImports.js";
5
- export * from "./getFileNameFromUrl.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/loaderUtils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
@@ -1,5 +0,0 @@
1
- export * from "./resolveImports.js";
2
- export * from "./resolveModulePath.js";
3
- export * from "./rewriteImports.js";
4
- export * from "./processImports.js";
5
- export * from "./getFileNameFromUrl.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"processImports.d.ts","sourceRoot":"","sources":["../../../src/loaderUtils/processImports.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,yBAAyB,CACvC,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,CAsEtB"}
@@ -1,82 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { rewriteImportsToSameDirectory } from "./rewriteImports.js";
3
- import { isJavaScriptModule } from "./resolveModulePath.js";
4
- import { getFileNameFromUrl } from "./getFileNameFromUrl.js";
5
- /**
6
- * Processes imports based on the specified storage mode, automatically handling
7
- * source rewriting when needed (e.g., for 'flat' mode).
8
- *
9
- * @param source - The original source code
10
- * @param importResult - The result from resolveImports
11
- * @param resolvedPathsMap - Map from import paths to resolved file paths
12
- * @param storeAt - How to process the imports
13
- * @returns Object with processed source and extraFiles mapping
14
- */
15
- export function processImportsWithStoreAt(source, importResult, resolvedPathsMap, storeAt) {
16
- var processedSource = source;
17
- var extraFiles = {};
18
-
19
- // For flat mode, automatically rewrite imports to same directory
20
- if (storeAt === 'flat') {
21
- var allResolvedPaths = new Set(resolvedPathsMap.values());
22
- processedSource = rewriteImportsToSameDirectory(source, allResolvedPaths);
23
- }
24
-
25
- // Process each import and generate extraFiles
26
- Object.entries(importResult).forEach(function (_ref) {
27
- var _ref2 = _slicedToArray(_ref, 2),
28
- relativePath = _ref2[0],
29
- importInfo = _ref2[1];
30
- var resolvedPath = resolvedPathsMap.get(importInfo.path);
31
- if (resolvedPath) {
32
- var fileExtension = getFileNameFromUrl(resolvedPath).extension;
33
- var isJavascriptModule = isJavaScriptModule(relativePath);
34
- var keyPath;
35
- if (!isJavascriptModule) {
36
- // For static assets (CSS, JSON, etc.), use the original import path as-is since it already has the extension
37
- switch (storeAt) {
38
- case 'canonical':
39
- case 'import':
40
- keyPath = relativePath;
41
- break;
42
- case 'flat':
43
- // For flat mode, use just the filename from the original import
44
- keyPath = "./".concat(getFileNameFromUrl(relativePath).fileName);
45
- break;
46
- default:
47
- keyPath = relativePath;
48
- }
49
- } else {
50
- // For JS/TS modules, apply the existing logic
51
- switch (storeAt) {
52
- case 'canonical':
53
- // Show the full resolved path including index files when they exist
54
- // e.g., import '../Component' resolved to '/src/Component/index.js'
55
- // becomes extraFiles: { '../Component/index.js': 'file:///src/Component/index.js' }
56
- keyPath = "".concat(relativePath).concat(resolvedPath.endsWith("/index".concat(fileExtension)) ? "/index".concat(fileExtension) : fileExtension);
57
- break;
58
- case 'import':
59
- // Use the original import path with the actual file extension
60
- // e.g., import '../Component' with '/src/Component/index.js'
61
- // becomes extraFiles: { '../Component.js': 'file:///src/Component/index.js' }
62
- keyPath = "".concat(relativePath).concat(fileExtension);
63
- break;
64
- case 'flat':
65
- // Flatten all files to current directory using just the filename
66
- // e.g., import '../Component' with '/src/Component/index.js'
67
- // becomes extraFiles: { './index.js': 'file:///src/Component/index.js' }
68
- // Note: This mode also requires rewriting imports in the source code (handled above)
69
- keyPath = "./".concat(getFileNameFromUrl(resolvedPath).fileName);
70
- break;
71
- default:
72
- keyPath = "".concat(relativePath).concat(fileExtension);
73
- }
74
- }
75
- extraFiles[keyPath] = "file://".concat(resolvedPath);
76
- }
77
- });
78
- return {
79
- processedSource: processedSource,
80
- extraFiles: extraFiles
81
- };
82
- }
@@ -1,4 +0,0 @@
1
- export declare function resolveImports(code: string, filePath: string): Promise<Record<string, {
2
- path: string;
3
- names: string[];
4
- }>>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveImports.d.ts","sourceRoot":"","sources":["../../../src/loaderUtils/resolveImports.ts"],"names":[],"mappings":"AAAA,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC,CAkC5D"}