@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
package/cli/loadNextConfig.d.mts
CHANGED
|
@@ -10,6 +10,14 @@ export interface DemoClientRequirement {
|
|
|
10
10
|
/** Import specifier passed verbatim into the generated `client.ts`. */
|
|
11
11
|
requireClient: string;
|
|
12
12
|
}
|
|
13
|
+
export interface DemoPageRequirement {
|
|
14
|
+
/**
|
|
15
|
+
* Either a Turbopack-style glob pattern (e.g. `./app/**\/demos/*\/index.ts`)
|
|
16
|
+
* or a webpack-style RegExp used as the rule's `test`. Globs are extracted
|
|
17
|
+
* from `turbopack.rules`; RegExps are extracted from `webpack` rules.
|
|
18
|
+
*/
|
|
19
|
+
pattern: string | RegExp;
|
|
20
|
+
}
|
|
13
21
|
export type ExtractedNextConfigOptions = {
|
|
14
22
|
ordering?: OrderingConfig;
|
|
15
23
|
descriptionReplacements?: DescriptionReplacement[];
|
|
@@ -17,5 +25,22 @@ export type ExtractedNextConfigOptions = {
|
|
|
17
25
|
socketDir?: string;
|
|
18
26
|
/** Demo index patterns that opted into automatic `client.ts` generation. */
|
|
19
27
|
demoClientRequirements?: DemoClientRequirement[];
|
|
28
|
+
/** Demo index patterns that opted into automatic `page.tsx` generation. */
|
|
29
|
+
demoPageRequirements?: DemoPageRequirement[];
|
|
20
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Walks Turbopack rules to collect demo patterns that opted into automatic
|
|
33
|
+
* `page.tsx` generation via the `requirePage` option.
|
|
34
|
+
*
|
|
35
|
+
* Exported for tests.
|
|
36
|
+
*/
|
|
37
|
+
export declare function extractDemoPageRequirementsFromTurbopack(config: any): DemoPageRequirement[];
|
|
38
|
+
/**
|
|
39
|
+
* Walks webpack rules to collect demo `test` regexes that opted into automatic
|
|
40
|
+
* `page.tsx` generation via the `requirePage` option. Mirrors the Turbopack
|
|
41
|
+
* extractor but uses the rule's RegExp `test` as the pattern.
|
|
42
|
+
*
|
|
43
|
+
* Exported for tests.
|
|
44
|
+
*/
|
|
45
|
+
export declare function extractDemoPageRequirementsFromWebpackResult(result: any): DemoPageRequirement[];
|
|
21
46
|
export declare function extractDocsInfraOptionsFromNextConfig(dir: string): Promise<ExtractedNextConfigOptions>;
|
package/cli/loadNextConfig.mjs
CHANGED
|
@@ -227,6 +227,61 @@ function extractDemoClientRequirementsFromWebpackResult(result) {
|
|
|
227
227
|
}
|
|
228
228
|
return requirements;
|
|
229
229
|
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Walks Turbopack rules to collect demo patterns that opted into automatic
|
|
233
|
+
* `page.tsx` generation via the `requirePage` option.
|
|
234
|
+
*
|
|
235
|
+
* Exported for tests.
|
|
236
|
+
*/
|
|
237
|
+
export function extractDemoPageRequirementsFromTurbopack(config) {
|
|
238
|
+
const rules = config?.turbopack?.rules;
|
|
239
|
+
if (!rules || typeof rules !== 'object') {
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
const requirements = [];
|
|
243
|
+
for (const [pattern, rule] of Object.entries(rules)) {
|
|
244
|
+
const loaders = rule?.loaders;
|
|
245
|
+
if (!Array.isArray(loaders)) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
for (const loader of loaders) {
|
|
249
|
+
if (loader?.loader === CODE_HIGHLIGHTER_LOADER && loader?.options?.requirePage === true) {
|
|
250
|
+
requirements.push({
|
|
251
|
+
pattern
|
|
252
|
+
});
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return requirements;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Walks webpack rules to collect demo `test` regexes that opted into automatic
|
|
262
|
+
* `page.tsx` generation via the `requirePage` option. Mirrors the Turbopack
|
|
263
|
+
* extractor but uses the rule's RegExp `test` as the pattern.
|
|
264
|
+
*
|
|
265
|
+
* Exported for tests.
|
|
266
|
+
*/
|
|
267
|
+
export function extractDemoPageRequirementsFromWebpackResult(result) {
|
|
268
|
+
const requirements = [];
|
|
269
|
+
for (const rule of result?.module?.rules ?? []) {
|
|
270
|
+
if (!(rule?.test instanceof RegExp)) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const useEntries = Array.isArray(rule.use) ? rule.use : [];
|
|
274
|
+
for (const loader of useEntries) {
|
|
275
|
+
if (loader?.loader === CODE_HIGHLIGHTER_LOADER && loader?.options?.requirePage === true) {
|
|
276
|
+
requirements.push({
|
|
277
|
+
pattern: rule.test
|
|
278
|
+
});
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return requirements;
|
|
284
|
+
}
|
|
230
285
|
export async function extractDocsInfraOptionsFromNextConfig(dir) {
|
|
231
286
|
const configPath = await findNextConfig(dir);
|
|
232
287
|
if (!configPath) {
|
|
@@ -260,12 +315,16 @@ export async function extractDocsInfraOptionsFromNextConfig(dir) {
|
|
|
260
315
|
const turbopackDemoClientRequirements = extractDemoClientRequirementsFromTurbopack(config);
|
|
261
316
|
const webpackDemoClientRequirements = webpackResult ? extractDemoClientRequirementsFromWebpackResult(webpackResult) : [];
|
|
262
317
|
const demoClientRequirements = [...new Map([...turbopackDemoClientRequirements, ...webpackDemoClientRequirements].map(requirement => [`${typeof requirement.pattern === 'string' ? requirement.pattern : requirement.pattern.toString()}::${requirement.requireClient}`, requirement])).values()];
|
|
318
|
+
const turbopackDemoPageRequirements = extractDemoPageRequirementsFromTurbopack(config);
|
|
319
|
+
const webpackDemoPageRequirements = webpackResult ? extractDemoPageRequirementsFromWebpackResult(webpackResult) : [];
|
|
320
|
+
const demoPageRequirements = [...new Map([...turbopackDemoPageRequirements, ...webpackDemoPageRequirements].map(requirement => [typeof requirement.pattern === 'string' ? requirement.pattern : requirement.pattern.toString(), requirement])).values()];
|
|
263
321
|
return {
|
|
264
322
|
ordering: turbopack.ordering ?? webpack.ordering,
|
|
265
323
|
descriptionReplacements: turbopack.descriptionReplacements ?? webpack.descriptionReplacements,
|
|
266
324
|
useVisibleDescription: turbopack.useVisibleDescription ?? webpack.useVisibleDescription,
|
|
267
325
|
socketDir: turbopack.socketDir ?? webpack.socketDir,
|
|
268
|
-
demoClientRequirements: demoClientRequirements.length > 0 ? demoClientRequirements : undefined
|
|
326
|
+
demoClientRequirements: demoClientRequirements.length > 0 ? demoClientRequirements : undefined,
|
|
327
|
+
demoPageRequirements: demoPageRequirements.length > 0 ? demoPageRequirements : undefined
|
|
269
328
|
};
|
|
270
329
|
}
|
|
271
330
|
async function findNextConfig(dir) {
|
package/cli/runBrowser.mjs
CHANGED
|
@@ -104,7 +104,7 @@ async function handler(argv) {
|
|
|
104
104
|
const xauthority = process.env.XAUTHORITY || `${process.env.HOME}/.Xauthority`;
|
|
105
105
|
containerArgs.push('-e', 'XAUTHORITY=/tmp/.Xauthority', '-v', `${xauthority}:/tmp/.Xauthority:ro`);
|
|
106
106
|
}
|
|
107
|
-
containerArgs.push(image, 'npx', '--yes', 'playwright'
|
|
107
|
+
containerArgs.push(image, 'npx', '--yes', `playwright@${argv['playwright-version']}`, 'run-server', '--port', String(port), '--host', '0.0.0.0');
|
|
108
108
|
console.log(`Starting Playwright server on port ${port}…`);
|
|
109
109
|
await engine(...containerArgs);
|
|
110
110
|
|
package/cli/runValidate.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { createPerformanceLogger, logPerformance, nameMark, performanceMeasure }
|
|
|
12
12
|
import { terminateWorkerManager } from "../pipeline/loadServerTypesMeta/workerManager.mjs";
|
|
13
13
|
import { extractDocsInfraOptionsFromNextConfig } from "./loadNextConfig.mjs";
|
|
14
14
|
import { ensureDemoClients } from "./ensureDemoClients.mjs";
|
|
15
|
+
import { ensureDemoPages } from "./ensureDemoPages.mjs";
|
|
15
16
|
const completeMessage = message => `✓ ${chalk.green(message)}`;
|
|
16
17
|
const functionName = 'Run Validate';
|
|
17
18
|
|
|
@@ -88,7 +89,8 @@ const runValidate = {
|
|
|
88
89
|
descriptionReplacements,
|
|
89
90
|
useVisibleDescription = false,
|
|
90
91
|
socketDir: configSocketDir,
|
|
91
|
-
demoClientRequirements = []
|
|
92
|
+
demoClientRequirements = [],
|
|
93
|
+
demoPageRequirements = []
|
|
92
94
|
} = await extractDocsInfraOptionsFromNextConfig(cwd);
|
|
93
95
|
const socketDir = configSocketDir ? path.resolve(cwd, configSocketDir) : undefined;
|
|
94
96
|
|
|
@@ -181,7 +183,9 @@ const runValidate = {
|
|
|
181
183
|
let indexesMark = currentMark;
|
|
182
184
|
let typesMark = currentMark;
|
|
183
185
|
let clientsMark = currentMark;
|
|
186
|
+
let pagesMark = currentMark;
|
|
184
187
|
let ranClients = false;
|
|
188
|
+
let ranPages = false;
|
|
185
189
|
try {
|
|
186
190
|
// === Validate page.mdx index files ===
|
|
187
191
|
if (runIndexes) {
|
|
@@ -363,6 +367,37 @@ const runValidate = {
|
|
|
363
367
|
}, [functionName], true);
|
|
364
368
|
currentMark = clientsMark;
|
|
365
369
|
}
|
|
370
|
+
|
|
371
|
+
// === Ensure demo page.tsx files for patterns that opted in ===
|
|
372
|
+
if (runIndexes && demoPageRequirements.length > 0) {
|
|
373
|
+
ranPages = true;
|
|
374
|
+
const demoPageResult = await ensureDemoPages({
|
|
375
|
+
baseDir: cwd,
|
|
376
|
+
requirements: demoPageRequirements
|
|
377
|
+
});
|
|
378
|
+
const patternCount = demoPageRequirements.length;
|
|
379
|
+
console.log(chalk.cyan(`\nEnsured demo page.tsx wiring for ${demoPageResult.demoCount} demo${demoPageResult.demoCount === 1 ? '' : 's'} across ${patternCount} pattern${patternCount === 1 ? '' : 's'}`));
|
|
380
|
+
for (const {
|
|
381
|
+
filePath,
|
|
382
|
+
message
|
|
383
|
+
} of demoPageResult.errors) {
|
|
384
|
+
console.error(chalk.red(` ✗ ${filePath}: ${message}`));
|
|
385
|
+
hasErrors = true;
|
|
386
|
+
}
|
|
387
|
+
if (demoPageResult.updatedFiles.length > 0) {
|
|
388
|
+
console.log(chalk.yellow('\nCreated demo page files:'));
|
|
389
|
+
for (const relativePath of demoPageResult.updatedFiles) {
|
|
390
|
+
console.log(chalk.gray(` ${relativePath}`));
|
|
391
|
+
updatedFilePaths.push(relativePath);
|
|
392
|
+
}
|
|
393
|
+
totalUpdatedFiles += demoPageResult.updatedFiles.length;
|
|
394
|
+
}
|
|
395
|
+
pagesMark = performanceMeasure(currentMark, {
|
|
396
|
+
mark: 'Validated Demo Pages',
|
|
397
|
+
measure: 'Validating Demo Pages'
|
|
398
|
+
}, [functionName], true);
|
|
399
|
+
currentMark = pagesMark;
|
|
400
|
+
}
|
|
366
401
|
} finally {
|
|
367
402
|
// Terminate worker pool
|
|
368
403
|
await Promise.all(workers.map(w => w.terminate()));
|
|
@@ -401,6 +436,14 @@ const runValidate = {
|
|
|
401
436
|
const clientsDuration = performance.measure(nameMark(functionName, 'Demo Clients Duration', []), typesMark, clientsMark).duration / 1000;
|
|
402
437
|
timingParts.push(`clients: ${clientsDuration.toFixed(2)}s`);
|
|
403
438
|
}
|
|
439
|
+
if (ranPages) {
|
|
440
|
+
// Pages run after clients, but clients are optional (requireDemoPage and
|
|
441
|
+
// requireDemoClient are independent). When clients didn't run, clientsMark
|
|
442
|
+
// is still the start mark, so measure from typesMark instead — mirroring how
|
|
443
|
+
// the types breakdown falls back to startMark when indexes didn't run.
|
|
444
|
+
const pagesDuration = performance.measure(nameMark(functionName, 'Demo Pages Duration', []), ranClients ? clientsMark : typesMark, pagesMark).duration / 1000;
|
|
445
|
+
timingParts.push(`pages: ${pagesDuration.toFixed(2)}s`);
|
|
446
|
+
}
|
|
404
447
|
const timingBreakdown = timingParts.length > 0 ? ` [${timingParts.join(', ')}]` : '';
|
|
405
448
|
console.log(completeMessage(`${totalUpdatedFiles} files updated in ${totalDuration.toFixed(2)}s${timingBreakdown}`));
|
|
406
449
|
if (hasErrors) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-docs-infra",
|
|
3
|
-
"version": "0.11.1
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Infra - internal documentation creation tools.",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"keywords": [
|
|
8
9
|
"react",
|
|
9
10
|
"react-component",
|
|
@@ -22,7 +23,6 @@
|
|
|
22
23
|
"homepage": "https://github.com/mui/mui-public/tree/master/packages/docs-infra",
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"@babel/runtime": "^7.29.2",
|
|
25
|
-
"@babel/standalone": "^7.29.4",
|
|
26
26
|
"@orama/orama": "^3.1.18",
|
|
27
27
|
"@orama/plugin-qps": "^3.1.18",
|
|
28
28
|
"@orama/stemmers": "^3.1.18",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"remark-parse": "^11.0.0",
|
|
47
47
|
"remark-stringify": "^11.0.0",
|
|
48
48
|
"remark-typography": "^0.7.3",
|
|
49
|
+
"sucrase": "^3.35.1",
|
|
49
50
|
"typescript-api-extractor": "1.0.0-beta.3",
|
|
50
51
|
"uint8-to-base64": "^0.2.1",
|
|
51
52
|
"unified": "^11.0.5",
|
|
@@ -83,6 +84,16 @@
|
|
|
83
84
|
"type": "commonjs",
|
|
84
85
|
"exports": {
|
|
85
86
|
"./package.json": "./package.json",
|
|
87
|
+
"./abstractCreateStream": {
|
|
88
|
+
"import": {
|
|
89
|
+
"types": "./abstractCreateStream/index.d.mts",
|
|
90
|
+
"default": "./abstractCreateStream/index.mjs"
|
|
91
|
+
},
|
|
92
|
+
"default": {
|
|
93
|
+
"types": "./abstractCreateStream/index.d.mts",
|
|
94
|
+
"default": "./abstractCreateStream/index.mjs"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
86
97
|
"./abstractCreateDemo": {
|
|
87
98
|
"import": {
|
|
88
99
|
"types": "./abstractCreateDemo/index.d.mts",
|
|
@@ -113,6 +124,26 @@
|
|
|
113
124
|
"default": "./abstractCreateTypes/index.mjs"
|
|
114
125
|
}
|
|
115
126
|
},
|
|
127
|
+
"./cli": {
|
|
128
|
+
"import": {
|
|
129
|
+
"types": "./cli/index.d.mts",
|
|
130
|
+
"default": "./cli/index.mjs"
|
|
131
|
+
},
|
|
132
|
+
"default": {
|
|
133
|
+
"types": "./cli/index.d.mts",
|
|
134
|
+
"default": "./cli/index.mjs"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"./ChunkProvider": {
|
|
138
|
+
"import": {
|
|
139
|
+
"types": "./ChunkProvider/index.d.mts",
|
|
140
|
+
"default": "./ChunkProvider/index.mjs"
|
|
141
|
+
},
|
|
142
|
+
"default": {
|
|
143
|
+
"types": "./ChunkProvider/index.d.mts",
|
|
144
|
+
"default": "./ChunkProvider/index.mjs"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
116
147
|
"./CodeControllerContext": {
|
|
117
148
|
"import": {
|
|
118
149
|
"types": "./CodeControllerContext/index.d.mts",
|
|
@@ -173,6 +204,26 @@
|
|
|
173
204
|
"default": "./CodeProvider/index.mjs"
|
|
174
205
|
}
|
|
175
206
|
},
|
|
207
|
+
"./CoordinatedLazy": {
|
|
208
|
+
"import": {
|
|
209
|
+
"types": "./CoordinatedLazy/index.d.mts",
|
|
210
|
+
"default": "./CoordinatedLazy/index.mjs"
|
|
211
|
+
},
|
|
212
|
+
"default": {
|
|
213
|
+
"types": "./CoordinatedLazy/index.d.mts",
|
|
214
|
+
"default": "./CoordinatedLazy/index.mjs"
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
"./CoordinatedLazy/types": {
|
|
218
|
+
"import": {
|
|
219
|
+
"types": "./CoordinatedLazy/types.d.mts",
|
|
220
|
+
"default": "./CoordinatedLazy/types.mjs"
|
|
221
|
+
},
|
|
222
|
+
"default": {
|
|
223
|
+
"types": "./CoordinatedLazy/types.d.mts",
|
|
224
|
+
"default": "./CoordinatedLazy/types.mjs"
|
|
225
|
+
}
|
|
226
|
+
},
|
|
176
227
|
"./createDemoData": {
|
|
177
228
|
"import": {
|
|
178
229
|
"types": "./createDemoData/index.d.mts",
|
|
@@ -213,6 +264,26 @@
|
|
|
213
264
|
"default": "./createSitemap/types.mjs"
|
|
214
265
|
}
|
|
215
266
|
},
|
|
267
|
+
"./useStream": {
|
|
268
|
+
"import": {
|
|
269
|
+
"types": "./useStream/index.d.mts",
|
|
270
|
+
"default": "./useStream/index.mjs"
|
|
271
|
+
},
|
|
272
|
+
"default": {
|
|
273
|
+
"types": "./useStream/index.d.mts",
|
|
274
|
+
"default": "./useStream/index.mjs"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
"./useStream/types": {
|
|
278
|
+
"import": {
|
|
279
|
+
"types": "./useStream/types.d.mts",
|
|
280
|
+
"default": "./useStream/types.mjs"
|
|
281
|
+
},
|
|
282
|
+
"default": {
|
|
283
|
+
"types": "./useStream/types.d.mts",
|
|
284
|
+
"default": "./useStream/types.mjs"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
216
287
|
"./useCode": {
|
|
217
288
|
"import": {
|
|
218
289
|
"types": "./useCode/index.d.mts",
|
|
@@ -233,6 +304,16 @@
|
|
|
233
304
|
"default": "./useCodeWindow/index.mjs"
|
|
234
305
|
}
|
|
235
306
|
},
|
|
307
|
+
"./useCoordinated": {
|
|
308
|
+
"import": {
|
|
309
|
+
"types": "./useCoordinated/index.d.mts",
|
|
310
|
+
"default": "./useCoordinated/index.mjs"
|
|
311
|
+
},
|
|
312
|
+
"default": {
|
|
313
|
+
"types": "./useCoordinated/index.d.mts",
|
|
314
|
+
"default": "./useCoordinated/index.mjs"
|
|
315
|
+
}
|
|
316
|
+
},
|
|
236
317
|
"./useCopier": {
|
|
237
318
|
"import": {
|
|
238
319
|
"types": "./useCopier/index.d.mts",
|
|
@@ -686,6 +767,5 @@
|
|
|
686
767
|
},
|
|
687
768
|
"bin": {
|
|
688
769
|
"docs-infra": "./cli/index.mjs"
|
|
689
|
-
}
|
|
690
|
-
"gitSha": "ec55950e5d74caba22afb552b951704f6c5761b8"
|
|
770
|
+
}
|
|
691
771
|
}
|
|
@@ -1354,6 +1354,34 @@ export function createEnhanceCodeEmphasis(options = {}) {
|
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
1356
1356
|
|
|
1357
|
+
// Helper: record the focused-window size (lines visible when collapsed)
|
|
1358
|
+
// alongside `totalLines`. Mirrors the visibility rule in `<Pre>` /
|
|
1359
|
+
// `hasCollapseInFocus`: frame types `'highlighted' | 'focus' |
|
|
1360
|
+
// 'padding-top' | 'padding-bottom'` make up the focused window.
|
|
1361
|
+
//
|
|
1362
|
+
// When `oversizedFocus: 'hide'` suppressed the focus window, no focused
|
|
1363
|
+
// frames exist (`focusedLines === 0`) yet there is hidden content to
|
|
1364
|
+
// expand into. Force `collapsible` so the block collapses to nothing
|
|
1365
|
+
// rather than reading as a non-collapsible (always-expanded) block.
|
|
1366
|
+
function recordFocusedLines(frameRanges) {
|
|
1367
|
+
let focusedLines = 0;
|
|
1368
|
+
for (const range of frameRanges) {
|
|
1369
|
+
if (range.type === 'highlighted' || range.type === 'focus' || range.type === 'padding-top' || range.type === 'padding-bottom') {
|
|
1370
|
+
focusedLines += range.endLine - range.startLine + 1;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
root.data = {
|
|
1374
|
+
...root.data,
|
|
1375
|
+
focusedLines
|
|
1376
|
+
};
|
|
1377
|
+
if (options.oversizedFocus === 'hide' && focusedLines === 0 && frameRanges.length > 0) {
|
|
1378
|
+
root.data = {
|
|
1379
|
+
...root.data,
|
|
1380
|
+
collapsible: true
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1357
1385
|
// Step 1: Parse directives from comments (no tree traversal)
|
|
1358
1386
|
const directives = comments && Object.keys(comments).length > 0 ? parseEmphasisDirectives(comments) : [];
|
|
1359
1387
|
const effectiveOptions = options;
|
|
@@ -1371,6 +1399,7 @@ export function createEnhanceCodeEmphasis(options = {}) {
|
|
|
1371
1399
|
const frameRanges = calculateFrameRanges(new Map(), totalLines, effectiveOptions, normalFrameMaxSize);
|
|
1372
1400
|
restructureFrames(root, frameRanges, new Map());
|
|
1373
1401
|
markCollapsible(frameRanges);
|
|
1402
|
+
recordFocusedLines(frameRanges);
|
|
1374
1403
|
return root;
|
|
1375
1404
|
}
|
|
1376
1405
|
|
|
@@ -1403,6 +1432,7 @@ export function createEnhanceCodeEmphasis(options = {}) {
|
|
|
1403
1432
|
// Step 7: Restructure frames (flat iteration, not deep recursive traversal)
|
|
1404
1433
|
restructureFrames(root, frameRanges, regionIndentLevels);
|
|
1405
1434
|
markCollapsible(frameRanges);
|
|
1435
|
+
recordFocusedLines(frameRanges);
|
|
1406
1436
|
|
|
1407
1437
|
// Step 8: Reconcile line-level data-hl with frame types and promote descriptions
|
|
1408
1438
|
reconcileLineAndFrameEmphasis(root, emphasizedLines);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SourceEnhancer } from "../../CodeHighlighter/types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Warms the emphasis-enhancer chunk so the next enhancement runs synchronously
|
|
4
|
+
* (no flash during live-edit re-enhancement). Optional — the wrapper loads on
|
|
5
|
+
* first use anyway; this is a head start, e.g. when a block becomes editable.
|
|
6
|
+
*/
|
|
7
|
+
export declare function preloadCodeEmphasis(): Promise<void>;
|
|
8
|
+
/** Clears the module cache. Intended for tests exercising the cold path. */
|
|
9
|
+
export declare function resetCodeEmphasisCache(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Defers the `enhanceCodeEmphasis` chunk until a block actually enhances
|
|
12
|
+
* (client highlight or live edit). Runs synchronously once the chunk is warm so
|
|
13
|
+
* live-edit re-enhancement does not flash; returns a promise on the first cold
|
|
14
|
+
* call (the existing async-enhancer path handles it). Carries the same
|
|
15
|
+
* `enhancerName` so precomputed HAST skips it without loading anything.
|
|
16
|
+
*/
|
|
17
|
+
export declare const enhanceCodeEmphasisLazy: SourceEnhancer;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Lazy form of `enhanceCodeEmphasis`. The real enhancer is ~13 KB gzip (frame
|
|
2
|
+
// range / indent logic); this wrapper keeps it out of the initial bundle and
|
|
3
|
+
// dynamic-imports it only when a block actually enhances client-side. A
|
|
4
|
+
// precomputed block's HAST already carries the emphasis (recorded under the
|
|
5
|
+
// same `enhancerName`), so `shouldSkipEnhancer` skips this wrapper without ever
|
|
6
|
+
// importing the chunk. `CodeProviderLazy` uses this; the eager `CodeProvider`
|
|
7
|
+
// uses the bundled `enhanceCodeEmphasis` directly so its zero-fetch invariant
|
|
8
|
+
// holds.
|
|
9
|
+
//
|
|
10
|
+
// Must stay light: only types are statically imported; the heavy module is
|
|
11
|
+
// reached exclusively through the dynamic `import()` below.
|
|
12
|
+
|
|
13
|
+
// Stable name — MUST match `enhanceCodeEmphasis.enhancerName` so a precomputed
|
|
14
|
+
// HAST that recorded the eager enhancer is correctly skipped by this wrapper
|
|
15
|
+
// (and vice versa). Hardcoded rather than imported to avoid pulling the chunk.
|
|
16
|
+
const ENHANCE_CODE_EMPHASIS_NAME = 'enhanceCodeEmphasis';
|
|
17
|
+
let cached;
|
|
18
|
+
async function load() {
|
|
19
|
+
if (!cached) {
|
|
20
|
+
cached = (await import("./enhanceCodeEmphasis.mjs")).enhanceCodeEmphasis;
|
|
21
|
+
}
|
|
22
|
+
return cached;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Warms the emphasis-enhancer chunk so the next enhancement runs synchronously
|
|
27
|
+
* (no flash during live-edit re-enhancement). Optional — the wrapper loads on
|
|
28
|
+
* first use anyway; this is a head start, e.g. when a block becomes editable.
|
|
29
|
+
*/
|
|
30
|
+
export async function preloadCodeEmphasis() {
|
|
31
|
+
await load();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Clears the module cache. Intended for tests exercising the cold path. */
|
|
35
|
+
export function resetCodeEmphasisCache() {
|
|
36
|
+
cached = undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Defers the `enhanceCodeEmphasis` chunk until a block actually enhances
|
|
41
|
+
* (client highlight or live edit). Runs synchronously once the chunk is warm so
|
|
42
|
+
* live-edit re-enhancement does not flash; returns a promise on the first cold
|
|
43
|
+
* call (the existing async-enhancer path handles it). Carries the same
|
|
44
|
+
* `enhancerName` so precomputed HAST skips it without loading anything.
|
|
45
|
+
*/
|
|
46
|
+
export const enhanceCodeEmphasisLazy = (root, comments, fileName) => {
|
|
47
|
+
if (cached) {
|
|
48
|
+
return cached(root, comments, fileName);
|
|
49
|
+
}
|
|
50
|
+
return load().then(enhance => enhance(root, comments, fileName));
|
|
51
|
+
};
|
|
52
|
+
enhanceCodeEmphasisLazy.enhancerName = ENHANCE_CODE_EMPHASIS_NAME;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ElementContent } from 'hast';
|
|
2
|
+
/**
|
|
3
|
+
* Derive the lightweight per-frame fallback nodes from a frame's child spans.
|
|
4
|
+
*
|
|
5
|
+
* Runs {@link stripHighlightingSpans} over the frame's children — unwrapping
|
|
6
|
+
* syntax-highlight spans while preserving `.collapse` placeholders and merging
|
|
7
|
+
* adjacent text — and returns the resulting nodes. This is the canonical way to
|
|
8
|
+
* produce a frame's `data.fallback` from its live hast: a frame with no collapse
|
|
9
|
+
* collapses to a single text node (matching `addLineGutters`), while a collapsed
|
|
10
|
+
* frame keeps its placeholder so the fallback render's height stays in sync with
|
|
11
|
+
* the highlighted render.
|
|
12
|
+
*
|
|
13
|
+
* Shared by the renderer (`Pre`, which derives this lazily for an
|
|
14
|
+
* un-highlighted frame) and `applyCodeTransform` (which regenerates it for a
|
|
15
|
+
* frame a transform rewrote), so the precomputed and lazy fallbacks are
|
|
16
|
+
* byte-identical.
|
|
17
|
+
*/
|
|
18
|
+
export declare function frameFallbackFromSpans(spans: ElementContent[]): ElementContent[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { stripHighlightingSpans } from "./stripHighlightingSpans.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Derive the lightweight per-frame fallback nodes from a frame's child spans.
|
|
5
|
+
*
|
|
6
|
+
* Runs {@link stripHighlightingSpans} over the frame's children — unwrapping
|
|
7
|
+
* syntax-highlight spans while preserving `.collapse` placeholders and merging
|
|
8
|
+
* adjacent text — and returns the resulting nodes. This is the canonical way to
|
|
9
|
+
* produce a frame's `data.fallback` from its live hast: a frame with no collapse
|
|
10
|
+
* collapses to a single text node (matching `addLineGutters`), while a collapsed
|
|
11
|
+
* frame keeps its placeholder so the fallback render's height stays in sync with
|
|
12
|
+
* the highlighted render.
|
|
13
|
+
*
|
|
14
|
+
* Shared by the renderer (`Pre`, which derives this lazily for an
|
|
15
|
+
* un-highlighted frame) and `applyCodeTransform` (which regenerates it for a
|
|
16
|
+
* frame a transform rewrote), so the precomputed and lazy fallbacks are
|
|
17
|
+
* byte-identical.
|
|
18
|
+
*/
|
|
19
|
+
export function frameFallbackFromSpans(spans) {
|
|
20
|
+
return stripHighlightingSpans({
|
|
21
|
+
type: 'root',
|
|
22
|
+
children: spans
|
|
23
|
+
}).children;
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Module augmentation for the `hast` type definitions. Lets us attach
|
|
2
|
+
// strongly-typed metadata to nodes via the user-extensible `Data` interfaces
|
|
3
|
+
// (see https://github.com/syntax-tree/hast#types) without scattering `as any`
|
|
4
|
+
// casts at every read/write site.
|
|
5
|
+
|
|
6
|
+
import type { ElementContent } from 'hast';
|
|
7
|
+
declare module 'hast' {
|
|
8
|
+
interface ElementData {
|
|
9
|
+
/**
|
|
10
|
+
* Precomputed lightweight hast used as the pre-hydration / SSR fallback
|
|
11
|
+
* for this element. Set by `addLineGutters` on each frame span (single
|
|
12
|
+
* `{ type: 'text' }` node carrying the frame's raw source text) so the
|
|
13
|
+
* renderer can skip running `stripHighlightingSpans` per frame.
|
|
14
|
+
*/
|
|
15
|
+
fallback?: ElementContent[];
|
|
16
|
+
}
|
|
17
|
+
interface RootData {
|
|
18
|
+
/** Total number of lines in the source represented by this tree. */
|
|
19
|
+
totalLines?: number;
|
|
20
|
+
/** Lines-per-frame size used when splitting the tree into frame spans. */
|
|
21
|
+
frameSize?: number;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Required to make this file a module so the `declare module` augmentation
|
|
26
|
+
// is picked up. The empty export keeps the runtime emit shape unchanged.
|
|
27
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { HAST_DICTIONARY, MAX_DICTIONARY_SIZE, CHECKSUM_BYTES, buildDictionary, computeDictionaryChecksum, HastDictionaryMismatchError } from "./hastDictionary.mjs";
|
|
2
2
|
export { compressHast, compressHastAsync } from "./hastCompress.mjs";
|
|
3
|
-
export { decompressHast, decompressHastAsync } from "./hastDecompress.mjs";
|
|
3
|
+
export { decompressHast, decompressHastAsync } from "./hastDecompress.mjs";
|
|
4
|
+
export { compressHast as compressString, compressHastAsync as compressStringAsync } from "./hastCompress.mjs";
|
|
5
|
+
export { decompressHast as decompressString, decompressHastAsync as decompressStringAsync } from "./hastDecompress.mjs";
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export { HAST_DICTIONARY, MAX_DICTIONARY_SIZE, CHECKSUM_BYTES, buildDictionary, computeDictionaryChecksum, HastDictionaryMismatchError } from "./hastDictionary.mjs";
|
|
2
2
|
export { compressHast, compressHastAsync } from "./hastCompress.mjs";
|
|
3
|
-
export { decompressHast, decompressHastAsync } from "./hastDecompress.mjs";
|
|
3
|
+
export { decompressHast, decompressHastAsync } from "./hastDecompress.mjs";
|
|
4
|
+
|
|
5
|
+
// `compressHast` / `decompressHast` are string-in/string-out DEFLATE with an
|
|
6
|
+
// optional preset dictionary — generic beyond HAST. These aliases name that
|
|
7
|
+
// generic use (e.g. the Coordinated Streaming pattern passing a compressed
|
|
8
|
+
// payload from a fallback to the full content, decoded against a hoisted
|
|
9
|
+
// dictionary).
|
|
10
|
+
export { compressHast as compressString, compressHastAsync as compressStringAsync } from "./hastCompress.mjs";
|
|
11
|
+
export { decompressHast as decompressString, decompressHastAsync as decompressStringAsync } from "./hastDecompress.mjs";
|
|
@@ -19,13 +19,19 @@ export function decompressHast(base64, textContent) {
|
|
|
19
19
|
const dictionary = buildDictionary(textContent);
|
|
20
20
|
if (textContent != null) {
|
|
21
21
|
verifyChecksum(raw, dictionary);
|
|
22
|
-
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const deflated = textContent != null ? raw.subarray(CHECKSUM_BYTES) : raw;
|
|
25
|
+
return strFromU8(inflateSync(deflated, {
|
|
23
26
|
dictionary
|
|
24
27
|
}));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
// A raw inflate failure (e.g. fflate's "unexpected EOF") is almost always a
|
|
30
|
+
// payload that was compressed with a fallback dictionary being decoded
|
|
31
|
+
// without one — the checksum prefix is then read as deflate data. Surface
|
|
32
|
+
// that cause instead of the cryptic `{code:0}` the raw error stringifies to.
|
|
33
|
+
throw new Error(`Failed to decompress payload${textContent == null ? ' — if it was compressed with a fallback dictionary, that dictionary must be provided' : ''}: ${error instanceof Error ? error.message : String(error)}`);
|
|
25
34
|
}
|
|
26
|
-
return strFromU8(inflateSync(raw, {
|
|
27
|
-
dictionary
|
|
28
|
-
}));
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
/**
|
|
@@ -24,6 +24,15 @@ export const CHECKSUM_BYTES = 4;
|
|
|
24
24
|
* small — currently ~3 KB uncompressed.
|
|
25
25
|
*/
|
|
26
26
|
export const HAST_DICTIONARY = strToU8([
|
|
27
|
+
// ── New entries go HERE, at the START (prepend only) ──
|
|
28
|
+
// DEFLATE back-references reach into the dictionary from its END, so a payload
|
|
29
|
+
// compressed with an earlier version of this dictionary only decodes correctly
|
|
30
|
+
// if the existing tail stays byte-identical. Prepending preserves that tail;
|
|
31
|
+
// appending or inserting in the middle silently corrupts older payloads (the
|
|
32
|
+
// text path also catches this loudly via the dictionary checksum). Always add
|
|
33
|
+
// new strings to the top of this list — never the middle or end. See the
|
|
34
|
+
// `dictionary mutation tolerance` tests in `hastCompression.test.ts`.
|
|
35
|
+
'collapseToEmpty', 'showCollapsedFocus', 'initialExpanded', 'initialCollapsed',
|
|
27
36
|
// JSON structural patterns (most frequent first)
|
|
28
37
|
'{"type":"element","tagName":"span","properties":{"className":["frame"],"dataFrameType":"', '{"type":"element","tagName":"span","properties":{"className":["line"],"dataLn":', '{"type":"element","tagName":"span","properties":{"className":["', '{"type":"element","tagName":"a","properties":{"href":"', '{"type":"text","value":"', '"children":[', '"properties":{}', '"tagName":"code"', '"tagName":"pre"', '"type":"root"', '"type":"element"', '"type":"text"',
|
|
29
38
|
// Starry Night / Pretty Lights class names (full set)
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { Nodes as HastNodes } from 'hast';
|
|
3
3
|
import type { Components } from 'hast-util-to-jsx-runtime';
|
|
4
|
+
import { type FallbackNode } from "./fallbackFormat.mjs";
|
|
4
5
|
export declare function hastToJsx(hast: HastNodes, components?: Partial<Components>): React.ReactNode;
|
|
5
6
|
export declare function hastOrJsonToJsx(hastOrJson: HastNodes | {
|
|
6
7
|
hastJson: string;
|
|
7
8
|
} | {
|
|
8
9
|
hastCompressed: string;
|
|
9
|
-
}, components?: Partial<Components
|
|
10
|
+
}, components?: Partial<Components>, fallback?: FallbackNode[]): React.ReactNode;
|
|
10
11
|
export declare function stringOrHastToString(source: string | HastNodes | {
|
|
11
12
|
hastJson: string;
|
|
12
13
|
} | {
|
|
13
14
|
hastCompressed: string;
|
|
14
|
-
}): string;
|
|
15
|
+
}, fallback?: FallbackNode[]): string;
|
|
15
16
|
export declare function stringOrHastToJsx(source: string | HastNodes | {
|
|
16
17
|
hastJson: string;
|
|
17
18
|
} | {
|
|
18
19
|
hastCompressed: string;
|
|
19
|
-
}, highlighted?: boolean, components?: Partial<Components
|
|
20
|
+
}, highlighted?: boolean, components?: Partial<Components>, fallback?: FallbackNode[]): React.ReactNode;
|