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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/CodeControllerContext/CodeControllerContext.d.ts +1 -1
  2. package/CodeControllerContext/CodeControllerContext.d.ts.map +1 -1
  3. package/CodeControllerContext/index.d.ts.map +1 -1
  4. package/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
  5. package/CodeExternalsContext/CodeExternalsContext.d.ts.map +1 -0
  6. package/CodeExternalsContext/CodeExternalsContext.js +7 -0
  7. package/CodeExternalsContext/index.d.ts +1 -0
  8. package/CodeExternalsContext/index.d.ts.map +1 -0
  9. package/CodeExternalsContext/index.js +1 -0
  10. package/CodeHighlighter/CodeHighlighter.d.ts +1 -1
  11. package/CodeHighlighter/CodeHighlighter.d.ts.map +1 -1
  12. package/CodeHighlighter/CodeHighlighter.js +235 -86
  13. package/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -1
  14. package/CodeHighlighter/CodeHighlighterClient.js +500 -62
  15. package/CodeHighlighter/CodeHighlighterContext.d.ts +2 -0
  16. package/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -1
  17. package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +1 -1
  18. package/CodeHighlighter/CodeHighlighterFallbackContext.js +3 -1
  19. package/CodeHighlighter/applyTransform.d.ts.map +1 -1
  20. package/CodeHighlighter/codeToFallbackProps.d.ts +2 -2
  21. package/CodeHighlighter/codeToFallbackProps.d.ts.map +1 -1
  22. package/CodeHighlighter/codeToFallbackProps.js +8 -5
  23. package/CodeHighlighter/errors.d.ts.map +1 -1
  24. package/CodeHighlighter/hasAllVariants.d.ts.map +1 -1
  25. package/CodeHighlighter/index.d.ts.map +1 -1
  26. package/CodeHighlighter/loadFallbackCode.d.ts +3 -2
  27. package/CodeHighlighter/loadFallbackCode.d.ts.map +1 -1
  28. package/CodeHighlighter/loadFallbackCode.js +325 -161
  29. package/CodeHighlighter/loadVariant.d.ts +3 -2
  30. package/CodeHighlighter/loadVariant.d.ts.map +1 -1
  31. package/CodeHighlighter/loadVariant.js +604 -229
  32. package/CodeHighlighter/maybeInitialData.d.ts +1 -1
  33. package/CodeHighlighter/maybeInitialData.d.ts.map +1 -1
  34. package/CodeHighlighter/parseCode.d.ts.map +1 -1
  35. package/CodeHighlighter/parseCode.js +14 -2
  36. package/CodeHighlighter/parseControlledCode.d.ts.map +1 -1
  37. package/CodeHighlighter/parseControlledCode.js +12 -1
  38. package/CodeHighlighter/transformCode.d.ts +1 -0
  39. package/CodeHighlighter/transformCode.d.ts.map +1 -1
  40. package/CodeHighlighter/transformCode.js +43 -3
  41. package/CodeHighlighter/transformParsedSource.d.ts.map +1 -1
  42. package/CodeHighlighter/transformSource.d.ts.map +1 -1
  43. package/CodeHighlighter/types.d.ts +39 -17
  44. package/CodeHighlighter/types.d.ts.map +1 -1
  45. package/CodeProvider/CodeContext.d.ts.map +1 -1
  46. package/CodeProvider/CodeProvider.d.ts.map +1 -1
  47. package/CodeProvider/CodeProvider.js +21 -6
  48. package/CodeProvider/index.d.ts +1 -2
  49. package/CodeProvider/index.d.ts.map +1 -1
  50. package/CodeProvider/index.js +1 -2
  51. package/abstractCreateDemo/abstractCreateDemo.d.ts +35 -0
  52. package/abstractCreateDemo/abstractCreateDemo.d.ts.map +1 -0
  53. package/abstractCreateDemo/abstractCreateDemo.js +91 -0
  54. package/abstractCreateDemo/index.d.ts +1 -0
  55. package/abstractCreateDemo/index.d.ts.map +1 -0
  56. package/abstractCreateDemo/index.js +1 -0
  57. package/createDemoData/createDemoData.d.ts +44 -0
  58. package/createDemoData/createDemoData.d.ts.map +1 -0
  59. package/createDemoData/createDemoData.js +75 -0
  60. package/createDemoData/index.d.ts +1 -0
  61. package/createDemoData/index.d.ts.map +1 -0
  62. package/createDemoData/index.js +1 -0
  63. package/createDemoData/types.d.ts +28 -0
  64. package/createDemoData/types.d.ts.map +1 -0
  65. package/createDemoData/types.js +1 -0
  66. package/package.json +15 -9
  67. package/pipeline/hastUtils/hastUtils.d.ts.map +1 -0
  68. package/{hast/hast.js → pipeline/hastUtils/hastUtils.js} +2 -1
  69. package/pipeline/hastUtils/index.d.ts +1 -0
  70. package/pipeline/hastUtils/index.d.ts.map +1 -0
  71. package/pipeline/hastUtils/index.js +1 -0
  72. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +54 -0
  73. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +1 -0
  74. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +465 -0
  75. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +15 -0
  76. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +1 -0
  77. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +253 -0
  78. package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +1 -0
  79. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +20 -0
  80. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -0
  81. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +228 -0
  82. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseCreateFactoryCall.d.ts +12 -1
  83. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +1 -0
  84. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +433 -0
  85. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.d.ts +5 -1
  86. package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +1 -0
  87. package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.js +1 -1
  88. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +25 -0
  89. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +1 -0
  90. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
  91. package/pipeline/loadServerCodeMeta/index.d.ts +1 -0
  92. package/pipeline/loadServerCodeMeta/index.d.ts.map +1 -0
  93. package/pipeline/loadServerCodeMeta/index.js +1 -0
  94. package/{loadServerCodeMeta/serverLoadCodeMeta.d.ts → pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts} +4 -4
  95. package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +1 -0
  96. package/{loadServerCodeMeta/serverLoadCodeMeta.js → pipeline/loadServerCodeMeta/loadServerCodeMeta.js} +18 -3
  97. package/pipeline/loadServerSource/index.d.ts +1 -0
  98. package/pipeline/loadServerSource/index.d.ts.map +1 -0
  99. package/pipeline/loadServerSource/index.js +1 -0
  100. package/{loadServerSource/serverLoadSource.d.ts → pipeline/loadServerSource/loadServerSource.d.ts} +5 -5
  101. package/pipeline/loadServerSource/loadServerSource.d.ts.map +1 -0
  102. package/pipeline/loadServerSource/loadServerSource.js +135 -0
  103. package/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
  104. package/pipeline/loaderUtils/externalsToPackages.d.ts.map +1 -0
  105. package/pipeline/loaderUtils/externalsToPackages.js +46 -0
  106. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
  107. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +1 -0
  108. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
  109. package/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.d.ts +1 -0
  110. package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
  111. package/pipeline/loaderUtils/getFileNameFromUrl.js +66 -0
  112. package/pipeline/loaderUtils/index.d.ts +7 -0
  113. package/pipeline/loaderUtils/index.d.ts.map +1 -0
  114. package/pipeline/loaderUtils/index.js +7 -0
  115. package/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
  116. package/pipeline/loaderUtils/mergeExternals.d.ts.map +1 -0
  117. package/pipeline/loaderUtils/mergeExternals.js +72 -0
  118. package/pipeline/loaderUtils/parseImports.d.ts +20 -0
  119. package/pipeline/loaderUtils/parseImports.d.ts.map +1 -0
  120. package/pipeline/loaderUtils/parseImports.js +307 -0
  121. package/{loaderUtils/processImports.d.ts → pipeline/loaderUtils/processRelativeImports.d.ts} +2 -2
  122. package/pipeline/loaderUtils/processRelativeImports.d.ts.map +1 -0
  123. package/pipeline/loaderUtils/processRelativeImports.js +352 -0
  124. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePath.d.ts +19 -6
  125. package/pipeline/loaderUtils/resolveModulePath.d.ts.map +1 -0
  126. package/pipeline/loaderUtils/resolveModulePath.js +1449 -0
  127. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.d.ts +6 -3
  128. package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
  129. package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.js +8 -4
  130. package/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
  131. package/pipeline/loaderUtils/rewriteImports.d.ts.map +1 -0
  132. package/pipeline/loaderUtils/rewriteImports.js +35 -0
  133. package/pipeline/parseSource/grammars.d.ts.map +1 -0
  134. package/pipeline/parseSource/index.d.ts.map +1 -0
  135. package/pipeline/parseSource/parseSource.d.ts +3 -0
  136. package/pipeline/parseSource/parseSource.d.ts.map +1 -0
  137. package/{parseSource → pipeline/parseSource}/parseSource.js +15 -5
  138. package/pipeline/transformHtmlCode/index.d.ts +2 -0
  139. package/pipeline/transformHtmlCode/index.d.ts.map +1 -0
  140. package/pipeline/transformHtmlCode/index.js +4 -0
  141. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
  142. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +1 -0
  143. package/pipeline/transformHtmlCode/transformHtmlCode.js +303 -0
  144. package/pipeline/transformMarkdownCode/index.d.ts +2 -0
  145. package/pipeline/transformMarkdownCode/index.d.ts.map +1 -0
  146. package/pipeline/transformMarkdownCode/index.js +4 -0
  147. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
  148. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +1 -0
  149. package/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
  150. package/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
  151. package/pipeline/transformTypescriptToJavascript/index.d.ts.map +1 -0
  152. package/pipeline/transformTypescriptToJavascript/index.js +1 -0
  153. package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +1 -0
  154. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
  155. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +1 -0
  156. package/{transformTsToJs/transformTsToJs.js → pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js} +4 -4
  157. package/useCode/index.d.ts.map +1 -1
  158. package/useCode/useCode.d.ts +14 -11
  159. package/useCode/useCode.d.ts.map +1 -1
  160. package/useCode/useCode.js +94 -364
  161. package/useCode/useCodeUtils.d.ts +45 -0
  162. package/useCode/useCodeUtils.d.ts.map +1 -0
  163. package/useCode/useCodeUtils.js +240 -0
  164. package/useCode/useCopyFunctionality.d.ts +17 -0
  165. package/useCode/useCopyFunctionality.d.ts.map +1 -0
  166. package/useCode/useCopyFunctionality.js +28 -0
  167. package/useCode/useFileNavigation.d.ts +49 -0
  168. package/useCode/useFileNavigation.d.ts.map +1 -0
  169. package/useCode/useFileNavigation.js +398 -0
  170. package/useCode/useSourceEditing.d.ts +19 -0
  171. package/useCode/useSourceEditing.d.ts.map +1 -0
  172. package/useCode/useSourceEditing.js +32 -0
  173. package/useCode/useTransformManagement.d.ts +28 -0
  174. package/useCode/useTransformManagement.d.ts.map +1 -0
  175. package/useCode/useTransformManagement.js +82 -0
  176. package/useCode/useUIState.d.ts +16 -0
  177. package/useCode/useUIState.d.ts.map +1 -0
  178. package/useCode/useUIState.js +21 -0
  179. package/useCode/useVariantSelection.d.ts +21 -0
  180. package/useCode/useVariantSelection.d.ts.map +1 -0
  181. package/useCode/useVariantSelection.js +84 -0
  182. package/useCopier/index.d.ts +1 -1
  183. package/useCopier/index.d.ts.map +1 -1
  184. package/useCopier/index.js +5 -5
  185. package/useDemo/createCodeSandbox.d.ts +18 -0
  186. package/useDemo/createCodeSandbox.d.ts.map +1 -0
  187. package/useDemo/createCodeSandbox.js +48 -0
  188. package/useDemo/createStackBlitz.d.ts +22 -0
  189. package/useDemo/createStackBlitz.d.ts.map +1 -0
  190. package/useDemo/createStackBlitz.js +38 -0
  191. package/useDemo/examineVariant.d.ts +25 -0
  192. package/useDemo/examineVariant.d.ts.map +1 -0
  193. package/useDemo/examineVariant.js +134 -0
  194. package/useDemo/exportVariant.d.ts +110 -0
  195. package/useDemo/exportVariant.d.ts.map +1 -0
  196. package/useDemo/exportVariant.js +320 -0
  197. package/useDemo/exportVariantAsCra.d.ts +15 -0
  198. package/useDemo/exportVariantAsCra.d.ts.map +1 -0
  199. package/useDemo/exportVariantAsCra.js +56 -0
  200. package/useDemo/flattenVariant.d.ts +17 -0
  201. package/useDemo/flattenVariant.d.ts.map +1 -0
  202. package/useDemo/flattenVariant.js +206 -0
  203. package/useDemo/index.d.ts +6 -39
  204. package/useDemo/index.d.ts.map +1 -1
  205. package/useDemo/index.js +6 -17
  206. package/useDemo/useDemo.d.ts +79 -0
  207. package/useDemo/useDemo.d.ts.map +1 -0
  208. package/useDemo/useDemo.js +174 -0
  209. package/useLocalStorageState/index.d.ts +2 -0
  210. package/useLocalStorageState/index.d.ts.map +1 -0
  211. package/useLocalStorageState/index.js +2 -0
  212. package/useLocalStorageState/useLocalStorageState.d.ts +14 -0
  213. package/useLocalStorageState/useLocalStorageState.d.ts.map +1 -0
  214. package/useLocalStorageState/useLocalStorageState.js +128 -0
  215. package/useOnHydrate/index.d.ts.map +1 -1
  216. package/useOnHydrate/useOnHydrate.d.ts.map +1 -1
  217. package/useOnIdle/index.d.ts.map +1 -1
  218. package/useOnIdle/useOnIdle.d.ts.map +1 -1
  219. package/useUrlHashState/index.d.ts +1 -0
  220. package/useUrlHashState/index.d.ts.map +1 -0
  221. package/useUrlHashState/index.js +1 -0
  222. package/useUrlHashState/useUrlHashState.d.ts +50 -0
  223. package/useUrlHashState/useUrlHashState.d.ts.map +1 -0
  224. package/useUrlHashState/useUrlHashState.js +113 -0
  225. package/hast/hast.d.ts.map +0 -1
  226. package/hast/index.d.ts +0 -1
  227. package/hast/index.d.ts.map +0 -1
  228. package/hast/index.js +0 -1
  229. package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
  230. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
  231. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
  232. package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -194
  233. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
  234. package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
  235. package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
  236. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
  237. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
  238. package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
  239. package/loadServerCodeMeta/index.d.ts +0 -1
  240. package/loadServerCodeMeta/index.d.ts.map +0 -1
  241. package/loadServerCodeMeta/index.js +0 -1
  242. package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
  243. package/loadServerSource/index.d.ts +0 -1
  244. package/loadServerSource/index.d.ts.map +0 -1
  245. package/loadServerSource/index.js +0 -1
  246. package/loadServerSource/serverLoadSource.d.ts.map +0 -1
  247. package/loadServerSource/serverLoadSource.js +0 -100
  248. package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
  249. package/loaderUtils/getFileNameFromUrl.js +0 -32
  250. package/loaderUtils/index.d.ts +0 -5
  251. package/loaderUtils/index.d.ts.map +0 -1
  252. package/loaderUtils/index.js +0 -5
  253. package/loaderUtils/processImports.d.ts.map +0 -1
  254. package/loaderUtils/processImports.js +0 -82
  255. package/loaderUtils/resolveImports.d.ts +0 -4
  256. package/loaderUtils/resolveImports.d.ts.map +0 -1
  257. package/loaderUtils/resolveImports.js +0 -71
  258. package/loaderUtils/resolveModulePath.d.ts.map +0 -1
  259. package/loaderUtils/resolveModulePath.js +0 -862
  260. package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
  261. package/loaderUtils/rewriteImports.d.ts +0 -9
  262. package/loaderUtils/rewriteImports.d.ts.map +0 -1
  263. package/loaderUtils/rewriteImports.js +0 -57
  264. package/parseSource/grammars.d.ts.map +0 -1
  265. package/parseSource/index.d.ts.map +0 -1
  266. package/parseSource/parseSource.d.ts +0 -3
  267. package/parseSource/parseSource.d.ts.map +0 -1
  268. package/transformRelativeMarkdownPaths/index.d.ts +0 -2
  269. package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
  270. package/transformRelativeMarkdownPaths/index.js +0 -4
  271. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
  272. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
  273. package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
  274. package/transformTsToJs/index.d.ts +0 -1
  275. package/transformTsToJs/index.d.ts.map +0 -1
  276. package/transformTsToJs/index.js +0 -1
  277. package/transformTsToJs/removeTypes.d.ts.map +0 -1
  278. package/transformTsToJs/transformTsToJs.d.ts +0 -3
  279. package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
  280. /package/{hast/hast.d.ts → pipeline/hastUtils/hastUtils.d.ts} +0 -0
  281. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.d.ts +0 -0
  282. /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.js +0 -0
  283. /package/{parseSource → pipeline/parseSource}/grammars.d.ts +0 -0
  284. /package/{parseSource → pipeline/parseSource}/grammars.js +0 -0
  285. /package/{parseSource → pipeline/parseSource}/index.d.ts +0 -0
  286. /package/{parseSource → pipeline/parseSource}/index.js +0 -0
  287. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.d.ts +0 -0
  288. /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.js +0 -0
