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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/CodeControllerContext/CodeControllerContext.d.ts +1 -1
  2. package/CodeControllerContext/CodeControllerContext.d.ts.map +1 -1
  3. package/CodeControllerContext/index.d.ts.map +1 -1
  4. package/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
  5. package/CodeExternalsContext/CodeExternalsContext.d.ts.map +1 -0
  6. package/CodeExternalsContext/CodeExternalsContext.js +7 -0
  7. package/CodeExternalsContext/index.d.ts +1 -0
  8. package/CodeExternalsContext/index.d.ts.map +1 -0
  9. package/CodeExternalsContext/index.js +1 -0
  10. package/CodeHighlighter/CodeHighlighter.d.ts +1 -1
  11. package/CodeHighlighter/CodeHighlighter.d.ts.map +1 -1
  12. package/CodeHighlighter/CodeHighlighter.js +235 -86
  13. package/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -1
  14. package/CodeHighlighter/CodeHighlighterClient.js +500 -62
  15. package/CodeHighlighter/CodeHighlighterContext.d.ts +2 -0
  16. package/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -1
  17. package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +1 -1
  18. package/CodeHighlighter/CodeHighlighterFallbackContext.js +3 -1
  19. package/CodeHighlighter/applyTransform.d.ts.map +1 -1
  20. package/CodeHighlighter/codeToFallbackProps.d.ts +2 -2
  21. package/CodeHighlighter/codeToFallbackProps.d.ts.map +1 -1
  22. package/CodeHighlighter/codeToFallbackProps.js +8 -5
  23. package/CodeHighlighter/errors.d.ts.map +1 -1
  24. package/CodeHighlighter/hasAllVariants.d.ts.map +1 -1
  25. package/CodeHighlighter/index.d.ts.map +1 -1
  26. package/CodeHighlighter/loadFallbackCode.d.ts +3 -2
  27. package/CodeHighlighter/loadFallbackCode.d.ts.map +1 -1
  28. package/CodeHighlighter/loadFallbackCode.js +325 -161
  29. package/CodeHighlighter/loadVariant.d.ts +3 -2
  30. package/CodeHighlighter/loadVariant.d.ts.map +1 -1
  31. package/CodeHighlighter/loadVariant.js +604 -229
  32. package/CodeHighlighter/maybeInitialData.d.ts +1 -1
  33. package/CodeHighlighter/maybeInitialData.d.ts.map +1 -1
  34. package/CodeHighlighter/parseCode.d.ts.map +1 -1
  35. package/CodeHighlighter/parseCode.js +14 -2
  36. package/CodeHighlighter/parseControlledCode.d.ts.map +1 -1
  37. package/CodeHighlighter/parseControlledCode.js +12 -1
  38. package/CodeHighlighter/transformCode.d.ts +1 -0
  39. package/CodeHighlighter/transformCode.d.ts.map +1 -1
  40. package/CodeHighlighter/transformCode.js +43 -3
  41. package/CodeHighlighter/transformParsedSource.d.ts.map +1 -1
  42. package/CodeHighlighter/transformSource.d.ts.map +1 -1
  43. package/CodeHighlighter/types.d.ts +39 -17
  44. package/CodeHighlighter/types.d.ts.map +1 -1
  45. package/CodeProvider/CodeContext.d.ts.map +1 -1
  46. package/CodeProvider/CodeProvider.d.ts.map +1 -1
  47. package/CodeProvider/CodeProvider.js +21 -6
  48. package/CodeProvider/index.d.ts +1 -2
  49. package/CodeProvider/index.d.ts.map +1 -1
  50. package/CodeProvider/index.js +1 -2
  51. package/abstractCreateDemo/abstractCreateDemo.d.ts +35 -0
  52. package/abstractCreateDemo/abstractCreateDemo.d.ts.map +1 -0
  53. package/abstractCreateDemo/abstractCreateDemo.js +91 -0
  54. package/abstractCreateDemo/index.d.ts +1 -0
  55. package/abstractCreateDemo/index.d.ts.map +1 -0
  56. package/abstractCreateDemo/index.js +1 -0
  57. package/createDemoData/createDemoData.d.ts +44 -0
  58. package/createDemoData/createDemoData.d.ts.map +1 -0
  59. package/createDemoData/createDemoData.js +75 -0
  60. package/createDemoData/index.d.ts +1 -0
  61. package/createDemoData/index.d.ts.map +1 -0
  62. package/createDemoData/index.js +1 -0
  63. package/createDemoData/types.d.ts +28 -0
  64. package/createDemoData/types.d.ts.map +1 -0
  65. package/createDemoData/types.js +1 -0
  66. package/package.json +15 -9
  67. package/pipeline/hastUtils/hastUtils.d.ts.map +1 -0
  68. package/{hast/hast.js → pipeline/hastUtils/hastUtils.js} +2 -1
  69. package/pipeline/hastUtils/index.d.ts +1 -0
  70. package/pipeline/hastUtils/index.d.ts.map +1 -0
  71. package/pipeline/hastUtils/index.js +1 -0
  72. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +54 -0
  73. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +1 -0
  74. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +465 -0
  75. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +15 -0
  76. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +1 -0
  77. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +253 -0
  78. package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +1 -0
  79. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +20 -0
  80. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -0
  81. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/loadPrecomputedCodeHighlighter.js +105 -75
  82. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseCreateFactoryCall.d.ts +12 -1
  83. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +1 -0
  84. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +433 -0
  85. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.d.ts +5 -1
  86. package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +1 -0
  87. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.js +1 -1
  88. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +25 -0
  89. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +1 -0
  90. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
  91. package/pipeline/loadServerCodeMeta/index.d.ts +1 -0
  92. package/pipeline/loadServerCodeMeta/index.d.ts.map +1 -0
  93. package/pipeline/loadServerCodeMeta/index.js +1 -0
  94. package/{loadServerCodeMeta/serverLoadCodeMeta.d.ts → pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts} +4 -4
  95. package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +1 -0
  96. package/{loadServerCodeMeta/serverLoadCodeMeta.js → pipeline/loadServerCodeMeta/loadServerCodeMeta.js} +18 -3
  97. package/pipeline/loadServerSource/index.d.ts +1 -0
  98. package/pipeline/loadServerSource/index.d.ts.map +1 -0
  99. package/pipeline/loadServerSource/index.js +1 -0
  100. package/{loadServerSource/serverLoadSource.d.ts → pipeline/loadServerSource/loadServerSource.d.ts} +5 -5
  101. package/pipeline/loadServerSource/loadServerSource.d.ts.map +1 -0
  102. package/pipeline/loadServerSource/loadServerSource.js +135 -0
  103. package/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
  104. package/pipeline/loaderUtils/externalsToPackages.d.ts.map +1 -0
  105. package/pipeline/loaderUtils/externalsToPackages.js +46 -0
  106. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
  107. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +1 -0
  108. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
  109. package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
  110. package/pipeline/loaderUtils/index.d.ts +7 -0
  111. package/pipeline/loaderUtils/index.d.ts.map +1 -0
  112. package/pipeline/loaderUtils/index.js +7 -0
  113. package/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
  114. package/pipeline/loaderUtils/mergeExternals.d.ts.map +1 -0
  115. package/pipeline/loaderUtils/mergeExternals.js +72 -0
  116. package/pipeline/loaderUtils/parseImports.d.ts +20 -0
  117. package/pipeline/loaderUtils/parseImports.d.ts.map +1 -0
  118. package/pipeline/loaderUtils/parseImports.js +307 -0
  119. package/{loaderUtils/processImports.d.ts → pipeline/loaderUtils/processRelativeImports.d.ts} +2 -2
  120. package/pipeline/loaderUtils/processRelativeImports.d.ts.map +1 -0
  121. package/pipeline/loaderUtils/processRelativeImports.js +329 -0
  122. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePath.d.ts +19 -6
  123. package/pipeline/loaderUtils/resolveModulePath.d.ts.map +1 -0
  124. package/pipeline/loaderUtils/resolveModulePath.js +1449 -0
  125. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.d.ts +6 -3
  126. package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
  127. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.js +8 -4
  128. package/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
  129. package/pipeline/loaderUtils/rewriteImports.d.ts.map +1 -0
  130. package/pipeline/loaderUtils/rewriteImports.js +35 -0
  131. package/pipeline/parseSource/grammars.d.ts.map +1 -0
  132. package/pipeline/parseSource/index.d.ts.map +1 -0
  133. package/pipeline/parseSource/parseSource.d.ts +3 -0
  134. package/pipeline/parseSource/parseSource.d.ts.map +1 -0
  135. package/{parseSource → pipeline/parseSource}/parseSource.js +15 -5
  136. package/pipeline/transformHtmlCode/index.d.ts +2 -0
  137. package/pipeline/transformHtmlCode/index.d.ts.map +1 -0
  138. package/pipeline/transformHtmlCode/index.js +4 -0
  139. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
  140. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +1 -0
  141. package/pipeline/transformHtmlCode/transformHtmlCode.js +303 -0
  142. package/pipeline/transformMarkdownCode/index.d.ts +2 -0
  143. package/pipeline/transformMarkdownCode/index.d.ts.map +1 -0
  144. package/pipeline/transformMarkdownCode/index.js +4 -0
  145. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
  146. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +1 -0
  147. package/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
  148. package/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
  149. package/pipeline/transformTypescriptToJavascript/index.d.ts.map +1 -0
  150. package/pipeline/transformTypescriptToJavascript/index.js +1 -0
  151. package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +1 -0
  152. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
  153. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +1 -0
  154. package/{transformTsToJs/transformTsToJs.js → pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js} +4 -4
  155. package/useCode/index.d.ts.map +1 -1
  156. package/useCode/useCode.d.ts +13 -11
  157. package/useCode/useCode.d.ts.map +1 -1
  158. package/useCode/useCode.js +93 -364
  159. package/useCode/useCodeUtils.d.ts +45 -0
  160. package/useCode/useCodeUtils.d.ts.map +1 -0
  161. package/useCode/useCodeUtils.js +240 -0
  162. package/useCode/useCopyFunctionality.d.ts +17 -0
  163. package/useCode/useCopyFunctionality.d.ts.map +1 -0
  164. package/useCode/useCopyFunctionality.js +28 -0
  165. package/useCode/useFileNavigation.d.ts +48 -0
  166. package/useCode/useFileNavigation.d.ts.map +1 -0
  167. package/useCode/useFileNavigation.js +370 -0
  168. package/useCode/useSourceEditing.d.ts +19 -0
  169. package/useCode/useSourceEditing.d.ts.map +1 -0
  170. package/useCode/useSourceEditing.js +32 -0
  171. package/useCode/useTransformManagement.d.ts +28 -0
  172. package/useCode/useTransformManagement.d.ts.map +1 -0
  173. package/useCode/useTransformManagement.js +82 -0
  174. package/useCode/useUIState.d.ts +16 -0
  175. package/useCode/useUIState.d.ts.map +1 -0
  176. package/useCode/useUIState.js +21 -0
  177. package/useCode/useVariantSelection.d.ts +21 -0
  178. package/useCode/useVariantSelection.d.ts.map +1 -0
  179. package/useCode/useVariantSelection.js +84 -0
  180. package/useCopier/index.d.ts +1 -1
  181. package/useCopier/index.d.ts.map +1 -1
  182. package/useCopier/index.js +5 -5
  183. package/useDemo/createCodeSandbox.d.ts +18 -0
  184. package/useDemo/createCodeSandbox.d.ts.map +1 -0
  185. package/useDemo/createCodeSandbox.js +48 -0
  186. package/useDemo/createStackBlitz.d.ts +22 -0
  187. package/useDemo/createStackBlitz.d.ts.map +1 -0
  188. package/useDemo/createStackBlitz.js +38 -0
  189. package/useDemo/examineVariant.d.ts +25 -0
  190. package/useDemo/examineVariant.d.ts.map +1 -0
  191. package/useDemo/examineVariant.js +134 -0
  192. package/useDemo/exportVariant.d.ts +110 -0
  193. package/useDemo/exportVariant.d.ts.map +1 -0
  194. package/useDemo/exportVariant.js +320 -0
  195. package/useDemo/exportVariantAsCra.d.ts +15 -0
  196. package/useDemo/exportVariantAsCra.d.ts.map +1 -0
  197. package/useDemo/exportVariantAsCra.js +56 -0
  198. package/useDemo/flattenVariant.d.ts +17 -0
  199. package/useDemo/flattenVariant.d.ts.map +1 -0
  200. package/useDemo/flattenVariant.js +206 -0
  201. package/useDemo/index.d.ts +6 -39
  202. package/useDemo/index.d.ts.map +1 -1
  203. package/useDemo/index.js +6 -17
  204. package/useDemo/useDemo.d.ts +78 -0
  205. package/useDemo/useDemo.d.ts.map +1 -0
  206. package/useDemo/useDemo.js +174 -0
  207. package/useLocalStorageState/index.d.ts +2 -0
  208. package/useLocalStorageState/index.d.ts.map +1 -0
  209. package/useLocalStorageState/index.js +2 -0
  210. package/useLocalStorageState/useLocalStorageState.d.ts +14 -0
  211. package/useLocalStorageState/useLocalStorageState.d.ts.map +1 -0
  212. package/useLocalStorageState/useLocalStorageState.js +128 -0
  213. package/useOnHydrate/index.d.ts.map +1 -1
  214. package/useOnHydrate/useOnHydrate.d.ts.map +1 -1
  215. package/useOnIdle/index.d.ts.map +1 -1
  216. package/useOnIdle/useOnIdle.d.ts.map +1 -1
  217. package/useUrlHashState/index.d.ts +1 -0
  218. package/useUrlHashState/index.d.ts.map +1 -0
  219. package/useUrlHashState/index.js +1 -0
  220. package/useUrlHashState/useUrlHashState.d.ts +50 -0
  221. package/useUrlHashState/useUrlHashState.d.ts.map +1 -0
  222. package/useUrlHashState/useUrlHashState.js +113 -0
  223. package/hast/hast.d.ts.map +0 -1
  224. package/hast/index.d.ts +0 -1
  225. package/hast/index.d.ts.map +0 -1
  226. package/hast/index.js +0 -1
  227. package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
  228. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
  229. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
  230. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
  231. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
  232. package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
  233. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
  234. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
  235. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
  236. package/loadServerCodeMeta/index.d.ts +0 -1
  237. package/loadServerCodeMeta/index.d.ts.map +0 -1
  238. package/loadServerCodeMeta/index.js +0 -1
  239. package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
  240. package/loadServerSource/index.d.ts +0 -1
  241. package/loadServerSource/index.d.ts.map +0 -1
  242. package/loadServerSource/index.js +0 -1
  243. package/loadServerSource/serverLoadSource.d.ts.map +0 -1
  244. package/loadServerSource/serverLoadSource.js +0 -100
  245. package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
  246. package/loaderUtils/index.d.ts +0 -5
  247. package/loaderUtils/index.d.ts.map +0 -1
  248. package/loaderUtils/index.js +0 -5
  249. package/loaderUtils/processImports.d.ts.map +0 -1
  250. package/loaderUtils/processImports.js +0 -82
  251. package/loaderUtils/resolveImports.d.ts +0 -4
  252. package/loaderUtils/resolveImports.d.ts.map +0 -1
  253. package/loaderUtils/resolveImports.js +0 -71
  254. package/loaderUtils/resolveModulePath.d.ts.map +0 -1
  255. package/loaderUtils/resolveModulePath.js +0 -862
  256. package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
  257. package/loaderUtils/rewriteImports.d.ts +0 -9
  258. package/loaderUtils/rewriteImports.d.ts.map +0 -1
  259. package/loaderUtils/rewriteImports.js +0 -57
  260. package/parseSource/grammars.d.ts.map +0 -1
  261. package/parseSource/index.d.ts.map +0 -1
  262. package/parseSource/parseSource.d.ts +0 -3
  263. package/parseSource/parseSource.d.ts.map +0 -1
  264. package/transformRelativeMarkdownPaths/index.d.ts +0 -2
  265. package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
  266. package/transformRelativeMarkdownPaths/index.js +0 -4
  267. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
  268. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
  269. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
  270. package/transformTsToJs/index.d.ts +0 -1
  271. package/transformTsToJs/index.d.ts.map +0 -1
  272. package/transformTsToJs/index.js +0 -1
  273. package/transformTsToJs/removeTypes.d.ts.map +0 -1
  274. package/transformTsToJs/transformTsToJs.d.ts +0 -3
  275. package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
  276. /package/{hast/hast.d.ts → pipeline/hastUtils/hastUtils.d.ts} +0 -0
  277. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.d.ts +0 -0
  278. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.js +0 -0
  279. /package/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.d.ts +0 -0
  280. /package/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.js +0 -0
  281. /package/{parseSource → pipeline/parseSource}/grammars.d.ts +0 -0
  282. /package/{parseSource → pipeline/parseSource}/grammars.js +0 -0
  283. /package/{parseSource → pipeline/parseSource}/index.d.ts +0 -0
  284. /package/{parseSource → pipeline/parseSource}/index.js +0 -0
  285. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.d.ts +0 -0
  286. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.js +0 -0
