@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,119 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { streamChunks } from "./streamChunks.mjs";
|
|
5
|
+
import { useStreamController } from "./useStreamController.mjs";
|
|
6
|
+
import { requestIdle } from "../useCoordinated/scheduleTasks.mjs";
|
|
7
|
+
|
|
8
|
+
/** Options for {@link useStream}. */
|
|
9
|
+
|
|
10
|
+
/** Result of {@link useStream}. */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Stream a list of chunks on the client and own a `StreamController` that scopes
|
|
14
|
+
* their coordination. Render the returned `chunks` as chunk components inside
|
|
15
|
+
* the returned `Controller`; each chunk registers its swap with the controller,
|
|
16
|
+
* and the list's completion (`markLast`) plus those swaps drive `loading`.
|
|
17
|
+
*
|
|
18
|
+
* The controller runs in `streaming` mode, so it stays `loading` until the list
|
|
19
|
+
* finishes streaming - at which point the chunks present can settle it.
|
|
20
|
+
*
|
|
21
|
+
* `refresh()` (and the opt-in `revalidateOnIdle`) re-stream the list in the
|
|
22
|
+
* background and swap the result in atomically when it completes, without a
|
|
23
|
+
* loading flash — the current list stays visible the whole time.
|
|
24
|
+
*/
|
|
25
|
+
export function useStream(options) {
|
|
26
|
+
const {
|
|
27
|
+
source,
|
|
28
|
+
loaderOptions,
|
|
29
|
+
channelKey,
|
|
30
|
+
revalidateOnIdle
|
|
31
|
+
} = options;
|
|
32
|
+
const {
|
|
33
|
+
Controller,
|
|
34
|
+
loading: controllerLoading,
|
|
35
|
+
markLast
|
|
36
|
+
} = useStreamController({
|
|
37
|
+
streaming: true,
|
|
38
|
+
channelKey
|
|
39
|
+
});
|
|
40
|
+
const [chunks, setChunks] = React.useState([]);
|
|
41
|
+
const [streamComplete, setStreamComplete] = React.useState(false);
|
|
42
|
+
const [revalidating, setRevalidating] = React.useState(false);
|
|
43
|
+
const [refreshToken, setRefreshToken] = React.useState(0);
|
|
44
|
+
|
|
45
|
+
// Set by `refresh()` so the stream effect can tell a background revalidation
|
|
46
|
+
// (keep the current list, swap on complete) from an initial / source-change
|
|
47
|
+
// stream (reveal progressively). Read-and-cleared at the start of the effect.
|
|
48
|
+
const refreshRef = React.useRef(false);
|
|
49
|
+
const refresh = React.useCallback(() => {
|
|
50
|
+
refreshRef.current = true;
|
|
51
|
+
setRefreshToken(token => token + 1);
|
|
52
|
+
}, []);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
const controller = new AbortController();
|
|
55
|
+
const isRefresh = refreshRef.current;
|
|
56
|
+
refreshRef.current = false;
|
|
57
|
+
if (isRefresh) {
|
|
58
|
+
setRevalidating(true);
|
|
59
|
+
}
|
|
60
|
+
(async () => {
|
|
61
|
+
try {
|
|
62
|
+
const stream = streamChunks(source, loaderOptions, controller.signal);
|
|
63
|
+
// Snapshots accumulate and reveal in order as the source streams.
|
|
64
|
+
let latest = [];
|
|
65
|
+
for await (const snapshot of stream) {
|
|
66
|
+
if (controller.signal.aborted) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
latest = snapshot.chunks;
|
|
70
|
+
// Initial / source-change: reveal progressively. A background refresh
|
|
71
|
+
// holds the current list and swaps once below (stale-while-revalidate).
|
|
72
|
+
if (!isRefresh) {
|
|
73
|
+
setChunks(snapshot.chunks);
|
|
74
|
+
if (snapshot.lastChunk) {
|
|
75
|
+
setStreamComplete(true);
|
|
76
|
+
markLast();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (isRefresh && !controller.signal.aborted) {
|
|
81
|
+
setChunks(latest);
|
|
82
|
+
setRevalidating(false);
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// Stream aborted by a newer run, or the loader failed.
|
|
86
|
+
if (isRefresh && !controller.signal.aborted) {
|
|
87
|
+
setRevalidating(false);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
return () => controller.abort();
|
|
92
|
+
// Re-stream when the source identity changes or a refresh is requested;
|
|
93
|
+
// options are read once at stream start, and `markLast` is stable.
|
|
94
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
|
+
}, [source, refreshToken]);
|
|
96
|
+
|
|
97
|
+
// Opt-in stale-while-revalidate: once the list has finished streaming,
|
|
98
|
+
// revalidate in the background on the first idle period. Browser-only.
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
if (!revalidateOnIdle || !streamComplete || typeof window === 'undefined') {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return requestIdle(() => refresh());
|
|
104
|
+
}, [revalidateOnIdle, streamComplete, refresh]);
|
|
105
|
+
|
|
106
|
+
// Loading until the list has finished streaming AND every rendered chunk has
|
|
107
|
+
// settled. The controller's `loading` only reflects chunk swaps (it settles
|
|
108
|
+
// immediately when no chunks have registered yet), so combine it with the
|
|
109
|
+
// list-streaming state.
|
|
110
|
+
const loading = !streamComplete || controllerLoading;
|
|
111
|
+
return {
|
|
112
|
+
chunks,
|
|
113
|
+
Controller,
|
|
114
|
+
loading,
|
|
115
|
+
streamComplete,
|
|
116
|
+
revalidating,
|
|
117
|
+
refresh
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UseStreamControllerOptions, UseStreamControllerResult } from "./types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Scope a group of chunks so the page can tell when they have all loaded.
|
|
4
|
+
*
|
|
5
|
+
* Returns a `Controller` provider to wrap the chunks in - it supplies the
|
|
6
|
+
* controller's gate as the ambient gate (via `CoordinatedGateContext`), so
|
|
7
|
+
* chunks rendered inside register their swap with it through `CoordinatedLazy`
|
|
8
|
+
* without a `gate` prop - and a reactive `loading` flag that stays `true` until
|
|
9
|
+
* every registered chunk settles. Completion resolves via the gate's
|
|
10
|
+
* **known-count** (`knownCount`) or **last-chunk** (`streaming` + `markLast`)
|
|
11
|
+
* signals; with neither, it opens as soon as the chunks present in the initial
|
|
12
|
+
* commit all settle. Each chunk also registers with the page-global gate (via
|
|
13
|
+
* `CoordinatedLazy`), so a page-wide coordinated commit waits for them too.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useStreamController(options?: UseStreamControllerOptions): UseStreamControllerResult;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { createSettleGate } from "../useCoordinated/createSettleGate.mjs";
|
|
5
|
+
import { CoordinatedGateContext } from "../CoordinatedLazy/CoordinatedGateContext.mjs";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* Scope a group of chunks so the page can tell when they have all loaded.
|
|
9
|
+
*
|
|
10
|
+
* Returns a `Controller` provider to wrap the chunks in - it supplies the
|
|
11
|
+
* controller's gate as the ambient gate (via `CoordinatedGateContext`), so
|
|
12
|
+
* chunks rendered inside register their swap with it through `CoordinatedLazy`
|
|
13
|
+
* without a `gate` prop - and a reactive `loading` flag that stays `true` until
|
|
14
|
+
* every registered chunk settles. Completion resolves via the gate's
|
|
15
|
+
* **known-count** (`knownCount`) or **last-chunk** (`streaming` + `markLast`)
|
|
16
|
+
* signals; with neither, it opens as soon as the chunks present in the initial
|
|
17
|
+
* commit all settle. Each chunk also registers with the page-global gate (via
|
|
18
|
+
* `CoordinatedLazy`), so a page-wide coordinated commit waits for them too.
|
|
19
|
+
*/
|
|
20
|
+
export function useStreamController(options = {}) {
|
|
21
|
+
const {
|
|
22
|
+
knownCount,
|
|
23
|
+
streaming = false,
|
|
24
|
+
safetyTimeoutMs
|
|
25
|
+
} = options;
|
|
26
|
+
|
|
27
|
+
// One gate per controller instance, configured once with its completion mode.
|
|
28
|
+
const [gate] = React.useState(() => {
|
|
29
|
+
const instance = createSettleGate(safetyTimeoutMs != null ? {
|
|
30
|
+
safetyTimeoutMs
|
|
31
|
+
} : undefined);
|
|
32
|
+
if (knownCount != null) {
|
|
33
|
+
instance.expect(knownCount);
|
|
34
|
+
} else if (streaming) {
|
|
35
|
+
// Hold open for an unknown-count stream until markLast.
|
|
36
|
+
instance.expect(Number.POSITIVE_INFINITY);
|
|
37
|
+
}
|
|
38
|
+
return instance;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Stable provider that hands this instance's gate down as the ambient gate
|
|
42
|
+
// (created once; `gate` is stable for the controller's lifetime).
|
|
43
|
+
const [Controller] = React.useState(() => function StreamControllerProvider({
|
|
44
|
+
children
|
|
45
|
+
}) {
|
|
46
|
+
return /*#__PURE__*/_jsx(CoordinatedGateContext.Provider, {
|
|
47
|
+
value: gate,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
const [loading, setLoading] = React.useState(() => knownCount !== 0);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
// Chunks register in their own (child) effects, which run before this
|
|
54
|
+
// (parent) effect - so by now the gate reflects every chunk present in the
|
|
55
|
+
// initial commit. These setState calls cannot move to render: at render
|
|
56
|
+
// time the gate is still unarmed, so `gate.isSettled()` returns `true` and a
|
|
57
|
+
// render-time derivation would wrongly report 'done' immediately. Only after
|
|
58
|
+
// the child effects register does the gate reflect the initial-commit chunks.
|
|
59
|
+
/* eslint-disable react-hooks/set-state-in-effect -- gate.isSettled() only reflects child chunks after their (child) effects register them; this parent effect runs after, so the value is unavailable during render */
|
|
60
|
+
if (gate.isSettled()) {
|
|
61
|
+
setLoading(false);
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
setLoading(true);
|
|
65
|
+
let cancelled = false;
|
|
66
|
+
const wait = gate.whenSettled();
|
|
67
|
+
if (wait) {
|
|
68
|
+
wait.then(() => {
|
|
69
|
+
if (!cancelled) {
|
|
70
|
+
setLoading(false);
|
|
71
|
+
}
|
|
72
|
+
}).catch(() => {});
|
|
73
|
+
} else {
|
|
74
|
+
setLoading(false);
|
|
75
|
+
}
|
|
76
|
+
/* eslint-enable react-hooks/set-state-in-effect */
|
|
77
|
+
return () => {
|
|
78
|
+
cancelled = true;
|
|
79
|
+
};
|
|
80
|
+
}, [gate]);
|
|
81
|
+
const markLast = React.useCallback(() => gate.markLast(), [gate]);
|
|
82
|
+
const setKnownCount = React.useCallback(count => gate.expect(count), [gate]);
|
|
83
|
+
return {
|
|
84
|
+
Controller,
|
|
85
|
+
loading,
|
|
86
|
+
gate,
|
|
87
|
+
markLast,
|
|
88
|
+
setKnownCount
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -71,6 +71,17 @@ export interface WithDocsInfraOptions {
|
|
|
71
71
|
* Existing `client.ts` files are never overwritten.
|
|
72
72
|
*/
|
|
73
73
|
requireDemoClient?: string;
|
|
74
|
+
/**
|
|
75
|
+
* When `true`, `pnpm docs-infra validate` ensures every demo `index.ts` matched by a
|
|
76
|
+
* `loadPrecomputedCodeHighlighter` demo rule has a sibling `page.tsx` that renders
|
|
77
|
+
* the demo as the route's default export, so each demo is browsable on its own page.
|
|
78
|
+
*
|
|
79
|
+
* The demo's export name is read from the `create*` factory call in `index.ts`, so the
|
|
80
|
+
* generated page imports the exact export (e.g. `import { DemoButton } from '.';`).
|
|
81
|
+
*
|
|
82
|
+
* Existing `page.tsx`/`page.ts` files are never overwritten.
|
|
83
|
+
*/
|
|
84
|
+
requireDemoPage?: boolean;
|
|
74
85
|
/**
|
|
75
86
|
* Performance logging options
|
|
76
87
|
*/
|
|
@@ -111,6 +122,14 @@ export interface WithDocsInfraOptions {
|
|
|
111
122
|
* Passed to `transformHtmlCodeBlock` through the types loader pipeline.
|
|
112
123
|
*/
|
|
113
124
|
codeBlockEmphasisOptions?: TransformHtmlCodeBlockOptions;
|
|
125
|
+
/**
|
|
126
|
+
* When `true`, the demo loaders register the `TypescriptToJavascriptTransformer`
|
|
127
|
+
* so that TypeScript variants also produce a JavaScript counterpart at build time.
|
|
128
|
+
*
|
|
129
|
+
* Defaults to `false` because the transform is comparatively expensive;
|
|
130
|
+
* enable it when the rendered demos should expose both TS and JS sources.
|
|
131
|
+
*/
|
|
132
|
+
transformTypescriptToJavascript?: boolean;
|
|
114
133
|
/**
|
|
115
134
|
* Name of the index file to update when syncing types metadata to parent indexes.
|
|
116
135
|
* The types loader will call syncPageIndex to update the parent directory's index
|
|
@@ -76,7 +76,9 @@ export function withDocsInfra(options = {}) {
|
|
|
76
76
|
notableCommentsPrefix,
|
|
77
77
|
typesIndexFileName = 'page.mdx',
|
|
78
78
|
errorIfTypesIndexOutOfDate = Boolean(process.env.CI),
|
|
79
|
-
requireDemoClient
|
|
79
|
+
requireDemoClient,
|
|
80
|
+
requireDemoPage = false,
|
|
81
|
+
transformTypescriptToJavascript = false
|
|
80
82
|
} = options;
|
|
81
83
|
|
|
82
84
|
// Only include ordering in loader options if explicitly provided
|
|
@@ -116,16 +118,22 @@ export function withDocsInfra(options = {}) {
|
|
|
116
118
|
}),
|
|
117
119
|
...(demoEmphasisOptions && {
|
|
118
120
|
emphasisOptions: demoEmphasisOptions
|
|
119
|
-
})
|
|
121
|
+
}),
|
|
122
|
+
...(transformTypescriptToJavascript ? {
|
|
123
|
+
transformTypescriptToJavascript: true
|
|
124
|
+
} : {})
|
|
120
125
|
};
|
|
121
126
|
|
|
122
|
-
// The demo highlighter options carry `requireClient` so the validate
|
|
123
|
-
// discover both the import specifier and the patterns it should ensure
|
|
124
|
-
// The loader itself ignores
|
|
127
|
+
// The demo highlighter options carry `requireClient`/`requirePage` so the validate
|
|
128
|
+
// CLI can discover both the import specifier and the patterns it should ensure
|
|
129
|
+
// clients/pages for. The loader itself ignores these options.
|
|
125
130
|
const demoCodeHighlighterOptions = {
|
|
126
131
|
...codeHighlighterOptions,
|
|
127
132
|
...(requireDemoClient ? {
|
|
128
133
|
requireClient: requireDemoClient
|
|
134
|
+
} : {}),
|
|
135
|
+
...(requireDemoPage ? {
|
|
136
|
+
requirePage: true
|
|
129
137
|
} : {})
|
|
130
138
|
};
|
|
131
139
|
const turbopackRules = {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SourceComments } from "../../CodeHighlighter/types.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* Convert comments from 0-based to 1-based line numbers.
|
|
4
|
-
*
|
|
5
|
-
* `parseImportsAndComments` emits 0-based line numbers, but the rest of the
|
|
6
|
-
* pipeline (HAST `dataLn`, source enhancers) uses 1-based lines.
|
|
7
|
-
*/
|
|
8
|
-
export declare function convertCommentsToOneIndexed(comments: SourceComments | undefined): SourceComments | undefined;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert comments from 0-based to 1-based line numbers.
|
|
3
|
-
*
|
|
4
|
-
* `parseImportsAndComments` emits 0-based line numbers, but the rest of the
|
|
5
|
-
* pipeline (HAST `dataLn`, source enhancers) uses 1-based lines.
|
|
6
|
-
*/
|
|
7
|
-
export function convertCommentsToOneIndexed(comments) {
|
|
8
|
-
if (!comments) {
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
const converted = {};
|
|
12
|
-
for (const [lineStr, commentArray] of Object.entries(comments)) {
|
|
13
|
-
converted[parseInt(lineStr, 10) + 1] = commentArray;
|
|
14
|
-
}
|
|
15
|
-
return converted;
|
|
16
|
-
}
|