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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/CodeControllerContext/CodeControllerContext.d.ts +1 -1
  2. package/CodeControllerContext/CodeControllerContext.d.ts.map +1 -1
  3. package/CodeControllerContext/index.d.ts.map +1 -1
  4. package/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
  5. package/CodeExternalsContext/CodeExternalsContext.d.ts.map +1 -0
  6. package/CodeExternalsContext/CodeExternalsContext.js +7 -0
  7. package/CodeExternalsContext/index.d.ts +1 -0
  8. package/CodeExternalsContext/index.d.ts.map +1 -0
  9. package/CodeExternalsContext/index.js +1 -0
  10. package/CodeHighlighter/CodeHighlighter.d.ts +1 -1
  11. package/CodeHighlighter/CodeHighlighter.d.ts.map +1 -1
  12. package/CodeHighlighter/CodeHighlighter.js +235 -86
  13. package/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -1
  14. package/CodeHighlighter/CodeHighlighterClient.js +500 -62
  15. package/CodeHighlighter/CodeHighlighterContext.d.ts +2 -0
  16. package/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -1
  17. package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +1 -1
  18. package/CodeHighlighter/CodeHighlighterFallbackContext.js +3 -1
  19. package/CodeHighlighter/applyTransform.d.ts.map +1 -1
  20. package/CodeHighlighter/codeToFallbackProps.d.ts +2 -2
  21. package/CodeHighlighter/codeToFallbackProps.d.ts.map +1 -1
  22. package/CodeHighlighter/codeToFallbackProps.js +8 -5
  23. package/CodeHighlighter/errors.d.ts.map +1 -1
  24. package/CodeHighlighter/hasAllVariants.d.ts.map +1 -1
  25. package/CodeHighlighter/index.d.ts.map +1 -1
  26. package/CodeHighlighter/loadFallbackCode.d.ts +3 -2
  27. package/CodeHighlighter/loadFallbackCode.d.ts.map +1 -1
  28. package/CodeHighlighter/loadFallbackCode.js +325 -161
  29. package/CodeHighlighter/loadVariant.d.ts +3 -2
  30. package/CodeHighlighter/loadVariant.d.ts.map +1 -1
  31. package/CodeHighlighter/loadVariant.js +604 -229
  32. package/CodeHighlighter/maybeInitialData.d.ts +1 -1
  33. package/CodeHighlighter/maybeInitialData.d.ts.map +1 -1
  34. package/CodeHighlighter/parseCode.d.ts.map +1 -1
  35. package/CodeHighlighter/parseCode.js +14 -2
  36. package/CodeHighlighter/parseControlledCode.d.ts.map +1 -1
  37. package/CodeHighlighter/parseControlledCode.js +12 -1
  38. package/CodeHighlighter/transformCode.d.ts +1 -0
  39. package/CodeHighlighter/transformCode.d.ts.map +1 -1
  40. package/CodeHighlighter/transformCode.js +43 -3
  41. package/CodeHighlighter/transformParsedSource.d.ts.map +1 -1
  42. package/CodeHighlighter/transformSource.d.ts.map +1 -1
  43. package/CodeHighlighter/types.d.ts +39 -17
  44. package/CodeHighlighter/types.d.ts.map +1 -1
  45. package/CodeProvider/CodeContext.d.ts.map +1 -1
  46. package/CodeProvider/CodeProvider.d.ts.map +1 -1
  47. package/CodeProvider/CodeProvider.js +21 -6
  48. package/CodeProvider/index.d.ts +1 -2
  49. package/CodeProvider/index.d.ts.map +1 -1
  50. package/CodeProvider/index.js +1 -2
  51. package/abstractCreateDemo/abstractCreateDemo.d.ts +35 -0
  52. package/abstractCreateDemo/abstractCreateDemo.d.ts.map +1 -0
  53. package/abstractCreateDemo/abstractCreateDemo.js +91 -0
  54. package/abstractCreateDemo/index.d.ts +1 -0
  55. package/abstractCreateDemo/index.d.ts.map +1 -0
  56. package/abstractCreateDemo/index.js +1 -0
  57. package/createDemoData/createDemoData.d.ts +44 -0
  58. package/createDemoData/createDemoData.d.ts.map +1 -0
  59. package/createDemoData/createDemoData.js +75 -0
  60. package/createDemoData/index.d.ts +1 -0
  61. package/createDemoData/index.d.ts.map +1 -0
  62. package/createDemoData/index.js +1 -0
  63. package/createDemoData/types.d.ts +28 -0
  64. package/createDemoData/types.d.ts.map +1 -0
  65. package/createDemoData/types.js +1 -0
  66. package/package.json +15 -9
  67. package/pipeline/hastUtils/hastUtils.d.ts.map +1 -0
  68. package/{hast/hast.js → pipeline/hastUtils/hastUtils.js} +2 -1
  69. package/pipeline/hastUtils/index.d.ts +1 -0
  70. package/pipeline/hastUtils/index.d.ts.map +1 -0
  71. package/pipeline/hastUtils/index.js +1 -0
  72. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +54 -0
  73. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +1 -0
  74. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +465 -0
  75. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +15 -0
  76. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +1 -0
  77. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +253 -0
  78. package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +1 -0
  79. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +20 -0
  80. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -0
  81. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +228 -0
  82. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseCreateFactoryCall.d.ts +12 -1
  83. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +1 -0
  84. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +433 -0
  85. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.d.ts +5 -1
  86. package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +1 -0
  87. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.js +1 -1
  88. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +25 -0
  89. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +1 -0
  90. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
  91. package/pipeline/loadServerCodeMeta/index.d.ts +1 -0
  92. package/pipeline/loadServerCodeMeta/index.d.ts.map +1 -0
  93. package/pipeline/loadServerCodeMeta/index.js +1 -0
  94. package/{loadServerCodeMeta/serverLoadCodeMeta.d.ts → pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts} +4 -4
  95. package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +1 -0
  96. package/{loadServerCodeMeta/serverLoadCodeMeta.js → pipeline/loadServerCodeMeta/loadServerCodeMeta.js} +18 -3
  97. package/pipeline/loadServerSource/index.d.ts +1 -0
  98. package/pipeline/loadServerSource/index.d.ts.map +1 -0
  99. package/pipeline/loadServerSource/index.js +1 -0
  100. package/{loadServerSource/serverLoadSource.d.ts → pipeline/loadServerSource/loadServerSource.d.ts} +5 -5
  101. package/pipeline/loadServerSource/loadServerSource.d.ts.map +1 -0
  102. package/pipeline/loadServerSource/loadServerSource.js +135 -0
  103. package/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
  104. package/pipeline/loaderUtils/externalsToPackages.d.ts.map +1 -0
  105. package/pipeline/loaderUtils/externalsToPackages.js +46 -0
  106. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
  107. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +1 -0
  108. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
  109. package/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.d.ts +1 -0
  110. package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
  111. package/pipeline/loaderUtils/getFileNameFromUrl.js +66 -0
  112. package/pipeline/loaderUtils/index.d.ts +7 -0
  113. package/pipeline/loaderUtils/index.d.ts.map +1 -0
  114. package/pipeline/loaderUtils/index.js +7 -0
  115. package/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
  116. package/pipeline/loaderUtils/mergeExternals.d.ts.map +1 -0
  117. package/pipeline/loaderUtils/mergeExternals.js +72 -0
  118. package/pipeline/loaderUtils/parseImports.d.ts +20 -0
  119. package/pipeline/loaderUtils/parseImports.d.ts.map +1 -0
  120. package/pipeline/loaderUtils/parseImports.js +307 -0
  121. package/{loaderUtils/processImports.d.ts → pipeline/loaderUtils/processRelativeImports.d.ts} +2 -2
  122. package/pipeline/loaderUtils/processRelativeImports.d.ts.map +1 -0
  123. package/pipeline/loaderUtils/processRelativeImports.js +352 -0
  124. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePath.d.ts +19 -6
  125. package/pipeline/loaderUtils/resolveModulePath.d.ts.map +1 -0
  126. package/pipeline/loaderUtils/resolveModulePath.js +1449 -0
  127. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.d.ts +6 -3
  128. package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
  129. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.js +8 -4
  130. package/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
  131. package/pipeline/loaderUtils/rewriteImports.d.ts.map +1 -0
  132. package/pipeline/loaderUtils/rewriteImports.js +35 -0
  133. package/pipeline/parseSource/grammars.d.ts.map +1 -0
  134. package/pipeline/parseSource/index.d.ts.map +1 -0
  135. package/pipeline/parseSource/parseSource.d.ts +3 -0
  136. package/pipeline/parseSource/parseSource.d.ts.map +1 -0
  137. package/{parseSource → pipeline/parseSource}/parseSource.js +15 -5
  138. package/pipeline/transformHtmlCode/index.d.ts +2 -0
  139. package/pipeline/transformHtmlCode/index.d.ts.map +1 -0
  140. package/pipeline/transformHtmlCode/index.js +4 -0
  141. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
  142. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +1 -0
  143. package/pipeline/transformHtmlCode/transformHtmlCode.js +303 -0
  144. package/pipeline/transformMarkdownCode/index.d.ts +2 -0
  145. package/pipeline/transformMarkdownCode/index.d.ts.map +1 -0
  146. package/pipeline/transformMarkdownCode/index.js +4 -0
  147. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
  148. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +1 -0
  149. package/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
  150. package/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
  151. package/pipeline/transformTypescriptToJavascript/index.d.ts.map +1 -0
  152. package/pipeline/transformTypescriptToJavascript/index.js +1 -0
  153. package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +1 -0
  154. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
  155. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +1 -0
  156. package/{transformTsToJs/transformTsToJs.js → pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js} +4 -4
  157. package/useCode/index.d.ts.map +1 -1
  158. package/useCode/useCode.d.ts +14 -11
  159. package/useCode/useCode.d.ts.map +1 -1
  160. package/useCode/useCode.js +94 -364
  161. package/useCode/useCodeUtils.d.ts +45 -0
  162. package/useCode/useCodeUtils.d.ts.map +1 -0
  163. package/useCode/useCodeUtils.js +240 -0
  164. package/useCode/useCopyFunctionality.d.ts +17 -0
  165. package/useCode/useCopyFunctionality.d.ts.map +1 -0
  166. package/useCode/useCopyFunctionality.js +28 -0
  167. package/useCode/useFileNavigation.d.ts +49 -0
  168. package/useCode/useFileNavigation.d.ts.map +1 -0
  169. package/useCode/useFileNavigation.js +398 -0
  170. package/useCode/useSourceEditing.d.ts +19 -0
  171. package/useCode/useSourceEditing.d.ts.map +1 -0
  172. package/useCode/useSourceEditing.js +32 -0
  173. package/useCode/useTransformManagement.d.ts +28 -0
  174. package/useCode/useTransformManagement.d.ts.map +1 -0
  175. package/useCode/useTransformManagement.js +82 -0
  176. package/useCode/useUIState.d.ts +16 -0
  177. package/useCode/useUIState.d.ts.map +1 -0
  178. package/useCode/useUIState.js +21 -0
  179. package/useCode/useVariantSelection.d.ts +21 -0
  180. package/useCode/useVariantSelection.d.ts.map +1 -0
  181. package/useCode/useVariantSelection.js +84 -0
  182. package/useCopier/index.d.ts +1 -1
  183. package/useCopier/index.d.ts.map +1 -1
  184. package/useCopier/index.js +5 -5
  185. package/useDemo/createCodeSandbox.d.ts +18 -0
  186. package/useDemo/createCodeSandbox.d.ts.map +1 -0
  187. package/useDemo/createCodeSandbox.js +48 -0
  188. package/useDemo/createStackBlitz.d.ts +22 -0
  189. package/useDemo/createStackBlitz.d.ts.map +1 -0
  190. package/useDemo/createStackBlitz.js +38 -0
  191. package/useDemo/examineVariant.d.ts +25 -0
  192. package/useDemo/examineVariant.d.ts.map +1 -0
  193. package/useDemo/examineVariant.js +134 -0
  194. package/useDemo/exportVariant.d.ts +110 -0
  195. package/useDemo/exportVariant.d.ts.map +1 -0
  196. package/useDemo/exportVariant.js +320 -0
  197. package/useDemo/exportVariantAsCra.d.ts +15 -0
  198. package/useDemo/exportVariantAsCra.d.ts.map +1 -0
  199. package/useDemo/exportVariantAsCra.js +56 -0
  200. package/useDemo/flattenVariant.d.ts +17 -0
  201. package/useDemo/flattenVariant.d.ts.map +1 -0
  202. package/useDemo/flattenVariant.js +206 -0
  203. package/useDemo/index.d.ts +6 -39
  204. package/useDemo/index.d.ts.map +1 -1
  205. package/useDemo/index.js +6 -17
  206. package/useDemo/useDemo.d.ts +79 -0
  207. package/useDemo/useDemo.d.ts.map +1 -0
  208. package/useDemo/useDemo.js +174 -0
  209. package/useLocalStorageState/index.d.ts +2 -0
  210. package/useLocalStorageState/index.d.ts.map +1 -0
  211. package/useLocalStorageState/index.js +2 -0
  212. package/useLocalStorageState/useLocalStorageState.d.ts +14 -0
  213. package/useLocalStorageState/useLocalStorageState.d.ts.map +1 -0
  214. package/useLocalStorageState/useLocalStorageState.js +128 -0
  215. package/useOnHydrate/index.d.ts.map +1 -1
  216. package/useOnHydrate/useOnHydrate.d.ts.map +1 -1
  217. package/useOnIdle/index.d.ts.map +1 -1
  218. package/useOnIdle/useOnIdle.d.ts.map +1 -1
  219. package/useUrlHashState/index.d.ts +1 -0
  220. package/useUrlHashState/index.d.ts.map +1 -0
  221. package/useUrlHashState/index.js +1 -0
  222. package/useUrlHashState/useUrlHashState.d.ts +50 -0
  223. package/useUrlHashState/useUrlHashState.d.ts.map +1 -0
  224. package/useUrlHashState/useUrlHashState.js +113 -0
  225. package/hast/hast.d.ts.map +0 -1
  226. package/hast/index.d.ts +0 -1
  227. package/hast/index.d.ts.map +0 -1
  228. package/hast/index.js +0 -1
  229. package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
  230. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
  231. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
  232. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -194
  233. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
  234. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
  235. package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
  236. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
  237. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
  238. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
  239. package/loadServerCodeMeta/index.d.ts +0 -1
  240. package/loadServerCodeMeta/index.d.ts.map +0 -1
  241. package/loadServerCodeMeta/index.js +0 -1
  242. package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
  243. package/loadServerSource/index.d.ts +0 -1
  244. package/loadServerSource/index.d.ts.map +0 -1
  245. package/loadServerSource/index.js +0 -1
  246. package/loadServerSource/serverLoadSource.d.ts.map +0 -1
  247. package/loadServerSource/serverLoadSource.js +0 -100
  248. package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
  249. package/loaderUtils/getFileNameFromUrl.js +0 -32
  250. package/loaderUtils/index.d.ts +0 -5
  251. package/loaderUtils/index.d.ts.map +0 -1
  252. package/loaderUtils/index.js +0 -5
  253. package/loaderUtils/processImports.d.ts.map +0 -1
  254. package/loaderUtils/processImports.js +0 -82
  255. package/loaderUtils/resolveImports.d.ts +0 -4
  256. package/loaderUtils/resolveImports.d.ts.map +0 -1
  257. package/loaderUtils/resolveImports.js +0 -71
  258. package/loaderUtils/resolveModulePath.d.ts.map +0 -1
  259. package/loaderUtils/resolveModulePath.js +0 -862
  260. package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
  261. package/loaderUtils/rewriteImports.d.ts +0 -9
  262. package/loaderUtils/rewriteImports.d.ts.map +0 -1
  263. package/loaderUtils/rewriteImports.js +0 -57
  264. package/parseSource/grammars.d.ts.map +0 -1
  265. package/parseSource/index.d.ts.map +0 -1
  266. package/parseSource/parseSource.d.ts +0 -3
  267. package/parseSource/parseSource.d.ts.map +0 -1
  268. package/transformRelativeMarkdownPaths/index.d.ts +0 -2
  269. package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
  270. package/transformRelativeMarkdownPaths/index.js +0 -4
  271. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
  272. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
  273. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
  274. package/transformTsToJs/index.d.ts +0 -1
  275. package/transformTsToJs/index.d.ts.map +0 -1
  276. package/transformTsToJs/index.js +0 -1
  277. package/transformTsToJs/removeTypes.d.ts.map +0 -1
  278. package/transformTsToJs/transformTsToJs.d.ts +0 -3
  279. package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
  280. /package/{hast/hast.d.ts → pipeline/hastUtils/hastUtils.d.ts} +0 -0
  281. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.d.ts +0 -0
  282. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.js +0 -0
  283. /package/{parseSource → pipeline/parseSource}/grammars.d.ts +0 -0
  284. /package/{parseSource → pipeline/parseSource}/grammars.js +0 -0
  285. /package/{parseSource → pipeline/parseSource}/index.d.ts +0 -0
  286. /package/{parseSource → pipeline/parseSource}/index.js +0 -0
  287. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.d.ts +0 -0
  288. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.js +0 -0
