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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/README.md +1 -3
  2. package/esm/package.json +1 -0
  3. package/esm/useCopier/index.d.ts +15 -0
  4. package/esm/useCopier/index.d.ts.map +1 -0
  5. package/esm/useCopier/index.js +62 -0
  6. package/esm/useDemo/index.d.ts +51 -0
  7. package/esm/useDemo/index.d.ts.map +1 -0
  8. package/esm/useDemo/index.js +104 -0
  9. package/package.json +31 -32
  10. package/useCopier/index.d.ts +1 -1
  11. package/useCopier/index.js +23 -15
  12. package/useDemo/index.d.ts +51 -6
  13. package/useDemo/index.js +112 -6
  14. package/CodeControllerContext/CodeControllerContext.d.ts +0 -22
  15. package/CodeControllerContext/CodeControllerContext.d.ts.map +0 -1
  16. package/CodeControllerContext/CodeControllerContext.js +0 -14
  17. package/CodeControllerContext/index.d.ts +0 -1
  18. package/CodeControllerContext/index.d.ts.map +0 -1
  19. package/CodeControllerContext/index.js +0 -1
  20. package/CodeExternalsContext/CodeExternalsContext.d.ts +0 -8
  21. package/CodeExternalsContext/CodeExternalsContext.d.ts.map +0 -1
  22. package/CodeExternalsContext/CodeExternalsContext.js +0 -7
  23. package/CodeExternalsContext/index.d.ts +0 -1
  24. package/CodeExternalsContext/index.d.ts.map +0 -1
  25. package/CodeExternalsContext/index.js +0 -1
  26. package/CodeHighlighter/CodeHighlighter.d.ts +0 -2
  27. package/CodeHighlighter/CodeHighlighter.d.ts.map +0 -1
  28. package/CodeHighlighter/CodeHighlighter.js +0 -470
  29. package/CodeHighlighter/CodeHighlighterClient.d.ts +0 -2
  30. package/CodeHighlighter/CodeHighlighterClient.d.ts.map +0 -1
  31. package/CodeHighlighter/CodeHighlighterClient.js +0 -837
  32. package/CodeHighlighter/CodeHighlighterContext.d.ts +0 -16
  33. package/CodeHighlighter/CodeHighlighterContext.d.ts.map +0 -1
  34. package/CodeHighlighter/CodeHighlighterContext.js +0 -14
  35. package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +0 -7
  36. package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +0 -1
  37. package/CodeHighlighter/CodeHighlighterFallbackContext.js +0 -13
  38. package/CodeHighlighter/applyTransform.d.ts +0 -19
  39. package/CodeHighlighter/applyTransform.d.ts.map +0 -1
  40. package/CodeHighlighter/applyTransform.js +0 -75
  41. package/CodeHighlighter/codeToFallbackProps.d.ts +0 -2
  42. package/CodeHighlighter/codeToFallbackProps.d.ts.map +0 -1
  43. package/CodeHighlighter/codeToFallbackProps.js +0 -73
  44. package/CodeHighlighter/errors.d.ts +0 -0
  45. package/CodeHighlighter/errors.d.ts.map +0 -1
  46. package/CodeHighlighter/errors.js +0 -1
  47. package/CodeHighlighter/hasAllVariants.d.ts +0 -2
  48. package/CodeHighlighter/hasAllVariants.d.ts.map +0 -1
  49. package/CodeHighlighter/hasAllVariants.js +0 -31
  50. package/CodeHighlighter/index.d.ts +0 -4
  51. package/CodeHighlighter/index.d.ts.map +0 -1
  52. package/CodeHighlighter/index.js +0 -4
  53. package/CodeHighlighter/loadFallbackCode.d.ts +0 -10
  54. package/CodeHighlighter/loadFallbackCode.d.ts.map +0 -1
  55. package/CodeHighlighter/loadFallbackCode.js +0 -632
  56. package/CodeHighlighter/loadVariant.d.ts +0 -12
  57. package/CodeHighlighter/loadVariant.d.ts.map +0 -1
  58. package/CodeHighlighter/loadVariant.js +0 -1083
  59. package/CodeHighlighter/maybeInitialData.d.ts +0 -10
  60. package/CodeHighlighter/maybeInitialData.d.ts.map +0 -1
  61. package/CodeHighlighter/maybeInitialData.js +0 -94
  62. package/CodeHighlighter/parseCode.d.ts +0 -6
  63. package/CodeHighlighter/parseCode.d.ts.map +0 -1
  64. package/CodeHighlighter/parseCode.js +0 -134
  65. package/CodeHighlighter/parseControlledCode.d.ts +0 -6
  66. package/CodeHighlighter/parseControlledCode.d.ts.map +0 -1
  67. package/CodeHighlighter/parseControlledCode.js +0 -87
  68. package/CodeHighlighter/transformCode.d.ts +0 -21
  69. package/CodeHighlighter/transformCode.d.ts.map +0 -1
  70. package/CodeHighlighter/transformCode.js +0 -263
  71. package/CodeHighlighter/transformParsedSource.d.ts +0 -3
  72. package/CodeHighlighter/transformParsedSource.d.ts.map +0 -1
  73. package/CodeHighlighter/transformParsedSource.js +0 -66
  74. package/CodeHighlighter/transformSource.d.ts +0 -2
  75. package/CodeHighlighter/transformSource.d.ts.map +0 -1
  76. package/CodeHighlighter/transformSource.js +0 -107
  77. package/CodeHighlighter/types.d.ts +0 -160
  78. package/CodeHighlighter/types.d.ts.map +0 -1
  79. package/CodeHighlighter/types.js +0 -1
  80. package/CodeProvider/CodeContext.d.ts +0 -12
  81. package/CodeProvider/CodeContext.d.ts.map +0 -1
  82. package/CodeProvider/CodeContext.js +0 -8
  83. package/CodeProvider/CodeProvider.d.ts +0 -13
  84. package/CodeProvider/CodeProvider.d.ts.map +0 -1
  85. package/CodeProvider/CodeProvider.js +0 -65
  86. package/CodeProvider/index.d.ts +0 -1
  87. package/CodeProvider/index.d.ts.map +0 -1
  88. package/CodeProvider/index.js +0 -1
  89. package/abstractCreateDemo/abstractCreateDemo.d.ts +0 -35
  90. package/abstractCreateDemo/abstractCreateDemo.d.ts.map +0 -1
  91. package/abstractCreateDemo/abstractCreateDemo.js +0 -91
  92. package/abstractCreateDemo/index.d.ts +0 -1
  93. package/abstractCreateDemo/index.d.ts.map +0 -1
  94. package/abstractCreateDemo/index.js +0 -1
  95. package/createDemoData/createDemoData.d.ts +0 -44
  96. package/createDemoData/createDemoData.d.ts.map +0 -1
  97. package/createDemoData/createDemoData.js +0 -75
  98. package/createDemoData/index.d.ts +0 -1
  99. package/createDemoData/index.d.ts.map +0 -1
  100. package/createDemoData/index.js +0 -1
  101. package/createDemoData/types.d.ts +0 -28
  102. package/createDemoData/types.d.ts.map +0 -1
  103. package/createDemoData/types.js +0 -1
  104. package/pipeline/hastUtils/hastUtils.d.ts +0 -11
  105. package/pipeline/hastUtils/hastUtils.d.ts.map +0 -1
  106. package/pipeline/hastUtils/hastUtils.js +0 -67
  107. package/pipeline/hastUtils/index.d.ts +0 -1
  108. package/pipeline/hastUtils/index.d.ts.map +0 -1
  109. package/pipeline/hastUtils/index.js +0 -1
  110. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +0 -54
  111. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +0 -1
  112. package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +0 -465
  113. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +0 -15
  114. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +0 -1
  115. package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +0 -253
  116. package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts +0 -2
  117. package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
  118. package/pipeline/loadPrecomputedCodeHighlighter/index.js +0 -4
  119. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -20
  120. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
  121. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -224
  122. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +0 -31
  123. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
  124. package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -433
  125. package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +0 -19
  126. package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
  127. package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +0 -168
  128. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -25
  129. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
  130. package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -73
  131. package/pipeline/loadServerCodeMeta/index.d.ts +0 -1
  132. package/pipeline/loadServerCodeMeta/index.d.ts.map +0 -1
  133. package/pipeline/loadServerCodeMeta/index.js +0 -1
  134. package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +0 -24
  135. package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +0 -1
  136. package/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +0 -92
  137. package/pipeline/loadServerSource/index.d.ts +0 -1
  138. package/pipeline/loadServerSource/index.d.ts.map +0 -1
  139. package/pipeline/loadServerSource/index.js +0 -1
  140. package/pipeline/loadServerSource/loadServerSource.d.ts +0 -25
  141. package/pipeline/loadServerSource/loadServerSource.d.ts.map +0 -1
  142. package/pipeline/loadServerSource/loadServerSource.js +0 -135
  143. package/pipeline/loaderUtils/externalsToPackages.d.ts +0 -1
  144. package/pipeline/loaderUtils/externalsToPackages.d.ts.map +0 -1
  145. package/pipeline/loaderUtils/externalsToPackages.js +0 -46
  146. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -34
  147. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +0 -1
  148. package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +0 -161
  149. package/pipeline/loaderUtils/getFileNameFromUrl.d.ts +0 -11
  150. package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
  151. package/pipeline/loaderUtils/getFileNameFromUrl.js +0 -32
  152. package/pipeline/loaderUtils/index.d.ts +0 -7
  153. package/pipeline/loaderUtils/index.d.ts.map +0 -1
  154. package/pipeline/loaderUtils/index.js +0 -7
  155. package/pipeline/loaderUtils/mergeExternals.d.ts +0 -32
  156. package/pipeline/loaderUtils/mergeExternals.d.ts.map +0 -1
  157. package/pipeline/loaderUtils/mergeExternals.js +0 -72
  158. package/pipeline/loaderUtils/parseImports.d.ts +0 -20
  159. package/pipeline/loaderUtils/parseImports.d.ts.map +0 -1
  160. package/pipeline/loaderUtils/parseImports.js +0 -307
  161. package/pipeline/loaderUtils/processRelativeImports.d.ts +0 -19
  162. package/pipeline/loaderUtils/processRelativeImports.d.ts.map +0 -1
  163. package/pipeline/loaderUtils/processRelativeImports.js +0 -329
  164. package/pipeline/loaderUtils/resolveModulePath.d.ts +0 -87
  165. package/pipeline/loaderUtils/resolveModulePath.d.ts.map +0 -1
  166. package/pipeline/loaderUtils/resolveModulePath.js +0 -1449
  167. package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +0 -47
  168. package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
  169. package/pipeline/loaderUtils/resolveModulePathWithFs.js +0 -163
  170. package/pipeline/loaderUtils/rewriteImports.d.ts +0 -9
  171. package/pipeline/loaderUtils/rewriteImports.d.ts.map +0 -1
  172. package/pipeline/loaderUtils/rewriteImports.js +0 -35
  173. package/pipeline/parseSource/grammars.d.ts +0 -2
  174. package/pipeline/parseSource/grammars.d.ts.map +0 -1
  175. package/pipeline/parseSource/grammars.js +0 -27
  176. package/pipeline/parseSource/index.d.ts +0 -1
  177. package/pipeline/parseSource/index.d.ts.map +0 -1
  178. package/pipeline/parseSource/index.js +0 -1
  179. package/pipeline/parseSource/parseSource.d.ts +0 -3
  180. package/pipeline/parseSource/parseSource.d.ts.map +0 -1
  181. package/pipeline/parseSource/parseSource.js +0 -47
  182. package/pipeline/transformHtmlCode/index.d.ts +0 -2
  183. package/pipeline/transformHtmlCode/index.d.ts.map +0 -1
  184. package/pipeline/transformHtmlCode/index.js +0 -4
  185. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +0 -13
  186. package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +0 -1
  187. package/pipeline/transformHtmlCode/transformHtmlCode.js +0 -303
  188. package/pipeline/transformMarkdownCode/index.d.ts +0 -2
  189. package/pipeline/transformMarkdownCode/index.d.ts.map +0 -1
  190. package/pipeline/transformMarkdownCode/index.js +0 -4
  191. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +0 -2
  192. package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +0 -1
  193. package/pipeline/transformMarkdownCode/transformMarkdownCode.js +0 -514
  194. package/pipeline/transformTypescriptToJavascript/index.d.ts +0 -1
  195. package/pipeline/transformTypescriptToJavascript/index.d.ts.map +0 -1
  196. package/pipeline/transformTypescriptToJavascript/index.js +0 -1
  197. package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts +0 -13
  198. package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +0 -1
  199. package/pipeline/transformTypescriptToJavascript/removeTypes.js +0 -134
  200. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +0 -3
  201. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +0 -1
  202. package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +0 -34
  203. package/useCode/index.d.ts +0 -1
  204. package/useCode/index.d.ts.map +0 -1
  205. package/useCode/index.js +0 -1
  206. package/useCode/useCode.d.ts +0 -39
  207. package/useCode/useCode.d.ts.map +0 -1
  208. package/useCode/useCode.js +0 -122
  209. package/useCode/useCodeUtils.d.ts +0 -45
  210. package/useCode/useCodeUtils.d.ts.map +0 -1
  211. package/useCode/useCodeUtils.js +0 -240
  212. package/useCode/useCopyFunctionality.d.ts +0 -17
  213. package/useCode/useCopyFunctionality.d.ts.map +0 -1
  214. package/useCode/useCopyFunctionality.js +0 -28
  215. package/useCode/useFileNavigation.d.ts +0 -48
  216. package/useCode/useFileNavigation.d.ts.map +0 -1
  217. package/useCode/useFileNavigation.js +0 -370
  218. package/useCode/useSourceEditing.d.ts +0 -19
  219. package/useCode/useSourceEditing.d.ts.map +0 -1
  220. package/useCode/useSourceEditing.js +0 -32
  221. package/useCode/useTransformManagement.d.ts +0 -28
  222. package/useCode/useTransformManagement.d.ts.map +0 -1
  223. package/useCode/useTransformManagement.js +0 -82
  224. package/useCode/useUIState.d.ts +0 -16
  225. package/useCode/useUIState.d.ts.map +0 -1
  226. package/useCode/useUIState.js +0 -21
  227. package/useCode/useVariantSelection.d.ts +0 -21
  228. package/useCode/useVariantSelection.d.ts.map +0 -1
  229. package/useCode/useVariantSelection.js +0 -84
  230. package/useCopier/index.d.ts.map +0 -1
  231. package/useDemo/createCodeSandbox.d.ts +0 -18
  232. package/useDemo/createCodeSandbox.d.ts.map +0 -1
  233. package/useDemo/createCodeSandbox.js +0 -48
  234. package/useDemo/createStackBlitz.d.ts +0 -22
  235. package/useDemo/createStackBlitz.d.ts.map +0 -1
  236. package/useDemo/createStackBlitz.js +0 -38
  237. package/useDemo/examineVariant.d.ts +0 -25
  238. package/useDemo/examineVariant.d.ts.map +0 -1
  239. package/useDemo/examineVariant.js +0 -134
  240. package/useDemo/exportVariant.d.ts +0 -110
  241. package/useDemo/exportVariant.d.ts.map +0 -1
  242. package/useDemo/exportVariant.js +0 -320
  243. package/useDemo/exportVariantAsCra.d.ts +0 -15
  244. package/useDemo/exportVariantAsCra.d.ts.map +0 -1
  245. package/useDemo/exportVariantAsCra.js +0 -56
  246. package/useDemo/flattenVariant.d.ts +0 -17
  247. package/useDemo/flattenVariant.d.ts.map +0 -1
  248. package/useDemo/flattenVariant.js +0 -206
  249. package/useDemo/index.d.ts.map +0 -1
  250. package/useDemo/useDemo.d.ts +0 -78
  251. package/useDemo/useDemo.d.ts.map +0 -1
  252. package/useDemo/useDemo.js +0 -174
  253. package/useLocalStorageState/index.d.ts +0 -2
  254. package/useLocalStorageState/index.d.ts.map +0 -1
  255. package/useLocalStorageState/index.js +0 -2
  256. package/useLocalStorageState/useLocalStorageState.d.ts +0 -14
  257. package/useLocalStorageState/useLocalStorageState.d.ts.map +0 -1
  258. package/useLocalStorageState/useLocalStorageState.js +0 -128
  259. package/useOnHydrate/index.d.ts +0 -1
  260. package/useOnHydrate/index.d.ts.map +0 -1
  261. package/useOnHydrate/index.js +0 -1
  262. package/useOnHydrate/useOnHydrate.d.ts +0 -1
  263. package/useOnHydrate/useOnHydrate.d.ts.map +0 -1
  264. package/useOnHydrate/useOnHydrate.js +0 -18
  265. package/useOnIdle/index.d.ts +0 -1
  266. package/useOnIdle/index.d.ts.map +0 -1
  267. package/useOnIdle/index.js +0 -1
  268. package/useOnIdle/useOnIdle.d.ts +0 -1
  269. package/useOnIdle/useOnIdle.d.ts.map +0 -1
  270. package/useOnIdle/useOnIdle.js +0 -39
  271. package/useUrlHashState/index.d.ts +0 -1
  272. package/useUrlHashState/index.d.ts.map +0 -1
  273. package/useUrlHashState/index.js +0 -1
  274. package/useUrlHashState/useUrlHashState.d.ts +0 -50
  275. package/useUrlHashState/useUrlHashState.d.ts.map +0 -1
  276. package/useUrlHashState/useUrlHashState.js +0 -113