@@ -0,0 +1,433 @@
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 { parseImports } from "../loaderUtils/index.js";
5
+ import { parseFunctionParameters, extractBalancedBraces } from "./parseFunctionParameters.js";
6
+ /**
7
+ * Helper function to convert the new parseImports format to a Map
8
+ * that maps import names to their resolved paths
9
+ */
10
+ function buildImportMap(importResult) {
11
+ var importMap = new Map();
12
+ Object.values(importResult.relative).forEach(function (_ref) {
13
+ var path = _ref.path,
14
+ names = _ref.names;
15
+ names.forEach(function (_ref2) {
16
+ var name = _ref2.name,
17
+ alias = _ref2.alias;
18
+ // Use alias if available, otherwise use the original name
19
+ var nameToUse = alias || name;
20
+ importMap.set(nameToUse, path);
21
+ });
22
+ });
23
+ return importMap;
24
+ }
25
+
26
+ /**
27
+ * Helper function to build a mapping from import aliases to their original named exports
28
+ */
29
+ function buildNamedExportsMap(importResult) {
30
+ var namedExportsMap = new Map();
31
+ Object.values(importResult.relative).forEach(function (_ref3) {
32
+ var names = _ref3.names;
33
+ names.forEach(function (_ref4) {
34
+ var name = _ref4.name,
35
+ alias = _ref4.alias,
36
+ type = _ref4.type;
37
+ // Use alias if available, otherwise use the original name as key
38
+ var nameToUse = alias || name;
39
+
40
+ // Only map to the original export name for named imports
41
+ // Default imports should map to undefined since they don't have a specific named export
42
+ if (type === 'named') {
43
+ namedExportsMap.set(nameToUse, name);
44
+ } else {
45
+ namedExportsMap.set(nameToUse, undefined); // undefined for default/namespace imports
46
+ }
47
+ });
48
+ });
49
+ return namedExportsMap;
50
+ }
51
+ /**
52
+ * Parses a variants object string and maps variant names to their import paths
53
+ */
54
+ function parseVariantsObject(variantsObjectStr, importMap, namedExportsMap, functionName, filePath) {
55
+ var demoImports = {};
56
+ var namedExports = {};
57
+
58
+ // Parse the demo object to extract key-value pairs
59
+ // Handle both { Default: BasicCode } and { Default } syntax
60
+ var objectContentRegex = /(\w+)(?:\s*:\s*(\w+))?/g;
61
+ var objectMatch = objectContentRegex.exec(variantsObjectStr);
62
+ while (objectMatch !== null) {
63
+ var _objectMatch = objectMatch,
64
+ _objectMatch2 = _slicedToArray(_objectMatch, 3),
65
+ key = _objectMatch2[1],
66
+ value = _objectMatch2[2];
67
+ var importName = value || key; // Use value if provided, otherwise use key (shorthand syntax)
68
+
69
+ if (importMap.has(importName)) {
70
+ demoImports[key] = importMap.get(importName);
71
+ namedExports[key] = namedExportsMap.get(importName);
72
+ } else {
73
+ // Throw error if any variant component is not imported
74
+ throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Component '".concat(importName, "' is not imported. Make sure to import it first."));
75
+ }
76
+ objectMatch = objectContentRegex.exec(variantsObjectStr);
77
+ }
78
+ return {
79
+ variants: demoImports,
80
+ namedExports: namedExports
81
+ };
82
+ }
83
+
84
+ /**
85
+ * Parses variants parameter which can be either an object literal or a single component identifier
86
+ */
87
+ function parseVariantsParameter(variantsParam, importMap, namedExportsMap, functionName, filePath) {
88
+ var trimmed = variantsParam.trim();
89
+
90
+ // If it's an object literal, use existing logic
91
+ if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
92
+ return parseVariantsObject(trimmed, importMap, namedExportsMap, functionName, filePath);
93
+ }
94
+
95
+ // If it's a single identifier, map it to "Default"
96
+ if (importMap.has(trimmed)) {
97
+ return {
98
+ variants: {
99
+ Default: importMap.get(trimmed)
100
+ },
101
+ namedExports: {
102
+ Default: namedExportsMap.get(trimmed)
103
+ }
104
+ };
105
+ }
106
+
107
+ // Throw error if the identifier is not found in imports
108
+ throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Component '".concat(trimmed, "' is not imported. Make sure to import it first."));
109
+ }
110
+
111
+ /**
112
+ * Validates that a URL parameter follows the expected convention
113
+ */
114
+ function validateUrlParameter(url, functionName, filePath) {
115
+ var trimmedUrl = url.trim();
116
+
117
+ // Check for import.meta.url
118
+ if (trimmedUrl === 'import.meta.url') {
119
+ return;
120
+ }
121
+
122
+ // Check for CJS equivalent: require('url').pathToFileURL(__filename).toString()
123
+ // https://github.com/javiertury/babel-plugin-transform-import-meta#importmetaurl
124
+ var cjsPattern = /require\s*\(\s*['"`]url['"`]\s*\)\s*\.\s*pathToFileURL\s*\(\s*__filename\s*\)\s*\.\s*toString\s*\(\s*\)/;
125
+ if (cjsPattern.test(trimmedUrl)) {
126
+ return;
127
+ }
128
+ 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));
129
+ }
130
+
131
+ /**
132
+ * Validates that a variants parameter is either an object mapping to imports or a single identifier
133
+ */
134
+ function validateVariantsParameter(variantsParam, functionName, filePath) {
135
+ if (!variantsParam || variantsParam.trim() === '') {
136
+ throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object mapping variant names to imports or a single component identifier.");
137
+ }
138
+ var trimmed = variantsParam.trim();
139
+
140
+ // Check if it's an object literal
141
+ if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
142
+ return; // Valid object literal
143
+ }
144
+
145
+ // Check if it's a valid identifier (single component)
146
+ if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(trimmed)) {
147
+ return; // Valid identifier
148
+ }
149
+ throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object mapping variant names to imports or a single component identifier, but got: ".concat(trimmed));
150
+ }
151
+
152
+ /**
153
+ * Parses a file to extract a single create* factory call and its variants and options
154
+ * Only supports one create* call per file - will throw an error if multiple are found
155
+ * Returns null if no create* call is found
156
+ */
157
+ export function parseCreateFactoryCall(_x, _x2) {
158
+ return _parseCreateFactoryCall.apply(this, arguments);
159
+ }
160
+
161
+ /**
162
+ * Finds create* factory calls in code, handling multiline cases
163
+ */
164
+ function _parseCreateFactoryCall() {
165
+ _parseCreateFactoryCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(code, filePath) {
166
+ var _yield$parseImports, importResult, externals, importMap, namedExportsMap, createFactoryMatches, match, functionName, fullMatch, urlParam, variantsParam, optionsObjectStr, hasOptions, url, _parseVariantsParamet, variants, namedExports, options, hasPrecompute, precomputeValue, precomputeKeyStart, precomputeValueStart, precomputeValueEnd, nameMatch, slugMatch, skipPrecomputeMatch, precomputeInfo, transformedExternals, _i, _Object$entries, _Object$entries$_i, modulePath, externalImport, live;
167
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
168
+ while (1) switch (_context.prev = _context.next) {
169
+ case 0:
170
+ _context.next = 2;
171
+ return parseImports(code, filePath);
172
+ case 2:
173
+ _yield$parseImports = _context.sent;
174
+ importResult = _yield$parseImports.relative;
175
+ externals = _yield$parseImports.externals;
176
+ importMap = buildImportMap({
177
+ relative: importResult,
178
+ externals: externals
179
+ });
180
+ namedExportsMap = buildNamedExportsMap({
181
+ relative: importResult,
182
+ externals: externals
183
+ }); // Find all create* calls in the code
184
+ createFactoryMatches = findCreateFactoryCalls(code, filePath); // Enforce single create* call per file
185
+ if (!(createFactoryMatches.length > 1)) {
186
+ _context.next = 10;
187
+ break;
188
+ }
189
+ throw new Error("Multiple create* factory calls found in ".concat(filePath, ". Only one create* call per file is supported. Found ").concat(createFactoryMatches.length, " calls."));
190
+ case 10:
191
+ if (!(createFactoryMatches.length === 0)) {
192
+ _context.next = 12;
193
+ break;
194
+ }
195
+ return _context.abrupt("return", null);
196
+ case 12:
197
+ match = createFactoryMatches[0];
198
+ functionName = match.functionName, fullMatch = match.fullMatch, urlParam = match.urlParam, variantsParam = match.variantsParam, optionsObjectStr = match.optionsObjectStr, hasOptions = match.hasOptions; // Validate URL parameter
199
+ validateUrlParameter(urlParam, functionName, filePath);
200
+
201
+ // Validate variants parameter
202
+ validateVariantsParameter(variantsParam, functionName, filePath);
203
+
204
+ // Extract URL (typically import.meta.url)
205
+ url = urlParam.trim(); // Resolve variants for this specific create* call
206
+ _parseVariantsParamet = parseVariantsParameter(variantsParam, importMap, namedExportsMap, functionName, filePath), variants = _parseVariantsParamet.variants, namedExports = _parseVariantsParamet.namedExports; // Parse options object
207
+ options = {};
208
+ hasPrecompute = false;
209
+ // Extract name
210
+ nameMatch = optionsObjectStr.match(/name\s*:\s*['"`]([^'"`]+)['"`]/);
211
+ if (nameMatch) {
212
+ options.name = nameMatch[1];
213
+ }
214
+
215
+ // Extract slug
216
+ slugMatch = optionsObjectStr.match(/slug\s*:\s*['"`]([^'"`]+)['"`]/);
217
+ if (slugMatch) {
218
+ options.slug = slugMatch[1];
219
+ }
220
+
221
+ // Extract skipPrecompute
222
+ skipPrecomputeMatch = optionsObjectStr.match(/skipPrecompute\s*:\s*(true|false)/);
223
+ if (skipPrecomputeMatch) {
224
+ options.skipPrecompute = skipPrecomputeMatch[1] === 'true';
225
+ }
226
+
227
+ // Extract precompute value using robust parsing
228
+ precomputeInfo = extractPrecomputeFromOptions(optionsObjectStr);
229
+ if (precomputeInfo) {
230
+ hasPrecompute = true;
231
+ precomputeKeyStart = precomputeInfo.keyStart;
232
+ precomputeValueStart = precomputeInfo.valueStart;
233
+ precomputeValueEnd = precomputeInfo.valueEnd;
234
+ precomputeValue = precomputeInfo.value;
235
+ options.precompute = precomputeValue;
236
+ }
237
+
238
+ // Transform externals from parseImports format to simplified format
239
+ // Only include side-effect imports (where names array is empty)
240
+ transformedExternals = {};
241
+ for (_i = 0, _Object$entries = Object.entries(externals); _i < _Object$entries.length; _i++) {
242
+ _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), modulePath = _Object$entries$_i[0], externalImport = _Object$entries$_i[1];
243
+ // Only include side-effect imports (empty names array)
244
+ if (externalImport.names.length === 0) {
245
+ transformedExternals[modulePath] = []; // Empty array for side-effect imports
246
+ }
247
+ }
248
+
249
+ // Detect if this is a live demo based on function name containing "Live" as a distinct component
250
+ // This catches: createLive, createLiveDemo, createDemoLive, etc.
251
+ // But avoids false positives like: createDelivery, delivery, etc.
252
+ live = /Live/.test(functionName);
253
+ return _context.abrupt("return", {
254
+ functionName: functionName,
255
+ url: url,
256
+ variants: variants,
257
+ namedExports: namedExports,
258
+ options: options,
259
+ fullMatch: fullMatch,
260
+ variantsObjectStr: variantsParam,
261
+ optionsObjectStr: optionsObjectStr,
262
+ hasOptions: hasOptions,
263
+ hasPrecompute: hasPrecompute,
264
+ precomputeValue: hasPrecompute ? precomputeValue : undefined,
265
+ externals: transformedExternals,
266
+ live: live,
267
+ precomputeKeyStart: hasPrecompute ? precomputeKeyStart : undefined,
268
+ precomputeValueStart: hasPrecompute ? precomputeValueStart : undefined,
269
+ precomputeValueEnd: hasPrecompute ? precomputeValueEnd : undefined
270
+ });
271
+ case 32:
272
+ case "end":
273
+ return _context.stop();
274
+ }
275
+ }, _callee);
276
+ }));
277
+ return _parseCreateFactoryCall.apply(this, arguments);
278
+ }
279
+ function findCreateFactoryCalls(code, filePath) {
280
+ var results = [];
281
+
282
+ // Find all create* function calls
283
+ var createFactoryRegex = /\b(create\w*)\s*\(/g;
284
+ var match = createFactoryRegex.exec(code);
285
+ while (match !== null) {
286
+ var functionName = match[1];
287
+ var startIndex = match.index;
288
+ var parenIndex = match.index + match[0].length - 1; // Position of opening parenthesis
289
+
290
+ // Find the matching closing parenthesis
291
+ var parenCount = 0;
292
+ var endIndex = -1;
293
+ for (var i = parenIndex; i < code.length; i += 1) {
294
+ if (code[i] === '(') {
295
+ parenCount += 1;
296
+ } else if (code[i] === ')') {
297
+ parenCount -= 1;
298
+ if (parenCount === 0) {
299
+ endIndex = i;
300
+ break;
301
+ }
302
+ }
303
+ }
304
+ if (endIndex === -1) {
305
+ match = createFactoryRegex.exec(code);
306
+ continue;
307
+ }
308
+ var fullMatch = code.substring(startIndex, endIndex + 1);
309
+ var content = code.substring(parenIndex + 1, endIndex);
310
+
311
+ // Split by commas at the top level, handling nested structures and comments
312
+ var _parseFunctionParamet = parseFunctionParameters(content),
313
+ parts = _parseFunctionParamet.parts,
314
+ objects = _parseFunctionParamet.objects;
315
+
316
+ // Validate the function follows the convention
317
+ if (parts.length < 2 || parts.length > 3) {
318
+ 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?)");
319
+ }
320
+ if (parts.length === 2) {
321
+ var _parts = _slicedToArray(parts, 1),
322
+ urlParam = _parts[0];
323
+
324
+ // The variants parameter can be either an object literal or a single identifier
325
+ var variantsParam = objects[1] || parts[1].trim();
326
+ results.push({
327
+ functionName: functionName,
328
+ fullMatch: fullMatch,
329
+ urlParam: urlParam.trim(),
330
+ variantsParam: variantsParam,
331
+ optionsObjectStr: '{}',
332
+ // Default empty options
333
+ hasOptions: false // No options parameter was provided
334
+ });
335
+ } else if (parts.length === 3) {
336
+ var _parts2 = _slicedToArray(parts, 1),
337
+ _urlParam = _parts2[0];
338
+
339
+ // The variants parameter can be either an object literal or a single identifier
340
+ var _variantsParam = objects[1] || parts[1].trim();
341
+ var optionsObjectStr = objects[2];
342
+ if (!optionsObjectStr) {
343
+ throw new Error("Invalid options parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object but could not parse: ".concat(parts[2].trim()));
344
+ }
345
+ results.push({
346
+ functionName: functionName,
347
+ fullMatch: fullMatch,
348
+ urlParam: _urlParam.trim(),
349
+ variantsParam: _variantsParam,
350
+ optionsObjectStr: optionsObjectStr,
351
+ hasOptions: true // Options parameter was provided
352
+ });
353
+ }
354
+ match = createFactoryRegex.exec(code);
355
+ }
356
+ return results;
357
+ }
358
+
359
+ /**
360
+ * Extracts precompute property from options object using robust parsing
361
+ */
362
+ function extractPrecomputeFromOptions(optionsObjectStr) {
363
+ // Find the precompute property using regex
364
+ var precomputeMatch = optionsObjectStr.match(/precompute\s*:\s*/);
365
+ if (!precomputeMatch) {
366
+ return null;
367
+ }
368
+ var keyStart = precomputeMatch.index;
369
+ var valueStartIndex = keyStart + precomputeMatch[0].length;
370
+
371
+ // Extract the remaining part after "precompute:"
372
+ var remainingStr = optionsObjectStr.substring(valueStartIndex);
373
+
374
+ // Try to extract a balanced object first
375
+ var objectValue = extractBalancedBraces(remainingStr);
376
+ if (objectValue) {
377
+ // It's an object value
378
+ var _actualValueStart = valueStartIndex;
379
+ while (_actualValueStart < optionsObjectStr.length && /\s/.test(optionsObjectStr[_actualValueStart])) {
380
+ _actualValueStart += 1;
381
+ }
382
+ var _valueEnd = _actualValueStart + objectValue.length;
383
+ return {
384
+ keyStart: keyStart,
385
+ valueStart: _actualValueStart,
386
+ valueEnd: _valueEnd,
387
+ value: objectValue // Keep object as string
388
+ };
389
+ }
390
+
391
+ // It's a simple value (true, false, etc.)
392
+ // Parse until comma, newline, or closing brace
393
+ var i = 0;
394
+ var inString = false;
395
+ var stringChar = '';
396
+ while (i < remainingStr.length) {
397
+ var _char = remainingStr[i];
398
+ if (!inString && (_char === '"' || _char === "'" || _char === '`')) {
399
+ inString = true;
400
+ stringChar = _char;
401
+ } else if (inString && _char === stringChar && remainingStr[i - 1] !== '\\') {
402
+ inString = false;
403
+ stringChar = '';
404
+ } else if (!inString && (_char === ',' || _char === '}' || _char === '\n')) {
405
+ break;
406
+ }
407
+ i += 1;
408
+ }
409
+ var valueStr = remainingStr.substring(0, i).trim();
410
+
411
+ // Calculate precise boundaries
412
+ var actualValueStart = valueStartIndex;
413
+ while (actualValueStart < optionsObjectStr.length && /\s/.test(optionsObjectStr[actualValueStart])) {
414
+ actualValueStart += 1;
415
+ }
416
+ var valueEnd = actualValueStart + valueStr.length;
417
+
418
+ // Parse the value
419
+ var parsedValue;
420
+ if (valueStr === 'true') {
421
+ parsedValue = true;
422
+ } else if (valueStr === 'false') {
423
+ parsedValue = false;
424
+ } else {
425
+ parsedValue = valueStr;
426
+ }
427
+ return {
428
+ keyStart: keyStart,
429
+ valueStart: actualValueStart,
430
+ valueEnd: valueEnd,
431
+ value: parsedValue
432
+ };
433
+ }
@@ -12,4 +12,8 @@ export interface ParsedParameters {
12
12
  * Parses function parameters, splitting by top-level commas and extracting object literals.
13
13
  * This combines comma-splitting with object extraction for common use cases.
14
14
  */
15
- export declare function parseFunctionParameters(str: string): ParsedParameters;
15
+ export declare function parseFunctionParameters(str: string): ParsedParameters;
16
+ /**
17
+ * Extracts a balanced brace object from a string, handling leading whitespace and comments
18
+ */
19
+ export declare function extractBalancedBraces(str: string): string | null;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseFunctionParameters.d.ts","sourceRoot":"","sources":["../../../src/pipeline/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;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyEhE"}
@@ -100,7 +100,7 @@ export function parseFunctionParameters(str) {
100
100
  /**
101
101
  * Extracts a balanced brace object from a string, handling leading whitespace and comments
102
102
  */
103
- function extractBalancedBraces(str) {
103
+ export function extractBalancedBraces(str) {
104
104
  // Find the first opening brace, skipping whitespace and comments
105
105
  var startIndex = -1;
106
106
  var inSingleLineComment = false;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Adds or replaces precompute data in createDemo function calls.
3
+ *
4
+ * This function handles multiple scenarios:
5
+ * 1. Replaces any existing 'precompute' property with actual data
6
+ * 2. Adds precompute property to existing options object when missing
7
+ * 3. Adds entire options object with precompute when no options exist
8
+ * 4. Optionally adds an ExternalsProvider property for external dependencies
9
+ *
10
+ * @param source - The source code string containing createDemo calls
11
+ * @param precomputeData - The data object to inject
12
+ * @param demoCallInfo - Information about the parsed demo call structure
13
+ * @param externalsProviderPath - Optional path to the generated externals provider file
14
+ * @returns The modified source code with precompute data injected
15
+ */
16
+ export declare function replacePrecomputeValue(source: string, precomputeData: Record<string, any>, demoCallInfo?: {
17
+ fullMatch: string;
18
+ optionsObjectStr: string;
19
+ hasOptions: boolean;
20
+ hasPrecompute: boolean;
21
+ precomputeValue?: any;
22
+ precomputeKeyStart?: number;
23
+ precomputeValueStart?: number;
24
+ precomputeValueEnd?: number;
25
+ }, externalsProviderPath?: string): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replacePrecomputeValue.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnC,YAAY,CAAC,EAAE;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,EACD,qBAAqB,CAAC,EAAE,MAAM,GAC7B,MAAM,CA8DR"}
@@ -0,0 +1,73 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ /**
3
+ * Adds or replaces precompute data in createDemo function calls.
4
+ *
5
+ * This function handles multiple scenarios:
6
+ * 1. Replaces any existing 'precompute' property with actual data
7
+ * 2. Adds precompute property to existing options object when missing
8
+ * 3. Adds entire options object with precompute when no options exist
9
+ * 4. Optionally adds an ExternalsProvider property for external dependencies
10
+ *
11
+ * @param source - The source code string containing createDemo calls
12
+ * @param precomputeData - The data object to inject
13
+ * @param demoCallInfo - Information about the parsed demo call structure
14
+ * @param externalsProviderPath - Optional path to the generated externals provider file
15
+ * @returns The modified source code with precompute data injected
16
+ */
17
+ export function replacePrecomputeValue(source, precomputeData, demoCallInfo, externalsProviderPath) {
18
+ // Convert the data to a properly formatted JSON string
19
+ var precomputeDataString = JSON.stringify(precomputeData, null, 2);
20
+
21
+ // If no demoCallInfo provided, return unchanged
22
+ if (!demoCallInfo) {
23
+ return source;
24
+ }
25
+ var callInfo = demoCallInfo;
26
+ var fullMatch = callInfo.fullMatch,
27
+ optionsObjectStr = callInfo.optionsObjectStr,
28
+ hasOptions = callInfo.hasOptions,
29
+ hasPrecompute = callInfo.hasPrecompute,
30
+ precomputeKeyStart = callInfo.precomputeKeyStart,
31
+ precomputeValueEnd = callInfo.precomputeValueEnd;
32
+
33
+ // Prepare externals provider import and property if needed
34
+ var modifiedSource = source;
35
+ var additionalProperties = '';
36
+ if (externalsProviderPath) {
37
+ // Add import statement at the top of the file
38
+ var importStatement = "import { CodeExternalsProvider } from '".concat(externalsProviderPath, "';\n");
39
+ modifiedSource = importStatement + modifiedSource;
40
+
41
+ // Prepare the CodeExternalsProvider property
42
+ additionalProperties = ", CodeExternalsProvider";
43
+ }
44
+
45
+ // Case 1: Replace existing precompute property (from key start to value end)
46
+ if (hasPrecompute && precomputeKeyStart !== undefined && precomputeValueEnd !== undefined) {
47
+ // Replace the entire property from key start to value end
48
+ var beforeProperty = optionsObjectStr.substring(0, precomputeKeyStart);
49
+ var afterProperty = optionsObjectStr.substring(precomputeValueEnd);
50
+ var newOptionsStr = "".concat(beforeProperty, "precompute: ").concat(precomputeDataString).concat(additionalProperties).concat(afterProperty);
51
+ return modifiedSource.replace(optionsObjectStr, newOptionsStr);
52
+ }
53
+
54
+ // Case 2: Add precompute to existing options object
55
+ if (hasOptions) {
56
+ var optionsMatch = optionsObjectStr.match(/^(\s*\{)([\s\S]*?)(\s*\}\s*)$/);
57
+ if (optionsMatch) {
58
+ var _optionsMatch = _slicedToArray(optionsMatch, 4),
59
+ openBrace = _optionsMatch[1],
60
+ content = _optionsMatch[2],
61
+ closeBrace = _optionsMatch[3];
62
+ var trimmedContent = content.trim();
63
+ var needsComma = trimmedContent !== '' && !trimmedContent.endsWith(',');
64
+ var newOptions = "".concat(openBrace).concat(content).concat(needsComma ? ',' : '', "\n precompute: ").concat(precomputeDataString).concat(additionalProperties).concat(closeBrace);
65
+ return modifiedSource.replace(optionsObjectStr, newOptions);
66
+ }
67
+ } else {
68
+ // Case 3: Add entire options object
69
+ var newCall = fullMatch.replace(/(\s*)\)$/, "$1, { precompute: ".concat(precomputeDataString).concat(additionalProperties, " })"));
70
+ return modifiedSource.replace(fullMatch, newCall);
71
+ }
72
+ return source;
73
+ }
@@ -0,0 +1 @@
1
+ export * from "./loadServerCodeMeta.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadServerCodeMeta/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./loadServerCodeMeta.js";
@@ -1,12 +1,12 @@
1
- import type { LoadCodeMeta } from "../CodeHighlighter/types.js";
1
+ import type { LoadCodeMeta } from "../../CodeHighlighter/types.js";
2
2
  export interface CreateLoadCodeMetaOptions {}
3
3
  /**
4
- * Default serverLoadCodeMeta function that resolves variant paths from demo files.
4
+ * Default loadServerCodeMeta function that resolves variant paths from demo files.
5
5
  * This function is used to load code metadata for demos, specifically resolving paths for variants defined in the demo files.
6
6
  * It reads the demo file, parses it to find `createDemo` calls with variants, and resolves the paths for those variants.
7
7
  * It returns a Code object mapping variant names to their resolved file URLs.
8
8
  */
9
- export declare const serverLoadCodeMeta: LoadCodeMeta;
9
+ export declare const loadServerCodeMeta: LoadCodeMeta;
10
10
  /**
11
11
  * Creates a loadCodeMeta function that resolves variant paths from demo files.
12
12
  *
@@ -21,4 +21,4 @@ export declare const serverLoadCodeMeta: LoadCodeMeta;
21
21
  * @param options - Configuration options (currently unused)
22
22
  * @returns LoadCodeMeta function that takes a URL and returns Promise<Code>
23
23
  */
24
- export declare function createServerLoadCodeMeta(_options?: CreateLoadCodeMetaOptions): LoadCodeMeta;
24
+ export declare function createLoadServerCodeMeta(_options?: CreateLoadCodeMetaOptions): LoadCodeMeta;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadServerCodeMeta.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadServerCodeMeta/loadServerCodeMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAQ,MAAM,6BAA6B,CAAC;AAKtE,MAAM,WAAW,yBAAyB;CAEzC;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAA6B,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,GAAE,yBAA8B,GAAG,YAAY,CAyC/F"}
@@ -4,13 +4,14 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import { readFile } from 'node:fs/promises';
5
5
  import { resolveVariantPathsWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
6
6
  import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
7
+ import { getFileNameFromUrl } from "../loaderUtils/index.js";
7
8
  /**
8
- * Default serverLoadCodeMeta function that resolves variant paths from demo files.
9
+ * Default loadServerCodeMeta function that resolves variant paths from demo files.
9
10
  * This function is used to load code metadata for demos, specifically resolving paths for variants defined in the demo files.
10
11
  * It reads the demo file, parses it to find `createDemo` calls with variants, and resolves the paths for those variants.
11
12
  * It returns a Code object mapping variant names to their resolved file URLs.
12
13
  */
13
- export var serverLoadCodeMeta = createServerLoadCodeMeta();
14
+ export var loadServerCodeMeta = createLoadServerCodeMeta();
14
15
 
15
16
  /**
16
17
  * Creates a loadCodeMeta function that resolves variant paths from demo files.
@@ -26,7 +27,7 @@ export var serverLoadCodeMeta = createServerLoadCodeMeta();
26
27
  * @param options - Configuration options (currently unused)
27
28
  * @returns LoadCodeMeta function that takes a URL and returns Promise<Code>
28
29
  */
29
- export function createServerLoadCodeMeta() {
30
+ export function createLoadServerCodeMeta() {
30
31
  var _options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
32
  return /*#__PURE__*/function () {
32
33
  var _loadCodeMeta = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
@@ -60,7 +61,21 @@ export function createServerLoadCodeMeta() {
60
61
  var _ref2 = _slicedToArray(_ref, 2),
61
62
  variantName = _ref2[0],
62
63
  fileUrl = _ref2[1];
64
+ var namedExport = demoCall.namedExports[variantName];
63
65
  code[variantName] = fileUrl;
66
+ if (namedExport) {
67
+ var _getFileNameFromUrl = getFileNameFromUrl(fileUrl),
68
+ fileName = _getFileNameFromUrl.fileName;
69
+ if (!fileName) {
70
+ throw new Error("Cannot determine fileName from URL \"".concat(fileUrl, "\" for variant \"").concat(variantName, "\". ") + "Please ensure the URL has a valid file extension.");
71
+ }
72
+ code[variantName] = {
73
+ url: fileUrl,
74
+ fileName: fileName,
75
+ namedExport: namedExport
76
+ };
77
+ }
78
+ // TODO: will this cause loadVariantMeta not to run? Maybe we should always run it
64
79
  });
65
80
  return _context.abrupt("return", code);
66
81
  case 15:
@@ -0,0 +1 @@
1
+ export * from "./loadServerSource.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadServerSource/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./loadServerSource.js";