@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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single live-editing engine chunk. Co-locates the two pieces an editable
|
|
3
|
+
* block always needs together — the contentEditable runtime + keyboard/paste/
|
|
4
|
+
* caret handlers (`createEditableEngine`, which pulls `react-dom` and the DOM
|
|
5
|
+
* utilities) and the edit-time source manipulation (`analyzeSource`,
|
|
6
|
+
* `shiftComments`, `toControlledCode`) — so the bundler emits ONE chunk for both
|
|
7
|
+
* instead of two. Importing this module is heavy; it is only ever reached
|
|
8
|
+
* through the `editingEngineLoader` accessor (eager `CodeProvider` bundles it;
|
|
9
|
+
* `CodeProviderLazy` code-splits it) or the dynamic import in
|
|
10
|
+
* `./editingEngineCache`, so a read-only block never pulls it in.
|
|
11
|
+
*/
|
|
12
|
+
export { createEditableEngine } from "./EditableEngine.mjs";
|
|
13
|
+
export { analyzeSource, shiftComments, toControlledCode } from "./SourceEditingEngine.mjs";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single live-editing engine chunk. Co-locates the two pieces an editable
|
|
3
|
+
* block always needs together — the contentEditable runtime + keyboard/paste/
|
|
4
|
+
* caret handlers (`createEditableEngine`, which pulls `react-dom` and the DOM
|
|
5
|
+
* utilities) and the edit-time source manipulation (`analyzeSource`,
|
|
6
|
+
* `shiftComments`, `toControlledCode`) — so the bundler emits ONE chunk for both
|
|
7
|
+
* instead of two. Importing this module is heavy; it is only ever reached
|
|
8
|
+
* through the `editingEngineLoader` accessor (eager `CodeProvider` bundles it;
|
|
9
|
+
* `CodeProviderLazy` code-splits it) or the dynamic import in
|
|
10
|
+
* `./editingEngineCache`, so a read-only block never pulls it in.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export { createEditableEngine } from "./EditableEngine.mjs";
|
|
14
|
+
export { analyzeSource, shiftComments, toControlledCode } from "./SourceEditingEngine.mjs";
|
package/useCode/Pre.browser.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
|
6
6
|
import { createParseSource } from "../pipeline/parseSource/index.mjs";
|
|
7
7
|
import { enhanceCodeEmphasis } from "../pipeline/enhanceCodeEmphasis/index.mjs";
|
|
8
8
|
import { Pre } from "./Pre.mjs";
|
|
9
|
+
import { preloadEditableEngine } from "./useEditable.mjs";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
const FILE_NAME = 'CheckboxBasic.tsx';
|
|
11
12
|
const INITIAL_SOURCE = ["import * as React from 'react';", "import { Checkbox } from '@/components/Checkbox';", '', 'export default function CheckboxBasic() {', ' return (', ' <div>', ' <Checkbox defaultChecked />', " <p style={{ color: '#CA244D' }}>Type Whatever You Want Below</p>", ' </div>', ' );', '}'].join('\n');
|
|
@@ -16,6 +17,9 @@ const HIGHLIGHT_COMMENTS = {
|
|
|
16
17
|
let parseSource;
|
|
17
18
|
beforeAll(async () => {
|
|
18
19
|
parseSource = await createParseSource();
|
|
20
|
+
// `<Pre>`'s editable path loads its editing engine on demand; warm it so
|
|
21
|
+
// editable renders below attach contentEditable synchronously (within `act`).
|
|
22
|
+
await preloadEditableEngine();
|
|
19
23
|
});
|
|
20
24
|
function createHighlightedSource(source) {
|
|
21
25
|
const root = parseSource(source, FILE_NAME);
|
|
@@ -153,7 +157,7 @@ describe('Pre - browser', () => {
|
|
|
153
157
|
it('edits correctly when surrounding frames are not hast-rendered (mixed visibility)', async () => {
|
|
154
158
|
// Build a tall source with two well-separated highlight regions and a
|
|
155
159
|
// long non-emphasised middle. The middle frame is `'normal'` (not in
|
|
156
|
-
// `
|
|
160
|
+
// `COLLAPSED_VISIBLE_FRAME_TYPES`), so it starts as plain text and only
|
|
157
161
|
// hydrates if the `IntersectionObserver` reports it as visible. Most
|
|
158
162
|
// viewports won't reach the bottom highlight either, leaving it
|
|
159
163
|
// un-hydrated. We verify editing in a hydrated frame still produces a
|
package/useCode/Pre.d.mts
CHANGED
|
@@ -1,32 +1,61 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { SetSource } from "./useSourceEditing.mjs";
|
|
3
3
|
import type { VariantSource } from "../CodeHighlighter/types.mjs";
|
|
4
|
+
import type { FallbackNode } from "../CodeHighlighter/fallbackFormat.mjs";
|
|
5
|
+
import { type SourceLineCounts } from "./sourceLineCounts.mjs";
|
|
4
6
|
export declare function Pre({
|
|
5
7
|
children,
|
|
6
8
|
className,
|
|
7
9
|
fileName,
|
|
10
|
+
bridgeLineMode,
|
|
8
11
|
language,
|
|
9
12
|
ref,
|
|
10
13
|
setSource,
|
|
11
14
|
shouldHighlight,
|
|
12
15
|
hydrateMargin,
|
|
16
|
+
fallback,
|
|
17
|
+
fallbackLineCounts,
|
|
13
18
|
expanded,
|
|
14
|
-
|
|
19
|
+
collapseToEmpty,
|
|
20
|
+
expand,
|
|
21
|
+
transforming,
|
|
22
|
+
onTransitionReady,
|
|
23
|
+
swapTarget,
|
|
24
|
+
editActivation,
|
|
25
|
+
onActivate
|
|
15
26
|
}: {
|
|
16
27
|
children: VariantSource;
|
|
17
28
|
className?: string;
|
|
18
29
|
fileName?: string;
|
|
30
|
+
bridgeLineMode?: 'focus' | 'total';
|
|
19
31
|
language?: string;
|
|
20
32
|
ref?: React.Ref<HTMLPreElement>;
|
|
21
33
|
setSource?: SetSource;
|
|
22
34
|
shouldHighlight?: boolean;
|
|
23
35
|
hydrateMargin?: string;
|
|
36
|
+
fallback?: FallbackNode[];
|
|
37
|
+
/**
|
|
38
|
+
* Authoritative line metadata for a string source's framed fallback. Deferred
|
|
39
|
+
* string sources do not have decoded HAST yet, but their loader-built fallback
|
|
40
|
+
* already knows whether the collapsed window hides lines.
|
|
41
|
+
*/
|
|
42
|
+
fallbackLineCounts?: SourceLineCounts | null;
|
|
24
43
|
/**
|
|
25
44
|
* Whether the host has expanded the (collapsible) code block. When `true`,
|
|
26
45
|
* collapsed-state behaviors such as `minColumn` are disabled so the caret
|
|
27
46
|
* can move into the indent gutter normally.
|
|
28
47
|
*/
|
|
29
48
|
expanded?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Render-time "collapse to empty": collapse the block to an *empty* window so the
|
|
51
|
+
* whole block is hidden until expanded. Demotes every collapsed-visible frame
|
|
52
|
+
* type to its hidden equivalent (`focus`→`focus-unfocused`,
|
|
53
|
+
* `highlighted`→`highlighted-unfocused`, `padding-*`→`normal`), forces the
|
|
54
|
+
* block collapsible, and reports `0` focused lines. Orthogonal to `expanded`
|
|
55
|
+
* — it only changes what the *collapsed* state shows, not whether the block
|
|
56
|
+
* starts expanded. The precomputed HAST is never mutated.
|
|
57
|
+
*/
|
|
58
|
+
collapseToEmpty?: boolean;
|
|
30
59
|
/**
|
|
31
60
|
* Called when the user attempts to navigate the caret past the visible
|
|
32
61
|
* region of a collapsed code block (e.g. `ArrowUp` on the first visible
|
|
@@ -34,4 +63,101 @@ export declare function Pre({
|
|
|
34
63
|
* `expand()` action.
|
|
35
64
|
*/
|
|
36
65
|
expand?: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* State of an in-flight transform animation, or `null` when settled.
|
|
68
|
+
* The rendered `<pre>` is annotated with `data-transforming={state}`
|
|
69
|
+
* so consumer CSS can react. The state machine moves through four
|
|
70
|
+
* values per swap so the host can hold the `.collapse` bridge at a
|
|
71
|
+
* static height while the new tree mounts, then release into the
|
|
72
|
+
* animation once it has painted:
|
|
73
|
+
*
|
|
74
|
+
* ```
|
|
75
|
+
* ┌──────────────┐ onTransitionReady ┌──────────────┐
|
|
76
|
+
* │ 'collapsed' │ ───────────────────▶ │ 'expanding' │
|
|
77
|
+
* │ (paused 0) │ │ (anim ↑) │
|
|
78
|
+
* └──────────────┘ └──────┬───────┘
|
|
79
|
+
* ▲ │ animationend
|
|
80
|
+
* │ next swap ▼
|
|
81
|
+
* ┌──────┴───────┐ onTransitionReady ┌──────────────┐
|
|
82
|
+
* │ 'collapsing' │ ◀─────────────────── │ 'expanded' │
|
|
83
|
+
* │ (anim ↓) │ │ (paused max) │
|
|
84
|
+
* └──────────────┘ └──────────────┘
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* - `'collapsed'` bridge is paused at 0 height (its closed rest
|
|
88
|
+
* state) waiting for the outgoing tree to be
|
|
89
|
+
* ready before animating open. Bridge is rendered
|
|
90
|
+
* so CSS can hold it closed.
|
|
91
|
+
* - `'expanding'` bridge is animating from 0 up to the partner
|
|
92
|
+
* variant's extra height. Outgoing tree's pre-swap
|
|
93
|
+
* exit window.
|
|
94
|
+
* - `'expanded'` bridge is paused at the partner-variant height
|
|
95
|
+
* (its open rest state) waiting for the incoming
|
|
96
|
+
* tree to be ready before animating closed.
|
|
97
|
+
* - `'collapsing'` bridge is animating from the open height back to
|
|
98
|
+
* 0. Incoming tree's post-swap entry window.
|
|
99
|
+
*
|
|
100
|
+
* Callers transition `'collapsed' → 'expanding'` and
|
|
101
|
+
* `'expanded' → 'collapsing'` once `onTransitionReady` fires for the
|
|
102
|
+
* paused state. The paused values are CSS-side animation gates: the
|
|
103
|
+
* bridge `.collapse` placeholder is rendered identically for the
|
|
104
|
+
* paused and active values so consumer styles only need to suppress
|
|
105
|
+
* the keyframes / transition on the paused selectors.
|
|
106
|
+
*/
|
|
107
|
+
transforming?: 'collapsed' | 'expanding' | 'expanded' | 'collapsing' | null;
|
|
108
|
+
/**
|
|
109
|
+
* Fired one animation frame after `transforming` enters a paused
|
|
110
|
+
* value (`'collapsed'` or `'expanded'`). Lets the host transition
|
|
111
|
+
* to the matching active value (`'expanding'` / `'collapsing'`)
|
|
112
|
+
* only after the browser has had a paint cycle to flush the new
|
|
113
|
+
* tree and the `.collapse` bridge into the layout. Without this
|
|
114
|
+
* gate the active animation can start before the incoming `<Pre>`
|
|
115
|
+
* has swapped from raw text to highlighted spans, producing a
|
|
116
|
+
* visible snap mid-animation.
|
|
117
|
+
*
|
|
118
|
+
* When `shouldHighlight` is true the callback is held until the
|
|
119
|
+
* highlighted HAST has committed *and* the IntersectionObserver has
|
|
120
|
+
* had a chance to fire — i.e. every visible frame has swapped from
|
|
121
|
+
* fallback text to highlighted spans and the `visibleFrames` map
|
|
122
|
+
* has stopped changing. One animation frame after that, the
|
|
123
|
+
* callback runs.
|
|
124
|
+
*
|
|
125
|
+
* When `shouldHighlight` is false there is no `.collapse` bridge to
|
|
126
|
+
* animate, so the callback fires on the next frame instead of
|
|
127
|
+
* deadlocking the swap waiting for hast/visibility that will never
|
|
128
|
+
* affect the result.
|
|
129
|
+
*/
|
|
130
|
+
onTransitionReady?: () => void;
|
|
131
|
+
/**
|
|
132
|
+
* Per-file line counts from the *other* variant participating in an
|
|
133
|
+
* in-flight variant swap. When set alongside `transforming`, `<Pre>`
|
|
134
|
+
* appends a bridge `<span class="collapse" data-lines={delta}>` to
|
|
135
|
+
* the last visible frame (when collapsed) or the last frame overall
|
|
136
|
+
* (when expanded) so consumer CSS can animate the height delta
|
|
137
|
+
* between the two variants. The placeholder is only added when the
|
|
138
|
+
* partner has *more* lines than the currently-rendered tree (i.e.
|
|
139
|
+
* this `<Pre>` is the shorter side of the swap); otherwise the
|
|
140
|
+
* rendered hast is returned untouched.
|
|
141
|
+
*
|
|
142
|
+
* `null` (or omitted) disables the bridge entirely — useful for
|
|
143
|
+
* transform-only swaps where `transforming` is set but no variant
|
|
144
|
+
* swap is in flight.
|
|
145
|
+
*/
|
|
146
|
+
swapTarget?: {
|
|
147
|
+
focusedLines: number;
|
|
148
|
+
totalLines: number;
|
|
149
|
+
} | null;
|
|
150
|
+
/**
|
|
151
|
+
* Controls when the editing engine loads for an editable block: `'eager'`
|
|
152
|
+
* (default) loads it as soon as the block is editable; `'interaction'` defers
|
|
153
|
+
* the load until the user hovers/focuses/clicks the `<pre>`. Ignored when the
|
|
154
|
+
* block is not editable. Forwarded to `useEditable` as its `activation` config.
|
|
155
|
+
*/
|
|
156
|
+
editActivation?: 'eager' | 'interaction';
|
|
157
|
+
/**
|
|
158
|
+
* Fired once when the block first engages for editing. Forwarded to
|
|
159
|
+
* `useEditable` as its `onActivate` config; `CodeHighlighter` uses it to warm
|
|
160
|
+
* the live-editing engine, grammars, and worker at the activation moment.
|
|
161
|
+
*/
|
|
162
|
+
onActivate?: () => void;
|
|
37
163
|
}): React.ReactNode;
|