@@ -1,632 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
6
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
- import { loadVariant } from "./loadVariant.js";
8
- import { getFileNameFromUrl } from "../pipeline/loaderUtils/index.js";
9
-
10
- // Helper function to get the source for a specific filename from a variant
11
- function getFileSource(_x, _x2, _x3) {
12
- return _getFileSource.apply(this, arguments);
13
- }
14
- function _getFileSource() {
15
- _getFileSource = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(variant, requestedFilename, loadSource) {
16
- var filename, extraFile, loadResult;
17
- return _regeneratorRuntime().wrap(function _callee$(_context) {
18
- while (1) switch (_context.prev = _context.next) {
19
- case 0:
20
- filename = requestedFilename || variant.fileName;
21
- if (filename) {
22
- _context.next = 5;
23
- break;
24
- }
25
- if (!(variant.source !== undefined)) {
26
- _context.next = 4;
27
- break;
28
- }
29
- return _context.abrupt("return", {
30
- source: variant.source,
31
- filename: undefined
32
- });
33
- case 4:
34
- throw new Error('No filename available and no source in variant');
35
- case 5:
36
- if (!(filename === variant.fileName && variant.source !== undefined)) {
37
- _context.next = 7;
38
- break;
39
- }
40
- return _context.abrupt("return", {
41
- source: variant.source,
42
- filename: filename
43
- });
44
- case 7:
45
- if (!(filename !== variant.fileName && variant.extraFiles)) {
46
- _context.next = 18;
47
- break;
48
- }
49
- extraFile = variant.extraFiles[filename];
50
- if (!(extraFile && typeof extraFile !== 'string' && extraFile.source !== undefined)) {
51
- _context.next = 11;
52
- break;
53
- }
54
- return _context.abrupt("return", {
55
- source: extraFile.source,
56
- filename: filename
57
- });
58
- case 11:
59
- if (!(typeof extraFile === 'string' && loadSource)) {
60
- _context.next = 16;
61
- break;
62
- }
63
- _context.next = 14;
64
- return loadSource(extraFile);
65
- case 14:
66
- loadResult = _context.sent;
67
- return _context.abrupt("return", {
68
- source: loadResult.source,
69
- filename: filename
70
- });
71
- case 16:
72
- if (!(extraFile && typeof extraFile !== 'string' && !extraFile.source && loadSource)) {
73
- _context.next = 18;
74
- break;
75
- }
76
- throw new Error("Extra file ".concat(filename, " has no source or URL to load from"));
77
- case 18:
78
- throw new Error("File ".concat(filename, " not found in variant or cannot be loaded"));
79
- case 19:
80
- case "end":
81
- return _context.stop();
82
- }
83
- }, _callee);
84
- }));
85
- return _getFileSource.apply(this, arguments);
86
- }
87
- export function loadFallbackCode(_x4, _x5, _x6, _x7, _x8, _x9, _x0, _x1, _x10, _x11, _x12, _x13, _x14) {
88
- return _loadFallbackCode.apply(this, arguments);
89
- }
90
- function _loadFallbackCode() {
91
- _loadFallbackCode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url, initialVariant, loaded, shouldHighlight, fallbackUsesExtraFiles, fallbackUsesAllVariants, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, initialFilename, variants, globalsCode) {
92
- var initial, _allFileNames, fileSource, actualFilename, result, parseSource, quickVariant, _allFileNames2, _fileSource, _actualFilename, _result, _parseSource, globalsCodeObjects, hasStringUrls, globalsPromises, resolvedGlobalsCode, _iterator, _step, codeObj, targetVariant, _yield$loadVariant, loadedVariant, allFileNames, allVariants, variantPromises, variantResults, finalInitial, finalFileSource, finalFilename, _result2;
93
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
94
- while (1) switch (_context4.prev = _context4.next) {
95
- case 0:
96
- loaded = _objectSpread({}, loaded);
97
-
98
- // Step 1: Ensure we have the initial variant loaded
99
- initial = loaded[initialVariant];
100
- if (initial) {
101
- _context4.next = 17;
102
- break;
103
- }
104
- if (loadCodeMeta) {
105
- _context4.next = 5;
106
- break;
107
- }
108
- throw new Error('"loadCodeMeta" function is required when initial variant is not provided');
109
- case 5:
110
- _context4.prev = 5;
111
- _context4.next = 8;
112
- return loadCodeMeta(url);
113
- case 8:
114
- loaded = _context4.sent;
115
- _context4.next = 14;
116
- break;
117
- case 11:
118
- _context4.prev = 11;
119
- _context4.t0 = _context4["catch"](5);
120
- throw new Error("Failed to load code from URL: ".concat(url, ". Error: ").concat(JSON.stringify(_context4.t0)));
121
- case 14:
122
- initial = loaded[initialVariant];
123
- if (initial) {
124
- _context4.next = 17;
125
- break;
126
- }
127
- throw new Error("Initial variant \"".concat(initialVariant, "\" not found in loaded code."));
128
- case 17:
129
- if (!(typeof initial !== 'string' && initial.allFilesListed && !fallbackUsesExtraFiles && !fallbackUsesAllVariants)) {
130
- _context4.next = 48;
131
- break;
132
- }
133
- // Collect all file names from the loaded code
134
- _allFileNames = new Set();
135
- if (initial.fileName) {
136
- _allFileNames.add(initial.fileName);
137
- }
138
- if (initial.extraFiles) {
139
- Object.keys(initial.extraFiles).forEach(function (fileName) {
140
- return _allFileNames.add(fileName);
141
- });
142
- }
143
-
144
- // Get the source for the requested filename (or main file if not specified)
145
- _context4.prev = 21;
146
- _context4.next = 24;
147
- return getFileSource(initial, initialFilename, loadSource);
148
- case 24:
149
- result = _context4.sent;
150
- fileSource = result.source;
151
- actualFilename = result.filename;
152
- _context4.next = 32;
153
- break;
154
- case 29:
155
- _context4.prev = 29;
156
- _context4.t1 = _context4["catch"](21);
157
- throw new Error("Failed to get source for file ".concat(initialFilename || initial.fileName, " in variant ").concat(initialVariant, ": ").concat(_context4.t1));
158
- case 32:
159
- if (!(shouldHighlight && typeof fileSource === 'string' && sourceParser && actualFilename)) {
160
- _context4.next = 45;
161
- break;
162
- }
163
- _context4.prev = 33;
164
- _context4.next = 36;
165
- return sourceParser;
166
- case 36:
167
- parseSource = _context4.sent;
168
- fileSource = parseSource(fileSource, actualFilename);
169
- _context4.next = 43;
170
- break;
171
- case 40:
172
- _context4.prev = 40;
173
- _context4.t2 = _context4["catch"](33);
174
- throw new Error("Failed to parse source for highlighting (variant: ".concat(initialVariant, ", file: ").concat(actualFilename, "): ").concat(JSON.stringify(_context4.t2)));
175
- case 43:
176
- _context4.next = 46;
177
- break;
178
- case 45:
179
- if (shouldHighlight && typeof fileSource === 'string' && !actualFilename) {
180
- // Create basic HAST node when we can't parse due to missing filename
181
- // This marks that the source has passed through the parsing pipeline
182
- fileSource = {
183
- type: 'root',
184
- children: [{
185
- type: 'text',
186
- value: fileSource
187
- }]
188
- };
189
- }
190
- case 46:
191
- // Update the loaded code with any changes we made
192
- if (actualFilename && actualFilename === initial.fileName) {
193
- initial = _objectSpread(_objectSpread({}, initial), {}, {
194
- source: fileSource
195
- });
196
- loaded = _objectSpread(_objectSpread({}, loaded), {}, _defineProperty({}, initialVariant, initial));
197
- } else if (!actualFilename && !initial.fileName) {
198
- // If both are undefined, we're dealing with the main source
199
- initial = _objectSpread(_objectSpread({}, initial), {}, {
200
- source: fileSource
201
- });
202
- loaded = _objectSpread(_objectSpread({}, loaded), {}, _defineProperty({}, initialVariant, initial));
203
- }
204
-
205
- // Early return - we have all the info we need
206
- return _context4.abrupt("return", {
207
- code: loaded,
208
- initialFilename: actualFilename,
209
- initialSource: fileSource,
210
- initialExtraFiles: initial.extraFiles || {},
211
- allFileNames: Array.from(_allFileNames)
212
- });
213
- case 48:
214
- if (!(typeof initial === 'string')) {
215
- _context4.next = 95;
216
- break;
217
- }
218
- _context4.prev = 49;
219
- if (!loadVariantMeta) {
220
- _context4.next = 56;
221
- break;
222
- }
223
- _context4.next = 53;
224
- return loadVariantMeta(initialVariant, initial);
225
- case 53:
226
- quickVariant = _context4.sent;
227
- _context4.next = 57;
228
- break;
229
- case 56:
230
- // Create a basic variant using fallback logic
231
- quickVariant = {
232
- url: initial,
233
- fileName: getFileNameFromUrl(initial).fileName
234
- };
235
- case 57:
236
- loaded = _objectSpread(_objectSpread({}, loaded), {}, _defineProperty({}, initialVariant, quickVariant));
237
- initial = quickVariant;
238
-
239
- // If we have all files listed and don't need extra file processing, we can optimize
240
- if (!(quickVariant.allFilesListed && !fallbackUsesExtraFiles && !fallbackUsesAllVariants)) {
241
- _context4.next = 90;
242
- break;
243
- }
244
- // Collect all file names from the quick load
245
- _allFileNames2 = new Set();
246
- if (quickVariant.fileName) {
247
- _allFileNames2.add(quickVariant.fileName);
248
- }
249
- if (quickVariant.extraFiles) {
250
- Object.keys(quickVariant.extraFiles).forEach(function (fileName) {
251
- return _allFileNames2.add(fileName);
252
- });
253
- }
254
-
255
- // Get the source for the requested filename (or main file if not specified)
256
- _context4.prev = 63;
257
- _context4.next = 66;
258
- return getFileSource(quickVariant, initialFilename, loadSource);
259
- case 66:
260
- _result = _context4.sent;
261
- _fileSource = _result.source;
262
- _actualFilename = _result.filename;
263
- _context4.next = 74;
264
- break;
265
- case 71:
266
- _context4.prev = 71;
267
- _context4.t3 = _context4["catch"](63);
268
- throw new Error("Failed to get source for file ".concat(initialFilename || quickVariant.fileName, " in variant ").concat(initialVariant, ": ").concat(_context4.t3));
269
- case 74:
270
- if (!(shouldHighlight && typeof _fileSource === 'string' && sourceParser && _actualFilename)) {
271
- _context4.next = 87;
272
- break;
273
- }
274
- _context4.prev = 75;
275
- _context4.next = 78;
276
- return sourceParser;
277
- case 78:
278
- _parseSource = _context4.sent;
279
- _fileSource = _parseSource(_fileSource, _actualFilename);
280
- _context4.next = 85;
281
- break;
282
- case 82:
283
- _context4.prev = 82;
284
- _context4.t4 = _context4["catch"](75);
285
- throw new Error("Failed to parse source for highlighting (variant: ".concat(initialVariant, ", file: ").concat(_actualFilename, "): ").concat(JSON.stringify(_context4.t4)));
286
- case 85:
287
- _context4.next = 88;
288
- break;
289
- case 87:
290
- if (shouldHighlight && typeof _fileSource === 'string' && !_actualFilename) {
291
- // Create basic HAST node when we can't parse due to missing filename
292
- // This marks that the source has passed through the parsing pipeline
293
- _fileSource = {
294
- type: 'root',
295
- children: [{
296
- type: 'text',
297
- value: _fileSource
298
- }]
299
- };
300
- }
301
- case 88:
302
- // Update the loaded code with any changes we made
303
- if (_actualFilename && _actualFilename === quickVariant.fileName) {
304
- initial = _objectSpread(_objectSpread({}, quickVariant), {}, {
305
- source: _fileSource
306
- });
307
- loaded = _objectSpread(_objectSpread({}, loaded), {}, _defineProperty({}, initialVariant, initial));
308
- } else if (!_actualFilename && !quickVariant.fileName) {
309
- // If both are undefined, we're dealing with the main source
310
- initial = _objectSpread(_objectSpread({}, quickVariant), {}, {
311
- source: _fileSource
312
- });
313
- loaded = _objectSpread(_objectSpread({}, loaded), {}, _defineProperty({}, initialVariant, initial));
314
- }
315
-
316
- // Early return - we have all the info we need
317
- return _context4.abrupt("return", {
318
- code: loaded,
319
- initialFilename: _actualFilename,
320
- initialSource: _fileSource,
321
- initialExtraFiles: quickVariant.extraFiles || {},
322
- allFileNames: Array.from(_allFileNames2)
323
- });
324
- case 90:
325
- _context4.next = 95;
326
- break;
327
- case 92:
328
- _context4.prev = 92;
329
- _context4.t5 = _context4["catch"](49);
330
- throw new Error("Failed to load initial variant code (variant: ".concat(initialVariant, ", url: ").concat(initial, "): ").concat(JSON.stringify(_context4.t5)));
331
- case 95:
332
- if (!(globalsCode && globalsCode.length > 0)) {
333
- _context4.next = 103;
334
- break;
335
- }
336
- hasStringUrls = globalsCode.some(function (item) {
337
- return typeof item === 'string';
338
- });
339
- if (!(hasStringUrls && !loadCodeMeta)) {
340
- _context4.next = 99;
341
- break;
342
- }
343
- throw new Error('loadCodeMeta function is required when globalsCode contains string URLs');
344
- case 99:
345
- // Load all string URLs in parallel, keep Code objects as-is
346
- globalsPromises = globalsCode.map(/*#__PURE__*/function () {
347
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(globalItem) {
348
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
349
- while (1) switch (_context2.prev = _context2.next) {
350
- case 0:
351
- if (!(typeof globalItem === 'string')) {
352
- _context2.next = 12;
353
- break;
354
- }
355
- _context2.prev = 1;
356
- _context2.next = 4;
357
- return loadCodeMeta(globalItem);
358
- case 4:
359
- return _context2.abrupt("return", _context2.sent);
360
- case 7:
361
- _context2.prev = 7;
362
- _context2.t0 = _context2["catch"](1);
363
- throw new Error("Failed to load globalsCode from URL: ".concat(globalItem, ". Error: ").concat(JSON.stringify(_context2.t0)));
364
- case 10:
365
- _context2.next = 13;
366
- break;
367
- case 12:
368
- return _context2.abrupt("return", globalItem);
369
- case 13:
370
- case "end":
371
- return _context2.stop();
372
- }
373
- }, _callee2, null, [[1, 7]]);
374
- }));
375
- return function (_x15) {
376
- return _ref.apply(this, arguments);
377
- };
378
- }());
379
- _context4.next = 102;
380
- return Promise.all(globalsPromises);
381
- case 102:
382
- globalsCodeObjects = _context4.sent;
383
- case 103:
384
- if (globalsCodeObjects && globalsCodeObjects.length > 0) {
385
- resolvedGlobalsCode = [];
386
- _iterator = _createForOfIteratorHelper(globalsCodeObjects);
387
- try {
388
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
389
- codeObj = _step.value;
390
- // Only use the variant that matches the current initialVariant
391
- targetVariant = codeObj[initialVariant];
392
- if (targetVariant) {
393
- resolvedGlobalsCode.push(targetVariant);
394
- }
395
- }
396
- } catch (err) {
397
- _iterator.e(err);
398
- } finally {
399
- _iterator.f();
400
- }
401
- }
402
- _context4.prev = 104;
403
- _context4.next = 107;
404
- return loadVariant(url, initialVariant, initial, sourceParser, loadSource, loadVariantMeta, undefined,
405
- // sourceTransformers - skip transforms for fallback
406
- {
407
- disableTransforms: true,
408
- // Don't apply transforms for fallback
409
- disableParsing: !shouldHighlight,
410
- // Only parse if highlighting is needed
411
- globalsCode: resolvedGlobalsCode // Pass resolved globalsCode
412
- });
413
- case 107:
414
- _yield$loadVariant = _context4.sent;
415
- loadedVariant = _yield$loadVariant.code;
416
- // Update the loaded code with the processed variant
417
- loaded = _objectSpread(_objectSpread({}, loaded), {}, _defineProperty({}, initialVariant, loadedVariant));
418
- initial = loadedVariant;
419
- _context4.next = 116;
420
- break;
421
- case 113:
422
- _context4.prev = 113;
423
- _context4.t6 = _context4["catch"](104);
424
- throw new Error("Failed to load initial variant using loadVariant (variant: ".concat(initialVariant, ", url: ").concat(url, "): ").concat(JSON.stringify(_context4.t6)));
425
- case 116:
426
- // Step 3: Collect all file names
427
- allFileNames = new Set();
428
- if (initial.fileName) {
429
- allFileNames.add(initial.fileName);
430
- }
431
-
432
- // Add extra files from the initial variant
433
- if (initial.extraFiles) {
434
- Object.keys(initial.extraFiles).forEach(function (fileName) {
435
- return allFileNames.add(fileName);
436
- });
437
- }
438
-
439
- // Step 4: Handle fallbackUsesAllVariants - load all variants to get all possible files
440
- if (!fallbackUsesAllVariants) {
441
- _context4.next = 130;
442
- break;
443
- }
444
- // Determine all variants to process - use provided variants or infer from loaded code
445
- allVariants = variants || Object.keys(loaded || {});
446
- if (!(allVariants.length === 0)) {
447
- _context4.next = 125;
448
- break;
449
- }
450
- console.warn('No variants found for fallbackUsesAllVariants processing');
451
- _context4.next = 130;
452
- break;
453
- case 125:
454
- // Process all required variants, not just the ones already loaded
455
- variantPromises = allVariants.map(/*#__PURE__*/function () {
456
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(variantName) {
457
- var _loaded;
458
- var variant, allCode, _yield$loadVariant2, _loadedVariant, fileNames;
459
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
460
- while (1) switch (_context3.prev = _context3.next) {
461
- case 0:
462
- if (!(variantName === initialVariant)) {
463
- _context3.next = 2;
464
- break;
465
- }
466
- return _context3.abrupt("return", {
467
- variantName: variantName,
468
- loadedVariant: null,
469
- fileNames: []
470
- });
471
- case 2:
472
- variant = (_loaded = loaded) == null ? void 0 : _loaded[variantName]; // If variant is not loaded yet, load it first using loadCodeMeta
473
- if (!(!variant && loadCodeMeta)) {
474
- _context3.next = 16;
475
- break;
476
- }
477
- _context3.prev = 4;
478
- _context3.next = 7;
479
- return loadCodeMeta(url);
480
- case 7:
481
- allCode = _context3.sent;
482
- variant = allCode[variantName];
483
- // Update loaded with all variants from loadCodeMeta
484
- loaded = _objectSpread(_objectSpread({}, loaded), allCode);
485
- _context3.next = 16;
486
- break;
487
- case 12:
488
- _context3.prev = 12;
489
- _context3.t0 = _context3["catch"](4);
490
- console.warn("Failed to load code meta for variant ".concat(variantName, ": ").concat(_context3.t0));
491
- return _context3.abrupt("return", {
492
- variantName: variantName,
493
- loadedVariant: null,
494
- fileNames: []
495
- });
496
- case 16:
497
- if (variant) {
498
- _context3.next = 19;
499
- break;
500
- }
501
- console.warn("Variant ".concat(variantName, " not found after loading code meta"));
502
- return _context3.abrupt("return", {
503
- variantName: variantName,
504
- loadedVariant: null,
505
- fileNames: []
506
- });
507
- case 19:
508
- _context3.prev = 19;
509
- _context3.next = 22;
510
- return loadVariant(url, variantName, variant, sourceParser, loadSource, loadVariantMeta, undefined,
511
- // sourceTransformers
512
- {
513
- disableTransforms: true,
514
- disableParsing: !shouldHighlight,
515
- globalsCode: globalsCodeObjects && globalsCodeObjects.length > 0 ? function () {
516
- // Convert globalsCodeObjects to VariantCode | string for this specific variant
517
- var variantGlobalsCode = [];
518
- var _iterator2 = _createForOfIteratorHelper(globalsCodeObjects),
519
- _step2;
520
- try {
521
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
522
- var _codeObj = _step2.value;
523
- // Only use the variant that matches the current variantName
524
- var _targetVariant = _codeObj[variantName];
525
- if (_targetVariant) {
526
- variantGlobalsCode.push(_targetVariant);
527
- }
528
- }
529
- } catch (err) {
530
- _iterator2.e(err);
531
- } finally {
532
- _iterator2.f();
533
- }
534
- return variantGlobalsCode;
535
- }() : undefined
536
- });
537
- case 22:
538
- _yield$loadVariant2 = _context3.sent;
539
- _loadedVariant = _yield$loadVariant2.code;
540
- // Collect file names from this variant
541
- fileNames = _loadedVariant.fileName ? [_loadedVariant.fileName] : [];
542
- if (_loadedVariant.extraFiles) {
543
- fileNames.push.apply(fileNames, _toConsumableArray(Object.keys(_loadedVariant.extraFiles)));
544
- }
545
- return _context3.abrupt("return", {
546
- variantName: variantName,
547
- loadedVariant: _loadedVariant,
548
- fileNames: fileNames
549
- });
550
- case 29:
551
- _context3.prev = 29;
552
- _context3.t1 = _context3["catch"](19);
553
- // Log but don't fail - we want to get as many file names as possible
554
- console.warn("Failed to load variant ".concat(variantName, " for file listing: ").concat(_context3.t1));
555
- return _context3.abrupt("return", {
556
- variantName: variantName,
557
- loadedVariant: null,
558
- fileNames: []
559
- });
560
- case 33:
561
- case "end":
562
- return _context3.stop();
563
- }
564
- }, _callee3, null, [[4, 12], [19, 29]]);
565
- }));
566
- return function (_x16) {
567
- return _ref2.apply(this, arguments);
568
- };
569
- }());
570
- _context4.next = 128;
571
- return Promise.all(variantPromises);
572
- case 128:
573
- variantResults = _context4.sent;
574
- // Update loaded code and collect file names
575
- variantResults.forEach(function (_ref3) {
576
- var variantName = _ref3.variantName,
577
- loadedVariant = _ref3.loadedVariant,
578
- fileNames = _ref3.fileNames;
579
- if (loadedVariant) {
580
- loaded = _objectSpread(_objectSpread({}, loaded), {}, _defineProperty({}, variantName, loadedVariant));
581
- }
582
- fileNames.forEach(function (fileName) {
583
- return allFileNames.add(fileName);
584
- });
585
- });
586
- case 130:
587
- // Ensure we have the latest initial variant data
588
- finalInitial = loaded[initialVariant];
589
- if (!(!finalInitial || typeof finalInitial === 'string')) {
590
- _context4.next = 133;
591
- break;
592
- }
593
- throw new Error("Failed to process initial variant: ".concat(initialVariant));
594
- case 133:
595
- _context4.prev = 133;
596
- _context4.next = 136;
597
- return getFileSource(finalInitial, initialFilename, loadSource);
598
- case 136:
599
- _result2 = _context4.sent;
600
- finalFileSource = _result2.source;
601
- finalFilename = _result2.filename;
602
- _context4.next = 147;
603
- break;
604
- case 141:
605
- _context4.prev = 141;
606
- _context4.t7 = _context4["catch"](133);
607
- if (!(!finalInitial.fileName && !finalInitial.source)) {
608
- _context4.next = 145;
609
- break;
610
- }
611
- throw new Error("Cannot determine filename for initial variant \"".concat(initialVariant, "\". ") + "No fileName available in variant definition, no initialFilename provided, and no source available.");
612
- case 145:
613
- // Fall back to the main file with proper validation
614
- finalFileSource = finalInitial.source || '';
615
- finalFilename = finalInitial.fileName;
616
- case 147:
617
- return _context4.abrupt("return", {
618
- code: loaded,
619
- initialFilename: finalFilename,
620
- initialSource: finalFileSource,
621
- initialExtraFiles: finalInitial.extraFiles || {},
622
- allFileNames: Array.from(allFileNames),
623
- processedGlobalsCode: globalsCodeObjects
624
- });
625
- case 148:
626
- case "end":
627
- return _context4.stop();
628
- }
629
- }, _callee4, null, [[5, 11], [21, 29], [33, 40], [49, 92], [63, 71], [75, 82], [104, 113], [133, 141]]);
630
- }));
631
- return _loadFallbackCode.apply(this, arguments);
632
- }
@@ -1,12 +0,0 @@
1
- import type { VariantCode, ParseSource, LoadSource, LoadVariantMeta, SourceTransformers, LoadFileOptions, Externals } from "./types.js";
2
- /**
3
- * Loads a variant with support for recursive extra file loading.
4
- * The loadSource function can now return extraFiles that will be loaded recursively.
5
- * Supports both relative and absolute paths for extra files.
6
- * Uses Promise.all for efficient parallel loading of extra files.
7
- */
8
- export declare function loadVariant(url: string | undefined, variantName: string, variant: VariantCode | string | undefined, sourceParser?: Promise<ParseSource>, loadSource?: LoadSource, loadVariantMeta?: LoadVariantMeta, sourceTransformers?: SourceTransformers, options?: LoadFileOptions): Promise<{
9
- code: VariantCode;
10
- dependencies: string[];
11
- externals: Externals;
12
- }>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadVariant.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/loadVariant.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EAIX,WAAW,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,SAAS,EACV,MAAM,SAAS,CAAC;AA0gBjB;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EACzC,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,EACnC,UAAU,CAAC,EAAE,UAAU,EACvB,eAAe,CAAC,EAAE,eAAe,EACjC,kBAAkB,CAAC,EAAE,kBAAkB,EACvC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC,CAwV9E"}