@mui/internal-docs-infra 0.11.1-canary.9 → 0.11.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.
- package/ChunkProvider/ChunkContext.d.mts +10 -0
- package/ChunkProvider/ChunkContext.mjs +15 -0
- package/ChunkProvider/ChunkProvider.d.mts +14 -0
- package/ChunkProvider/ChunkProvider.mjs +38 -0
- package/ChunkProvider/PreloadContext.d.mts +14 -0
- package/ChunkProvider/PreloadContext.mjs +18 -0
- package/ChunkProvider/PreloadProvider.d.mts +13 -0
- package/ChunkProvider/PreloadProvider.mjs +33 -0
- package/ChunkProvider/index.d.mts +7 -0
- package/ChunkProvider/index.mjs +7 -0
- package/ChunkProvider/types.d.mts +23 -0
- package/ChunkProvider/types.mjs +1 -0
- package/ChunkProvider/usePreload.d.mts +8 -0
- package/ChunkProvider/usePreload.mjs +21 -0
- package/CodeControllerContext/CodeControllerContext.d.mts +11 -0
- package/CodeControllerContext/CodeControllerContext.mjs +2 -1
- package/CodeHighlighter/CodeHighlighter.d.mts +15 -1
- package/CodeHighlighter/CodeHighlighter.mjs +97 -319
- package/CodeHighlighter/CodeHighlighterChunk.d.mts +42 -0
- package/CodeHighlighter/CodeHighlighterChunk.mjs +77 -0
- package/CodeHighlighter/CodeHighlighterClient.mjs +597 -128
- package/CodeHighlighter/CodeHighlighterContext.d.mts +57 -1
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.mts +14 -2
- package/CodeHighlighter/CodeHighlighterFallbackContext.mjs +1 -3
- package/CodeHighlighter/CodeInitialSourceLoader.d.mts +10 -0
- package/CodeHighlighter/CodeInitialSourceLoader.mjs +108 -0
- package/CodeHighlighter/CodeSourceLoader.d.mts +11 -0
- package/CodeHighlighter/CodeSourceLoader.mjs +128 -0
- package/CodeHighlighter/buildCodeHighlighterChunkProps.d.mts +47 -0
- package/CodeHighlighter/buildCodeHighlighterChunkProps.mjs +61 -0
- package/CodeHighlighter/buildStringFallback.d.mts +29 -0
- package/CodeHighlighter/buildStringFallback.mjs +42 -0
- package/CodeHighlighter/codeToFallbackProps.d.mts +31 -2
- package/CodeHighlighter/codeToFallbackProps.mjs +347 -42
- package/CodeHighlighter/createClientProps.d.mts +17 -0
- package/CodeHighlighter/createClientProps.mjs +78 -0
- package/CodeHighlighter/errors.d.mts +6 -0
- package/CodeHighlighter/errors.mjs +10 -0
- package/CodeHighlighter/fallbackCompression.d.mts +96 -0
- package/CodeHighlighter/fallbackCompression.mjs +253 -0
- package/CodeHighlighter/fallbackFormat.d.mts +137 -0
- package/CodeHighlighter/fallbackFormat.mjs +422 -0
- package/CodeHighlighter/index.d.mts +4 -1
- package/CodeHighlighter/index.mjs +3 -1
- package/CodeHighlighter/mergeComments.d.mts +38 -0
- package/CodeHighlighter/mergeComments.mjs +80 -0
- package/CodeHighlighter/prepareInitialSource.d.mts +42 -0
- package/CodeHighlighter/prepareInitialSource.mjs +292 -0
- package/CodeHighlighter/resolveFallbackCritical.d.mts +23 -0
- package/CodeHighlighter/resolveFallbackCritical.mjs +44 -0
- package/CodeHighlighter/types.d.mts +272 -8
- package/CodeHighlighter/useCodeFallback.d.mts +94 -0
- package/CodeHighlighter/useCodeFallback.mjs +204 -0
- package/CodeHighlighter/useGrammarsReady.d.mts +18 -0
- package/CodeHighlighter/useGrammarsReady.mjs +45 -0
- package/CodeHighlighter/useSpeculativeCodePreload.d.mts +26 -0
- package/CodeHighlighter/useSpeculativeCodePreload.mjs +40 -0
- package/CodeHighlighter/useSpeculativeEditingPreload.d.mts +33 -0
- package/CodeHighlighter/useSpeculativeEditingPreload.mjs +58 -0
- package/CodeHighlighter/useSpeculativeGrammarPreload.d.mts +23 -0
- package/CodeHighlighter/useSpeculativeGrammarPreload.mjs +31 -0
- package/CodeHighlighter/useSpeculativeUseCodePreload.d.mts +22 -0
- package/CodeHighlighter/useSpeculativeUseCodePreload.mjs +41 -0
- package/CodeProvider/CodeContext.d.mts +47 -12
- package/CodeProvider/CodeContext.mjs +7 -0
- package/CodeProvider/CodeProvider.d.mts +4 -2
- package/CodeProvider/CodeProvider.mjs +40 -102
- package/CodeProvider/CodeProviderLazy.d.mts +40 -0
- package/CodeProvider/CodeProviderLazy.mjs +96 -0
- package/CodeProvider/constants.d.mts +26 -0
- package/CodeProvider/constants.mjs +24 -0
- package/CodeProvider/createParseSourceWorkerClient.d.mts +6 -0
- package/CodeProvider/createParseSourceWorkerClient.mjs +22 -2
- package/CodeProvider/index.d.mts +2 -1
- package/CodeProvider/index.mjs +9 -1
- package/CodeProvider/parseSourceWorker.mjs +33 -0
- package/CodeProvider/useCodeProviderValue.d.mts +54 -0
- package/CodeProvider/useCodeProviderValue.mjs +188 -0
- package/CoordinatedLazy/ChunkServerLoader.d.mts +25 -0
- package/CoordinatedLazy/ChunkServerLoader.mjs +97 -0
- package/CoordinatedLazy/CoordinatedContentContext.d.mts +15 -0
- package/CoordinatedLazy/CoordinatedContentContext.mjs +22 -0
- package/CoordinatedLazy/CoordinatedFallbackContext.d.mts +11 -0
- package/CoordinatedLazy/CoordinatedFallbackContext.mjs +13 -0
- package/CoordinatedLazy/CoordinatedGateContext.d.mts +14 -0
- package/CoordinatedLazy/CoordinatedGateContext.mjs +19 -0
- package/CoordinatedLazy/CoordinatedLazy.d.mts +14 -0
- package/CoordinatedLazy/CoordinatedLazy.mjs +86 -0
- package/CoordinatedLazy/CoordinatedLazyClient.d.mts +24 -0
- package/CoordinatedLazy/CoordinatedLazyClient.mjs +65 -0
- package/CoordinatedLazy/LazyContent.d.mts +26 -0
- package/CoordinatedLazy/LazyContent.mjs +80 -0
- package/CoordinatedLazy/LazyContentServer.d.mts +18 -0
- package/CoordinatedLazy/LazyContentServer.mjs +25 -0
- package/CoordinatedLazy/buildChunkRenderInputs.d.mts +8 -0
- package/CoordinatedLazy/buildChunkRenderInputs.mjs +35 -0
- package/CoordinatedLazy/createCoordinatedLazy.d.mts +32 -0
- package/CoordinatedLazy/createCoordinatedLazy.mjs +127 -0
- package/CoordinatedLazy/index.d.mts +14 -0
- package/CoordinatedLazy/index.mjs +18 -0
- package/CoordinatedLazy/resolveChunkRender.d.mts +26 -0
- package/CoordinatedLazy/resolveChunkRender.mjs +73 -0
- package/CoordinatedLazy/types.d.mts +408 -0
- package/CoordinatedLazy/types.mjs +1 -0
- package/CoordinatedLazy/useChunk.d.mts +30 -0
- package/CoordinatedLazy/useChunk.mjs +135 -0
- package/CoordinatedLazy/useCoordinatedFallback.d.mts +12 -0
- package/CoordinatedLazy/useCoordinatedFallback.mjs +40 -0
- package/CoordinatedLazy/useCoordinatedSwap.d.mts +16 -0
- package/CoordinatedLazy/useCoordinatedSwap.mjs +124 -0
- package/LICENSE +1 -1
- package/abstractCreateDemo/abstractCreateDemo.d.mts +54 -3
- package/abstractCreateDemo/abstractCreateDemo.mjs +47 -7
- package/abstractCreateDemo/resolveDemoFlag.d.mts +20 -0
- package/abstractCreateDemo/resolveDemoFlag.mjs +25 -0
- package/abstractCreateStream/abstractCreateStream.d.mts +18 -0
- package/abstractCreateStream/abstractCreateStream.mjs +45 -0
- package/abstractCreateStream/index.d.mts +2 -0
- package/abstractCreateStream/index.mjs +1 -0
- package/abstractCreateStream/types.d.mts +34 -0
- package/abstractCreateStream/types.mjs +1 -0
- package/abstractCreateTypes/TypeCode.mjs +12 -11
- package/abstractCreateTypes/typesToJsx.mjs +30 -9
- package/cli/ensureDemoClients.mjs +4 -148
- package/cli/ensureDemoPages.d.mts +45 -0
- package/cli/ensureDemoPages.mjs +99 -0
- package/cli/fileUtils/index.d.mts +11 -0
- package/cli/fileUtils/index.mjs +48 -0
- package/cli/findDemoIndexFiles.d.mts +15 -0
- package/cli/findDemoIndexFiles.mjs +121 -0
- package/cli/index.mjs +1 -1
- package/cli/loadNextConfig.d.mts +25 -0
- package/cli/loadNextConfig.mjs +60 -1
- package/cli/runBrowser.mjs +1 -1
- package/cli/runValidate.mjs +44 -1
- package/package.json +84 -4
- package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasis.mjs +30 -0
- package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasisLazy.d.mts +17 -0
- package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasisLazy.mjs +52 -0
- package/pipeline/hastUtils/frameFallbackFromSpans.d.mts +18 -0
- package/pipeline/hastUtils/frameFallbackFromSpans.mjs +24 -0
- package/pipeline/hastUtils/hast.d.mts +27 -0
- package/pipeline/hastUtils/hastCompression.d.mts +3 -1
- package/pipeline/hastUtils/hastCompression.mjs +9 -1
- package/pipeline/hastUtils/hastDecompress.mjs +10 -4
- package/pipeline/hastUtils/hastDictionary.mjs +9 -0
- package/pipeline/hastUtils/hastUtils.d.mts +4 -3
- package/pipeline/hastUtils/hastUtils.mjs +24 -12
- package/pipeline/hastUtils/index.d.mts +2 -1
- package/pipeline/hastUtils/index.mjs +2 -1
- package/pipeline/hastUtils/stripHighlightingSpans.d.mts +6 -2
- package/pipeline/hastUtils/stripHighlightingSpans.mjs +22 -10
- package/pipeline/lintJavascriptDemoFocus/lintJavascriptDemoFocus.mjs +10 -7
- package/pipeline/loadIsomorphicCodeVariant/applyCodeTransform.d.mts +31 -13
- package/pipeline/loadIsomorphicCodeVariant/applyCodeTransform.mjs +50 -55
- package/pipeline/loadIsomorphicCodeVariant/applyCodeTransformWithComments.d.mts +78 -0
- package/pipeline/loadIsomorphicCodeVariant/applyCodeTransformWithComments.mjs +405 -0
- package/pipeline/loadIsomorphicCodeVariant/computeHastDeltas.d.mts +5 -5
- package/pipeline/loadIsomorphicCodeVariant/computeHastDeltas.mjs +36 -66
- package/pipeline/loadIsomorphicCodeVariant/decodeHastSource.d.mts +23 -0
- package/pipeline/loadIsomorphicCodeVariant/decodeHastSource.mjs +92 -0
- package/pipeline/loadIsomorphicCodeVariant/decodeSource.d.mts +19 -0
- package/pipeline/loadIsomorphicCodeVariant/decodeSource.mjs +25 -0
- package/pipeline/loadIsomorphicCodeVariant/decodeSourceToText.d.mts +17 -0
- package/pipeline/loadIsomorphicCodeVariant/decodeSourceToText.mjs +26 -0
- package/pipeline/loadIsomorphicCodeVariant/diffHast.d.mts +26 -2
- package/pipeline/loadIsomorphicCodeVariant/diffHast.mjs +563 -19
- package/pipeline/loadIsomorphicCodeVariant/embedTransforms.d.mts +49 -0
- package/pipeline/loadIsomorphicCodeVariant/embedTransforms.mjs +152 -0
- package/pipeline/loadIsomorphicCodeVariant/findExpandingRanges.d.mts +51 -0
- package/pipeline/loadIsomorphicCodeVariant/findExpandingRanges.mjs +161 -0
- package/pipeline/loadIsomorphicCodeVariant/flattenCodeVariant.mjs +6 -3
- package/pipeline/loadIsomorphicCodeVariant/getAvailableTransforms.d.mts +12 -0
- package/pipeline/loadIsomorphicCodeVariant/getAvailableTransforms.mjs +44 -0
- package/pipeline/loadIsomorphicCodeVariant/getInitialVisibleSourceLines.d.mts +16 -0
- package/pipeline/loadIsomorphicCodeVariant/getInitialVisibleSourceLines.mjs +74 -0
- package/pipeline/loadIsomorphicCodeVariant/loadCodeFallback.mjs +17 -5
- package/pipeline/loadIsomorphicCodeVariant/loadIsomorphicCodeVariant.mjs +229 -15
- package/pipeline/loadIsomorphicCodeVariant/transformSource.d.mts +2 -2
- package/pipeline/loadIsomorphicCodeVariant/transformSource.mjs +56 -22
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.mts +18 -0
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.mjs +11 -7
- package/pipeline/loadServerTypes/hastTypeUtils.d.mts +2 -2
- package/pipeline/loadServerTypes/hastTypeUtils.mjs +4 -4
- package/pipeline/loadServerTypes/loadServerTypes.mjs +1 -1
- package/pipeline/loadServerTypesMeta/extractJSDocText.d.mts +14 -0
- package/pipeline/loadServerTypesMeta/extractJSDocText.mjs +60 -0
- package/pipeline/loadServerTypesMeta/processTypes.mjs +43 -46
- package/pipeline/loadServerTypesText/order.mjs +1 -1
- package/pipeline/loadServerTypesText/parseTypesMarkdown.mjs +3 -1
- package/pipeline/loaderUtils/index.d.mts +0 -1
- package/pipeline/loaderUtils/index.mjs +0 -1
- package/pipeline/loaderUtils/parseImportsAndComments.d.mts +5 -1
- package/pipeline/loaderUtils/parseImportsAndComments.mjs +19 -9
- package/pipeline/loaderUtils/resolveModulePath.mjs +23 -1
- package/pipeline/parseCreateFactoryCall/parseCreateFactoryCall.d.mts +12 -0
- package/pipeline/parseCreateFactoryCall/parseCreateFactoryCall.mjs +17 -13
- package/pipeline/parseSource/addLineGutters.mjs +45 -11
- package/pipeline/parseSource/calculateFrameRanges.d.mts +22 -0
- package/pipeline/parseSource/calculateFrameRanges.mjs +69 -25
- package/pipeline/parseSource/detectGrammarScopes.d.mts +13 -0
- package/pipeline/parseSource/detectGrammarScopes.mjs +35 -0
- package/pipeline/parseSource/extendSyntaxTokens.mjs +501 -43
- package/pipeline/parseSource/frameVisibility.d.mts +47 -0
- package/pipeline/parseSource/frameVisibility.mjs +114 -0
- package/pipeline/parseSource/grammarCache.d.mts +33 -0
- package/pipeline/parseSource/grammarCache.mjs +73 -0
- package/pipeline/parseSource/grammarLoaders.d.mts +14 -0
- package/pipeline/parseSource/grammarLoaders.mjs +24 -0
- package/pipeline/parseSource/grammarMaps.d.mts +21 -1
- package/pipeline/parseSource/grammarMaps.mjs +36 -0
- package/pipeline/parseSource/isFrameSpan.d.mts +19 -0
- package/pipeline/parseSource/isFrameSpan.mjs +24 -0
- package/pipeline/parseSource/parseSource.d.mts +41 -6
- package/pipeline/parseSource/parseSource.mjs +184 -36
- package/pipeline/parseSource/redistributeFrameFallbacks.d.mts +40 -0
- package/pipeline/parseSource/redistributeFrameFallbacks.mjs +138 -0
- package/pipeline/parseSource/restructureFrames.d.mts +5 -0
- package/pipeline/parseSource/restructureFrames.mjs +179 -16
- package/pipeline/syncPageIndex/metadataToMarkdown.mjs +6 -2
- package/pipeline/transformHtmlCodeBlock/transformHtmlCodeBlock.d.mts +26 -0
- package/pipeline/transformHtmlCodeBlock/transformHtmlCodeBlock.mjs +181 -114
- package/pipeline/transformHtmlCodeInline/removeSuffixFromHighlightedNodes.d.mts +12 -0
- package/pipeline/transformHtmlCodeInline/removeSuffixFromHighlightedNodes.mjs +52 -0
- package/pipeline/transformHtmlCodeInline/transformHtmlCodeInline.mjs +22 -1
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.mts +5 -8
- package/pipeline/transformTypescriptToJavascript/removeTypes.mjs +27 -93
- package/useCode/EditableEngine.d.mts +233 -0
- package/useCode/EditableEngine.mjs +1712 -0
- package/useCode/EditingEngine.d.mts +13 -0
- package/useCode/EditingEngine.mjs +14 -0
- package/useCode/Pre.browser.mjs +5 -1
- package/useCode/Pre.d.mts +127 -1
- package/useCode/Pre.mjs +417 -165
- package/useCode/SourceEditingEngine.d.mts +50 -0
- package/useCode/SourceEditingEngine.mjs +461 -0
- package/useCode/TransformEngine.d.mts +39 -0
- package/useCode/TransformEngine.mjs +208 -0
- package/useCode/editingEngineCache.d.mts +29 -0
- package/useCode/editingEngineCache.mjs +68 -0
- package/useCode/sourceLineCounts.d.mts +80 -0
- package/useCode/sourceLineCounts.mjs +284 -0
- package/useCode/subscribeToggleNudge.d.mts +3 -0
- package/useCode/subscribeToggleNudge.mjs +95 -0
- package/useCode/transformEngineCache.d.mts +21 -0
- package/useCode/transformEngineCache.mjs +60 -0
- package/useCode/useCode.d.mts +140 -1
- package/useCode/useCode.mjs +250 -19
- package/useCode/useCodeUtils.d.mts +131 -20
- package/useCode/useCodeUtils.mjs +267 -194
- package/useCode/useCopyFunctionality.d.mts +13 -1
- package/useCode/useCopyFunctionality.mjs +39 -9
- package/useCode/useEditable.browser.mjs +10 -2
- package/useCode/useEditable.d.mts +27 -106
- package/useCode/useEditable.integration.browser.d.mts +1 -0
- package/useCode/useEditable.integration.browser.mjs +870 -0
- package/useCode/useEditable.mjs +198 -1247
- package/useCode/useEditableUtils.d.mts +50 -1
- package/useCode/useEditableUtils.mjs +29 -0
- package/useCode/useFileNavigation.d.mts +91 -3
- package/useCode/useFileNavigation.mjs +201 -41
- package/useCode/useHighlightGate.d.mts +17 -0
- package/useCode/useHighlightGate.mjs +147 -0
- package/useCode/useSourceEditing.d.mts +8 -0
- package/useCode/useSourceEditing.mjs +158 -314
- package/useCode/useSourceEnhancing.d.mts +5 -1
- package/useCode/useSourceEnhancing.mjs +22 -36
- package/useCode/useTransformManagement.d.mts +93 -5
- package/useCode/useTransformManagement.mjs +496 -28
- package/useCode/useTransitionPhase.d.mts +24 -0
- package/useCode/useTransitionPhase.mjs +49 -0
- package/useCode/useUIState.d.mts +2 -2
- package/useCode/useUIState.mjs +8 -8
- package/useCode/useVariantSelection.d.mts +130 -6
- package/useCode/useVariantSelection.mjs +529 -93
- package/useCodeWindow/useCodeWindow.d.mts +19 -2
- package/useCodeWindow/useCodeWindow.mjs +98 -71
- package/useCoordinated/coordinatePreference.d.mts +439 -0
- package/useCoordinated/coordinatePreference.mjs +951 -0
- package/useCoordinated/coordinatePreference.testUtils.d.mts +21 -0
- package/useCoordinated/coordinatePreference.testUtils.mjs +69 -0
- package/useCoordinated/createSettleGate.d.mts +96 -0
- package/useCoordinated/createSettleGate.mjs +171 -0
- package/useCoordinated/index.d.mts +8 -0
- package/useCoordinated/index.mjs +8 -0
- package/useCoordinated/layoutShiftGate.d.mts +24 -0
- package/useCoordinated/layoutShiftGate.mjs +79 -0
- package/useCoordinated/pageSettleGate.d.mts +11 -0
- package/useCoordinated/pageSettleGate.mjs +13 -0
- package/useCoordinated/scheduleTasks.d.mts +23 -0
- package/useCoordinated/scheduleTasks.mjs +45 -0
- package/useCoordinated/useCoordinated.d.mts +193 -0
- package/useCoordinated/useCoordinated.mjs +469 -0
- package/useCoordinated/useCoordinatedLazy.d.mts +17 -0
- package/useCoordinated/useCoordinatedLazy.mjs +38 -0
- package/useCoordinated/useCoordinatedLocalStorage.d.mts +16 -0
- package/useCoordinated/useCoordinatedLocalStorage.mjs +22 -0
- package/useCoordinated/useCoordinatedPreference.d.mts +20 -0
- package/useCoordinated/useCoordinatedPreference.mjs +26 -0
- package/useCoordinated/useSettleGate.d.mts +11 -0
- package/useCoordinated/useSettleGate.mjs +34 -0
- package/useDemo/exportVariant.d.mts +12 -5
- package/useDemo/exportVariant.mjs +59 -5
- package/useDemo/useDemo.d.mts +5 -2
- package/useScrollAnchor/useScrollAnchor.mjs +28 -5
- package/useStream/index.d.mts +6 -0
- package/useStream/index.mjs +6 -0
- package/useStream/streamChunks.d.mts +23 -0
- package/useStream/streamChunks.mjs +85 -0
- package/useStream/types.d.mts +45 -0
- package/useStream/types.mjs +1 -0
- package/useStream/useStream.d.mts +57 -0
- package/useStream/useStream.mjs +119 -0
- package/useStream/useStreamController.d.mts +15 -0
- package/useStream/useStreamController.mjs +90 -0
- package/withDocsInfra/withDocsInfra.d.mts +19 -0
- package/withDocsInfra/withDocsInfra.mjs +13 -5
- package/pipeline/loaderUtils/convertCommentsToOneIndexed.d.mts +0 -8
- package/pipeline/loaderUtils/convertCommentsToOneIndexed.mjs +0 -16
|
@@ -1,304 +1,26 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { loadIsomorphicCodeVariant } from "../pipeline/loadIsomorphicCodeVariant/loadIsomorphicCodeVariant.mjs";
|
|
3
|
-
import { loadCodeFallback } from "../pipeline/loadIsomorphicCodeVariant/loadCodeFallback.mjs";
|
|
4
|
-
import { CodeHighlighterClient } from "./CodeHighlighterClient.mjs";
|
|
5
2
|
import { maybeCodeInitialData } from "../pipeline/loadIsomorphicCodeVariant/maybeCodeInitialData.mjs";
|
|
6
|
-
import { hasAllVariants } from "../pipeline/loadIsomorphicCodeVariant/hasAllCodeVariants.mjs";
|
|
7
3
|
import { getFileNameFromUrl, getLanguageFromExtension } from "../pipeline/loaderUtils/index.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { buildCodeHighlighterChunkProps } from "./buildCodeHighlighterChunkProps.mjs";
|
|
5
|
+
import { prepareInitialSource } from "./prepareInitialSource.mjs";
|
|
6
|
+
import { CodeHighlighterChunk } from "./CodeHighlighterChunk.mjs";
|
|
10
7
|
import * as Errors from "./errors.mjs";
|
|
11
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
9
|
const DEBUG = false; // Set to true for debugging purposes
|
|
13
10
|
|
|
14
|
-
function createClientProps(props) {
|
|
15
|
-
const highlightAfter = props.highlightAfter === 'stream' ? 'init' : props.highlightAfter;
|
|
16
|
-
const enhanceAfter = props.enhanceAfter === 'stream' ? 'init' : props.enhanceAfter;
|
|
17
|
-
|
|
18
|
-
// Rewrite the top-level URL before it leaves the server. The client never
|
|
19
|
-
// receives `urlPrefix` (and shouldn't deal with `file://` URLs), so any
|
|
20
|
-
// local URL must be translated to its hosted form here. Variant-level URLs
|
|
21
|
-
// inside `code`/`precompute` are already rewritten upstream (by
|
|
22
|
-
// `loadIsomorphicCodeVariant` on the server, or by the demo factory for precomputed
|
|
23
|
-
// input).
|
|
24
|
-
const url = props.urlPrefix && props.url ? replaceUrlPrefix(props.url, props.urlPrefix) : props.url;
|
|
25
|
-
const contentProps = {
|
|
26
|
-
code: props.code || props.precompute,
|
|
27
|
-
components: props.components,
|
|
28
|
-
name: props.name,
|
|
29
|
-
slug: props.slug,
|
|
30
|
-
url,
|
|
31
|
-
variantType: props.variantType,
|
|
32
|
-
...props.contentProps
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
url,
|
|
36
|
-
code: props.code,
|
|
37
|
-
precompute: props.precompute,
|
|
38
|
-
components: props.components,
|
|
39
|
-
variants: props.variants,
|
|
40
|
-
variant: props.variant,
|
|
41
|
-
fileName: props.fileName,
|
|
42
|
-
initialVariant: props.initialVariant,
|
|
43
|
-
defaultVariant: props.defaultVariant,
|
|
44
|
-
highlightAfter: highlightAfter || 'idle',
|
|
45
|
-
enhanceAfter: enhanceAfter || 'idle',
|
|
46
|
-
skipFallback: props.skipFallback,
|
|
47
|
-
controlled: props.controlled,
|
|
48
|
-
name: props.name,
|
|
49
|
-
slug: props.slug,
|
|
50
|
-
// Use processedGlobalsCode if available, otherwise fall back to raw globalsCode
|
|
51
|
-
globalsCode: props.processedGlobalsCode || props.globalsCode,
|
|
52
|
-
// Note: it is important that we render components before passing them to the client
|
|
53
|
-
// otherwise we will get an error because functions can't be serialized
|
|
54
|
-
// On the client, in order to send data to these components, we have to set context
|
|
55
|
-
fallback: props.fallback,
|
|
56
|
-
children: /*#__PURE__*/_jsx(props.Content, {
|
|
57
|
-
...contentProps
|
|
58
|
-
})
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
async function CodeSourceLoader(props) {
|
|
62
|
-
// Start with the loaded code from precompute, or load it if needed
|
|
63
|
-
let loadedCode = props.code || props.precompute;
|
|
64
|
-
if (!loadedCode) {
|
|
65
|
-
if (!props.loadCodeMeta) {
|
|
66
|
-
throw new Errors.ErrorCodeHighlighterServerMissingLoadCodeMeta();
|
|
67
|
-
}
|
|
68
|
-
if (!props.url) {
|
|
69
|
-
throw new Errors.ErrorCodeHighlighterServerMissingUrlForLoadCodeMeta();
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
loadedCode = await props.loadCodeMeta(props.url);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
throw new Errors.ErrorCodeHighlighterServerLoadCodeFailure(props.url, error);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// TODO: if props.variant is provided, we should only load that variant
|
|
79
|
-
|
|
80
|
-
// Process globalsCode: use already processed version if available, otherwise convert string URLs to Code objects
|
|
81
|
-
let processedGlobalsCode = props.processedGlobalsCode;
|
|
82
|
-
if (!processedGlobalsCode && props.globalsCode && props.globalsCode.length > 0) {
|
|
83
|
-
const hasStringUrls = props.globalsCode.some(item => typeof item === 'string');
|
|
84
|
-
if (hasStringUrls && !props.loadCodeMeta) {
|
|
85
|
-
throw new Errors.ErrorCodeHighlighterServerMissingLoadCodeMetaForGlobals();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Load all string URLs in parallel, keep Code objects as-is
|
|
89
|
-
const globalsPromises = props.globalsCode.map(async globalItem => {
|
|
90
|
-
if (typeof globalItem === 'string') {
|
|
91
|
-
// String URL - load Code object via loadCodeMeta
|
|
92
|
-
try {
|
|
93
|
-
return await props.loadCodeMeta(globalItem);
|
|
94
|
-
} catch (error) {
|
|
95
|
-
throw new Errors.ErrorCodeHighlighterServerLoadGlobalsFailure(globalItem, error);
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
// Code object - return as-is
|
|
99
|
-
return globalItem;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
processedGlobalsCode = await Promise.all(globalsPromises);
|
|
103
|
-
}
|
|
104
|
-
const variantNames = Object.keys(props.components || loadedCode || {});
|
|
105
|
-
const variantCodes = await Promise.all(variantNames.map(variantName => {
|
|
106
|
-
const variantCode = loadedCode[variantName];
|
|
107
|
-
const variantUrl = typeof variantCode === 'object' && variantCode?.url ? variantCode.url : props.url;
|
|
108
|
-
|
|
109
|
-
// Convert processedGlobalsCode to VariantCode | string for this specific variant
|
|
110
|
-
let resolvedGlobalsCode;
|
|
111
|
-
if (processedGlobalsCode && processedGlobalsCode.length > 0) {
|
|
112
|
-
resolvedGlobalsCode = [];
|
|
113
|
-
for (const codeObj of processedGlobalsCode) {
|
|
114
|
-
// Only include if this variant exists in the globalsCode
|
|
115
|
-
const targetVariant = codeObj[variantName];
|
|
116
|
-
if (targetVariant) {
|
|
117
|
-
resolvedGlobalsCode.push(targetVariant);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
let output = 'hastCompressed';
|
|
122
|
-
if (props.deferParsing === 'json') {
|
|
123
|
-
output = 'hastJson';
|
|
124
|
-
} else if (props.deferParsing === 'none') {
|
|
125
|
-
output = 'hast';
|
|
126
|
-
}
|
|
127
|
-
return loadIsomorphicCodeVariant(variantUrl, variantName, variantCode, {
|
|
128
|
-
sourceParser: props.sourceParser,
|
|
129
|
-
loadSource: props.loadSource,
|
|
130
|
-
loadVariantMeta: props.loadVariantMeta,
|
|
131
|
-
sourceTransformers: props.sourceTransformers,
|
|
132
|
-
sourceEnhancers: props.sourceEnhancers,
|
|
133
|
-
globalsCode: resolvedGlobalsCode,
|
|
134
|
-
output,
|
|
135
|
-
urlPrefix: props.urlPrefix
|
|
136
|
-
}).then(variant => ({
|
|
137
|
-
name: variantName,
|
|
138
|
-
variant
|
|
139
|
-
})).catch(error => ({
|
|
140
|
-
error
|
|
141
|
-
}));
|
|
142
|
-
}));
|
|
143
|
-
const processedCode = {};
|
|
144
|
-
const errors = [];
|
|
145
|
-
for (const item of variantCodes) {
|
|
146
|
-
if ('error' in item) {
|
|
147
|
-
console.error(new Errors.ErrorCodeHighlighterServerLoadVariantFailure(props.url, item.error));
|
|
148
|
-
errors.push(item.error);
|
|
149
|
-
} else {
|
|
150
|
-
processedCode[item.name] = item.variant.code;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (errors.length > 0) {
|
|
154
|
-
throw new Errors.ErrorCodeHighlighterServerLoadVariantsFailure(props.url, errors);
|
|
155
|
-
}
|
|
156
|
-
const clientProps = createClientProps({
|
|
157
|
-
...props,
|
|
158
|
-
code: processedCode,
|
|
159
|
-
processedGlobalsCode
|
|
160
|
-
});
|
|
161
|
-
return /*#__PURE__*/_jsx(CodeHighlighterClient, {
|
|
162
|
-
...clientProps
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function renderCodeHighlighter(props) {
|
|
166
|
-
const code = props.code || props.precompute;
|
|
167
|
-
const variants = props.variants || Object.keys(props.components || code || {});
|
|
168
|
-
const allCodeVariantsLoaded = code && hasAllVariants(variants, code, true);
|
|
169
|
-
|
|
170
|
-
// Check if any loader functions are available before trying async loading
|
|
171
|
-
const hasAnyLoaderFunction = !!(props.loadCodeMeta || props.loadVariantMeta || props.loadSource || props.sourceParser || props.sourceTransformers);
|
|
172
|
-
if (!allCodeVariantsLoaded && hasAnyLoaderFunction && !props.forceClient) {
|
|
173
|
-
return /*#__PURE__*/_jsx(CodeSourceLoader, {
|
|
174
|
-
...props
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
const clientProps = createClientProps(props);
|
|
178
|
-
return /*#__PURE__*/_jsx(CodeHighlighterClient, {
|
|
179
|
-
...clientProps
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
11
|
/**
|
|
184
|
-
*
|
|
12
|
+
* Isomorphic entry for a code block. Validates and normalizes props, then maps them
|
|
13
|
+
* onto the generic {@link CodeHighlighterChunk} (a `createCoordinatedLazy` chunk):
|
|
14
|
+
* the decision inputs (`controlled`/`isInitial`/`forceClient`) computed by
|
|
15
|
+
* {@link buildCodeHighlighterChunkProps} route between rendering the client directly
|
|
16
|
+
* (precomputed content), dynamically importing the server `Loader` (load all
|
|
17
|
+
* variants), or the server `InitialLoader` (load a quick initial first). When a
|
|
18
|
+
* `ContentLoading` and an initial paint are available, the loading fallback +
|
|
19
|
+
* compressed residual are prepared up front via {@link prepareInitialSource}.
|
|
20
|
+
*
|
|
21
|
+
* The heavy load/parse pipeline lives behind the dynamically-imported loaders, so it
|
|
22
|
+
* never reaches the path that renders precomputed content.
|
|
185
23
|
*/
|
|
186
|
-
async function CodeHighlighterSuspense(props) {
|
|
187
|
-
await new Promise(resolve => {
|
|
188
|
-
setTimeout(resolve, 0);
|
|
189
|
-
});
|
|
190
|
-
return props.children;
|
|
191
|
-
}
|
|
192
|
-
function renderWithInitialSource(props) {
|
|
193
|
-
const ContentLoading = props.ContentLoading;
|
|
194
|
-
const {
|
|
195
|
-
slug,
|
|
196
|
-
name,
|
|
197
|
-
initialVariant,
|
|
198
|
-
code,
|
|
199
|
-
initialFilename,
|
|
200
|
-
fallbackUsesExtraFiles,
|
|
201
|
-
fallbackUsesAllVariants
|
|
202
|
-
} = props;
|
|
203
|
-
|
|
204
|
-
// Rewrite the top-level URL before it reaches the loading fallback so the
|
|
205
|
-
// browser never sees `file://` URLs. See `createClientProps` for the same
|
|
206
|
-
// rewrite on the regular client path.
|
|
207
|
-
const url = props.urlPrefix && props.url ? replaceUrlPrefix(props.url, props.urlPrefix) : props.url;
|
|
208
|
-
const fallbackProps = codeToFallbackProps(initialVariant, code, initialFilename, fallbackUsesExtraFiles, fallbackUsesAllVariants);
|
|
209
|
-
|
|
210
|
-
// Get the component for the selected variant
|
|
211
|
-
const component = props.components?.[initialVariant];
|
|
212
|
-
|
|
213
|
-
// Only include components (plural) if we're also including extraVariants
|
|
214
|
-
const components = fallbackProps.extraVariants ? props.components : undefined;
|
|
215
|
-
const contentProps = {
|
|
216
|
-
name,
|
|
217
|
-
slug,
|
|
218
|
-
url,
|
|
219
|
-
initialFilename,
|
|
220
|
-
component,
|
|
221
|
-
components,
|
|
222
|
-
...fallbackProps,
|
|
223
|
-
...props.contentProps
|
|
224
|
-
};
|
|
225
|
-
const fallback = /*#__PURE__*/_jsx(ContentLoading, {
|
|
226
|
-
...contentProps
|
|
227
|
-
});
|
|
228
|
-
if (props.highlightAfter === 'stream' && !props.forceClient) {
|
|
229
|
-
return /*#__PURE__*/_jsx(React.Suspense, {
|
|
230
|
-
fallback: fallback,
|
|
231
|
-
children: /*#__PURE__*/_jsx(CodeHighlighterSuspense, {
|
|
232
|
-
children: renderCodeHighlighter({
|
|
233
|
-
...props,
|
|
234
|
-
fallback,
|
|
235
|
-
skipFallback: props.enhanceAfter === 'stream'
|
|
236
|
-
})
|
|
237
|
-
})
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
return renderCodeHighlighter({
|
|
241
|
-
...props,
|
|
242
|
-
fallback
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
async function CodeInitialSourceLoader(props) {
|
|
246
|
-
const {
|
|
247
|
-
url,
|
|
248
|
-
initialVariant,
|
|
249
|
-
highlightAfter,
|
|
250
|
-
fallbackUsesExtraFiles,
|
|
251
|
-
fallbackUsesAllVariants,
|
|
252
|
-
sourceParser,
|
|
253
|
-
loadSource,
|
|
254
|
-
loadVariantMeta,
|
|
255
|
-
loadCodeMeta,
|
|
256
|
-
sourceEnhancers,
|
|
257
|
-
fileName,
|
|
258
|
-
variants,
|
|
259
|
-
globalsCode,
|
|
260
|
-
ContentLoading
|
|
261
|
-
} = props;
|
|
262
|
-
if (!url) {
|
|
263
|
-
throw new Errors.ErrorCodeHighlighterServerMissingUrl();
|
|
264
|
-
}
|
|
265
|
-
let output = 'hastCompressed';
|
|
266
|
-
if (props.deferParsing === 'json') {
|
|
267
|
-
output = 'hastJson';
|
|
268
|
-
} else if (props.deferParsing === 'none') {
|
|
269
|
-
output = 'hast';
|
|
270
|
-
}
|
|
271
|
-
const {
|
|
272
|
-
code,
|
|
273
|
-
initialFilename,
|
|
274
|
-
initialSource,
|
|
275
|
-
initialExtraFiles,
|
|
276
|
-
processedGlobalsCode
|
|
277
|
-
} = await loadCodeFallback(url, initialVariant, props.code, {
|
|
278
|
-
shouldHighlight: highlightAfter === 'init',
|
|
279
|
-
fallbackUsesExtraFiles,
|
|
280
|
-
fallbackUsesAllVariants,
|
|
281
|
-
sourceParser,
|
|
282
|
-
loadSource,
|
|
283
|
-
loadVariantMeta,
|
|
284
|
-
loadCodeMeta,
|
|
285
|
-
sourceEnhancers,
|
|
286
|
-
initialFilename: fileName,
|
|
287
|
-
variants,
|
|
288
|
-
globalsCode,
|
|
289
|
-
output,
|
|
290
|
-
urlPrefix: props.urlPrefix
|
|
291
|
-
});
|
|
292
|
-
return renderWithInitialSource({
|
|
293
|
-
...props,
|
|
294
|
-
ContentLoading,
|
|
295
|
-
code,
|
|
296
|
-
initialFilename,
|
|
297
|
-
initialSource,
|
|
298
|
-
initialExtraFiles,
|
|
299
|
-
processedGlobalsCode
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
24
|
export function CodeHighlighter(props) {
|
|
303
25
|
// Validate mutually exclusive props
|
|
304
26
|
if (props.children && (props.code || props.precompute)) {
|
|
@@ -338,62 +60,118 @@ export function CodeHighlighter(props) {
|
|
|
338
60
|
}
|
|
339
61
|
}
|
|
340
62
|
const ContentLoading = props.ContentLoading;
|
|
63
|
+
const initialKey = props.initialVariant || props.variant || props.defaultVariant || variants[0];
|
|
64
|
+
|
|
65
|
+
// Map the props onto the chunk decision inputs (replaces the bespoke
|
|
66
|
+
// renderCodeHighlighter/renderWithInitialSource branching).
|
|
67
|
+
const {
|
|
68
|
+
controlled,
|
|
69
|
+
isInitial,
|
|
70
|
+
forceClient
|
|
71
|
+
} = buildCodeHighlighterChunkProps({
|
|
72
|
+
...props,
|
|
73
|
+
code
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Render the chunk. `controlled`/`isInitial`/`forceClient` drive the decision; a
|
|
77
|
+
// prepared `fallback`/`residualFallbacks` (and the wire `Code` as `preloaded`) are
|
|
78
|
+
// threaded through when an initial paint was available up front.
|
|
79
|
+
const renderChunk = options => {
|
|
80
|
+
const userProps = {
|
|
81
|
+
...props,
|
|
82
|
+
code: options.preloaded,
|
|
83
|
+
ContentLoading,
|
|
84
|
+
initialVariant: initialKey,
|
|
85
|
+
fallback: options.fallback,
|
|
86
|
+
residualFallbacks: options.residualFallbacks
|
|
87
|
+
// The user's content generic is erased at the chunk boundary; the real props
|
|
88
|
+
// ride through `Content`/`contentProps` and are rebuilt by `createClientProps`.
|
|
89
|
+
};
|
|
90
|
+
return /*#__PURE__*/_jsx(CodeHighlighterChunk, {
|
|
91
|
+
preloaded: options.preloaded,
|
|
92
|
+
controlled: controlled,
|
|
93
|
+
isInitial: isInitial,
|
|
94
|
+
forceClient: forceClient
|
|
95
|
+
// No ContentLoading -> no fallback to paint an initial into, so skip the
|
|
96
|
+
// initial-loader stage and load the full content directly.
|
|
97
|
+
,
|
|
98
|
+
skipInitialLoad: !ContentLoading
|
|
99
|
+
// Stream the fallback (Suspense) only when streaming the full load behind an
|
|
100
|
+
// already-in-hand initial; otherwise block on the loader so its content is in
|
|
101
|
+
// the initial HTML (the server-initial loader streams its own 2nd stage).
|
|
102
|
+
,
|
|
103
|
+
awaitServerLoad: !(isInitial && props.highlightAfter === 'stream'),
|
|
104
|
+
userProps: userProps
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// No ContentLoading: render the content/full-load directly, with no loading
|
|
109
|
+
// fallback (the client shows nothing until content is ready). For
|
|
110
|
+
// `highlightAt: 'init'`, `createClientProps` folds each variant's highlighted-visible
|
|
111
|
+
// `fallbackCritical` over its plain `fallback`, so `<Pre>` paints the visible frames
|
|
112
|
+
// highlighted on the first render (no decompression) and decodes the full tree after
|
|
113
|
+
// paint (the `decodeAllowed` latch).
|
|
114
|
+
if (process.env.NODE_ENV !== "production") renderChunk.displayName = "renderChunk";
|
|
341
115
|
if (!ContentLoading) {
|
|
342
116
|
if (props.highlightAfter === 'stream') {
|
|
343
|
-
//
|
|
117
|
+
// `highlightAfter: 'stream'` needs a ContentLoading component to stream into.
|
|
344
118
|
throw new Errors.ErrorCodeHighlighterServerMissingContentLoading();
|
|
345
119
|
}
|
|
346
|
-
return
|
|
347
|
-
|
|
348
|
-
code
|
|
120
|
+
return renderChunk({
|
|
121
|
+
preloaded: code
|
|
349
122
|
});
|
|
350
123
|
}
|
|
351
|
-
const initialKey = props.initialVariant || props.variant || props.defaultVariant || variants[0];
|
|
352
124
|
const initial = code?.[initialKey] || props.precompute?.[initialKey];
|
|
353
125
|
if (!initial && !props.components?.[initialKey]) {
|
|
354
126
|
throw new Errors.ErrorCodeHighlighterServerMissingVariant(initialKey);
|
|
355
127
|
}
|
|
356
128
|
|
|
357
|
-
// TODO: use initial.filesOrder to
|
|
358
|
-
|
|
129
|
+
// TODO: use initial.filesOrder to determine which source to use
|
|
359
130
|
const {
|
|
360
131
|
initialData,
|
|
361
132
|
reason
|
|
362
133
|
} = maybeCodeInitialData(variants, initialKey, code || props.precompute, undefined,
|
|
363
134
|
// TODO: use initial.filesOrder if provided?
|
|
364
135
|
props.highlightAfter === 'init', props.fallbackUsesExtraFiles, props.fallbackUsesAllVariants);
|
|
136
|
+
|
|
137
|
+
// No initial paint in hand: either the client takes over (no loader fns / forced
|
|
138
|
+
// client), or the server initial loader fetches a quick initial first.
|
|
365
139
|
if (!initialData) {
|
|
366
140
|
if (DEBUG) {
|
|
367
141
|
// eslint-disable-next-line no-console
|
|
368
142
|
console.log('Initial data not found:', reason);
|
|
369
143
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const hasAnyLoaderFunction = !!(props.loadCodeMeta || props.loadVariantMeta || props.loadSource || props.sourceParser || props.sourceTransformers);
|
|
373
|
-
|
|
374
|
-
// If no loader functions are available, skip async loading and go directly to client
|
|
375
|
-
if (!hasAnyLoaderFunction || props.forceClient) {
|
|
376
|
-
if (props.highlightAfter === 'init') {
|
|
377
|
-
throw new Errors.ErrorCodeHighlighterServerInvalidClientMode();
|
|
378
|
-
}
|
|
379
|
-
return renderCodeHighlighter({
|
|
380
|
-
...props,
|
|
381
|
-
code
|
|
382
|
-
});
|
|
144
|
+
if (forceClient && props.highlightAfter === 'init') {
|
|
145
|
+
throw new Errors.ErrorCodeHighlighterServerInvalidClientMode();
|
|
383
146
|
}
|
|
384
|
-
return
|
|
385
|
-
|
|
386
|
-
ContentLoading: ContentLoading,
|
|
387
|
-
initialVariant: initialKey
|
|
147
|
+
return renderChunk({
|
|
148
|
+
preloaded: code
|
|
388
149
|
});
|
|
389
150
|
}
|
|
390
|
-
|
|
151
|
+
|
|
152
|
+
// Initial paint in hand: prepare the loading fallback + compressed residual, and
|
|
153
|
+
// send the wire `Code` as the preloaded value.
|
|
154
|
+
const {
|
|
155
|
+
fallback,
|
|
156
|
+
residualFallbacks,
|
|
157
|
+
codeForClient
|
|
158
|
+
} = prepareInitialSource({
|
|
391
159
|
...props,
|
|
392
160
|
code: initialData.code,
|
|
393
|
-
ContentLoading,
|
|
394
161
|
initialVariant: initialKey,
|
|
395
162
|
initialFilename: initialData.initialFilename,
|
|
396
163
|
initialSource: initialData.initialSource,
|
|
397
|
-
initialExtraFiles: initialData.initialExtraFiles
|
|
164
|
+
initialExtraFiles: initialData.initialExtraFiles,
|
|
165
|
+
ContentLoading,
|
|
166
|
+
// Compressing the residual fallbacks only shrinks the server→client payload. This
|
|
167
|
+
// entry is isomorphic, so when it runs on the client (e.g. a Pages-Router app that
|
|
168
|
+
// renders everything client-side) there is no wire — skip the compress and keep the
|
|
169
|
+
// fallbacks inline rather than compressing them only to decompress them right back.
|
|
170
|
+
compressResidual: typeof window === 'undefined'
|
|
171
|
+
});
|
|
172
|
+
return renderChunk({
|
|
173
|
+
preloaded: codeForClient,
|
|
174
|
+
fallback,
|
|
175
|
+
residualFallbacks
|
|
398
176
|
});
|
|
399
177
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ChunkContentProps as CoordinatedChunkContentProps } from "../CoordinatedLazy/types.mjs";
|
|
3
|
+
import type { Code, CodeHighlighterBaseProps, ContentLoadingProps } from "./types.mjs";
|
|
4
|
+
import type { CompressedFallback } from "./fallbackFormat.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* The user props the CodeHighlighter chunk threads to its content + loaders. It
|
|
7
|
+
* carries the isomorphic CodeHighlighter props plus the values prepared up front:
|
|
8
|
+
* the rendered loading `fallback`, the compressed `residualFallbacks`, and the
|
|
9
|
+
* resolved `initialVariant`. The content generic is erased here (`{}`); the user's
|
|
10
|
+
* real content props ride through `Content`/`contentProps` and are rebuilt by
|
|
11
|
+
* `createClientProps`.
|
|
12
|
+
*/
|
|
13
|
+
export interface CodeHighlighterChunkUserProps extends CodeHighlighterBaseProps<{}> {
|
|
14
|
+
ContentLoading?: React.ComponentType<ContentLoadingProps<{}>>;
|
|
15
|
+
/** The resolved initial variant key. */
|
|
16
|
+
initialVariant?: string;
|
|
17
|
+
/** Pre-rendered loading fallback, when an initial paint was prepared up front. */
|
|
18
|
+
fallback?: React.ReactNode;
|
|
19
|
+
/** Compressed residual fallbacks prepared alongside `fallback`. */
|
|
20
|
+
residualFallbacks?: CompressedFallback;
|
|
21
|
+
/** Globals code already resolved from string URLs to `Code`, when available. */
|
|
22
|
+
processedGlobalsCode?: Array<Code>;
|
|
23
|
+
/** Skip rendering the loading fallback on the client swap. */
|
|
24
|
+
skipFallback?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Props the chunk content/loaders receive (user props + resolved `data`/`loading`). */
|
|
27
|
+
export type CodeHighlighterChunkContentProps = CoordinatedChunkContentProps<CodeHighlighterChunkUserProps, Code>;
|
|
28
|
+
/**
|
|
29
|
+
* The isomorphic chunk that drives `CodeHighlighter`. `CodeHighlighter` computes the
|
|
30
|
+
* decision inputs (`controlled`/`isInitial`/`forceClient`/`awaitServerLoad`/
|
|
31
|
+
* `skipInitialLoad`) and this routes via the generic chunk decision:
|
|
32
|
+
*
|
|
33
|
+
* - content / content-initial / attempt-initial-client -> render the client directly
|
|
34
|
+
* (it self-manages its swap).
|
|
35
|
+
* - server-loader -> dynamically import `CodeSourceLoader` (load all variants).
|
|
36
|
+
* - server-initial -> dynamically import `CodeInitialSourceLoader` (load the initial,
|
|
37
|
+
* then re-enter this chunk to load the full content).
|
|
38
|
+
*
|
|
39
|
+
* The `Loader`/`InitialLoader` are only imported when the decision routes to them, so
|
|
40
|
+
* the heavy load/parse pipeline stays off the path that renders precomputed content.
|
|
41
|
+
*/
|
|
42
|
+
export declare const CodeHighlighterChunk: React.ComponentType<import("../CoordinatedLazy/index.mjs").ChunkComponentProps<CodeHighlighterChunkUserProps, Code, never>>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createCoordinatedLazy } from "../CoordinatedLazy/createCoordinatedLazy.mjs";
|
|
3
|
+
import { createClientProps } from "./createClientProps.mjs";
|
|
4
|
+
import { CodeHighlighterClient } from "./CodeHighlighterClient.mjs";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The user props the CodeHighlighter chunk threads to its content + loaders. It
|
|
8
|
+
* carries the isomorphic CodeHighlighter props plus the values prepared up front:
|
|
9
|
+
* the rendered loading `fallback`, the compressed `residualFallbacks`, and the
|
|
10
|
+
* resolved `initialVariant`. The content generic is erased here (`{}`); the user's
|
|
11
|
+
* real content props ride through `Content`/`contentProps` and are rebuilt by
|
|
12
|
+
* `createClientProps`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Props the chunk content/loaders receive (user props + resolved `data`/`loading`). */
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
/**
|
|
18
|
+
* Render the `'use client'` `CodeHighlighterClient` from the resolved chunk props.
|
|
19
|
+
* `data` is the `Code` to send to the client; the prepared `fallback`/`residualFallbacks`
|
|
20
|
+
* ride through the user props. `CodeHighlighterClient` owns its own fallback->content
|
|
21
|
+
* swap (so the chunk is configured `contentManagesSwap`).
|
|
22
|
+
*/
|
|
23
|
+
function CodeHighlighterChunkContent(props) {
|
|
24
|
+
const {
|
|
25
|
+
data,
|
|
26
|
+
loading,
|
|
27
|
+
...userProps
|
|
28
|
+
} = props;
|
|
29
|
+
const clientProps = createClientProps({
|
|
30
|
+
...userProps,
|
|
31
|
+
code: data ?? userProps.code
|
|
32
|
+
});
|
|
33
|
+
return /*#__PURE__*/_jsx(CodeHighlighterClient, {
|
|
34
|
+
...clientProps
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The chunk's loading placeholder, used as the Suspense fallback while a server
|
|
40
|
+
* loader streams. It renders the pre-prepared `<ContentLoading />` element threaded
|
|
41
|
+
* through the user props (the actual loading UI is built up front by
|
|
42
|
+
* `prepareInitialSource`).
|
|
43
|
+
*/
|
|
44
|
+
function CodeHighlighterChunkLoading(props) {
|
|
45
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
46
|
+
children: props.fallback ?? null
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The isomorphic chunk that drives `CodeHighlighter`. `CodeHighlighter` computes the
|
|
52
|
+
* decision inputs (`controlled`/`isInitial`/`forceClient`/`awaitServerLoad`/
|
|
53
|
+
* `skipInitialLoad`) and this routes via the generic chunk decision:
|
|
54
|
+
*
|
|
55
|
+
* - content / content-initial / attempt-initial-client -> render the client directly
|
|
56
|
+
* (it self-manages its swap).
|
|
57
|
+
* - server-loader -> dynamically import `CodeSourceLoader` (load all variants).
|
|
58
|
+
* - server-initial -> dynamically import `CodeInitialSourceLoader` (load the initial,
|
|
59
|
+
* then re-enter this chunk to load the full content).
|
|
60
|
+
*
|
|
61
|
+
* The `Loader`/`InitialLoader` are only imported when the decision routes to them, so
|
|
62
|
+
* the heavy load/parse pipeline stays off the path that renders precomputed content.
|
|
63
|
+
*/
|
|
64
|
+
export const CodeHighlighterChunk = createCoordinatedLazy({
|
|
65
|
+
ChunkContent: CodeHighlighterChunkContent,
|
|
66
|
+
ChunkLoading: CodeHighlighterChunkLoading,
|
|
67
|
+
// `CodeHighlighter` computes the decision per-render (it depends on more than the
|
|
68
|
+
// preloaded value) and passes `controlled`/`isInitial` as overrides, so the config
|
|
69
|
+
// predicates always defer (returning `false` disables the default
|
|
70
|
+
// "preloaded !== undefined" rule, which would otherwise force content mode because
|
|
71
|
+
// CodeHighlighter always has a preloaded `Code`).
|
|
72
|
+
isLoaded: () => false,
|
|
73
|
+
isInitial: () => false,
|
|
74
|
+
Loader: () => import("./CodeSourceLoader.mjs"),
|
|
75
|
+
InitialLoader: () => import("./CodeInitialSourceLoader.mjs"),
|
|
76
|
+
contentManagesSwap: true
|
|
77
|
+
});
|