@@ -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,194 +0,0 @@
1
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
- import { loadVariant } from "../CodeHighlighter/loadVariant.js";
6
- import { parseSourceFactory } from "../parseSource/index.js";
7
- import { TsToJsTransformer } from "../transformTsToJs/index.js";
8
- import { parseCreateFactoryCall } from "./parseCreateFactoryCall.js";
9
- import { resolveVariantPathsWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
10
- import { replacePrecomputeValue } from "./replacePrecomputeValue.js";
11
- import { createServerLoadSource } from "../loadServerSource/index.js";
12
- /**
13
- * Webpack loader that processes demo files and precomputes variant data.
14
- *
15
- * This loader:
16
- * 1. Parses demo files to find a single createDemo call with precompute: true
17
- * 2. Resolves all variant entry point paths using resolveModulePathsWithFs
18
- * 3. Uses loadVariant to handle all loading, parsing, and transformation:
19
- * - loadSource: Loads individual files and extracts dependencies
20
- * - loadVariantMeta: Creates basic variant structure
21
- * - parseSource: Applies syntax highlighting using Starry Night
22
- * - sourceTransformers: Handles TypeScript to JavaScript conversion
23
- * 4. loadVariant handles recursive dependency loading automatically
24
- * 5. Adds all dependencies to webpack's watch list
25
- * 6. Replaces precompute: true with the actual precomputed data using replacePrecomputeValue
26
- *
27
- * Note: Only supports one createDemo call per file. Will throw an error if multiple calls are found.
28
- *
29
- * Features:
30
- * - Proper variant entry point resolution using resolveModulePathsWithFs
31
- * - Complete dependency tree loading handled by loadVariant
32
- * - Syntax highlighting using Starry Night (via parseSource)
33
- * - TypeScript to JavaScript transformation (via transformTsToJs)
34
- * - Webpack dependency tracking for hot reloading
35
- * - Precise precompute value replacement (via replacePrecomputeValue)
36
- *
37
- * Example input:
38
- * ```typescript
39
- * import { createDemo } from '@/functions/createDemo';
40
- * import CssModules from './CssModules';
41
- * import Tailwind from './Tailwind';
42
- *
43
- * export const CodeDemo = createDemo(
44
- * import.meta.url,
45
- * { CssModules, Tailwind },
46
- * {
47
- * name: 'Basic Code Block',
48
- * slug: 'code',
49
- * precompute: true,
50
- * },
51
- * );
52
- * ```
53
- *
54
- * Example output (precompute: true replaced with processed data):
55
- * The precompute property is replaced with an object containing:
56
- * - fileName: The main file name
57
- * - source: HAST nodes with syntax highlighting applied
58
- * - extraFiles: Object containing additional dependency files
59
- * - transforms: Object with language variants (e.g., JavaScript version from TypeScript)
60
- */
61
- export function loadPrecomputedCodeHighlighter(_x) {
62
- return _loadPrecomputedCodeHighlighter.apply(this, arguments);
63
- }
64
- function _loadPrecomputedCodeHighlighter() {
65
- _loadPrecomputedCodeHighlighter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(source) {
66
- var _this = this;
67
- var callback, demoCall, variantData, allDependencies, resolvedVariantMap, loadSource, sourceTransformers, sourceParser, variantPromises, variantResults, _iterator, _step, result, modifiedSource;
68
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
69
- while (1) switch (_context2.prev = _context2.next) {
70
- case 0:
71
- callback = this.async();
72
- this.cacheable();
73
- _context2.prev = 2;
74
- _context2.next = 5;
75
- return parseCreateFactoryCall(source, this.resourcePath);
76
- case 5:
77
- demoCall = _context2.sent;
78
- if (demoCall) {
79
- _context2.next = 9;
80
- break;
81
- }
82
- callback(null, source);
83
- return _context2.abrupt("return");
84
- case 9:
85
- if (demoCall.options.precompute) {
86
- _context2.next = 12;
87
- break;
88
- }
89
- callback(null, source);
90
- return _context2.abrupt("return");
91
- case 12:
92
- // Load variant data for all variants
93
- variantData = {};
94
- allDependencies = []; // Resolve all variant entry point paths using resolveVariantPathsWithFs
95
- _context2.next = 16;
96
- return resolveVariantPathsWithFs(demoCall.variants);
97
- case 16:
98
- resolvedVariantMap = _context2.sent;
99
- // Create loader functions
100
- loadSource = createServerLoadSource({
101
- includeDependencies: true,
102
- storeAt: 'flat' // TODO: this should be configurable
103
- }); // Setup source transformers for TypeScript to JavaScript conversion
104
- sourceTransformers = [TsToJsTransformer]; // Create sourceParser promise for syntax highlighting
105
- sourceParser = parseSourceFactory(); // Process variants in parallel
106
- variantPromises = Array.from(resolvedVariantMap.entries()).map(/*#__PURE__*/function () {
107
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
108
- var _ref3, variantName, fileUrl, _yield$loadVariant, processedVariant, dependencies;
109
- return _regeneratorRuntime().wrap(function _callee$(_context) {
110
- while (1) switch (_context.prev = _context.next) {
111
- case 0:
112
- _ref3 = _slicedToArray(_ref, 2), variantName = _ref3[0], fileUrl = _ref3[1];
113
- _context.prev = 1;
114
- _context.next = 4;
115
- return loadVariant(fileUrl,
116
- // URL for the variant entry point (already includes file://)
117
- variantName, fileUrl,
118
- // Let loadVariantMeta handle creating the initial variant
119
- sourceParser,
120
- // For syntax highlighting
121
- loadSource,
122
- // For loading source files and dependencies
123
- undefined, sourceTransformers,
124
- // For TypeScript to JavaScript conversion
125
- {
126
- maxDepth: 5
127
- });
128
- case 4:
129
- _yield$loadVariant = _context.sent;
130
- processedVariant = _yield$loadVariant.code;
131
- dependencies = _yield$loadVariant.dependencies;
132
- return _context.abrupt("return", {
133
- variantName: variantName,
134
- variantData: processedVariant,
135
- // processedVariant is a complete VariantCode
136
- dependencies: dependencies // All files that were loaded
137
- });
138
- case 10:
139
- _context.prev = 10;
140
- _context.t0 = _context["catch"](1);
141
- console.warn("Failed to load variant ".concat(variantName, " from ").concat(fileUrl, ":"), _context.t0);
142
- return _context.abrupt("return", null);
143
- case 14:
144
- case "end":
145
- return _context.stop();
146
- }
147
- }, _callee, null, [[1, 10]]);
148
- }));
149
- return function (_x2) {
150
- return _ref2.apply(this, arguments);
151
- };
152
- }());
153
- _context2.next = 23;
154
- return Promise.all(variantPromises);
155
- case 23:
156
- variantResults = _context2.sent;
157
- // Process results and collect dependencies
158
- _iterator = _createForOfIteratorHelper(variantResults);
159
- try {
160
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
161
- result = _step.value;
162
- if (result) {
163
- variantData[result.variantName] = result.variantData;
164
- result.dependencies.forEach(function (file) {
165
- allDependencies.push(file);
166
- });
167
- }
168
- }
169
-
170
- // Replace 'precompute: true' with the actual precomputed data
171
- } catch (err) {
172
- _iterator.e(err);
173
- } finally {
174
- _iterator.f();
175
- }
176
- modifiedSource = replacePrecomputeValue(source, variantData); // Add all dependencies to webpack's watch list
177
- allDependencies.forEach(function (dep) {
178
- return _this.addDependency(dep);
179
- });
180
- callback(null, modifiedSource);
181
- _context2.next = 34;
182
- break;
183
- case 31:
184
- _context2.prev = 31;
185
- _context2.t0 = _context2["catch"](2);
186
- callback(_context2.t0 instanceof Error ? _context2.t0 : new Error(String(_context2.t0)));
187
- case 34:
188
- case "end":
189
- return _context2.stop();
190
- }
191
- }, _callee2, this, [[2, 31]]);
192
- }));
193
- return _loadPrecomputedCodeHighlighter.apply(this, arguments);
194
- }
@@ -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"}