@mui/internal-docs-infra 0.11.1-canary.8 → 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 +85 -5
- 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
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { buildStringFallback } from "./buildStringFallback.mjs";
|
|
3
|
+
import { resolveFallbackCritical } from "./resolveFallbackCritical.mjs";
|
|
4
|
+
import { codeToFallbackProps, stripFallbackHastsFromCode } from "./codeToFallbackProps.mjs";
|
|
5
|
+
import { collapseRenderedFallbacks, compressResidualFallbacks, extractResidualFallbacks, mergeResidualFallbacks, residualDictionaryText } from "./fallbackCompression.mjs";
|
|
6
|
+
import { replaceUrlPrefix } from "../pipeline/loaderUtils/applyUrlPrefix.mjs";
|
|
7
|
+
import { getVariantFileLineCounts } from "../useCode/sourceLineCounts.mjs";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* Prepare the loading fallback and the wire `Code` from the initial source. Hoists
|
|
11
|
+
* the rendered subset onto `ContentLoading` props, strips those fallback HASTs off
|
|
12
|
+
* `Code`, and consolidates the rest into a compressed `residualFallbacks` blob the
|
|
13
|
+
* client decodes against the rendered text. The render *decision* (client vs server
|
|
14
|
+
* load, stream vs await) is the chunk's job; this is just the shared preparation
|
|
15
|
+
* used by the content path and the server loaders.
|
|
16
|
+
*/
|
|
17
|
+
export function prepareInitialSource(props) {
|
|
18
|
+
const ContentLoading = props.ContentLoading;
|
|
19
|
+
const {
|
|
20
|
+
slug,
|
|
21
|
+
name,
|
|
22
|
+
initialVariant,
|
|
23
|
+
code: initialCode,
|
|
24
|
+
initialFilename,
|
|
25
|
+
fallbackUsesExtraFiles,
|
|
26
|
+
fallbackUsesAllVariants,
|
|
27
|
+
fallbackCollapsed
|
|
28
|
+
} = props;
|
|
29
|
+
const contentPropsFlags = props.contentProps;
|
|
30
|
+
const collapseToEmpty = props.collapseToEmpty !== undefined ? props.collapseToEmpty : contentPropsFlags?.collapseToEmpty;
|
|
31
|
+
const initialExpanded = props.initialExpanded !== undefined ? props.initialExpanded : contentPropsFlags?.initialExpanded;
|
|
32
|
+
const collapseToEmptyEnabled = collapseToEmpty === true;
|
|
33
|
+
const initialExpandedEnabled = initialExpanded === true;
|
|
34
|
+
|
|
35
|
+
// Fold each variant's staging `fallbackCritical` into its plain `fallback` up front
|
|
36
|
+
// (under `highlightAt: 'init'`, not `collapseToEmpty`), then strip it. The hoisted
|
|
37
|
+
// loading fallback is therefore already highlighted-visible — so the first paint is
|
|
38
|
+
// highlighted with no decompression — while the rest of this function (strip, hoist,
|
|
39
|
+
// window, compress) operates on a single `fallback` field with no awareness of the
|
|
40
|
+
// staging companion.
|
|
41
|
+
// Normalize `'stream'` → `'init'` before resolving, mirroring `createClientProps`: stream
|
|
42
|
+
// mode wants the loading fallback highlighted on first paint too (the client highlightAfter
|
|
43
|
+
// type even collapses 'stream' into 'init').
|
|
44
|
+
const highlightAfter = props.highlightAfter === 'stream' ? 'init' : props.highlightAfter;
|
|
45
|
+
const code = resolveFallbackCritical(initialCode, highlightAfter, collapseToEmptyEnabled) ?? initialCode;
|
|
46
|
+
|
|
47
|
+
// When the block starts expanded, the loading UI needs the full content, so
|
|
48
|
+
// the `fallbackCollapsed` window optimization (paint only the collapsed slice,
|
|
49
|
+
// defer the rest) doesn't apply — treat it as off everywhere below.
|
|
50
|
+
const effectiveFallbackCollapsed = fallbackCollapsed && !initialExpandedEnabled;
|
|
51
|
+
|
|
52
|
+
// Strip fallbackHast entries from Code — they move to ContentLoading props
|
|
53
|
+
// as source/extraSource instead of being serialized on Code.
|
|
54
|
+
const {
|
|
55
|
+
strippedCode,
|
|
56
|
+
allFallbackHasts
|
|
57
|
+
} = stripFallbackHastsFromCode(code, initialVariant, fallbackUsesExtraFiles, fallbackUsesAllVariants);
|
|
58
|
+
|
|
59
|
+
// Compute the line counts (and, for inline strings, the windowed frames) for EVERY
|
|
60
|
+
// file/variant passed to the fallback — the main file, extra files
|
|
61
|
+
// (`fallbackUsesExtraFiles`), and extra variants (`fallbackUsesAllVariants`) — so
|
|
62
|
+
// each carries its own `{ totalLines, focusedLines, collapsible }` downstream. Counts come from:
|
|
63
|
+
// (1) the loader-stored counts on the code, else (2) reading the *original* source
|
|
64
|
+
// here (where `hastCompressed` dictionaries are still present — they're stripped
|
|
65
|
+
// before `codeToFallbackProps` runs), else (3) windowing an inline plain string.
|
|
66
|
+
// Windowing also runs `sourceEnhancers` over a cheap line-guttered HAST (no syntax
|
|
67
|
+
// highlighting) and hoists the truncated frames into `allFallbackHasts`, matching
|
|
68
|
+
// the live render instead of `sourceToFallback`'s naive single focus frame. The raw
|
|
69
|
+
// string stays on `codeForClient`, so the client still highlights it after hydration.
|
|
70
|
+
const allLineCounts = {};
|
|
71
|
+
const {
|
|
72
|
+
sourceEnhancers
|
|
73
|
+
} = props;
|
|
74
|
+
const variantsInScope = fallbackUsesAllVariants ? Object.keys(code ?? {}) : [initialVariant];
|
|
75
|
+
for (const variantName of variantsInScope) {
|
|
76
|
+
const variant = code?.[variantName];
|
|
77
|
+
if (!variant || typeof variant === 'string') {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const files = [];
|
|
81
|
+
if (variant.fileName) {
|
|
82
|
+
files.push({
|
|
83
|
+
fileName: variant.fileName,
|
|
84
|
+
source: variant.source,
|
|
85
|
+
comments: variant.comments
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if ((fallbackUsesExtraFiles || fallbackUsesAllVariants) && variant.extraFiles) {
|
|
89
|
+
for (const [fileName, fileData] of Object.entries(variant.extraFiles)) {
|
|
90
|
+
if (typeof fileData === 'object') {
|
|
91
|
+
files.push({
|
|
92
|
+
fileName,
|
|
93
|
+
source: fileData.source,
|
|
94
|
+
comments: fileData.comments
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const file of files) {
|
|
100
|
+
const storedFile = variant.fileName === file.fileName ? variant : variant.extraFiles?.[file.fileName];
|
|
101
|
+
let counts = storedFile && typeof storedFile !== 'string' && storedFile.totalLines !== undefined ? {
|
|
102
|
+
totalLines: storedFile.totalLines,
|
|
103
|
+
focusedLines: storedFile.focusedLines ?? storedFile.totalLines,
|
|
104
|
+
collapsible: storedFile.collapsible === true
|
|
105
|
+
} : undefined;
|
|
106
|
+
if (!counts) {
|
|
107
|
+
// Read off the original source; a missing dictionary throws — non-fatal here.
|
|
108
|
+
// `totalLines === 0` ⇒ a hast with no `root.data` counts (not a real count).
|
|
109
|
+
try {
|
|
110
|
+
const read = getVariantFileLineCounts(variant, file.fileName);
|
|
111
|
+
counts = read && read.totalLines > 0 ? read : undefined;
|
|
112
|
+
} catch {
|
|
113
|
+
counts = undefined;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Window an inline plain-string source (needs enhancers, and not already framed
|
|
117
|
+
// by the loader) and override the counts with the resulting window.
|
|
118
|
+
if (sourceEnhancers && sourceEnhancers.length > 0 && typeof file.source === 'string' && !allFallbackHasts[variantName]?.[file.fileName]) {
|
|
119
|
+
const windowed = buildStringFallback(file.source,
|
|
120
|
+
// `Code` comments are always 1-indexed and `buildStringFallback` passes them
|
|
121
|
+
// straight to the enhancer (matched against the 1-indexed `dataLn` gutter).
|
|
122
|
+
file.comments, file.fileName, sourceEnhancers);
|
|
123
|
+
if (windowed) {
|
|
124
|
+
(allFallbackHasts[variantName] ??= {})[file.fileName] = windowed.fallback;
|
|
125
|
+
counts = {
|
|
126
|
+
totalLines: windowed.totalLines,
|
|
127
|
+
focusedLines: windowed.focusedLines,
|
|
128
|
+
collapsible: windowed.collapsible
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (counts) {
|
|
133
|
+
(allLineCounts[variantName] ??= {})[file.fileName] = {
|
|
134
|
+
totalLines: counts.totalLines,
|
|
135
|
+
// Render-time collapse-to-empty empties every file's window (oversized
|
|
136
|
+
// `'hide'` already records `focusedLines === 0`). `useCodeFallback` applies
|
|
137
|
+
// the same rule when it demotes the source, so they stay consistent.
|
|
138
|
+
focusedLines: collapseToEmptyEnabled ? 0 : counts.focusedLines,
|
|
139
|
+
collapsible: collapseToEmptyEnabled ? true : counts.collapsible
|
|
140
|
+
};
|
|
141
|
+
// Carry the RAW counts onto the wire `code` too, so the content component's base
|
|
142
|
+
// render (before `hast` decodes) reads the same `collapsible`/window metadata the
|
|
143
|
+
// loading fallback got. A windowed inline string — or a `hastCompressed` source
|
|
144
|
+
// whose dictionary was stripped for residual compression — otherwise has no stored
|
|
145
|
+
// counts on `codeForClient`, so `getVariantFileLineCounts` falls back to the raw
|
|
146
|
+
// (non-collapsible) string count and `data-collapsible` flashes off until the
|
|
147
|
+
// source highlights. `<Pre>` re-applies collapse-to-empty from the stored counts.
|
|
148
|
+
const wireVariant = strippedCode[variantName];
|
|
149
|
+
if (wireVariant && typeof wireVariant === 'object') {
|
|
150
|
+
const stored = {
|
|
151
|
+
totalLines: counts.totalLines,
|
|
152
|
+
focusedLines: counts.focusedLines,
|
|
153
|
+
collapsible: counts.collapsible
|
|
154
|
+
};
|
|
155
|
+
if (wireVariant.fileName === file.fileName) {
|
|
156
|
+
strippedCode[variantName] = {
|
|
157
|
+
...wireVariant,
|
|
158
|
+
...stored
|
|
159
|
+
};
|
|
160
|
+
} else {
|
|
161
|
+
const extra = wireVariant.extraFiles?.[file.fileName];
|
|
162
|
+
if (extra && typeof extra === 'object') {
|
|
163
|
+
strippedCode[variantName] = {
|
|
164
|
+
...wireVariant,
|
|
165
|
+
extraFiles: {
|
|
166
|
+
...wireVariant.extraFiles,
|
|
167
|
+
[file.fileName]: {
|
|
168
|
+
...extra,
|
|
169
|
+
...stored
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Rewrite the top-level URL before it reaches the loading fallback so the
|
|
181
|
+
// browser never sees `file://` URLs. See `createClientProps` for the same
|
|
182
|
+
// rewrite on the regular client path.
|
|
183
|
+
const url = props.urlPrefix && props.url ? replaceUrlPrefix(props.url, props.urlPrefix) : props.url;
|
|
184
|
+
|
|
185
|
+
// `fallbackCollapsed` paints only each file's collapsed window in the loading
|
|
186
|
+
// UI; the full fallbacks defer into the blob. Otherwise the loading UI gets
|
|
187
|
+
// the full rendered subset, as usual.
|
|
188
|
+
//
|
|
189
|
+
// A file produced with `oversizedFocus: 'hide'` records `focusedLines === 0`
|
|
190
|
+
// (collapse-to-nothing): its collapsed window is empty, so we tell
|
|
191
|
+
// `collapseRenderedFallbacks` to emit no frames for it rather than fall back
|
|
192
|
+
// to the first frame — matching the hydrated render. The render-time
|
|
193
|
+
// `collapseToEmpty` flag empties the window for every file the same way.
|
|
194
|
+
const collapsesToEmpty = (variantName, fileName) => {
|
|
195
|
+
if (collapseToEmptyEnabled) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
// A windowed inline-string file has authoritative counts here; precomputed
|
|
199
|
+
// sources read theirs off `root.data` via `getVariantFileLineCounts`.
|
|
200
|
+
const windowed = allLineCounts[variantName]?.[fileName];
|
|
201
|
+
if (windowed) {
|
|
202
|
+
return windowed.focusedLines === 0;
|
|
203
|
+
}
|
|
204
|
+
const variant = code[variantName];
|
|
205
|
+
if (!variant || typeof variant === 'string') {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
// Mirror the count path's guard above: `focusedLines === 0` only means
|
|
209
|
+
// collapse-to-empty when there's a real count. A decoded HAST with no `root.data`
|
|
210
|
+
// reads as `{ totalLines: 0, focusedLines: 0 }` — that's "no count", not an empty
|
|
211
|
+
// window — so don't mistake it for an intentional collapse-to-nothing.
|
|
212
|
+
const counts = getVariantFileLineCounts(variant, fileName);
|
|
213
|
+
return counts ? counts.totalLines > 0 && counts.focusedLines === 0 : false;
|
|
214
|
+
};
|
|
215
|
+
const contentLoadingHasts = effectiveFallbackCollapsed ? collapseRenderedFallbacks(allFallbackHasts, collapsesToEmpty) : allFallbackHasts;
|
|
216
|
+
|
|
217
|
+
// `allLineCounts` gives `codeToFallbackProps` a window for EVERY file/variant it
|
|
218
|
+
// emits — main, extra files, and extra variants — so each carries its own
|
|
219
|
+
// `totalLines`/`focusedLines`/`collapsible` (collapse-to-empty is applied per file in
|
|
220
|
+
// `useCodeFallback`).
|
|
221
|
+
const fallbackProps = codeToFallbackProps(initialVariant, strippedCode, initialFilename, fallbackUsesExtraFiles, fallbackUsesAllVariants, contentLoadingHasts, allLineCounts);
|
|
222
|
+
|
|
223
|
+
// Consolidate every fallback the loading UI won't render into a single DEFLATE
|
|
224
|
+
// blob, primed with the rendered (collapsed, when `fallbackCollapsed`) text so
|
|
225
|
+
// it dedupes against what's already on the client. That's everything still on
|
|
226
|
+
// `strippedCode` after hoisting — plus, when `fallbackCollapsed`, each
|
|
227
|
+
// rendered file's *full* fallback (the loading UI only painted its collapsed
|
|
228
|
+
// window, so the rest must travel here). The blob crosses once; `wireCode`
|
|
229
|
+
// carries no inline fallbacks, and the client decompresses + scatters them back
|
|
230
|
+
// onto the code so its consumers (render and the swap line-count classifier)
|
|
231
|
+
// read the dictionary off `code` regardless of which variant is active. When
|
|
232
|
+
// there's nothing worth compressing, keep the plain inline fallbacks unchanged.
|
|
233
|
+
// Compressing the residual only shrinks the server→client wire, so skip it entirely
|
|
234
|
+
// on the client (`compressResidual === false`): keep the fallbacks INLINE on
|
|
235
|
+
// `codeForClient` so `CodeHighlighterClient` reads them directly — no
|
|
236
|
+
// compress→decompress round-trip, and nothing to recompute on every re-render. This
|
|
237
|
+
// is the same shape the `strippedCode` branch below already produces for a payload
|
|
238
|
+
// too small to be worth compressing.
|
|
239
|
+
const compressResidual = props.compressResidual ?? true;
|
|
240
|
+
let residualFallbacks;
|
|
241
|
+
let codeForClient = strippedCode;
|
|
242
|
+
if (compressResidual) {
|
|
243
|
+
const {
|
|
244
|
+
wireCode,
|
|
245
|
+
residual
|
|
246
|
+
} = extractResidualFallbacks(strippedCode);
|
|
247
|
+
const fullResidual = effectiveFallbackCollapsed ? mergeResidualFallbacks(residual, allFallbackHasts) : residual;
|
|
248
|
+
residualFallbacks = compressResidualFallbacks(fullResidual, residualDictionaryText(contentLoadingHasts));
|
|
249
|
+
codeForClient = residualFallbacks ? wireCode : strippedCode;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Get the component for the selected variant
|
|
253
|
+
const component = props.components?.[initialVariant];
|
|
254
|
+
|
|
255
|
+
// Only include components (plural) if we're also including extraVariants
|
|
256
|
+
const components = fallbackProps.extraVariants ? props.components : undefined;
|
|
257
|
+
const contentProps = {
|
|
258
|
+
...props.contentProps,
|
|
259
|
+
...fallbackProps,
|
|
260
|
+
name,
|
|
261
|
+
slug,
|
|
262
|
+
url,
|
|
263
|
+
initialFilename,
|
|
264
|
+
initialVariant,
|
|
265
|
+
component,
|
|
266
|
+
components,
|
|
267
|
+
// Signals the ContentLoading that `source` is only the collapsed window,
|
|
268
|
+
// so it can disable any expand control until the full content swaps in.
|
|
269
|
+
// Off when the block starts expanded (the loading UI gets the full content).
|
|
270
|
+
...(effectiveFallbackCollapsed ? {
|
|
271
|
+
fallbackCollapsed: true
|
|
272
|
+
} : undefined),
|
|
273
|
+
// Render-time collapse-to-empty: the loading placeholder paints an empty window
|
|
274
|
+
// too (via `useCodeFallback`), matching the hydrated render.
|
|
275
|
+
...(collapseToEmpty !== undefined ? {
|
|
276
|
+
collapseToEmpty
|
|
277
|
+
} : undefined),
|
|
278
|
+
// Render-time default-expanded: the loading placeholder can render expanded
|
|
279
|
+
// so it doesn't flash collapsed before hydration.
|
|
280
|
+
...(initialExpanded !== undefined ? {
|
|
281
|
+
initialExpanded
|
|
282
|
+
} : undefined)
|
|
283
|
+
};
|
|
284
|
+
const fallback = /*#__PURE__*/_jsx(ContentLoading, {
|
|
285
|
+
...contentProps
|
|
286
|
+
});
|
|
287
|
+
return {
|
|
288
|
+
fallback,
|
|
289
|
+
residualFallbacks,
|
|
290
|
+
codeForClient
|
|
291
|
+
};
|
|
292
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Code, CodeHighlighterBaseProps } from "./types.mjs";
|
|
2
|
+
type HighlightAfter = CodeHighlighterBaseProps<{}>['highlightAfter'];
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the staging `fallbackCritical` field at a server→client (or client-load)
|
|
5
|
+
* boundary, returning a clone of `code` ready to cross to the client:
|
|
6
|
+
*
|
|
7
|
+
* - **Promote** — under `highlightAt: 'init'` (and not `collapseToEmpty`), each
|
|
8
|
+
* variant whose `fallbackCritical` *and* plain `fallback` are both present has the
|
|
9
|
+
* sparse `fallbackCritical` diff spliced over its `fallback` (`promoteCriticalFallback`)
|
|
10
|
+
* — the visible frames become highlighted, the rest stay plain — so the first paint is
|
|
11
|
+
* highlighted with no client-side decompression. The promoted `fallback` stays a valid
|
|
12
|
+
* DEFLATE dictionary because the spliced frames have byte-identical text. With
|
|
13
|
+
* `collapseToEmpty`, the correct critical fallback is all-plain (no frame is visible),
|
|
14
|
+
* which already equals `fallback` — so promotion is skipped.
|
|
15
|
+
* - **Strip** — `fallbackCritical` is always deleted (even when not promoting, and
|
|
16
|
+
* even for non-`init` modes), so it never crosses to the `Content`/`ContentLoading`
|
|
17
|
+
* components or bloats the serialized payload.
|
|
18
|
+
*
|
|
19
|
+
* Returns `code` unchanged (same reference) when no variant carries `fallbackCritical`,
|
|
20
|
+
* and clones only the variants that do.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveFallbackCritical(code: Code | undefined, highlightAfter: HighlightAfter, collapseToEmpty: boolean): Code | undefined;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { promoteCriticalFallback } from "./fallbackFormat.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the staging `fallbackCritical` field at a server→client (or client-load)
|
|
4
|
+
* boundary, returning a clone of `code` ready to cross to the client:
|
|
5
|
+
*
|
|
6
|
+
* - **Promote** — under `highlightAt: 'init'` (and not `collapseToEmpty`), each
|
|
7
|
+
* variant whose `fallbackCritical` *and* plain `fallback` are both present has the
|
|
8
|
+
* sparse `fallbackCritical` diff spliced over its `fallback` (`promoteCriticalFallback`)
|
|
9
|
+
* — the visible frames become highlighted, the rest stay plain — so the first paint is
|
|
10
|
+
* highlighted with no client-side decompression. The promoted `fallback` stays a valid
|
|
11
|
+
* DEFLATE dictionary because the spliced frames have byte-identical text. With
|
|
12
|
+
* `collapseToEmpty`, the correct critical fallback is all-plain (no frame is visible),
|
|
13
|
+
* which already equals `fallback` — so promotion is skipped.
|
|
14
|
+
* - **Strip** — `fallbackCritical` is always deleted (even when not promoting, and
|
|
15
|
+
* even for non-`init` modes), so it never crosses to the `Content`/`ContentLoading`
|
|
16
|
+
* components or bloats the serialized payload.
|
|
17
|
+
*
|
|
18
|
+
* Returns `code` unchanged (same reference) when no variant carries `fallbackCritical`,
|
|
19
|
+
* and clones only the variants that do.
|
|
20
|
+
*/
|
|
21
|
+
export function resolveFallbackCritical(code, highlightAfter, collapseToEmpty) {
|
|
22
|
+
if (!code) {
|
|
23
|
+
return code;
|
|
24
|
+
}
|
|
25
|
+
const promote = highlightAfter === 'init' && !collapseToEmpty;
|
|
26
|
+
let changed = false;
|
|
27
|
+
const resolved = {};
|
|
28
|
+
for (const [key, variant] of Object.entries(code)) {
|
|
29
|
+
if (!variant || typeof variant === 'string' || variant.fallbackCritical === undefined) {
|
|
30
|
+
resolved[key] = variant;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const {
|
|
34
|
+
fallbackCritical,
|
|
35
|
+
...rest
|
|
36
|
+
} = variant;
|
|
37
|
+
resolved[key] = promote && rest.fallback ? {
|
|
38
|
+
...rest,
|
|
39
|
+
fallback: promoteCriticalFallback(rest.fallback, fallbackCritical)
|
|
40
|
+
} : rest;
|
|
41
|
+
changed = true;
|
|
42
|
+
}
|
|
43
|
+
return changed ? resolved : code;
|
|
44
|
+
}
|