@mui/internal-docs-infra 0.1.1-canary.9 → 0.2.0-alpha.2
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.
- package/CHANGELOG.md +9 -0
- package/README.md +3 -11
- package/esm/CodeControllerContext/CodeControllerContext.d.ts +62 -0
- package/esm/CodeControllerContext/CodeControllerContext.js +33 -0
- package/esm/CodeControllerContext/index.d.ts +1 -0
- package/esm/CodeControllerContext/index.js +1 -0
- package/esm/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
- package/esm/CodeExternalsContext/CodeExternalsContext.js +8 -0
- package/esm/CodeExternalsContext/index.d.ts +1 -0
- package/esm/CodeExternalsContext/index.js +1 -0
- package/esm/CodeHighlighter/CodeHighlighter.d.ts +2 -0
- package/esm/CodeHighlighter/CodeHighlighter.js +441 -0
- package/esm/CodeHighlighter/CodeHighlighterClient.d.ts +2 -0
- package/esm/CodeHighlighter/CodeHighlighterClient.js +984 -0
- package/esm/CodeHighlighter/CodeHighlighterContext.d.ts +16 -0
- package/esm/CodeHighlighter/CodeHighlighterContext.js +15 -0
- package/esm/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +7 -0
- package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +14 -0
- package/esm/CodeHighlighter/addPathsToVariant.d.ts +14 -0
- package/esm/CodeHighlighter/addPathsToVariant.js +68 -0
- package/esm/CodeHighlighter/applyTransform.d.ts +19 -0
- package/esm/CodeHighlighter/applyTransform.js +75 -0
- package/esm/CodeHighlighter/calculateMainFilePath.d.ts +1 -0
- package/esm/CodeHighlighter/calculateMainFilePath.js +108 -0
- package/esm/CodeHighlighter/codeToFallbackProps.d.ts +2 -0
- package/esm/CodeHighlighter/codeToFallbackProps.js +73 -0
- package/esm/CodeHighlighter/errors.d.ts +141 -0
- package/esm/CodeHighlighter/errors.js +441 -0
- package/esm/CodeHighlighter/examineVariant.d.ts +25 -0
- package/esm/CodeHighlighter/examineVariant.js +73 -0
- package/esm/CodeHighlighter/hasAllVariants.d.ts +27 -0
- package/esm/CodeHighlighter/hasAllVariants.js +63 -0
- package/esm/CodeHighlighter/index.d.ts +1 -0
- package/esm/CodeHighlighter/index.js +1 -0
- package/esm/CodeHighlighter/loadFallbackCode.d.ts +10 -0
- package/esm/CodeHighlighter/loadFallbackCode.js +679 -0
- package/esm/CodeHighlighter/loadVariant.d.ts +12 -0
- package/esm/CodeHighlighter/loadVariant.js +1044 -0
- package/esm/CodeHighlighter/maybeInitialData.d.ts +108 -0
- package/esm/CodeHighlighter/maybeInitialData.js +192 -0
- package/esm/CodeHighlighter/mergeMetadata.d.ts +40 -0
- package/esm/CodeHighlighter/mergeMetadata.js +165 -0
- package/esm/CodeHighlighter/parseCode.d.ts +6 -0
- package/esm/CodeHighlighter/parseCode.js +134 -0
- package/esm/CodeHighlighter/parseControlledCode.d.ts +6 -0
- package/esm/CodeHighlighter/parseControlledCode.js +87 -0
- package/esm/CodeHighlighter/pathUtils.d.ts +120 -0
- package/esm/CodeHighlighter/pathUtils.js +258 -0
- package/esm/CodeHighlighter/transformCode.d.ts +21 -0
- package/esm/CodeHighlighter/transformCode.js +251 -0
- package/esm/CodeHighlighter/transformParsedSource.d.ts +3 -0
- package/esm/CodeHighlighter/transformParsedSource.js +60 -0
- package/esm/CodeHighlighter/transformSource.d.ts +2 -0
- package/esm/CodeHighlighter/transformSource.js +103 -0
- package/esm/CodeHighlighter/types.d.ts +276 -0
- package/esm/CodeHighlighter/types.js +1 -0
- package/esm/CodeProvider/CodeContext.d.ts +31 -0
- package/esm/CodeProvider/CodeContext.js +12 -0
- package/esm/CodeProvider/CodeProvider.d.ts +13 -0
- package/esm/CodeProvider/CodeProvider.js +83 -0
- package/esm/CodeProvider/index.d.ts +1 -0
- package/esm/CodeProvider/index.js +1 -0
- package/esm/abstractCreateDemo/abstractCreateDemo.d.ts +45 -0
- package/esm/abstractCreateDemo/abstractCreateDemo.js +100 -0
- package/esm/abstractCreateDemo/index.d.ts +1 -0
- package/esm/abstractCreateDemo/index.js +1 -0
- package/esm/abstractCreateDemoClient/abstractCreateDemoClient.d.ts +32 -0
- package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +52 -0
- package/esm/abstractCreateDemoClient/index.d.ts +1 -0
- package/esm/abstractCreateDemoClient/index.js +1 -0
- package/esm/createDemoData/createDemoData.d.ts +44 -0
- package/esm/createDemoData/createDemoData.js +74 -0
- package/esm/createDemoData/index.d.ts +1 -0
- package/esm/createDemoData/index.js +1 -0
- package/esm/createDemoData/types.d.ts +25 -0
- package/esm/createDemoData/types.js +1 -0
- package/esm/pipeline/hastUtils/hastUtils.d.ts +11 -0
- package/esm/pipeline/hastUtils/hastUtils.js +67 -0
- package/esm/pipeline/hastUtils/index.d.ts +1 -0
- package/esm/pipeline/hastUtils/index.js +1 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/index.js +4 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +14 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +178 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +47 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +849 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.d.ts +85 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +715 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +14 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.d.ts +11 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +203 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.d.ts +6 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +23 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.d.ts +6 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +148 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.d.ts +9 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +198 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/index.js +4 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.d.ts +5 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +21 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.d.ts +15 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +233 -0
- package/esm/pipeline/loadServerCodeMeta/index.d.ts +1 -0
- package/esm/pipeline/loadServerCodeMeta/index.js +1 -0
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +24 -0
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +90 -0
- package/esm/pipeline/loadServerSource/index.d.ts +1 -0
- package/esm/pipeline/loadServerSource/index.js +1 -0
- package/esm/pipeline/loadServerSource/loadServerSource.d.ts +25 -0
- package/esm/pipeline/loadServerSource/loadServerSource.js +134 -0
- package/esm/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
- package/esm/pipeline/loaderUtils/externalsToPackages.js +46 -0
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
- package/esm/pipeline/loaderUtils/getFileNameFromUrl.d.ts +12 -0
- package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +66 -0
- package/esm/pipeline/loaderUtils/index.d.ts +7 -0
- package/esm/pipeline/loaderUtils/index.js +7 -0
- package/esm/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
- package/esm/pipeline/loaderUtils/mergeExternals.js +72 -0
- package/esm/pipeline/loaderUtils/parseImports.d.ts +19 -0
- package/esm/pipeline/loaderUtils/parseImports.js +306 -0
- package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +19 -0
- package/esm/pipeline/loaderUtils/processRelativeImports.js +352 -0
- package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +87 -0
- package/esm/pipeline/loaderUtils/resolveModulePath.js +1435 -0
- package/esm/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +47 -0
- package/esm/pipeline/loaderUtils/resolveModulePathWithFs.js +150 -0
- package/esm/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
- package/esm/pipeline/loaderUtils/rewriteImports.js +35 -0
- package/esm/pipeline/parseSource/addLineGutters.d.ts +9 -0
- package/esm/pipeline/parseSource/addLineGutters.js +181 -0
- package/esm/pipeline/parseSource/grammars.d.ts +2 -0
- package/esm/pipeline/parseSource/grammars.js +27 -0
- package/esm/pipeline/parseSource/index.d.ts +1 -0
- package/esm/pipeline/parseSource/index.js +1 -0
- package/esm/pipeline/parseSource/parseSource.d.ts +3 -0
- package/esm/pipeline/parseSource/parseSource.js +51 -0
- package/esm/pipeline/transformHtmlCode/index.d.ts +2 -0
- package/esm/pipeline/transformHtmlCode/index.js +4 -0
- package/esm/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
- package/esm/pipeline/transformHtmlCode/transformHtmlCode.js +300 -0
- package/esm/pipeline/transformMarkdownCode/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownCode/index.js +4 -0
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
- package/esm/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
- package/esm/pipeline/transformTypescriptToJavascript/index.js +1 -0
- package/esm/pipeline/transformTypescriptToJavascript/removeTypes.d.ts +13 -0
- package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +131 -0
- package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
- package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +31 -0
- package/esm/useCode/Pre.d.ts +15 -0
- package/esm/useCode/Pre.js +164 -0
- package/esm/useCode/index.d.ts +1 -0
- package/esm/useCode/index.js +1 -0
- package/esm/useCode/useCode.d.ts +41 -0
- package/esm/useCode/useCode.js +128 -0
- package/esm/useCode/useCodeUtils.d.ts +44 -0
- package/esm/useCode/useCodeUtils.js +245 -0
- package/esm/useCode/useCopyFunctionality.d.ts +18 -0
- package/esm/useCode/useCopyFunctionality.js +28 -0
- package/esm/useCode/useFileNavigation.d.ts +41 -0
- package/esm/useCode/useFileNavigation.js +453 -0
- package/esm/useCode/useSourceEditing.d.ts +21 -0
- package/esm/useCode/useSourceEditing.js +32 -0
- package/esm/useCode/useTransformManagement.d.ts +30 -0
- package/esm/useCode/useTransformManagement.js +72 -0
- package/esm/useCode/useUIState.d.ts +16 -0
- package/esm/useCode/useUIState.js +21 -0
- package/esm/useCode/useVariantSelection.d.ts +23 -0
- package/esm/useCode/useVariantSelection.js +75 -0
- package/esm/useCopier/index.d.ts +1 -1
- package/esm/useCopier/index.js +5 -5
- package/esm/useDemo/createCodeSandbox.d.ts +15 -0
- package/esm/useDemo/createCodeSandbox.js +42 -0
- package/esm/useDemo/createStackBlitz.d.ts +22 -0
- package/esm/useDemo/createStackBlitz.js +38 -0
- package/esm/useDemo/exportVariant.d.ts +184 -0
- package/esm/useDemo/exportVariant.js +422 -0
- package/esm/useDemo/exportVariantAsCra.d.ts +15 -0
- package/esm/useDemo/exportVariantAsCra.js +57 -0
- package/esm/useDemo/flattenVariant.d.ts +19 -0
- package/esm/useDemo/flattenVariant.js +49 -0
- package/esm/useDemo/index.d.ts +6 -51
- package/esm/useDemo/index.js +6 -104
- package/esm/useDemo/useDemo.d.ts +81 -0
- package/esm/useDemo/useDemo.js +193 -0
- package/esm/useErrors/ErrorsContext.d.ts +6 -0
- package/esm/useErrors/ErrorsContext.js +8 -0
- package/esm/useErrors/index.d.ts +1 -0
- package/esm/useErrors/index.js +1 -0
- package/esm/useErrors/useErrors.d.ts +5 -0
- package/esm/useErrors/useErrors.js +7 -0
- package/esm/useLocalStorageState/index.d.ts +2 -0
- package/esm/useLocalStorageState/index.js +2 -0
- package/esm/useLocalStorageState/useLocalStorageState.d.ts +14 -0
- package/esm/useLocalStorageState/useLocalStorageState.js +128 -0
- package/esm/usePreference/PreferencesProvider.d.ts +6 -0
- package/esm/usePreference/PreferencesProvider.js +8 -0
- package/esm/usePreference/index.d.ts +2 -0
- package/esm/usePreference/index.js +2 -0
- package/esm/usePreference/usePreference.d.ts +2 -0
- package/esm/usePreference/usePreference.js +25 -0
- package/esm/useUrlHashState/index.d.ts +1 -0
- package/esm/useUrlHashState/index.js +1 -0
- package/esm/useUrlHashState/useUrlHashState.d.ts +5 -0
- package/esm/useUrlHashState/useUrlHashState.js +68 -0
- package/esm/withDocsInfra/index.d.ts +1 -0
- package/esm/withDocsInfra/index.js +1 -0
- package/esm/withDocsInfra/withDocsInfra.d.ts +82 -0
- package/esm/withDocsInfra/withDocsInfra.js +147 -0
- package/package.json +178 -11
- package/esm/useCopier/index.d.ts.map +0 -1
- package/esm/useDemo/index.d.ts.map +0 -1
|
@@ -0,0 +1,984 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
7
|
+
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
8
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useCodeContext } from "../CodeProvider/CodeContext.js";
|
|
11
|
+
import { CodeHighlighterContext } from "./CodeHighlighterContext.js";
|
|
12
|
+
import { maybeInitialData } from "./maybeInitialData.js";
|
|
13
|
+
import { hasAllVariants } from "./hasAllVariants.js";
|
|
14
|
+
import { CodeHighlighterFallbackContext } from "./CodeHighlighterFallbackContext.js";
|
|
15
|
+
import { useControlledCode } from "../CodeControllerContext/index.js";
|
|
16
|
+
import { codeToFallbackProps } from "./codeToFallbackProps.js";
|
|
17
|
+
import { mergeMetadata } from "./mergeMetadata.js";
|
|
18
|
+
import * as Errors from "./errors.js";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
var DEBUG = false; // Set to true for debugging purposes
|
|
21
|
+
|
|
22
|
+
function useInitialData(_ref) {
|
|
23
|
+
var variants = _ref.variants,
|
|
24
|
+
variantName = _ref.variantName,
|
|
25
|
+
code = _ref.code,
|
|
26
|
+
setCode = _ref.setCode,
|
|
27
|
+
fileName = _ref.fileName,
|
|
28
|
+
url = _ref.url,
|
|
29
|
+
highlightAt = _ref.highlightAt,
|
|
30
|
+
fallbackUsesExtraFiles = _ref.fallbackUsesExtraFiles,
|
|
31
|
+
fallbackUsesAllVariants = _ref.fallbackUsesAllVariants,
|
|
32
|
+
isControlled = _ref.isControlled,
|
|
33
|
+
globalsCode = _ref.globalsCode,
|
|
34
|
+
setProcessedGlobalsCode = _ref.setProcessedGlobalsCode;
|
|
35
|
+
var _useCodeContext = useCodeContext(),
|
|
36
|
+
sourceParser = _useCodeContext.sourceParser,
|
|
37
|
+
loadCodeMeta = _useCodeContext.loadCodeMeta,
|
|
38
|
+
loadVariantMeta = _useCodeContext.loadVariantMeta,
|
|
39
|
+
loadSource = _useCodeContext.loadSource,
|
|
40
|
+
loadFallbackCode = _useCodeContext.loadFallbackCode;
|
|
41
|
+
var _React$useMemo = React.useMemo(function () {
|
|
42
|
+
return maybeInitialData(variants, variantName, code, fileName, highlightAt === 'init', fallbackUsesExtraFiles, fallbackUsesAllVariants);
|
|
43
|
+
}, [variants, variantName, code, fileName, highlightAt, fallbackUsesExtraFiles, fallbackUsesAllVariants]),
|
|
44
|
+
initialData = _React$useMemo.initialData,
|
|
45
|
+
reason = _React$useMemo.reason;
|
|
46
|
+
var needsFallback = !initialData && !isControlled;
|
|
47
|
+
if (needsFallback) {
|
|
48
|
+
if (!url) {
|
|
49
|
+
// URL is required for loading fallback data
|
|
50
|
+
throw new Errors.ErrorCodeHighlighterClientMissingUrlForFallback();
|
|
51
|
+
}
|
|
52
|
+
if (!loadFallbackCode) {
|
|
53
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadFallbackCode(url);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// TODO: fallbackInitialRenderOnly option? this would mean we can't fetch fallback data on the client side
|
|
58
|
+
// Load initial data if not provided
|
|
59
|
+
React.useEffect(function () {
|
|
60
|
+
if (!needsFallback || !url || !loadFallbackCode) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// TODO: abort controller
|
|
65
|
+
|
|
66
|
+
_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
67
|
+
var loaded;
|
|
68
|
+
return _regenerator().w(function (_context) {
|
|
69
|
+
while (1) switch (_context.n) {
|
|
70
|
+
case 0:
|
|
71
|
+
if (DEBUG) {
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log('Loading initial data for CodeHighlighterClient: ', reason);
|
|
74
|
+
}
|
|
75
|
+
_context.n = 1;
|
|
76
|
+
return loadFallbackCode(url, variantName, code, {
|
|
77
|
+
shouldHighlight: highlightAt === 'init',
|
|
78
|
+
fallbackUsesExtraFiles: fallbackUsesExtraFiles,
|
|
79
|
+
fallbackUsesAllVariants: fallbackUsesAllVariants,
|
|
80
|
+
sourceParser: sourceParser,
|
|
81
|
+
loadSource: loadSource,
|
|
82
|
+
loadVariantMeta: loadVariantMeta,
|
|
83
|
+
loadCodeMeta: loadCodeMeta,
|
|
84
|
+
initialFilename: fileName,
|
|
85
|
+
variants: variants,
|
|
86
|
+
globalsCode: globalsCode // Let loadFallbackCode handle processing
|
|
87
|
+
})["catch"](function (error) {
|
|
88
|
+
return {
|
|
89
|
+
error: error
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
case 1:
|
|
93
|
+
loaded = _context.v;
|
|
94
|
+
if ('error' in loaded) {
|
|
95
|
+
console.error(new Errors.ErrorCodeHighlighterClientLoadFallbackFailure(loaded.error));
|
|
96
|
+
} else {
|
|
97
|
+
setCode(loaded.code);
|
|
98
|
+
// Store processed globalsCode from loadFallbackCode result
|
|
99
|
+
if (loaded.processedGlobalsCode) {
|
|
100
|
+
setProcessedGlobalsCode(loaded.processedGlobalsCode);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
case 2:
|
|
104
|
+
return _context.a(2);
|
|
105
|
+
}
|
|
106
|
+
}, _callee);
|
|
107
|
+
}))();
|
|
108
|
+
}, [initialData, reason, needsFallback, variantName, code, setCode, highlightAt, url, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, fallbackUsesExtraFiles, fallbackUsesAllVariants, fileName, variants, globalsCode, setProcessedGlobalsCode, loadFallbackCode]);
|
|
109
|
+
}
|
|
110
|
+
function useAllVariants(_ref3) {
|
|
111
|
+
var readyForContent = _ref3.readyForContent,
|
|
112
|
+
variants = _ref3.variants,
|
|
113
|
+
isControlled = _ref3.isControlled,
|
|
114
|
+
url = _ref3.url,
|
|
115
|
+
code = _ref3.code,
|
|
116
|
+
setCode = _ref3.setCode,
|
|
117
|
+
processedGlobalsCode = _ref3.processedGlobalsCode,
|
|
118
|
+
globalsCode = _ref3.globalsCode,
|
|
119
|
+
setProcessedGlobalsCode = _ref3.setProcessedGlobalsCode;
|
|
120
|
+
var _useCodeContext2 = useCodeContext(),
|
|
121
|
+
loadCodeMeta = _useCodeContext2.loadCodeMeta,
|
|
122
|
+
loadVariantMeta = _useCodeContext2.loadVariantMeta,
|
|
123
|
+
loadSource = _useCodeContext2.loadSource,
|
|
124
|
+
loadVariant = _useCodeContext2.loadVariant;
|
|
125
|
+
var needsData = !readyForContent && !isControlled;
|
|
126
|
+
|
|
127
|
+
// validation
|
|
128
|
+
React.useMemo(function () {
|
|
129
|
+
if (needsData) {
|
|
130
|
+
if (!url) {
|
|
131
|
+
throw new Errors.ErrorCodeHighlighterClientMissingUrlForVariants();
|
|
132
|
+
}
|
|
133
|
+
if (!loadVariant) {
|
|
134
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadVariant(url);
|
|
135
|
+
}
|
|
136
|
+
if (!code && !loadCodeMeta) {
|
|
137
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadCodeMetaForNoCode(url);
|
|
138
|
+
}
|
|
139
|
+
if (globalsCode && globalsCode.length > 0 && globalsCode.some(function (item) {
|
|
140
|
+
return typeof item === 'string';
|
|
141
|
+
}) && !loadCodeMeta) {
|
|
142
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadCodeMetaForGlobals();
|
|
143
|
+
}
|
|
144
|
+
if (!code && !loadSource) {
|
|
145
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadSourceForNoCode();
|
|
146
|
+
}
|
|
147
|
+
if (code && Object.keys(code).some(function (variantName) {
|
|
148
|
+
var variant = code[variantName];
|
|
149
|
+
if (!variant || typeof variant === 'string' || !variant.source) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
var extraFiles = variant.extraFiles;
|
|
153
|
+
if (extraFiles && Object.keys(extraFiles).some(function (fileName) {
|
|
154
|
+
return !extraFiles[fileName] || typeof extraFiles[fileName] === 'string' || !extraFiles[fileName].source;
|
|
155
|
+
})) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}) && !loadSource) {
|
|
160
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadSourceForUnloadedUrls();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, [code, globalsCode, loadCodeMeta, loadVariant, loadSource, needsData, url]);
|
|
164
|
+
React.useEffect(function () {
|
|
165
|
+
if (!needsData || !url || !loadVariant) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// TODO: abort controller
|
|
170
|
+
|
|
171
|
+
_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
172
|
+
var loadedCode, globalsCodeObjects, result, resultCode, errors, _iterator, _step, item, _t;
|
|
173
|
+
return _regenerator().w(function (_context3) {
|
|
174
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
175
|
+
case 0:
|
|
176
|
+
_context3.p = 0;
|
|
177
|
+
loadedCode = code;
|
|
178
|
+
if (loadedCode) {
|
|
179
|
+
_context3.n = 3;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (loadCodeMeta) {
|
|
183
|
+
_context3.n = 1;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadCodeMeta();
|
|
187
|
+
case 1:
|
|
188
|
+
_context3.n = 2;
|
|
189
|
+
return loadCodeMeta(url);
|
|
190
|
+
case 2:
|
|
191
|
+
loadedCode = _context3.v;
|
|
192
|
+
case 3:
|
|
193
|
+
// Use the already-processed globalsCode from state, or process it if not available
|
|
194
|
+
globalsCodeObjects = [];
|
|
195
|
+
if (!processedGlobalsCode) {
|
|
196
|
+
_context3.n = 4;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
// Use the already-processed globalsCode from state
|
|
200
|
+
globalsCodeObjects = processedGlobalsCode;
|
|
201
|
+
_context3.n = 6;
|
|
202
|
+
break;
|
|
203
|
+
case 4:
|
|
204
|
+
if (!(globalsCode && globalsCode.length > 0)) {
|
|
205
|
+
_context3.n = 6;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
_context3.n = 5;
|
|
209
|
+
return Promise.all(globalsCode.map(/*#__PURE__*/function () {
|
|
210
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(item) {
|
|
211
|
+
return _regenerator().w(function (_context2) {
|
|
212
|
+
while (1) switch (_context2.n) {
|
|
213
|
+
case 0:
|
|
214
|
+
if (!(typeof item === 'string')) {
|
|
215
|
+
_context2.n = 2;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
if (loadCodeMeta) {
|
|
219
|
+
_context2.n = 1;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadCodeMeta();
|
|
223
|
+
case 1:
|
|
224
|
+
return _context2.a(2, loadCodeMeta(item));
|
|
225
|
+
case 2:
|
|
226
|
+
return _context2.a(2, item);
|
|
227
|
+
}
|
|
228
|
+
}, _callee2);
|
|
229
|
+
}));
|
|
230
|
+
return function (_x) {
|
|
231
|
+
return _ref5.apply(this, arguments);
|
|
232
|
+
};
|
|
233
|
+
}()));
|
|
234
|
+
case 5:
|
|
235
|
+
globalsCodeObjects = _context3.v;
|
|
236
|
+
// Store processed globalsCode in state for future use
|
|
237
|
+
setProcessedGlobalsCode(globalsCodeObjects);
|
|
238
|
+
case 6:
|
|
239
|
+
_context3.n = 7;
|
|
240
|
+
return Promise.all(variants.map(function (name) {
|
|
241
|
+
// Resolve globalsCode for this specific variant
|
|
242
|
+
var globalsForVariant = globalsCodeObjects.map(function (codeObj) {
|
|
243
|
+
// Only include if this variant exists in the globalsCode
|
|
244
|
+
return codeObj[name];
|
|
245
|
+
}).filter(function (item) {
|
|
246
|
+
return Boolean(item);
|
|
247
|
+
});
|
|
248
|
+
return loadVariant(url, name, loadedCode[name], {
|
|
249
|
+
disableParsing: true,
|
|
250
|
+
disableTransforms: true,
|
|
251
|
+
loadSource: loadSource,
|
|
252
|
+
loadVariantMeta: loadVariantMeta,
|
|
253
|
+
globalsCode: globalsForVariant
|
|
254
|
+
}).then(function (variant) {
|
|
255
|
+
return {
|
|
256
|
+
name: name,
|
|
257
|
+
variant: variant
|
|
258
|
+
};
|
|
259
|
+
})["catch"](function (error) {
|
|
260
|
+
return {
|
|
261
|
+
error: error
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
}));
|
|
265
|
+
case 7:
|
|
266
|
+
result = _context3.v;
|
|
267
|
+
resultCode = {};
|
|
268
|
+
errors = [];
|
|
269
|
+
_iterator = _createForOfIteratorHelper(result);
|
|
270
|
+
try {
|
|
271
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
272
|
+
item = _step.value;
|
|
273
|
+
if ('error' in item) {
|
|
274
|
+
errors.push(item.error);
|
|
275
|
+
} else {
|
|
276
|
+
resultCode[item.name] = item.variant.code;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
} catch (err) {
|
|
280
|
+
_iterator.e(err);
|
|
281
|
+
} finally {
|
|
282
|
+
_iterator.f();
|
|
283
|
+
}
|
|
284
|
+
if (errors.length > 0) {
|
|
285
|
+
console.error(new Errors.ErrorCodeHighlighterClientLoadVariantsFailure(url, errors));
|
|
286
|
+
} else {
|
|
287
|
+
setCode(resultCode);
|
|
288
|
+
}
|
|
289
|
+
_context3.n = 9;
|
|
290
|
+
break;
|
|
291
|
+
case 8:
|
|
292
|
+
_context3.p = 8;
|
|
293
|
+
_t = _context3.v;
|
|
294
|
+
console.error(new Errors.ErrorCodeHighlighterClientLoadAllVariantsFailure(url, _t));
|
|
295
|
+
case 9:
|
|
296
|
+
return _context3.a(2);
|
|
297
|
+
}
|
|
298
|
+
}, _callee3, null, [[0, 8]]);
|
|
299
|
+
}))();
|
|
300
|
+
}, [needsData, variants, url, code, setCode, loadSource, loadVariantMeta, loadCodeMeta, processedGlobalsCode, globalsCode, setProcessedGlobalsCode, loadVariant]);
|
|
301
|
+
return {
|
|
302
|
+
readyForContent: readyForContent
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function useCodeParsing(_ref6) {
|
|
306
|
+
var code = _ref6.code,
|
|
307
|
+
readyForContent = _ref6.readyForContent,
|
|
308
|
+
highlightAt = _ref6.highlightAt,
|
|
309
|
+
forceClient = _ref6.forceClient,
|
|
310
|
+
url = _ref6.url;
|
|
311
|
+
var _useCodeContext3 = useCodeContext(),
|
|
312
|
+
parseSource = _useCodeContext3.parseSource,
|
|
313
|
+
parseCode = _useCodeContext3.parseCode;
|
|
314
|
+
|
|
315
|
+
// Use useSyncExternalStore to detect hydration
|
|
316
|
+
var subscribe = React.useCallback(function () {
|
|
317
|
+
return function () {};
|
|
318
|
+
}, []);
|
|
319
|
+
var getSnapshot = React.useCallback(function () {
|
|
320
|
+
return true;
|
|
321
|
+
}, []);
|
|
322
|
+
var getServerSnapshot = React.useCallback(function () {
|
|
323
|
+
return false;
|
|
324
|
+
}, []);
|
|
325
|
+
var useIsHydrated = function useIsHydrated() {
|
|
326
|
+
return React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
327
|
+
};
|
|
328
|
+
var isHydrated = useIsHydrated();
|
|
329
|
+
var _React$useState = React.useState(highlightAt === 'init' || highlightAt === 'hydration' && isHydrated),
|
|
330
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
331
|
+
isHighlightAllowed = _React$useState2[0],
|
|
332
|
+
setIsHighlightAllowed = _React$useState2[1];
|
|
333
|
+
React.useEffect(function () {
|
|
334
|
+
if (highlightAt === 'idle') {
|
|
335
|
+
var idleRequest = window.requestIdleCallback(function () {
|
|
336
|
+
setIsHighlightAllowed(true);
|
|
337
|
+
});
|
|
338
|
+
return function () {
|
|
339
|
+
return window.cancelIdleCallback(idleRequest);
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
return undefined;
|
|
343
|
+
}, [highlightAt]);
|
|
344
|
+
|
|
345
|
+
// Update highlight allowed state when hydration completes
|
|
346
|
+
React.useEffect(function () {
|
|
347
|
+
if (highlightAt === 'hydration' && isHydrated) {
|
|
348
|
+
setIsHighlightAllowed(true);
|
|
349
|
+
}
|
|
350
|
+
}, [highlightAt, isHydrated]);
|
|
351
|
+
|
|
352
|
+
// Determine if we should highlight based on the highlightAt setting
|
|
353
|
+
var shouldHighlight = React.useMemo(function () {
|
|
354
|
+
if (!readyForContent) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
return isHighlightAllowed;
|
|
358
|
+
}, [readyForContent, isHighlightAllowed]);
|
|
359
|
+
|
|
360
|
+
// Parse the internal code state when ready and timing conditions are met
|
|
361
|
+
var parsedCode = React.useMemo(function () {
|
|
362
|
+
if (!code || !shouldHighlight || hasAllVariants(Object.keys(code), code, true)) {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
if (!parseSource) {
|
|
366
|
+
if (forceClient) {
|
|
367
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseSource(url, true));
|
|
368
|
+
} else {
|
|
369
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseSource(url, false));
|
|
370
|
+
}
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
if (!parseCode) {
|
|
374
|
+
if (forceClient) {
|
|
375
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseCode(url, true));
|
|
376
|
+
} else {
|
|
377
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseCode(url, false));
|
|
378
|
+
}
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
return parseCode(code, parseSource);
|
|
382
|
+
}, [code, shouldHighlight, parseSource, parseCode, forceClient, url]);
|
|
383
|
+
var deferHighlight = !shouldHighlight;
|
|
384
|
+
return {
|
|
385
|
+
parsedCode: parsedCode,
|
|
386
|
+
deferHighlight: deferHighlight
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function useCodeTransforms(_ref7) {
|
|
390
|
+
var parsedCode = _ref7.parsedCode,
|
|
391
|
+
variantName = _ref7.variantName;
|
|
392
|
+
var _useCodeContext4 = useCodeContext(),
|
|
393
|
+
sourceParser = _useCodeContext4.sourceParser,
|
|
394
|
+
getAvailableTransforms = _useCodeContext4.getAvailableTransforms,
|
|
395
|
+
applyTransforms = _useCodeContext4.applyTransforms;
|
|
396
|
+
var _React$useState3 = React.useState(undefined),
|
|
397
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
398
|
+
transformedCode = _React$useState4[0],
|
|
399
|
+
setTransformedCode = _React$useState4[1];
|
|
400
|
+
|
|
401
|
+
// Get available transforms from the current variant (separate memo for efficiency)
|
|
402
|
+
var availableTransforms = React.useMemo(function () {
|
|
403
|
+
if (!getAvailableTransforms) {
|
|
404
|
+
return [];
|
|
405
|
+
}
|
|
406
|
+
return getAvailableTransforms(parsedCode, variantName);
|
|
407
|
+
}, [parsedCode, variantName, getAvailableTransforms]);
|
|
408
|
+
|
|
409
|
+
// Effect to compute transformations for all variants
|
|
410
|
+
React.useEffect(function () {
|
|
411
|
+
if (!parsedCode || !sourceParser || !applyTransforms) {
|
|
412
|
+
setTransformedCode(parsedCode);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Process transformations for all variants
|
|
417
|
+
_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
418
|
+
var parseSource, enhanced, _t2;
|
|
419
|
+
return _regenerator().w(function (_context4) {
|
|
420
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
421
|
+
case 0:
|
|
422
|
+
_context4.p = 0;
|
|
423
|
+
_context4.n = 1;
|
|
424
|
+
return sourceParser;
|
|
425
|
+
case 1:
|
|
426
|
+
parseSource = _context4.v;
|
|
427
|
+
_context4.n = 2;
|
|
428
|
+
return applyTransforms(parsedCode, parseSource);
|
|
429
|
+
case 2:
|
|
430
|
+
enhanced = _context4.v;
|
|
431
|
+
setTransformedCode(enhanced);
|
|
432
|
+
_context4.n = 4;
|
|
433
|
+
break;
|
|
434
|
+
case 3:
|
|
435
|
+
_context4.p = 3;
|
|
436
|
+
_t2 = _context4.v;
|
|
437
|
+
console.error(new Errors.ErrorCodeHighlighterClientTransformProcessingFailure(_t2));
|
|
438
|
+
setTransformedCode(parsedCode);
|
|
439
|
+
case 4:
|
|
440
|
+
return _context4.a(2);
|
|
441
|
+
}
|
|
442
|
+
}, _callee4, null, [[0, 3]]);
|
|
443
|
+
}))();
|
|
444
|
+
}, [parsedCode, sourceParser, applyTransforms]);
|
|
445
|
+
return {
|
|
446
|
+
transformedCode: transformedCode,
|
|
447
|
+
availableTransforms: availableTransforms
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function useControlledCodeParsing(_ref9) {
|
|
451
|
+
var code = _ref9.code,
|
|
452
|
+
forceClient = _ref9.forceClient,
|
|
453
|
+
url = _ref9.url;
|
|
454
|
+
var _useCodeContext5 = useCodeContext(),
|
|
455
|
+
parseSource = _useCodeContext5.parseSource,
|
|
456
|
+
parseControlledCode = _useCodeContext5.parseControlledCode;
|
|
457
|
+
|
|
458
|
+
// Parse the controlled code separately (no need to check readyForContent)
|
|
459
|
+
var parsedControlledCode = React.useMemo(function () {
|
|
460
|
+
if (!code) {
|
|
461
|
+
return undefined;
|
|
462
|
+
}
|
|
463
|
+
if (!parseSource || !parseControlledCode) {
|
|
464
|
+
// Log when provider functions are missing to help with debugging
|
|
465
|
+
if (!parseSource) {
|
|
466
|
+
if (forceClient) {
|
|
467
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseSource(url, true));
|
|
468
|
+
} else {
|
|
469
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseSource(url, false));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (!parseControlledCode) {
|
|
473
|
+
if (forceClient) {
|
|
474
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseControlledCode(url, true));
|
|
475
|
+
} else {
|
|
476
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingParseControlledCode(url, false));
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return undefined;
|
|
480
|
+
}
|
|
481
|
+
return parseControlledCode(code, parseSource);
|
|
482
|
+
}, [code, parseSource, parseControlledCode, forceClient, url]);
|
|
483
|
+
return {
|
|
484
|
+
parsedControlledCode: parsedControlledCode
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function useGlobalsCodeMerging(_ref0) {
|
|
488
|
+
var url = _ref0.url,
|
|
489
|
+
code = _ref0.code,
|
|
490
|
+
globalsCode = _ref0.globalsCode,
|
|
491
|
+
processedGlobalsCode = _ref0.processedGlobalsCode,
|
|
492
|
+
setProcessedGlobalsCode = _ref0.setProcessedGlobalsCode,
|
|
493
|
+
readyForContent = _ref0.readyForContent,
|
|
494
|
+
variants = _ref0.variants;
|
|
495
|
+
var _useCodeContext6 = useCodeContext(),
|
|
496
|
+
loadCodeMeta = _useCodeContext6.loadCodeMeta,
|
|
497
|
+
loadSource = _useCodeContext6.loadSource,
|
|
498
|
+
loadVariantMeta = _useCodeContext6.loadVariantMeta,
|
|
499
|
+
loadVariant = _useCodeContext6.loadVariant;
|
|
500
|
+
|
|
501
|
+
// Set processedGlobalsCode if we have ready Code objects but haven't stored them yet
|
|
502
|
+
React.useEffect(function () {
|
|
503
|
+
if (!globalsCode || processedGlobalsCode) {
|
|
504
|
+
return; // No globals or already processed
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// Check if all items are already Code objects (precomputed)
|
|
508
|
+
if (globalsCode.every(function (item) {
|
|
509
|
+
return _typeof(item) === 'object';
|
|
510
|
+
})) {
|
|
511
|
+
var codeObjects = globalsCode;
|
|
512
|
+
// Check if all Code objects have all their own variants
|
|
513
|
+
var allReady = codeObjects.every(function (codeObj) {
|
|
514
|
+
return hasAllVariants(Object.keys(codeObj), codeObj);
|
|
515
|
+
});
|
|
516
|
+
if (allReady) {
|
|
517
|
+
setProcessedGlobalsCode(codeObjects);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
// If not all ready, fall through to loading logic below
|
|
521
|
+
}
|
|
522
|
+
if (!loadVariant) {
|
|
523
|
+
console.error(new Errors.ErrorCodeHighlighterClientMissingLoadVariantForGlobals());
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Need to load string URLs or load missing variants
|
|
528
|
+
_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
529
|
+
var basicCodeObjects, fullyLoadedCodeObjects, _t6;
|
|
530
|
+
return _regenerator().w(function (_context8) {
|
|
531
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
532
|
+
case 0:
|
|
533
|
+
_context8.p = 0;
|
|
534
|
+
_context8.n = 1;
|
|
535
|
+
return Promise.all(globalsCode.map(/*#__PURE__*/function () {
|
|
536
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(item) {
|
|
537
|
+
var _t3, _t4;
|
|
538
|
+
return _regenerator().w(function (_context5) {
|
|
539
|
+
while (1) switch (_context5.n) {
|
|
540
|
+
case 0:
|
|
541
|
+
if (!(typeof item === 'string')) {
|
|
542
|
+
_context5.n = 3;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
if (loadCodeMeta) {
|
|
546
|
+
_context5.n = 1;
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
throw new Errors.ErrorCodeHighlighterClientMissingLoadCodeMetaForStringUrls();
|
|
550
|
+
case 1:
|
|
551
|
+
_context5.n = 2;
|
|
552
|
+
return loadCodeMeta(item);
|
|
553
|
+
case 2:
|
|
554
|
+
_t3 = _context5.v;
|
|
555
|
+
_t4 = item;
|
|
556
|
+
return _context5.a(2, {
|
|
557
|
+
codeObj: _t3,
|
|
558
|
+
originalUrl: _t4
|
|
559
|
+
});
|
|
560
|
+
case 3:
|
|
561
|
+
return _context5.a(2, {
|
|
562
|
+
codeObj: item,
|
|
563
|
+
originalUrl: undefined
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
}, _callee5);
|
|
567
|
+
}));
|
|
568
|
+
return function (_x2) {
|
|
569
|
+
return _ref10.apply(this, arguments);
|
|
570
|
+
};
|
|
571
|
+
}()));
|
|
572
|
+
case 1:
|
|
573
|
+
basicCodeObjects = _context8.v;
|
|
574
|
+
_context8.n = 2;
|
|
575
|
+
return Promise.all(basicCodeObjects.map(/*#__PURE__*/function () {
|
|
576
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(_ref11) {
|
|
577
|
+
var codeObj, originalUrl, loadedVariants;
|
|
578
|
+
return _regenerator().w(function (_context7) {
|
|
579
|
+
while (1) switch (_context7.n) {
|
|
580
|
+
case 0:
|
|
581
|
+
codeObj = _ref11.codeObj, originalUrl = _ref11.originalUrl;
|
|
582
|
+
if (!hasAllVariants(variants, codeObj)) {
|
|
583
|
+
_context7.n = 1;
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
return _context7.a(2, codeObj);
|
|
587
|
+
case 1:
|
|
588
|
+
// Need to load missing variants
|
|
589
|
+
loadedVariants = _extends({}, codeObj);
|
|
590
|
+
_context7.n = 2;
|
|
591
|
+
return Promise.all(variants.map(/*#__PURE__*/function () {
|
|
592
|
+
var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(variantName) {
|
|
593
|
+
var result, _t5;
|
|
594
|
+
return _regenerator().w(function (_context6) {
|
|
595
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
596
|
+
case 0:
|
|
597
|
+
if (!(codeObj[variantName] && _typeof(codeObj[variantName]) === 'object')) {
|
|
598
|
+
_context6.n = 1;
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
return _context6.a(2);
|
|
602
|
+
case 1:
|
|
603
|
+
_context6.p = 1;
|
|
604
|
+
_context6.n = 2;
|
|
605
|
+
return loadVariant(originalUrl || '',
|
|
606
|
+
// Use the original URL if available
|
|
607
|
+
variantName, codeObj[variantName],
|
|
608
|
+
// May be undefined or string
|
|
609
|
+
{
|
|
610
|
+
disableParsing: true,
|
|
611
|
+
disableTransforms: true,
|
|
612
|
+
loadSource: loadSource,
|
|
613
|
+
loadVariantMeta: loadVariantMeta
|
|
614
|
+
});
|
|
615
|
+
case 2:
|
|
616
|
+
result = _context6.v;
|
|
617
|
+
loadedVariants[variantName] = result.code;
|
|
618
|
+
_context6.n = 4;
|
|
619
|
+
break;
|
|
620
|
+
case 3:
|
|
621
|
+
_context6.p = 3;
|
|
622
|
+
_t5 = _context6.v;
|
|
623
|
+
console.error(new Errors.ErrorCodeHighlighterClientLoadVariantFailureForGlobals(variantName, originalUrl, _t5));
|
|
624
|
+
// Keep the original variant data (may be undefined)
|
|
625
|
+
case 4:
|
|
626
|
+
return _context6.a(2);
|
|
627
|
+
}
|
|
628
|
+
}, _callee6, null, [[1, 3]]);
|
|
629
|
+
}));
|
|
630
|
+
return function (_x4) {
|
|
631
|
+
return _ref13.apply(this, arguments);
|
|
632
|
+
};
|
|
633
|
+
}()));
|
|
634
|
+
case 2:
|
|
635
|
+
return _context7.a(2, loadedVariants);
|
|
636
|
+
}
|
|
637
|
+
}, _callee7);
|
|
638
|
+
}));
|
|
639
|
+
return function (_x3) {
|
|
640
|
+
return _ref12.apply(this, arguments);
|
|
641
|
+
};
|
|
642
|
+
}()));
|
|
643
|
+
case 2:
|
|
644
|
+
fullyLoadedCodeObjects = _context8.v;
|
|
645
|
+
setProcessedGlobalsCode(fullyLoadedCodeObjects);
|
|
646
|
+
_context8.n = 4;
|
|
647
|
+
break;
|
|
648
|
+
case 3:
|
|
649
|
+
_context8.p = 3;
|
|
650
|
+
_t6 = _context8.v;
|
|
651
|
+
console.error(new Errors.ErrorCodeHighlighterClientLoadGlobalsCodeFailure(url || 'No URL', _t6));
|
|
652
|
+
case 4:
|
|
653
|
+
return _context8.a(2);
|
|
654
|
+
}
|
|
655
|
+
}, _callee8, null, [[0, 3]]);
|
|
656
|
+
}))();
|
|
657
|
+
}, [url, globalsCode, processedGlobalsCode, setProcessedGlobalsCode, loadCodeMeta, loadSource, loadVariantMeta, variants, loadVariant]);
|
|
658
|
+
|
|
659
|
+
// Determine globalsCodeObjects to use (prefer processed, fallback to direct if ready)
|
|
660
|
+
var globalsCodeObjects = React.useMemo(function () {
|
|
661
|
+
if (processedGlobalsCode) {
|
|
662
|
+
return processedGlobalsCode;
|
|
663
|
+
}
|
|
664
|
+
if (globalsCode && globalsCode.every(function (item) {
|
|
665
|
+
return _typeof(item) === 'object';
|
|
666
|
+
})) {
|
|
667
|
+
var codeObjects = globalsCode;
|
|
668
|
+
var allGlobalsReady = codeObjects.every(function (codeObj) {
|
|
669
|
+
return hasAllVariants(Object.keys(codeObj), codeObj);
|
|
670
|
+
});
|
|
671
|
+
if (allGlobalsReady) {
|
|
672
|
+
return codeObjects;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return undefined;
|
|
676
|
+
}, [processedGlobalsCode, globalsCode]);
|
|
677
|
+
|
|
678
|
+
// Merge globalsCode with code when ready
|
|
679
|
+
return React.useMemo(function () {
|
|
680
|
+
// If no globalsCode or code not ready, return as-is
|
|
681
|
+
if (!globalsCode || !code || !readyForContent) {
|
|
682
|
+
return code;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// If globalsCodeObjects isn't ready yet, return unmerged code for now
|
|
686
|
+
if (!globalsCodeObjects) {
|
|
687
|
+
return code;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// For precomputed code, do simple synchronous merging of extraFiles
|
|
691
|
+
var mergedCode = _extends({}, code);
|
|
692
|
+
var hasChanges = false;
|
|
693
|
+
variants.forEach(function (variant) {
|
|
694
|
+
var variantData = code[variant];
|
|
695
|
+
if (!variantData || typeof variantData === 'string') {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// Get globalsCode for this variant (only exact matches, no fallback)
|
|
700
|
+
var globalsForVariant = globalsCodeObjects.map(function (codeObj) {
|
|
701
|
+
return codeObj[variant];
|
|
702
|
+
}).filter(function (item) {
|
|
703
|
+
return Boolean(item) && _typeof(item) === 'object';
|
|
704
|
+
});
|
|
705
|
+
if (globalsForVariant.length > 0) {
|
|
706
|
+
// Use mergeMetadata for sophisticated globals merging with proper positioning
|
|
707
|
+
var currentVariant = variantData;
|
|
708
|
+
globalsForVariant.forEach(function (globalVariant) {
|
|
709
|
+
if (globalVariant.extraFiles) {
|
|
710
|
+
// Convert globals extraFiles to metadata format for mergeMetadata
|
|
711
|
+
var globalsMetadata = {};
|
|
712
|
+
for (var _i = 0, _Object$entries = Object.entries(globalVariant.extraFiles); _i < _Object$entries.length; _i++) {
|
|
713
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
714
|
+
key = _Object$entries$_i[0],
|
|
715
|
+
value = _Object$entries$_i[1];
|
|
716
|
+
if (typeof value === 'string') {
|
|
717
|
+
globalsMetadata[key] = {
|
|
718
|
+
source: value
|
|
719
|
+
};
|
|
720
|
+
} else {
|
|
721
|
+
globalsMetadata[key] = _extends({}, value);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// Use mergeMetadata to properly position and merge the globals
|
|
726
|
+
currentVariant = mergeMetadata(currentVariant, globalsMetadata);
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
// Only update if the variant actually changed
|
|
731
|
+
if (currentVariant !== variantData) {
|
|
732
|
+
mergedCode[variant] = currentVariant;
|
|
733
|
+
hasChanges = true;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
// Return merged code if we made changes, otherwise return original code
|
|
739
|
+
return hasChanges ? mergedCode : code;
|
|
740
|
+
}, [code, globalsCode, globalsCodeObjects, readyForContent, variants]);
|
|
741
|
+
}
|
|
742
|
+
function usePropsCodeGlobalsMerging(_ref14) {
|
|
743
|
+
var code = _ref14.code,
|
|
744
|
+
globalsCode = _ref14.globalsCode,
|
|
745
|
+
processedGlobalsCode = _ref14.processedGlobalsCode,
|
|
746
|
+
variants = _ref14.variants;
|
|
747
|
+
// For props.code, always do synchronous merging if possible
|
|
748
|
+
// We don't want to cache this in state since props.code can change frequently
|
|
749
|
+
return React.useMemo(function () {
|
|
750
|
+
if (!code || !globalsCode || !processedGlobalsCode) {
|
|
751
|
+
return code; // No merge needed or not ready
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// Use processedGlobalsCode for synchronous merging
|
|
755
|
+
var globalsCodeObjects = processedGlobalsCode;
|
|
756
|
+
|
|
757
|
+
// For props.code (controlled), do simple synchronous merging
|
|
758
|
+
var mergedCode = _extends({}, code);
|
|
759
|
+
var hasChanges = false;
|
|
760
|
+
variants.forEach(function (variant) {
|
|
761
|
+
var variantData = code[variant];
|
|
762
|
+
if (!variantData || typeof variantData === 'string') {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Get globalsCode for this variant (only exact matches, no fallback)
|
|
767
|
+
var globalsForVariant = globalsCodeObjects.map(function (codeObj) {
|
|
768
|
+
return codeObj[variant];
|
|
769
|
+
}).filter(function (item) {
|
|
770
|
+
return Boolean(item) && _typeof(item) === 'object';
|
|
771
|
+
});
|
|
772
|
+
if (globalsForVariant.length > 0) {
|
|
773
|
+
// Use mergeMetadata for sophisticated globals merging with proper positioning
|
|
774
|
+
var currentVariant = variantData;
|
|
775
|
+
globalsForVariant.forEach(function (globalVariant) {
|
|
776
|
+
if (globalVariant.extraFiles) {
|
|
777
|
+
// Convert globals extraFiles to metadata format for mergeMetadata
|
|
778
|
+
var globalsMetadata = {};
|
|
779
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(globalVariant.extraFiles); _i2 < _Object$entries2.length; _i2++) {
|
|
780
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
781
|
+
key = _Object$entries2$_i[0],
|
|
782
|
+
value = _Object$entries2$_i[1];
|
|
783
|
+
if (typeof value === 'string') {
|
|
784
|
+
globalsMetadata[key] = {
|
|
785
|
+
source: value
|
|
786
|
+
};
|
|
787
|
+
} else {
|
|
788
|
+
globalsMetadata[key] = _extends({}, value);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// Use mergeMetadata to properly position and merge the globals
|
|
793
|
+
currentVariant = mergeMetadata(currentVariant, globalsMetadata);
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
// Only update if the variant actually changed
|
|
798
|
+
if (currentVariant !== variantData) {
|
|
799
|
+
mergedCode[variant] = currentVariant;
|
|
800
|
+
hasChanges = true;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
// Return merged code if we made changes, otherwise return original code
|
|
806
|
+
return hasChanges ? mergedCode : code;
|
|
807
|
+
}, [code, globalsCode, processedGlobalsCode, variants]);
|
|
808
|
+
}
|
|
809
|
+
export function CodeHighlighterClient(props) {
|
|
810
|
+
var _controlled$selection, _controlled$selection2;
|
|
811
|
+
var controlled = useControlledCode();
|
|
812
|
+
var isControlled = Boolean(props.code || (controlled == null ? void 0 : controlled.code));
|
|
813
|
+
var _React$useState5 = React.useState(_typeof(props.precompute) === 'object' ? props.precompute : undefined),
|
|
814
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
815
|
+
code = _React$useState6[0],
|
|
816
|
+
setCode = _React$useState6[1];
|
|
817
|
+
|
|
818
|
+
// Sync code state with precompute prop changes (for hot-reload)
|
|
819
|
+
React.useEffect(function () {
|
|
820
|
+
if (_typeof(props.precompute) === 'object') {
|
|
821
|
+
setCode(props.precompute);
|
|
822
|
+
} else if (props.precompute === undefined) {
|
|
823
|
+
// Only reset to undefined if precompute is explicitly undefined
|
|
824
|
+
setCode(undefined);
|
|
825
|
+
}
|
|
826
|
+
}, [props.precompute]);
|
|
827
|
+
|
|
828
|
+
// State to store processed globalsCode to avoid duplicate loading
|
|
829
|
+
var _React$useState7 = React.useState(undefined),
|
|
830
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
831
|
+
processedGlobalsCode = _React$useState8[0],
|
|
832
|
+
setProcessedGlobalsCode = _React$useState8[1];
|
|
833
|
+
var activeCode = (controlled == null ? void 0 : controlled.code) || props.code || code;
|
|
834
|
+
var variants = React.useMemo(function () {
|
|
835
|
+
return props.variants || Object.keys(props.components || activeCode || {});
|
|
836
|
+
}, [props.variants, props.components, activeCode]);
|
|
837
|
+
|
|
838
|
+
// TODO: if using props.variant, then the variant is controlled and we can't use our own state
|
|
839
|
+
// does props.variant make any sense instead of controlledSelection?.variant?
|
|
840
|
+
var _React$useState9 = React.useState({
|
|
841
|
+
variant: props.initialVariant || props.defaultVariant || variants[0]
|
|
842
|
+
}),
|
|
843
|
+
_React$useState0 = _slicedToArray(_React$useState9, 2),
|
|
844
|
+
selection = _React$useState0[0],
|
|
845
|
+
setSelection = _React$useState0[1];
|
|
846
|
+
var variantName = (controlled == null || (_controlled$selection = controlled.selection) == null ? void 0 : _controlled$selection.variant) || props.variant || selection.variant;
|
|
847
|
+
var initialFilename;
|
|
848
|
+
if (_typeof(activeCode == null ? void 0 : activeCode[variantName]) === 'object') {
|
|
849
|
+
var variant = activeCode[variantName];
|
|
850
|
+
initialFilename = variant != null && variant.filesOrder ? variant.filesOrder[0] : variant == null ? void 0 : variant.fileName;
|
|
851
|
+
}
|
|
852
|
+
var fileName = (controlled == null || (_controlled$selection2 = controlled.selection) == null ? void 0 : _controlled$selection2.fileName) || props.fileName || initialFilename;
|
|
853
|
+
var url = props.url,
|
|
854
|
+
highlightAt = props.highlightAt,
|
|
855
|
+
fallbackUsesExtraFiles = props.fallbackUsesExtraFiles,
|
|
856
|
+
fallbackUsesAllVariants = props.fallbackUsesAllVariants;
|
|
857
|
+
useInitialData({
|
|
858
|
+
variants: variants,
|
|
859
|
+
variantName: variantName,
|
|
860
|
+
code: code,
|
|
861
|
+
setCode: setCode,
|
|
862
|
+
fileName: fileName,
|
|
863
|
+
url: url,
|
|
864
|
+
highlightAt: highlightAt,
|
|
865
|
+
fallbackUsesExtraFiles: fallbackUsesExtraFiles,
|
|
866
|
+
fallbackUsesAllVariants: fallbackUsesAllVariants,
|
|
867
|
+
isControlled: isControlled,
|
|
868
|
+
globalsCode: props.globalsCode,
|
|
869
|
+
setProcessedGlobalsCode: setProcessedGlobalsCode
|
|
870
|
+
});
|
|
871
|
+
var readyForContent = React.useMemo(function () {
|
|
872
|
+
if (!code) {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
return hasAllVariants(variants, code);
|
|
876
|
+
}, [code, variants]);
|
|
877
|
+
|
|
878
|
+
// Separate check for activeCode to determine when to show fallback
|
|
879
|
+
var activeCodeReady = React.useMemo(function () {
|
|
880
|
+
if (!activeCode) {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// Controlled code is always ready since it comes from editing already-ready code
|
|
885
|
+
if (controlled != null && controlled.code) {
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// For regular code, use the existing hasAllVariants function
|
|
890
|
+
var regularCode = props.code || code;
|
|
891
|
+
return regularCode ? hasAllVariants(variants, regularCode) : false;
|
|
892
|
+
}, [activeCode, controlled == null ? void 0 : controlled.code, variants, props.code, code]);
|
|
893
|
+
useAllVariants({
|
|
894
|
+
readyForContent: readyForContent,
|
|
895
|
+
variants: variants,
|
|
896
|
+
isControlled: isControlled,
|
|
897
|
+
url: url,
|
|
898
|
+
code: code,
|
|
899
|
+
setCode: setCode,
|
|
900
|
+
processedGlobalsCode: processedGlobalsCode,
|
|
901
|
+
globalsCode: props.globalsCode,
|
|
902
|
+
setProcessedGlobalsCode: setProcessedGlobalsCode
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
// Merge globalsCode with internal state code (fetched data) - this should be stable once ready
|
|
906
|
+
var stateCodeWithGlobals = useGlobalsCodeMerging({
|
|
907
|
+
url: url,
|
|
908
|
+
code: code,
|
|
909
|
+
// Only use internal state, not props.code
|
|
910
|
+
globalsCode: props.globalsCode,
|
|
911
|
+
processedGlobalsCode: processedGlobalsCode,
|
|
912
|
+
setProcessedGlobalsCode: setProcessedGlobalsCode,
|
|
913
|
+
readyForContent: readyForContent,
|
|
914
|
+
variants: variants
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
// For props.code (controlled), always re-merge when it changes (don't cache in state)
|
|
918
|
+
var propsCodeWithGlobals = usePropsCodeGlobalsMerging({
|
|
919
|
+
code: props.code,
|
|
920
|
+
globalsCode: props.globalsCode,
|
|
921
|
+
processedGlobalsCode: processedGlobalsCode,
|
|
922
|
+
variants: variants
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
// Use props.code result if available, otherwise use state code result
|
|
926
|
+
var codeWithGlobals = propsCodeWithGlobals || stateCodeWithGlobals;
|
|
927
|
+
var _useCodeParsing = useCodeParsing({
|
|
928
|
+
code: codeWithGlobals,
|
|
929
|
+
readyForContent: readyForContent || Boolean(props.code),
|
|
930
|
+
highlightAt: highlightAt,
|
|
931
|
+
forceClient: props.forceClient,
|
|
932
|
+
url: props.url
|
|
933
|
+
}),
|
|
934
|
+
parsedCode = _useCodeParsing.parsedCode,
|
|
935
|
+
deferHighlight = _useCodeParsing.deferHighlight;
|
|
936
|
+
var _useCodeTransforms = useCodeTransforms({
|
|
937
|
+
parsedCode: parsedCode,
|
|
938
|
+
variantName: variantName
|
|
939
|
+
}),
|
|
940
|
+
transformedCode = _useCodeTransforms.transformedCode,
|
|
941
|
+
availableTransforms = _useCodeTransforms.availableTransforms;
|
|
942
|
+
var _useControlledCodePar = useControlledCodeParsing({
|
|
943
|
+
code: controlled == null ? void 0 : controlled.code,
|
|
944
|
+
forceClient: props.forceClient,
|
|
945
|
+
url: props.url
|
|
946
|
+
}),
|
|
947
|
+
parsedControlledCode = _useControlledCodePar.parsedControlledCode;
|
|
948
|
+
|
|
949
|
+
// Determine the final overlaid code (controlled takes precedence)
|
|
950
|
+
var overlaidCode = parsedControlledCode || transformedCode || codeWithGlobals;
|
|
951
|
+
|
|
952
|
+
// For fallback context, use the processed code or fall back to non-controlled code
|
|
953
|
+
var codeForFallback = overlaidCode || (controlled != null && controlled.code ? undefined : props.code || code);
|
|
954
|
+
var fallbackContext = React.useMemo(function () {
|
|
955
|
+
return codeToFallbackProps(variantName, codeForFallback, fileName, props.fallbackUsesExtraFiles, props.fallbackUsesAllVariants);
|
|
956
|
+
}, [variantName, codeForFallback, fileName, props.fallbackUsesExtraFiles, props.fallbackUsesAllVariants]);
|
|
957
|
+
var context = React.useMemo(function () {
|
|
958
|
+
return {
|
|
959
|
+
code: overlaidCode,
|
|
960
|
+
// Use processed/transformed code
|
|
961
|
+
setCode: controlled == null ? void 0 : controlled.setCode,
|
|
962
|
+
selection: (controlled == null ? void 0 : controlled.selection) || selection,
|
|
963
|
+
setSelection: (controlled == null ? void 0 : controlled.setSelection) || setSelection,
|
|
964
|
+
components: (controlled == null ? void 0 : controlled.components) || props.components,
|
|
965
|
+
availableTransforms: isControlled ? [] : availableTransforms,
|
|
966
|
+
url: props.url,
|
|
967
|
+
deferHighlight: deferHighlight
|
|
968
|
+
};
|
|
969
|
+
}, [overlaidCode, controlled == null ? void 0 : controlled.setCode, selection, controlled == null ? void 0 : controlled.selection, controlled == null ? void 0 : controlled.setSelection, controlled == null ? void 0 : controlled.components, props.components, isControlled, availableTransforms, props.url, deferHighlight]);
|
|
970
|
+
if (!props.variants && !props.components && !activeCode) {
|
|
971
|
+
throw new Errors.ErrorCodeHighlighterClientMissingData();
|
|
972
|
+
}
|
|
973
|
+
var fallback = props.fallback;
|
|
974
|
+
if (fallback && !props.skipFallback && !activeCodeReady) {
|
|
975
|
+
return /*#__PURE__*/_jsx(CodeHighlighterFallbackContext.Provider, {
|
|
976
|
+
value: fallbackContext,
|
|
977
|
+
children: fallback
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
return /*#__PURE__*/_jsx(CodeHighlighterContext.Provider, {
|
|
981
|
+
value: context,
|
|
982
|
+
children: props.children
|
|
983
|
+
});
|
|
984
|
+
}
|