@@ -0,0 +1,84 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
4
+ import * as React from 'react';
5
+ import useLocalStorageState from "../useLocalStorageState/index.js";
6
+ /**
7
+ * Hook for managing variant selection and providing variant-related data
8
+ * Uses the useLocalStorage hook for local storage persistence of variant preferences
9
+ */
10
+ export function useVariantSelection(_ref) {
11
+ var effectiveCode = _ref.effectiveCode,
12
+ initialVariant = _ref.initialVariant;
13
+ // Get variant keys from effective code
14
+ var variantKeys = React.useMemo(function () {
15
+ return Object.keys(effectiveCode).filter(function (key) {
16
+ var variant = effectiveCode[key];
17
+ return variant && _typeof(variant) === 'object' && 'source' in variant;
18
+ });
19
+ }, [effectiveCode]);
20
+
21
+ // Generate storage key from sorted variant keys (only for multiple variants)
22
+ var storageKey = React.useMemo(function () {
23
+ if (variantKeys.length <= 1) {
24
+ return null; // Don't use localStorage for single variants - no choice to remember
25
+ }
26
+ var sortedKeys = _toConsumableArray(variantKeys).sort();
27
+ return "_docs_infra_variant_prefs_".concat(sortedKeys.join(':'));
28
+ }, [variantKeys]);
29
+
30
+ // Use localStorage hook for variant persistence - this is our single source of truth
31
+ var _useLocalStorageState = useLocalStorageState(storageKey, function () {
32
+ // Don't use initialVariant as the fallback - localStorage should take precedence
33
+ // We'll handle the initial variant separately in the selectedVariantKey logic
34
+ return null;
35
+ }),
36
+ _useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
37
+ storedValue = _useLocalStorageState2[0],
38
+ setStoredValue = _useLocalStorageState2[1];
39
+
40
+ // Handle validation manually - localStorage should take precedence over initialVariant
41
+ var selectedVariantKey = React.useMemo(function () {
42
+ // First priority: use stored value if it exists and is valid
43
+ if (storedValue && variantKeys.includes(storedValue)) {
44
+ return storedValue;
45
+ }
46
+
47
+ // Second priority: use initial variant if provided and valid (only when no localStorage value)
48
+ if (initialVariant && variantKeys.includes(initialVariant)) {
49
+ return initialVariant;
50
+ }
51
+
52
+ // Final fallback: use first available variant
53
+ return variantKeys[0] || '';
54
+ }, [storedValue, variantKeys, initialVariant]);
55
+ var setSelectedVariantKey = React.useCallback(function (value) {
56
+ setStoredValue(value);
57
+ }, [setStoredValue]);
58
+ var setSelectedVariantKeyAsUser = React.useCallback(function (value) {
59
+ var resolvedValue = typeof value === 'function' ? value(selectedVariantKey) : value;
60
+ setStoredValue(resolvedValue);
61
+ }, [setStoredValue, selectedVariantKey]);
62
+ var selectedVariant = React.useMemo(function () {
63
+ var variant = effectiveCode[selectedVariantKey];
64
+ if (variant && _typeof(variant) === 'object' && 'source' in variant) {
65
+ return variant;
66
+ }
67
+ return null;
68
+ }, [effectiveCode, selectedVariantKey]);
69
+
70
+ // Safety check: if selectedVariant doesn't exist, fall back to first variant
71
+ React.useEffect(function () {
72
+ if (!selectedVariant && variantKeys.length > 0) {
73
+ // Don't mark this as a user selection - it's just a fallback
74
+ // Use setValue instead of setValueAsUserSelection to avoid localStorage save
75
+ setSelectedVariantKey(variantKeys[0]);
76
+ }
77
+ }, [selectedVariant, variantKeys, setSelectedVariantKey]);
78
+ return {
79
+ variantKeys: variantKeys,
80
+ selectedVariantKey: selectedVariantKey,
81
+ selectedVariant: selectedVariant,
82
+ selectVariant: setSelectedVariantKeyAsUser
83
+ };
84
+ }
@@ -10,6 +10,6 @@ export type UseCopierOpts = {
10
10
  };
