@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,114 @@
|
|
|
1
|
+
import { isFrameSpan } from "./isFrameSpan.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `data-frame-type` values whose frames make up the window a collapsible
|
|
5
|
+
* code block shows while collapsed (the contiguous focused window:
|
|
6
|
+
* `padding-top`, `highlighted` / `focus`, `padding-bottom`).
|
|
7
|
+
*
|
|
8
|
+
* This is the single source of truth shared by the runtime visibility rule in
|
|
9
|
+
* `useCode/Pre.tsx`, the collapsed fallback reducer in
|
|
10
|
+
* `CodeHighlighter/fallbackFormat.ts`, and the collapsed line computation in
|
|
11
|
+
* `pipeline/loadIsomorphicCodeVariant/getInitialVisibleSourceLines.ts`. It is
|
|
12
|
+
* intentionally isomorphic (no client-only code) so the server and the client
|
|
13
|
+
* stay in sync.
|
|
14
|
+
*/
|
|
15
|
+
const COLLAPSED_VISIBLE_FRAME_TYPE_LIST = ['highlighted', 'focus', 'padding-top', 'padding-bottom'];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Set form of {@link COLLAPSED_VISIBLE_FRAME_TYPE_LIST} for fast membership
|
|
19
|
+
* checks. Typed as `ReadonlySet<string>` so callers can pass a raw
|
|
20
|
+
* `data-frame-type` string to `.has()` without narrowing first.
|
|
21
|
+
*/
|
|
22
|
+
export const COLLAPSED_VISIBLE_FRAME_TYPES = new Set(COLLAPSED_VISIBLE_FRAME_TYPE_LIST);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Runtime "collapse to empty" frame-type rewrite.
|
|
26
|
+
*
|
|
27
|
+
* `collapseToEmpty` is a render-time option (it never touches the precomputed
|
|
28
|
+
* HAST) that makes a collapsible code block render with an *empty* collapsed
|
|
29
|
+
* window — the whole block is hidden until the reader expands it. It works by
|
|
30
|
+
* demoting every collapsed-visible frame type to a hidden equivalent so the
|
|
31
|
+
* existing collapse CSS (which only shows {@link COLLAPSED_VISIBLE_FRAME_TYPES}
|
|
32
|
+
* while collapsed) hides everything:
|
|
33
|
+
*
|
|
34
|
+
* - `focus` → `focus-unfocused`
|
|
35
|
+
* - `highlighted` → `highlighted-unfocused`
|
|
36
|
+
* - `padding-top` / `padding-bottom` → `normal`
|
|
37
|
+
*
|
|
38
|
+
* The `-unfocused` variants are kept (rather than `normal`) for `focus` /
|
|
39
|
+
* `highlighted` so the highlight styling is still present once the block is
|
|
40
|
+
* expanded. Padding frames carry no styling, so they become `normal`.
|
|
41
|
+
*
|
|
42
|
+
* Frame types that are already hidden (or non-region, e.g. `comment`) are
|
|
43
|
+
* returned unchanged. Returns the input untouched when `collapseToEmpty` is false.
|
|
44
|
+
*
|
|
45
|
+
* @param frameType - The frame's `data-frame-type` (may be `undefined` for `normal`)
|
|
46
|
+
* @param collapseToEmpty - Whether the block is rendered collapse-to-empty
|
|
47
|
+
*/
|
|
48
|
+
export function resolveCollapsedFrameType(frameType, collapseToEmpty) {
|
|
49
|
+
if (!collapseToEmpty) {
|
|
50
|
+
return frameType;
|
|
51
|
+
}
|
|
52
|
+
switch (frameType) {
|
|
53
|
+
case 'focus':
|
|
54
|
+
return 'focus-unfocused';
|
|
55
|
+
case 'highlighted':
|
|
56
|
+
return 'highlighted-unfocused';
|
|
57
|
+
case 'padding-top':
|
|
58
|
+
case 'padding-bottom':
|
|
59
|
+
return 'normal';
|
|
60
|
+
default:
|
|
61
|
+
return frameType;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The set of frame indices that are visible on the initial (collapsed) render of
|
|
67
|
+
* a code block: the contiguous focused window
|
|
68
|
+
* ({@link COLLAPSED_VISIBLE_FRAME_TYPES}), falling back to the first frame when no
|
|
69
|
+
* frame carries an emphasis type. Returns an empty set for `collapseToEmpty` (an
|
|
70
|
+
* empty collapsed window) and for a `focusedLines === 0` carve-out
|
|
71
|
+
* (`oversizedFocus: 'hide'`).
|
|
72
|
+
*
|
|
73
|
+
* Shared by the runtime rule in `useCode/Pre.tsx` and the server-side
|
|
74
|
+
* highlighted-visible fallback builder, so the frames highlighted on the first
|
|
75
|
+
* paint match exactly. Isomorphic — reads only precomputed HAST attributes.
|
|
76
|
+
*/
|
|
77
|
+
export function getInitialVisibleFrames(hast, collapseToEmpty = false) {
|
|
78
|
+
if (!hast) {
|
|
79
|
+
return collapseToEmpty ? {} : {
|
|
80
|
+
0: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Collapse-to-empty renders an empty collapsed window — no frame is visible while
|
|
85
|
+
// collapsed, regardless of the precomputed frame types.
|
|
86
|
+
if (collapseToEmpty) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
const visibleFrames = {};
|
|
90
|
+
let frameIndex = 0;
|
|
91
|
+
let hasVisibleEmphasisFrame = false;
|
|
92
|
+
hast.children.forEach(child => {
|
|
93
|
+
if (child.type !== 'element' || !isFrameSpan(child)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const frameType = child.properties.dataFrameType;
|
|
97
|
+
if (typeof frameType === 'string' && COLLAPSED_VISIBLE_FRAME_TYPES.has(frameType)) {
|
|
98
|
+
visibleFrames[frameIndex] = true;
|
|
99
|
+
hasVisibleEmphasisFrame = true;
|
|
100
|
+
}
|
|
101
|
+
frameIndex += 1;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Collapse-to-nothing (oversizedFocus: 'hide'): `focusedLines === 0` means
|
|
105
|
+
// the collapsed window is intentionally empty, so skip the first-frame
|
|
106
|
+
// fallback and keep every frame hidden when collapsed.
|
|
107
|
+
if (hast.data?.focusedLines === 0) {
|
|
108
|
+
return visibleFrames;
|
|
109
|
+
}
|
|
110
|
+
if (!hasVisibleEmphasisFrame && frameIndex > 0) {
|
|
111
|
+
visibleFrames[0] = true;
|
|
112
|
+
}
|
|
113
|
+
return visibleFrames;
|
|
114
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light, client-reachable facade over the grammar engine in `./parseSource`.
|
|
3
|
+
*
|
|
4
|
+
* Importing this module must NOT pull `createStarryNight` (the regex engine:
|
|
5
|
+
* vscode-textmate + oniguruma) or any grammar JSON into the bundle — the engine
|
|
6
|
+
* is reached only through the dynamic `import()` in {@link ensureGrammars}. That
|
|
7
|
+
* keeps `CodeHighlighter` (which drives lazy, per-language grammar loading from
|
|
8
|
+
* the client chunk) free of the engine until a block actually needs to
|
|
9
|
+
* highlight, mirroring the `./useCode/transformEngineCache` split.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Synchronously reports whether every given scope's grammar is already
|
|
13
|
+
* registered. Reads the shared singleton without importing the engine, so it is
|
|
14
|
+
* safe on the render path (e.g. a `useState` initializer) to decide whether a
|
|
15
|
+
* block can highlight immediately or must wait — avoiding a cold flash.
|
|
16
|
+
*/
|
|
17
|
+
export declare function areGrammarsRegistered(scopes: string[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Ensures the grammars for the given scopes (and their dependencies) are
|
|
20
|
+
* registered, loading the engine and the per-scope grammar chunks on demand. A
|
|
21
|
+
* synchronous no-op when the scopes are already registered (warm — e.g. a prior
|
|
22
|
+
* block, the speculative preload, or an eager `CodeProvider` primed them), so it
|
|
23
|
+
* is cheap to call on render or as a speculative preload. Fails open: a failed
|
|
24
|
+
* load leaves the affected scope as plain text.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ensureGrammars(scopes: string[]): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Registers ALL grammars via the single barrel chunk (~146 KB gzip). Backs the
|
|
29
|
+
* `preloadGrammars: 'all'` provider opt-in — for layouts that will render code
|
|
30
|
+
* in many languages and prefer one upfront fetch over per-language chunks. Fails
|
|
31
|
+
* open.
|
|
32
|
+
*/
|
|
33
|
+
export declare function preloadAllGrammars(): Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light, client-reachable facade over the grammar engine in `./parseSource`.
|
|
3
|
+
*
|
|
4
|
+
* Importing this module must NOT pull `createStarryNight` (the regex engine:
|
|
5
|
+
* vscode-textmate + oniguruma) or any grammar JSON into the bundle — the engine
|
|
6
|
+
* is reached only through the dynamic `import()` in {@link ensureGrammars}. That
|
|
7
|
+
* keeps `CodeHighlighter` (which drives lazy, per-language grammar loading from
|
|
8
|
+
* the client chunk) free of the engine until a block actually needs to
|
|
9
|
+
* highlight, mirroring the `./useCode/transformEngineCache` split.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Must match STARRY_NIGHT_KEY in ./parseSource. Duplicated intentionally to keep
|
|
13
|
+
// this module free of a static `./parseSource` import (which would pull the
|
|
14
|
+
// engine into every consumer's bundle).
|
|
15
|
+
const STARRY_NIGHT_KEY = '__docs_infra_starry_night_instance__';
|
|
16
|
+
|
|
17
|
+
// The narrow slice of the Starry Night instance this module reads synchronously.
|
|
18
|
+
|
|
19
|
+
function getInstance() {
|
|
20
|
+
return globalThis[STARRY_NIGHT_KEY];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Synchronously reports whether every given scope's grammar is already
|
|
25
|
+
* registered. Reads the shared singleton without importing the engine, so it is
|
|
26
|
+
* safe on the render path (e.g. a `useState` initializer) to decide whether a
|
|
27
|
+
* block can highlight immediately or must wait — avoiding a cold flash.
|
|
28
|
+
*/
|
|
29
|
+
export function areGrammarsRegistered(scopes) {
|
|
30
|
+
if (scopes.length === 0) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const instance = getInstance();
|
|
34
|
+
if (!instance) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const registered = new Set(instance.scopes());
|
|
38
|
+
return scopes.every(scope => registered.has(scope));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Ensures the grammars for the given scopes (and their dependencies) are
|
|
43
|
+
* registered, loading the engine and the per-scope grammar chunks on demand. A
|
|
44
|
+
* synchronous no-op when the scopes are already registered (warm — e.g. a prior
|
|
45
|
+
* block, the speculative preload, or an eager `CodeProvider` primed them), so it
|
|
46
|
+
* is cheap to call on render or as a speculative preload. Fails open: a failed
|
|
47
|
+
* load leaves the affected scope as plain text.
|
|
48
|
+
*/
|
|
49
|
+
export async function ensureGrammars(scopes) {
|
|
50
|
+
if (scopes.length === 0 || areGrammarsRegistered(scopes)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Cold: pull the engine + registration impl now (this is when a block is about
|
|
54
|
+
// to highlight, so the engine load is expected and runs in parallel with the
|
|
55
|
+
// content via the speculative preload).
|
|
56
|
+
const {
|
|
57
|
+
registerGrammars
|
|
58
|
+
} = await import("./parseSource.mjs");
|
|
59
|
+
await registerGrammars(scopes);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Registers ALL grammars via the single barrel chunk (~146 KB gzip). Backs the
|
|
64
|
+
* `preloadGrammars: 'all'` provider opt-in — for layouts that will render code
|
|
65
|
+
* in many languages and prefer one upfront fetch over per-language chunks. Fails
|
|
66
|
+
* open.
|
|
67
|
+
*/
|
|
68
|
+
export async function preloadAllGrammars() {
|
|
69
|
+
const {
|
|
70
|
+
registerAllGrammars
|
|
71
|
+
} = await import("./parseSource.mjs");
|
|
72
|
+
await registerAllGrammars();
|
|
73
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-scope grammar loaders. Each entry dynamically imports a single
|
|
3
|
+
* `@wooorm/starry-night` grammar module, so the bundler emits one chunk per
|
|
4
|
+
* grammar instead of the all-in-one `./grammars` barrel. `ensureGrammars`
|
|
5
|
+
* (in `./parseSource`) resolves only the scopes a block needs, keeping the
|
|
6
|
+
* unused grammar payloads (~146 KB gzip for all 10) out of the download.
|
|
7
|
+
*
|
|
8
|
+
* Keys are starry-night scope names — the same values `./grammarMaps` resolves
|
|
9
|
+
* file extensions and language props to, so every detectable language has a
|
|
10
|
+
* loader (asserted in the tests).
|
|
11
|
+
*/
|
|
12
|
+
import type { Grammar } from '@wooorm/starry-night';
|
|
13
|
+
export type GrammarLoader = () => Promise<Grammar>;
|
|
14
|
+
export declare const grammarLoaders: Record<string, GrammarLoader>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-scope grammar loaders. Each entry dynamically imports a single
|
|
3
|
+
* `@wooorm/starry-night` grammar module, so the bundler emits one chunk per
|
|
4
|
+
* grammar instead of the all-in-one `./grammars` barrel. `ensureGrammars`
|
|
5
|
+
* (in `./parseSource`) resolves only the scopes a block needs, keeping the
|
|
6
|
+
* unused grammar payloads (~146 KB gzip for all 10) out of the download.
|
|
7
|
+
*
|
|
8
|
+
* Keys are starry-night scope names — the same values `./grammarMaps` resolves
|
|
9
|
+
* file extensions and language props to, so every detectable language has a
|
|
10
|
+
* loader (asserted in the tests).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const grammarLoaders = {
|
|
14
|
+
'source.js': () => import('@wooorm/starry-night/source.js').then(mod => mod.default),
|
|
15
|
+
'source.ts': () => import('@wooorm/starry-night/source.ts').then(mod => mod.default),
|
|
16
|
+
'source.tsx': () => import('@wooorm/starry-night/source.tsx').then(mod => mod.default),
|
|
17
|
+
'source.json': () => import('@wooorm/starry-night/source.json').then(mod => mod.default),
|
|
18
|
+
'text.md': () => import('@wooorm/starry-night/text.md').then(mod => mod.default),
|
|
19
|
+
'source.mdx': () => import('@wooorm/starry-night/source.mdx').then(mod => mod.default),
|
|
20
|
+
'text.html.basic': () => import('@wooorm/starry-night/text.html.basic').then(mod => mod.default),
|
|
21
|
+
'source.css': () => import('@wooorm/starry-night/source.css').then(mod => mod.default),
|
|
22
|
+
'source.shell': () => import('@wooorm/starry-night/source.shell').then(mod => mod.default),
|
|
23
|
+
'source.yaml': () => import('@wooorm/starry-night/source.yaml').then(mod => mod.default)
|
|
24
|
+
};
|
|
@@ -15,4 +15,24 @@ export declare const languageToGrammarMap: Record<string, string>;
|
|
|
15
15
|
* @param language - The language name (e.g., 'tsx', 'css', 'typescript')
|
|
16
16
|
* @returns The grammar scope or undefined if not recognized
|
|
17
17
|
*/
|
|
18
|
-
export declare function getGrammarFromLanguage(language: string): string | undefined;
|
|
18
|
+
export declare function getGrammarFromLanguage(language: string): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a grammar scope from a file's name and/or explicit language,
|
|
21
|
+
* preferring `language` and falling back to the file extension. This is the
|
|
22
|
+
* single source of truth for how `parseSource` picks a grammar and how
|
|
23
|
+
* `detectGrammarScopes` enumerates the grammars a code block needs, so the two
|
|
24
|
+
* never disagree.
|
|
25
|
+
*
|
|
26
|
+
* @param fileName - File name used to detect language via its extension
|
|
27
|
+
* @param language - Optional explicit language override (e.g., 'tsx', 'css')
|
|
28
|
+
* @returns The grammar scope, or undefined for unsupported / unknown inputs
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveGrammarScope(fileName?: string, language?: string): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Normalizes a user-supplied list (the `preloadGrammars` provider prop) to
|
|
33
|
+
* grammar scope names, accepting either language names (`'tsx'`, `'typescript'`)
|
|
34
|
+
* or scope names (`'source.tsx'`) and de-duplicating. Entries that match neither
|
|
35
|
+
* are passed through as-is, so an unrecognized scope is simply ignored
|
|
36
|
+
* downstream (it has no loader) rather than throwing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function normalizeToScopes(entries: string[]): string[];
|
|
@@ -50,4 +50,40 @@ export const languageToGrammarMap = {
|
|
|
50
50
|
*/
|
|
51
51
|
export function getGrammarFromLanguage(language) {
|
|
52
52
|
return languageToGrammarMap[language.toLowerCase()];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Resolves a grammar scope from a file's name and/or explicit language,
|
|
57
|
+
* preferring `language` and falling back to the file extension. This is the
|
|
58
|
+
* single source of truth for how `parseSource` picks a grammar and how
|
|
59
|
+
* `detectGrammarScopes` enumerates the grammars a code block needs, so the two
|
|
60
|
+
* never disagree.
|
|
61
|
+
*
|
|
62
|
+
* @param fileName - File name used to detect language via its extension
|
|
63
|
+
* @param language - Optional explicit language override (e.g., 'tsx', 'css')
|
|
64
|
+
* @returns The grammar scope, or undefined for unsupported / unknown inputs
|
|
65
|
+
*/
|
|
66
|
+
export function resolveGrammarScope(fileName, language) {
|
|
67
|
+
if (language) {
|
|
68
|
+
const scope = getGrammarFromLanguage(language);
|
|
69
|
+
if (scope) {
|
|
70
|
+
return scope;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (fileName) {
|
|
74
|
+
const fileType = fileName.slice(fileName.lastIndexOf('.'));
|
|
75
|
+
return extensionMap[fileType];
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Normalizes a user-supplied list (the `preloadGrammars` provider prop) to
|
|
82
|
+
* grammar scope names, accepting either language names (`'tsx'`, `'typescript'`)
|
|
83
|
+
* or scope names (`'source.tsx'`) and de-duplicating. Entries that match neither
|
|
84
|
+
* are passed through as-is, so an unrecognized scope is simply ignored
|
|
85
|
+
* downstream (it has no loader) rather than throwing.
|
|
86
|
+
*/
|
|
87
|
+
export function normalizeToScopes(entries) {
|
|
88
|
+
return [...new Set(entries.map(entry => getGrammarFromLanguage(entry) ?? entry))];
|
|
53
89
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Element as HastElement } from 'hast';
|
|
2
|
+
/**
|
|
3
|
+
* Returns `true` when a HAST element carries the given class name, accepting
|
|
4
|
+
* both shapes `className` can take:
|
|
5
|
+
*
|
|
6
|
+
* - the string form (`className: 'frame'`), used by freshly parsed / live HAST
|
|
7
|
+
* (e.g. `createFrame`), and
|
|
8
|
+
* - the array form (`className: ['frame']`), produced by `fallbackToHast` and by
|
|
9
|
+
* any HAST that round-trips through serialization.
|
|
10
|
+
*
|
|
11
|
+
* Matching only the string silently skips real fallback frames, so class checks
|
|
12
|
+
* on HAST that may come from either path must go through this helper.
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasClassName(element: HastElement, name: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Returns `true` when a HAST element is a code frame span — its `className`
|
|
17
|
+
* includes `'frame'` in either the string or array shape (see {@link hasClassName}).
|
|
18
|
+
*/
|
|
19
|
+
export declare function isFrameSpan(element: HastElement): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when a HAST element carries the given class name, accepting
|
|
3
|
+
* both shapes `className` can take:
|
|
4
|
+
*
|
|
5
|
+
* - the string form (`className: 'frame'`), used by freshly parsed / live HAST
|
|
6
|
+
* (e.g. `createFrame`), and
|
|
7
|
+
* - the array form (`className: ['frame']`), produced by `fallbackToHast` and by
|
|
8
|
+
* any HAST that round-trips through serialization.
|
|
9
|
+
*
|
|
10
|
+
* Matching only the string silently skips real fallback frames, so class checks
|
|
11
|
+
* on HAST that may come from either path must go through this helper.
|
|
12
|
+
*/
|
|
13
|
+
export function hasClassName(element, name) {
|
|
14
|
+
const className = element.properties?.className;
|
|
15
|
+
return className === name || Array.isArray(className) && className.includes(name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns `true` when a HAST element is a code frame span — its `className`
|
|
20
|
+
* includes `'frame'` in either the string or array shape (see {@link hasClassName}).
|
|
21
|
+
*/
|
|
22
|
+
export function isFrameSpan(element) {
|
|
23
|
+
return hasClassName(element, 'frame');
|
|
24
|
+
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { ParseSource } from "../../CodeHighlighter/types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Parses source into a line-guttered HAST **without** syntax highlighting — the
|
|
4
|
+
* raw text wrapped in the same `.line`/`.frame` structure `parseSource` produces,
|
|
5
|
+
* just no starry-night tokenization. It is a `ParseSource` so it can be dropped
|
|
6
|
+
* into the loader in place of the highlighting parser.
|
|
7
|
+
*
|
|
8
|
+
* Used for the deferred (un-highlighted) fallback: the enhancer pipeline needs the
|
|
9
|
+
* line/frame structure to compute focus windows and truncation, but the syntax
|
|
10
|
+
* colors are exactly the part being deferred — so we skip them. Cheap (no grammar,
|
|
11
|
+
* no `getInstance`); the frames it produces collapse back to text via `buildRootFallback`.
|
|
12
|
+
*
|
|
13
|
+
* Takes only `source` (it ignores file name / language since it never highlights) but
|
|
14
|
+
* stays structurally assignable to `ParseSource`, so it drops into the loader in place
|
|
15
|
+
* of the highlighting parser.
|
|
16
|
+
*/
|
|
17
|
+
export declare const parsePlainText: (source: string) => ReturnType<ParseSource>;
|
|
2
18
|
/**
|
|
3
19
|
* Parses source code into a HAST tree with syntax highlighting.
|
|
4
20
|
*
|
|
@@ -9,15 +25,34 @@ import type { ParseSource } from "../../CodeHighlighter/types.mjs";
|
|
|
9
25
|
* @throws Error if `createParseSource()` has not been called first
|
|
10
26
|
*/
|
|
11
27
|
export declare const parseSource: ParseSource;
|
|
28
|
+
/**
|
|
29
|
+
* Registers the grammars for the given scopes (and their dependencies) on the
|
|
30
|
+
* global Starry Night instance, loading the per-scope chunks on demand.
|
|
31
|
+
* Idempotent and deduped. Fails open: a chunk that fails to load leaves its
|
|
32
|
+
* scope as plain text rather than rejecting the batch.
|
|
33
|
+
*
|
|
34
|
+
* This is the heavy implementation (it can create the engine instance). Client
|
|
35
|
+
* code should call the light facade {@link ensureGrammars} from `./grammarCache`
|
|
36
|
+
* instead, so the engine stays out of the client bundle until a block needs it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function registerGrammars(scopes: string[]): Promise<void>;
|
|
39
|
+
export declare function registerAllGrammars(): Promise<void>;
|
|
12
40
|
/**
|
|
13
41
|
* Initializes Starry Night and returns a configured `parseSource` function.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
42
|
+
* Only needs to be called once per application; the instance is stored globally
|
|
43
|
+
* for reuse across calls.
|
|
16
44
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
45
|
+
* With no `initialScopes`, loads ALL grammars via the (lazy) `./grammars` barrel
|
|
46
|
+
* — the eager `CodeProvider` / Node / build-time behavior, so the heavy TextMate
|
|
47
|
+
* JSON is split into its own chunk but fully available. Pass `initialScopes`
|
|
48
|
+
* (possibly `[]`) to create a lean instance that registers grammars on demand
|
|
49
|
+
* via {@link registerGrammars} — the `CodeProviderLazy` per-language path.
|
|
20
50
|
*
|
|
21
51
|
* @returns A Promise that resolves to the initialized `parseSource` function
|
|
22
52
|
*/
|
|
23
|
-
export declare const createParseSource: () => Promise<ParseSource>;
|
|
53
|
+
export declare const createParseSource: (initialScopes?: string[]) => Promise<ParseSource>;
|
|
54
|
+
/**
|
|
55
|
+
* Clears the global Starry Night singleton and registration state. Intended for
|
|
56
|
+
* tests exercising lazy registration from a known-empty registry.
|
|
57
|
+
*/
|
|
58
|
+
export declare function resetStarryNight(): void;
|