11
11
  export declare function useCopier(contents: (() => string | undefined) | string, opts?: UseCopierOpts): {
12
12
  copy: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
13
- disabled: boolean;
13
+ recentlySuccessful: boolean;
14
14
  };
15
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/useCopier/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAC3B,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAC5C,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa;kBAO3E,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC;;EA0BpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useCopier/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAC3B,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAC5C,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa;kBAO3E,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC;;EA0BpD"}
@@ -13,8 +13,8 @@ export function useCopier(contents, opts) {
13
13
  var copyTimeoutRef = React.useRef(undefined);
14
14
  var _React$useState = React.useState(false),
15
15
  _React$useState2 = _slicedToArray(_React$useState, 2),
16
- disabled = _React$useState2[0],
17
- setDisabled = _React$useState2[1];
16
+ recentlySuccessful = _React$useState2[0],
17
+ setRecentlySuccessful = _React$useState2[1];
18
18
  var copy = React.useCallback(/*#__PURE__*/function () {
19
19
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
20
20
  var content;
@@ -22,7 +22,7 @@ export function useCopier(contents, opts) {
22
22
  while (1) switch (_context.prev = _context.next) {
23
23
  case 0:
24
24
  clearTimeout(copyTimeoutRef.current);
25
- setDisabled(true);
25
+ setRecentlySuccessful(false);
26
26
  _context.prev = 2;
27
27
  content = typeof contents === 'function' ? contents() : contents;
28
28
  if (!content) {
@@ -43,7 +43,7 @@ export function useCopier(contents, opts) {
43
43
  onClick == null || onClick(event);
44
44
  copyTimeoutRef.current = setTimeout(function () {
45
45
  clearTimeout(copyTimeoutRef.current);
46
- setDisabled(false);
46
+ setRecentlySuccessful(false);
47
47
  }, timeout);
48
48
  case 15:
49
49
  case "end":
@@ -57,6 +57,6 @@ export function useCopier(contents, opts) {
57
57
  }(), [contents, timeout, onCopied, onError, onClick]);
58
58
  return {
59
59
  copy: copy,
60
- disabled: disabled
60
+ recentlySuccessful: recentlySuccessful
61
61
  };
62
62
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Utility function for creating CodeSandbox demos
3
+ * Returns the configuration that can be used with openWithForm
4
+ */
5
+ import type { FlattenedFiles } from "./flattenVariant.js";
6
+ /**
7
+ * Create CodeSandbox for use with openWithForm
8
+ */
9
+ export declare function createCodeSandbox({
10
+ flattenedFiles,
11
+ rootFile
12
+ }: {
13
+ flattenedFiles: FlattenedFiles;
14
+ rootFile: string;
15
+ }): {
16
+ url: string;
17
+ formData: Record<string, string>;
18
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCodeSandbox.d.ts","sourceRoot":"","sources":["../../src/useDemo/createCodeSandbox.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYvD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,cAAc,EACd,QAAQ,GACT,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAsBA"}
@@ -0,0 +1,48 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ /**
3
+ * Utility function for creating CodeSandbox demos
4
+ * Returns the configuration that can be used with openWithForm
5
+ */
6
+
7
+ // @ts-ignore
8
+ import LZString from 'lz-string';
9
+ /**
10
+ * Compress object for CodeSandbox API
11
+ */
12
+ function compress(object) {
13
+ return LZString.compressToBase64(JSON.stringify(object)).replace(/\+/g, '-') // Convert '+' to '-'
14
+ .replace(/\//g, '_') // Convert '/' to '_'
15
+ .replace(/=+$/, ''); // Remove ending '='
16
+ }
17
+
18
+ /**
19
+ * Create CodeSandbox for use with openWithForm
20
+ */
21
+ export function createCodeSandbox(_ref) {
22
+ var flattenedFiles = _ref.flattenedFiles,
23
+ rootFile = _ref.rootFile;
24
+ // Convert flattened files to string format
25
+ var files = {};
26
+ Object.entries(flattenedFiles).forEach(function (_ref2) {
27
+ var _ref3 = _slicedToArray(_ref2, 2),
28
+ filePath = _ref3[0],
29
+ fileData = _ref3[1];
30
+ files[filePath] = {
31
+ content: fileData.source
32
+ };
33
+ });
34
+ var parameters = compress({
35
+ files: files
36
+ });
37
+
38
+ // ref: https://codesandbox.io/docs/api/#define-api
39
+ var formData = {
40
+ parameters: parameters,
41
+ embed: '1',
42
+ query: "module=/".concat(rootFile, "&fontsize=12")
43
+ };
44
+ return {
45
+ url: 'https://codesandbox.io/api/v1/sandboxes/define',
46
+ formData: formData
47
+ };
48
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utility function for creating StackBlitz demos
3
+ * Returns the configuration that can be used with openWithForm
4
+ */
5
+ import type { FlattenedFiles } from "./flattenVariant.js";
6
+ /**
7
+ * Create StackBlitz configuration for use with openWithForm
8
+ */
9
+ export declare function createStackBlitz({
10
+ title,
11
+ description,
12
+ flattenedFiles,
13
+ rootFile
14
+ }: {
15
+ title: string;
16
+ description: string;
17
+ flattenedFiles: FlattenedFiles;
18
+ rootFile: string;
19
+ }): {
20
+ url: string;
21
+ formData: Record<string, string>;
22
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStackBlitz.d.ts","sourceRoot":"","sources":["../../src/useDemo/createStackBlitz.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,WAAW,EACX,cAAc,EACd,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAqBA"}
@@ -0,0 +1,38 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ /**
3
+ * Utility function for creating StackBlitz demos
4
+ * Returns the configuration that can be used with openWithForm
5
+ */
6
+
7
+ /**
8
+ * Create StackBlitz configuration for use with openWithForm
9
+ */
10
+ export function createStackBlitz(_ref) {
11
+ var title = _ref.title,
12
+ description = _ref.description,
13
+ flattenedFiles = _ref.flattenedFiles,
14
+ rootFile = _ref.rootFile;
15
+ // Convert flattened files to string format
16
+ var files = {};
17
+ Object.entries(flattenedFiles).forEach(function (_ref2) {
18
+ var _ref3 = _slicedToArray(_ref2, 2),
19
+ filePath = _ref3[0],
20
+ fileData = _ref3[1];
21
+ files[filePath] = fileData.source;
22
+ });
23
+ var formData = {
24
+ 'project[template]': 'node',
25
+ 'project[title]': title,
26
+ 'project[description]': "# ".concat(title, "\n").concat(description)
27
+ };
28
+ Object.entries(files).forEach(function (_ref4) {
29
+ var _ref5 = _slicedToArray(_ref4, 2),
30
+ key = _ref5[0],
31
+ value = _ref5[1];
32
+ formData["project[files][".concat(key, "]")] = value;
33
+ });
34
+ return {
35
+ url: "https://stackblitz.com/run?file=".concat(rootFile),
36
+ formData: formData
37
+ };
38
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Variant examination utility for analyzing variant structure and paths
3
+ */
4
+ import type { VariantCode } from "../CodeHighlighter/types.js";
5
+ interface PathContextBase {
6
+ hasMetadata: boolean;
7
+ maxBackNavigation: number;
8
+ urlDirectory: string[];
9
+ rootLevel: string;
10
+ pathInwardFromRoot: string;
11
+ }
12
+ interface PathContextWithUrl extends PathContextBase {
13
+ hasUrl: true;
14
+ actualUrl: string;
15
+ }
16
+ interface PathContextWithoutUrl extends PathContextBase {
17
+ hasUrl: false;
18
+ actualUrl?: undefined;
19
+ }
20
+ export type PathContext = PathContextWithUrl | PathContextWithoutUrl;
21
+ /**
22
+ * Create path context for processing files with extended information
23
+ */
24
+ export declare function createPathContext(variant: VariantCode): PathContext;
25
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examineVariant.d.ts","sourceRoot":"","sources":["../../src/useDemo/examineVariant.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,UAAU,eAAe;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,UAAU,kBAAmB,SAAQ,eAAe;IAClD,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,qBAAsB,SAAQ,eAAe;IACrD,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AA8FrE;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,CA0CnE"}
@@ -0,0 +1,134 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ /**
4
+ * Variant examination utility for analyzing variant structure and paths
5
+ */
6
+
7
+ /**
8
+ * Extract directory segments from URL pathname
9
+ */
10
+ function getDirectoryFromUrl(url) {
11
+ var urlObj = new URL(url);
12
+ var segments = urlObj.pathname.split('/').filter(Boolean);
13
+ segments.pop(); // Remove filename
14
+ return segments;
15
+ }
16
+
17
+ /**
18
+ * Calculate the maximum back navigation level from extra files
19
+ */
20
+ function calculateMaxBackNavigation(extraFiles) {
21
+ var maxBackNavigation = 0;
22
+ for (var _i = 0, _Object$entries = Object.entries(extraFiles); _i < _Object$entries.length; _i++) {
23
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
24
+ relativePath = _Object$entries$_i[0],
25
+ fileContent = _Object$entries$_i[1];
26
+ if (relativePath.startsWith('.')) {
27
+ var backCount = (relativePath.match(/\.\.\//g) || []).length;
28
+
29
+ // For metadata files, subtract 1 from their back navigation count
30
+ var file = typeof fileContent === 'string' ? {
31
+ source: fileContent
32
+ } : fileContent;
33
+ var adjustedBackCount = file.metadata ? Math.max(0, backCount - 1) : backCount;
34
+ maxBackNavigation = Math.max(maxBackNavigation, adjustedBackCount);
35
+ }
36
+ }
37
+ return maxBackNavigation;
38
+ }
39
+
40
+ /**
41
+ * Generate a synthetic path using alphabetic progression (a/b/c/d/e/...)
42
+ */
43
+ function generateSyntheticPath(levels) {
44
+ if (levels <= 0) {
45
+ return '';
46
+ }
47
+ var parts = [];
48
+ for (var i = 0; i < levels; i += 1) {
49
+ var charCode = 97 + i % 26; // 97 is 'a', cycles through a-z
50
+ parts.push(String.fromCharCode(charCode));
51
+ }
52
+ return parts.join('/') + (levels > 0 ? '/' : '');
53
+ }
54
+
55
+ /**
56
+ * Calculate root level path based on URL and max back navigation
57
+ */
58
+ function calculateRootLevel(url, maxBackNavigation) {
59
+ if (!url || maxBackNavigation === 0) {
60
+ return '';
61
+ }
62
+ var pathSegments = getDirectoryFromUrl(url);
63
+
64
+ // Go back by maxBackNavigation levels
65
+ for (var i = 0; i < maxBackNavigation; i += 1) {
66
+ pathSegments.pop();
67
+ }
68
+ var rootLevel = pathSegments.join('/');
69
+ return rootLevel && !rootLevel.endsWith('/') ? "".concat(rootLevel, "/") : rootLevel;
70
+ }
71
+
72
+ /**
73
+ * Calculate the path inward from the root to the variant location
74
+ */
75
+ function calculatePathInwardFromRoot(url, maxBackNavigation) {
76
+ if (!url || maxBackNavigation === 0) {
77
+ return '';
78
+ }
79
+ var pathSegments = getDirectoryFromUrl(url);
80
+
81
+ // The path inward is the segments that remain after going back by maxBackNavigation
82
+ // but we want the path from root to the variant location, not to the parent directory
83
+ var variantDepthFromRoot = pathSegments.length - maxBackNavigation;
84
+ if (variantDepthFromRoot <= 0) {
85
+ return '';
86
+ }
87
+
88
+ // Get segments starting from the root level up to (but not including) the current directory
89
+ var rootSegments = pathSegments.slice(0, pathSegments.length - maxBackNavigation);
90
+ var variantSegments = pathSegments.slice(rootSegments.length);
91
+ return variantSegments.length > 0 ? "".concat(variantSegments.join('/'), "/") : '';
92
+ }
93
+
94
+ /**
95
+ * Create path context for processing files with extended information
96
+ */
97
+ export function createPathContext(variant) {
98
+ var hasUrl = Boolean(variant.url);
99
+ var actualUrl = variant.url;
100
+ var hasMetadata = variant.extraFiles ? Object.values(variant.extraFiles).some(function (file) {
101
+ return _typeof(file) === 'object' && file.metadata;
102
+ }) : false;
103
+ var maxBackNavigation = variant.extraFiles ? calculateMaxBackNavigation(variant.extraFiles) : 0;
104
+
105
+ // If no URL but we have back navigation, create a synthetic URL
106
+ if (!hasUrl && maxBackNavigation > 0 && variant.fileName) {
107
+ var syntheticPath = generateSyntheticPath(maxBackNavigation);
108
+ actualUrl = "file:///".concat(syntheticPath).concat(variant.fileName);
109
+ hasUrl = true;
110
+ }
111
+ var urlDirectory = hasUrl && actualUrl ? getDirectoryFromUrl(actualUrl) : [];
112
+ var rootLevel = calculateRootLevel(actualUrl, maxBackNavigation);
113
+ var pathInwardFromRoot = calculatePathInwardFromRoot(actualUrl, maxBackNavigation);
114
+ if (hasUrl && actualUrl) {
115
+ return {
116
+ hasUrl: true,
117
+ hasMetadata: hasMetadata,
118
+ maxBackNavigation: maxBackNavigation,
119
+ urlDirectory: urlDirectory,
120
+ rootLevel: rootLevel,
121
+ pathInwardFromRoot: pathInwardFromRoot,
122
+ actualUrl: actualUrl
123
+ };
124
+ }
125
+ return {
126
+ hasUrl: false,
127
+ hasMetadata: hasMetadata,
128
+ maxBackNavigation: maxBackNavigation,
129
+ urlDirectory: urlDirectory,
130
+ rootLevel: rootLevel,
131
+ pathInwardFromRoot: pathInwardFromRoot,
132
+ actualUrl: undefined
133
+ };
134
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Export variant functionality to add extra files like package.json, tsconfig, etc.
3
+ * Users can pass configuration options that vary the output here.
4
+ */
5
+ import type { VariantCode } from "../CodeHighlighter/types.js";
6
+ /**
7
+ * Extract filename from URL or return undefined if not available
8
+ */
9
+ export declare function getFilenameFromVariant(variantCode: VariantCode): string | undefined;
10
+ /**
11
+ * Generate a unique entrypoint filename that doesn't conflict with existing files
12
+ */
13
+ export declare function generateEntrypointFilename(existingFiles: Record<string, any>, sourceFilename: string | undefined, useTypescript: boolean, pathPrefix?: string): string;
14
+ /**
15
+ * Generate the relative import path from entrypoint to source file
16
+ */
17
+ export declare function getRelativeImportPath(sourceFilename: string | undefined): string;
18
+ /**
19
+ * Default HTML template function for Vite-based demos
20
+ */
21
+ export declare function defaultHtmlTemplate({
22
+ language,
23
+ title,
24
+ description,
25
+ head,
26
+ entrypoint
27
+ }: {
28
+ language: string;
29
+ title: string;
30
+ description: string;
31
+ head?: string;
32
+ entrypoint: string;
33
+ }): string;
34
+ export interface ExportConfig {
35
+ /** The title for the demo (used in HTML title and package.json name) */
36
+ title?: string;
37
+ /** Description for package.json */
38
+ description?: string;
39
+ /**
40
+ * Prefix for output file paths (e.g., 'public/' for CRA, '' for Vite)
41
+ * @example
42
+ * htmlPrefix: 'public/' // outputs index.html to correct depth + public/index.html
43
+ */
44
+ htmlPrefix?: string;
45
+ /**
46
+ * Whether the framework handles entrypoint and HTML generation (e.g., CRA with webpack)
47
+ * When true, skips generating index.html and entrypoint files
48
+ */
49
+ frameworkHandlesEntrypoint?: boolean;
50
+ /**
51
+ * Custom HTML template function
52
+ * @example
53
+ * htmlTemplate: ({ language, title, description, head, entrypoint }) =>
54
+ * `<!doctype html><html><head><title>${title}</title>${head || ''}</head><body><div id="root"></div><script src="${entrypoint}"></script></body></html>`
55
+ */
56
+ htmlTemplate?: (params: {
57
+ language: string;
58
+ title: string;
59
+ description: string;
60
+ head?: string;
61
+ entrypoint: string;
62
+ }) => string;
63
+ /**
64
+ * Custom head template function for generating additional head content
65
+ * @example
66
+ * headTemplate: ({ sourcePrefix, assetPrefix }) =>
67
+ * `<link rel="stylesheet" href="${assetPrefix}/styles.css" />\n<meta name="theme-color" content="#000000" />`
68
+ */
69
+ headTemplate?: (params: {
70
+ sourcePrefix: string;
71
+ assetPrefix: string;
72
+ }) => string;
73
+ /** Custom React root index template function */
74
+ rootIndexTemplate?: (params: {
75
+ importString: string;
76
+ useTypescript: boolean;
77
+ }) => string;
78
+ /** Extra package.json dependencies to add */
79
+ dependencies?: Record<string, string>;
80
+ /** Extra package.json devDependencies to add */
81
+ devDependencies?: Record<string, string>;
82
+ /** Extra package.json scripts to add */
83
+ scripts?: Record<string, string>;
84
+ /** Package type: 'module' for ESM, 'commonjs' for CJS, undefined to omit */
85
+ packageType?: 'module' | 'commonjs';
86
+ /** Custom package.json fields to merge */
87
+ packageJsonFields?: Record<string, any>;
88
+ /** Extra tsconfig.json options to merge */
89
+ tsconfigOptions?: Record<string, any>;
90
+ /** Whether to include TypeScript configuration files */
91
+ useTypescript?: boolean;
92
+ /** Custom metadata files to add */
93
+ extraMetadataFiles?: Record<string, {
94
+ source: string;
95
+ metadata?: boolean;
96
+ }>;
97
+ /** Framework-specific files that override default files (index.html, entrypoint, etc.) */
98
+ frameworkFiles?: Record<string, {
99
+ source: string;
100
+ metadata?: boolean;
101
+ }>;
102
+ }
103
+ /**
104
+ * Export a VariantCode with additional configuration files
105
+ * Returns an object with the exported VariantCode and rootPath path
106
+ */
107
+ export declare function exportVariant(variantCode: VariantCode, config?: ExportConfig): {
108
+ exported: VariantCode;
109
+ rootFile: string;
110
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportVariant.d.ts","sourceRoot":"","sources":["../../src/useDemo/exportVariant.ts"],"names":[],"mappings":"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"}