@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.
Files changed (319) hide show
  1. package/ChunkProvider/ChunkContext.d.mts +10 -0
  2. package/ChunkProvider/ChunkContext.mjs +15 -0
  3. package/ChunkProvider/ChunkProvider.d.mts +14 -0
  4. package/ChunkProvider/ChunkProvider.mjs +38 -0
  5. package/ChunkProvider/PreloadContext.d.mts +14 -0
  6. package/ChunkProvider/PreloadContext.mjs +18 -0
  7. package/ChunkProvider/PreloadProvider.d.mts +13 -0
  8. package/ChunkProvider/PreloadProvider.mjs +33 -0
  9. package/ChunkProvider/index.d.mts +7 -0
  10. package/ChunkProvider/index.mjs +7 -0
  11. package/ChunkProvider/types.d.mts +23 -0
  12. package/ChunkProvider/types.mjs +1 -0
  13. package/ChunkProvider/usePreload.d.mts +8 -0
  14. package/ChunkProvider/usePreload.mjs +21 -0
  15. package/CodeControllerContext/CodeControllerContext.d.mts +11 -0
  16. package/CodeControllerContext/CodeControllerContext.mjs +2 -1
  17. package/CodeHighlighter/CodeHighlighter.d.mts +15 -1
  18. package/CodeHighlighter/CodeHighlighter.mjs +97 -319
  19. package/CodeHighlighter/CodeHighlighterChunk.d.mts +42 -0
  20. package/CodeHighlighter/CodeHighlighterChunk.mjs +77 -0
  21. package/CodeHighlighter/CodeHighlighterClient.mjs +597 -128
  22. package/CodeHighlighter/CodeHighlighterContext.d.mts +57 -1
  23. package/CodeHighlighter/CodeHighlighterFallbackContext.d.mts +14 -2
  24. package/CodeHighlighter/CodeHighlighterFallbackContext.mjs +1 -3
  25. package/CodeHighlighter/CodeInitialSourceLoader.d.mts +10 -0
  26. package/CodeHighlighter/CodeInitialSourceLoader.mjs +108 -0
  27. package/CodeHighlighter/CodeSourceLoader.d.mts +11 -0
  28. package/CodeHighlighter/CodeSourceLoader.mjs +128 -0
  29. package/CodeHighlighter/buildCodeHighlighterChunkProps.d.mts +47 -0
  30. package/CodeHighlighter/buildCodeHighlighterChunkProps.mjs +61 -0
  31. package/CodeHighlighter/buildStringFallback.d.mts +29 -0
  32. package/CodeHighlighter/buildStringFallback.mjs +42 -0
  33. package/CodeHighlighter/codeToFallbackProps.d.mts +31 -2
  34. package/CodeHighlighter/codeToFallbackProps.mjs +347 -42
  35. package/CodeHighlighter/createClientProps.d.mts +17 -0
  36. package/CodeHighlighter/createClientProps.mjs +78 -0
  37. package/CodeHighlighter/errors.d.mts +6 -0
  38. package/CodeHighlighter/errors.mjs +10 -0
  39. package/CodeHighlighter/fallbackCompression.d.mts +96 -0
  40. package/CodeHighlighter/fallbackCompression.mjs +253 -0
  41. package/CodeHighlighter/fallbackFormat.d.mts +137 -0
  42. package/CodeHighlighter/fallbackFormat.mjs +422 -0
  43. package/CodeHighlighter/index.d.mts +4 -1
  44. package/CodeHighlighter/index.mjs +3 -1
  45. package/CodeHighlighter/mergeComments.d.mts +38 -0
  46. package/CodeHighlighter/mergeComments.mjs +80 -0
  47. package/CodeHighlighter/prepareInitialSource.d.mts +42 -0
  48. package/CodeHighlighter/prepareInitialSource.mjs +292 -0
  49. package/CodeHighlighter/resolveFallbackCritical.d.mts +23 -0
  50. package/CodeHighlighter/resolveFallbackCritical.mjs +44 -0
  51. package/CodeHighlighter/types.d.mts +272 -8
  52. package/CodeHighlighter/useCodeFallback.d.mts +94 -0
  53. package/CodeHighlighter/useCodeFallback.mjs +204 -0
  54. package/CodeHighlighter/useGrammarsReady.d.mts +18 -0
  55. package/CodeHighlighter/useGrammarsReady.mjs +45 -0
  56. package/CodeHighlighter/useSpeculativeCodePreload.d.mts +26 -0
  57. package/CodeHighlighter/useSpeculativeCodePreload.mjs +40 -0
  58. package/CodeHighlighter/useSpeculativeEditingPreload.d.mts +33 -0
  59. package/CodeHighlighter/useSpeculativeEditingPreload.mjs +58 -0
  60. package/CodeHighlighter/useSpeculativeGrammarPreload.d.mts +23 -0
  61. package/CodeHighlighter/useSpeculativeGrammarPreload.mjs +31 -0
  62. package/CodeHighlighter/useSpeculativeUseCodePreload.d.mts +22 -0
  63. package/CodeHighlighter/useSpeculativeUseCodePreload.mjs +41 -0
  64. package/CodeProvider/CodeContext.d.mts +47 -12
  65. package/CodeProvider/CodeContext.mjs +7 -0
  66. package/CodeProvider/CodeProvider.d.mts +4 -2
  67. package/CodeProvider/CodeProvider.mjs +40 -102
  68. package/CodeProvider/CodeProviderLazy.d.mts +40 -0
  69. package/CodeProvider/CodeProviderLazy.mjs +96 -0
  70. package/CodeProvider/constants.d.mts +26 -0
  71. package/CodeProvider/constants.mjs +24 -0
  72. package/CodeProvider/createParseSourceWorkerClient.d.mts +6 -0
  73. package/CodeProvider/createParseSourceWorkerClient.mjs +22 -2
  74. package/CodeProvider/index.d.mts +2 -1
  75. package/CodeProvider/index.mjs +9 -1
  76. package/CodeProvider/parseSourceWorker.mjs +33 -0
  77. package/CodeProvider/useCodeProviderValue.d.mts +54 -0
  78. package/CodeProvider/useCodeProviderValue.mjs +188 -0
  79. package/CoordinatedLazy/ChunkServerLoader.d.mts +25 -0
  80. package/CoordinatedLazy/ChunkServerLoader.mjs +97 -0
  81. package/CoordinatedLazy/CoordinatedContentContext.d.mts +15 -0
  82. package/CoordinatedLazy/CoordinatedContentContext.mjs +22 -0
  83. package/CoordinatedLazy/CoordinatedFallbackContext.d.mts +11 -0
  84. package/CoordinatedLazy/CoordinatedFallbackContext.mjs +13 -0
  85. package/CoordinatedLazy/CoordinatedGateContext.d.mts +14 -0
  86. package/CoordinatedLazy/CoordinatedGateContext.mjs +19 -0
  87. package/CoordinatedLazy/CoordinatedLazy.d.mts +14 -0
  88. package/CoordinatedLazy/CoordinatedLazy.mjs +86 -0
  89. package/CoordinatedLazy/CoordinatedLazyClient.d.mts +24 -0
  90. package/CoordinatedLazy/CoordinatedLazyClient.mjs +65 -0
  91. package/CoordinatedLazy/LazyContent.d.mts +26 -0
  92. package/CoordinatedLazy/LazyContent.mjs +80 -0
  93. package/CoordinatedLazy/LazyContentServer.d.mts +18 -0
  94. package/CoordinatedLazy/LazyContentServer.mjs +25 -0
  95. package/CoordinatedLazy/buildChunkRenderInputs.d.mts +8 -0
  96. package/CoordinatedLazy/buildChunkRenderInputs.mjs +35 -0
  97. package/CoordinatedLazy/createCoordinatedLazy.d.mts +32 -0
  98. package/CoordinatedLazy/createCoordinatedLazy.mjs +127 -0
  99. package/CoordinatedLazy/index.d.mts +14 -0
  100. package/CoordinatedLazy/index.mjs +18 -0
  101. package/CoordinatedLazy/resolveChunkRender.d.mts +26 -0
  102. package/CoordinatedLazy/resolveChunkRender.mjs +73 -0
  103. package/CoordinatedLazy/types.d.mts +408 -0
  104. package/CoordinatedLazy/types.mjs +1 -0
  105. package/CoordinatedLazy/useChunk.d.mts +30 -0
  106. package/CoordinatedLazy/useChunk.mjs +135 -0
  107. package/CoordinatedLazy/useCoordinatedFallback.d.mts +12 -0
  108. package/CoordinatedLazy/useCoordinatedFallback.mjs +40 -0
  109. package/CoordinatedLazy/useCoordinatedSwap.d.mts +16 -0
  110. package/CoordinatedLazy/useCoordinatedSwap.mjs +124 -0
  111. package/LICENSE +1 -1
  112. package/abstractCreateDemo/abstractCreateDemo.d.mts +54 -3
  113. package/abstractCreateDemo/abstractCreateDemo.mjs +47 -7
  114. package/abstractCreateDemo/resolveDemoFlag.d.mts +20 -0
  115. package/abstractCreateDemo/resolveDemoFlag.mjs +25 -0
  116. package/abstractCreateStream/abstractCreateStream.d.mts +18 -0
  117. package/abstractCreateStream/abstractCreateStream.mjs +45 -0
  118. package/abstractCreateStream/index.d.mts +2 -0
  119. package/abstractCreateStream/index.mjs +1 -0
  120. package/abstractCreateStream/types.d.mts +34 -0
  121. package/abstractCreateStream/types.mjs +1 -0
  122. package/abstractCreateTypes/TypeCode.mjs +12 -11
  123. package/abstractCreateTypes/typesToJsx.mjs +30 -9
  124. package/cli/ensureDemoClients.mjs +4 -148
  125. package/cli/ensureDemoPages.d.mts +45 -0
  126. package/cli/ensureDemoPages.mjs +99 -0
  127. package/cli/fileUtils/index.d.mts +11 -0
  128. package/cli/fileUtils/index.mjs +48 -0
  129. package/cli/findDemoIndexFiles.d.mts +15 -0
  130. package/cli/findDemoIndexFiles.mjs +121 -0
  131. package/cli/index.mjs +1 -1
  132. package/cli/loadNextConfig.d.mts +25 -0
  133. package/cli/loadNextConfig.mjs +60 -1
  134. package/cli/runBrowser.mjs +1 -1
  135. package/cli/runValidate.mjs +44 -1
  136. package/package.json +85 -5
  137. package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasis.mjs +30 -0
  138. package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasisLazy.d.mts +17 -0
  139. package/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasisLazy.mjs +52 -0
  140. package/pipeline/hastUtils/frameFallbackFromSpans.d.mts +18 -0
  141. package/pipeline/hastUtils/frameFallbackFromSpans.mjs +24 -0
  142. package/pipeline/hastUtils/hast.d.mts +27 -0
  143. package/pipeline/hastUtils/hastCompression.d.mts +3 -1
  144. package/pipeline/hastUtils/hastCompression.mjs +9 -1
  145. package/pipeline/hastUtils/hastDecompress.mjs +10 -4
  146. package/pipeline/hastUtils/hastDictionary.mjs +9 -0
  147. package/pipeline/hastUtils/hastUtils.d.mts +4 -3
  148. package/pipeline/hastUtils/hastUtils.mjs +24 -12
  149. package/pipeline/hastUtils/index.d.mts +2 -1
  150. package/pipeline/hastUtils/index.mjs +2 -1
  151. package/pipeline/hastUtils/stripHighlightingSpans.d.mts +6 -2
  152. package/pipeline/hastUtils/stripHighlightingSpans.mjs +22 -10
  153. package/pipeline/lintJavascriptDemoFocus/lintJavascriptDemoFocus.mjs +10 -7
  154. package/pipeline/loadIsomorphicCodeVariant/applyCodeTransform.d.mts +31 -13
  155. package/pipeline/loadIsomorphicCodeVariant/applyCodeTransform.mjs +50 -55
  156. package/pipeline/loadIsomorphicCodeVariant/applyCodeTransformWithComments.d.mts +78 -0
  157. package/pipeline/loadIsomorphicCodeVariant/applyCodeTransformWithComments.mjs +405 -0
  158. package/pipeline/loadIsomorphicCodeVariant/computeHastDeltas.d.mts +5 -5
  159. package/pipeline/loadIsomorphicCodeVariant/computeHastDeltas.mjs +36 -66
  160. package/pipeline/loadIsomorphicCodeVariant/decodeHastSource.d.mts +23 -0
  161. package/pipeline/loadIsomorphicCodeVariant/decodeHastSource.mjs +92 -0
  162. package/pipeline/loadIsomorphicCodeVariant/decodeSource.d.mts +19 -0
  163. package/pipeline/loadIsomorphicCodeVariant/decodeSource.mjs +25 -0
  164. package/pipeline/loadIsomorphicCodeVariant/decodeSourceToText.d.mts +17 -0
  165. package/pipeline/loadIsomorphicCodeVariant/decodeSourceToText.mjs +26 -0
  166. package/pipeline/loadIsomorphicCodeVariant/diffHast.d.mts +26 -2
  167. package/pipeline/loadIsomorphicCodeVariant/diffHast.mjs +563 -19
  168. package/pipeline/loadIsomorphicCodeVariant/embedTransforms.d.mts +49 -0
  169. package/pipeline/loadIsomorphicCodeVariant/embedTransforms.mjs +152 -0
  170. package/pipeline/loadIsomorphicCodeVariant/findExpandingRanges.d.mts +51 -0
  171. package/pipeline/loadIsomorphicCodeVariant/findExpandingRanges.mjs +161 -0
  172. package/pipeline/loadIsomorphicCodeVariant/flattenCodeVariant.mjs +6 -3
  173. package/pipeline/loadIsomorphicCodeVariant/getAvailableTransforms.d.mts +12 -0
  174. package/pipeline/loadIsomorphicCodeVariant/getAvailableTransforms.mjs +44 -0
  175. package/pipeline/loadIsomorphicCodeVariant/getInitialVisibleSourceLines.d.mts +16 -0
  176. package/pipeline/loadIsomorphicCodeVariant/getInitialVisibleSourceLines.mjs +74 -0
  177. package/pipeline/loadIsomorphicCodeVariant/loadCodeFallback.mjs +17 -5
  178. package/pipeline/loadIsomorphicCodeVariant/loadIsomorphicCodeVariant.mjs +229 -15
  179. package/pipeline/loadIsomorphicCodeVariant/transformSource.d.mts +2 -2
  180. package/pipeline/loadIsomorphicCodeVariant/transformSource.mjs +56 -22
  181. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.mts +18 -0
  182. package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.mjs +11 -7
  183. package/pipeline/loadServerTypes/hastTypeUtils.d.mts +2 -2
  184. package/pipeline/loadServerTypes/hastTypeUtils.mjs +4 -4
  185. package/pipeline/loadServerTypes/loadServerTypes.mjs +1 -1
  186. package/pipeline/loadServerTypesMeta/extractJSDocText.d.mts +14 -0
  187. package/pipeline/loadServerTypesMeta/extractJSDocText.mjs +60 -0
  188. package/pipeline/loadServerTypesMeta/processTypes.mjs +43 -46
  189. package/pipeline/loadServerTypesText/order.mjs +1 -1
  190. package/pipeline/loadServerTypesText/parseTypesMarkdown.mjs +3 -1
  191. package/pipeline/loaderUtils/index.d.mts +0 -1
  192. package/pipeline/loaderUtils/index.mjs +0 -1
  193. package/pipeline/loaderUtils/parseImportsAndComments.d.mts +5 -1
  194. package/pipeline/loaderUtils/parseImportsAndComments.mjs +19 -9
  195. package/pipeline/loaderUtils/resolveModulePath.mjs +23 -1
  196. package/pipeline/parseCreateFactoryCall/parseCreateFactoryCall.d.mts +12 -0
  197. package/pipeline/parseCreateFactoryCall/parseCreateFactoryCall.mjs +17 -13
  198. package/pipeline/parseSource/addLineGutters.mjs +45 -11
  199. package/pipeline/parseSource/calculateFrameRanges.d.mts +22 -0
  200. package/pipeline/parseSource/calculateFrameRanges.mjs +69 -25
  201. package/pipeline/parseSource/detectGrammarScopes.d.mts +13 -0
  202. package/pipeline/parseSource/detectGrammarScopes.mjs +35 -0
  203. package/pipeline/parseSource/extendSyntaxTokens.mjs +501 -43
  204. package/pipeline/parseSource/frameVisibility.d.mts +47 -0
  205. package/pipeline/parseSource/frameVisibility.mjs +114 -0
  206. package/pipeline/parseSource/grammarCache.d.mts +33 -0
  207. package/pipeline/parseSource/grammarCache.mjs +73 -0
  208. package/pipeline/parseSource/grammarLoaders.d.mts +14 -0
  209. package/pipeline/parseSource/grammarLoaders.mjs +24 -0
  210. package/pipeline/parseSource/grammarMaps.d.mts +21 -1
  211. package/pipeline/parseSource/grammarMaps.mjs +36 -0
  212. package/pipeline/parseSource/isFrameSpan.d.mts +19 -0
  213. package/pipeline/parseSource/isFrameSpan.mjs +24 -0
  214. package/pipeline/parseSource/parseSource.d.mts +41 -6
  215. package/pipeline/parseSource/parseSource.mjs +184 -36
  216. package/pipeline/parseSource/redistributeFrameFallbacks.d.mts +40 -0
  217. package/pipeline/parseSource/redistributeFrameFallbacks.mjs +138 -0
  218. package/pipeline/parseSource/restructureFrames.d.mts +5 -0
  219. package/pipeline/parseSource/restructureFrames.mjs +179 -16
  220. package/pipeline/syncPageIndex/metadataToMarkdown.mjs +6 -2
  221. package/pipeline/transformHtmlCodeBlock/transformHtmlCodeBlock.d.mts +26 -0
  222. package/pipeline/transformHtmlCodeBlock/transformHtmlCodeBlock.mjs +181 -114
  223. package/pipeline/transformHtmlCodeInline/removeSuffixFromHighlightedNodes.d.mts +12 -0
  224. package/pipeline/transformHtmlCodeInline/removeSuffixFromHighlightedNodes.mjs +52 -0
  225. package/pipeline/transformHtmlCodeInline/transformHtmlCodeInline.mjs +22 -1
  226. package/pipeline/transformTypescriptToJavascript/removeTypes.d.mts +5 -8
  227. package/pipeline/transformTypescriptToJavascript/removeTypes.mjs +27 -93
  228. package/useCode/EditableEngine.d.mts +233 -0
  229. package/useCode/EditableEngine.mjs +1712 -0
  230. package/useCode/EditingEngine.d.mts +13 -0
  231. package/useCode/EditingEngine.mjs +14 -0
  232. package/useCode/Pre.browser.mjs +5 -1
  233. package/useCode/Pre.d.mts +127 -1
  234. package/useCode/Pre.mjs +417 -165
  235. package/useCode/SourceEditingEngine.d.mts +50 -0
  236. package/useCode/SourceEditingEngine.mjs +461 -0
  237. package/useCode/TransformEngine.d.mts +39 -0
  238. package/useCode/TransformEngine.mjs +208 -0
  239. package/useCode/editingEngineCache.d.mts +29 -0
  240. package/useCode/editingEngineCache.mjs +68 -0
  241. package/useCode/sourceLineCounts.d.mts +80 -0
  242. package/useCode/sourceLineCounts.mjs +284 -0
  243. package/useCode/subscribeToggleNudge.d.mts +3 -0
  244. package/useCode/subscribeToggleNudge.mjs +95 -0
  245. package/useCode/transformEngineCache.d.mts +21 -0
  246. package/useCode/transformEngineCache.mjs +60 -0
  247. package/useCode/useCode.d.mts +140 -1
  248. package/useCode/useCode.mjs +250 -19
  249. package/useCode/useCodeUtils.d.mts +131 -20
  250. package/useCode/useCodeUtils.mjs +267 -194
  251. package/useCode/useCopyFunctionality.d.mts +13 -1
  252. package/useCode/useCopyFunctionality.mjs +39 -9
  253. package/useCode/useEditable.browser.mjs +10 -2
  254. package/useCode/useEditable.d.mts +27 -106
  255. package/useCode/useEditable.integration.browser.d.mts +1 -0
  256. package/useCode/useEditable.integration.browser.mjs +870 -0
  257. package/useCode/useEditable.mjs +198 -1247
  258. package/useCode/useEditableUtils.d.mts +50 -1
  259. package/useCode/useEditableUtils.mjs +29 -0
  260. package/useCode/useFileNavigation.d.mts +91 -3
  261. package/useCode/useFileNavigation.mjs +201 -41
  262. package/useCode/useHighlightGate.d.mts +17 -0
  263. package/useCode/useHighlightGate.mjs +147 -0
  264. package/useCode/useSourceEditing.d.mts +8 -0
  265. package/useCode/useSourceEditing.mjs +158 -314
  266. package/useCode/useSourceEnhancing.d.mts +5 -1
  267. package/useCode/useSourceEnhancing.mjs +22 -36
  268. package/useCode/useTransformManagement.d.mts +93 -5
  269. package/useCode/useTransformManagement.mjs +496 -28
  270. package/useCode/useTransitionPhase.d.mts +24 -0
  271. package/useCode/useTransitionPhase.mjs +49 -0
  272. package/useCode/useUIState.d.mts +2 -2
  273. package/useCode/useUIState.mjs +8 -8
  274. package/useCode/useVariantSelection.d.mts +130 -6
  275. package/useCode/useVariantSelection.mjs +529 -93
  276. package/useCodeWindow/useCodeWindow.d.mts +19 -2
  277. package/useCodeWindow/useCodeWindow.mjs +98 -71
  278. package/useCoordinated/coordinatePreference.d.mts +439 -0
  279. package/useCoordinated/coordinatePreference.mjs +951 -0
  280. package/useCoordinated/coordinatePreference.testUtils.d.mts +21 -0
  281. package/useCoordinated/coordinatePreference.testUtils.mjs +69 -0
  282. package/useCoordinated/createSettleGate.d.mts +96 -0
  283. package/useCoordinated/createSettleGate.mjs +171 -0
  284. package/useCoordinated/index.d.mts +8 -0
  285. package/useCoordinated/index.mjs +8 -0
  286. package/useCoordinated/layoutShiftGate.d.mts +24 -0
  287. package/useCoordinated/layoutShiftGate.mjs +79 -0
  288. package/useCoordinated/pageSettleGate.d.mts +11 -0
  289. package/useCoordinated/pageSettleGate.mjs +13 -0
  290. package/useCoordinated/scheduleTasks.d.mts +23 -0
  291. package/useCoordinated/scheduleTasks.mjs +45 -0
  292. package/useCoordinated/useCoordinated.d.mts +193 -0
  293. package/useCoordinated/useCoordinated.mjs +469 -0
  294. package/useCoordinated/useCoordinatedLazy.d.mts +17 -0
  295. package/useCoordinated/useCoordinatedLazy.mjs +38 -0
  296. package/useCoordinated/useCoordinatedLocalStorage.d.mts +16 -0
  297. package/useCoordinated/useCoordinatedLocalStorage.mjs +22 -0
  298. package/useCoordinated/useCoordinatedPreference.d.mts +20 -0
  299. package/useCoordinated/useCoordinatedPreference.mjs +26 -0
  300. package/useCoordinated/useSettleGate.d.mts +11 -0
  301. package/useCoordinated/useSettleGate.mjs +34 -0
  302. package/useDemo/exportVariant.d.mts +12 -5
  303. package/useDemo/exportVariant.mjs +59 -5
  304. package/useDemo/useDemo.d.mts +5 -2
  305. package/useScrollAnchor/useScrollAnchor.mjs +28 -5
  306. package/useStream/index.d.mts +6 -0
  307. package/useStream/index.mjs +6 -0
  308. package/useStream/streamChunks.d.mts +23 -0
  309. package/useStream/streamChunks.mjs +85 -0
  310. package/useStream/types.d.mts +45 -0
  311. package/useStream/types.mjs +1 -0
  312. package/useStream/useStream.d.mts +57 -0
  313. package/useStream/useStream.mjs +119 -0
  314. package/useStream/useStreamController.d.mts +15 -0
  315. package/useStream/useStreamController.mjs +90 -0
  316. package/withDocsInfra/withDocsInfra.d.mts +19 -0
  317. package/withDocsInfra/withDocsInfra.mjs +13 -5
  318. package/pipeline/loaderUtils/convertCommentsToOneIndexed.d.mts +0 -8
  319. package/pipeline/loaderUtils/convertCommentsToOneIndexed.mjs +0 -16
@@ -9,17 +9,25 @@ import { useFileNavigation } from "./useFileNavigation.mjs";
9
9
  import { useUIState } from "./useUIState.mjs";
10
10
  import { useCopyFunctionality } from "./useCopyFunctionality.mjs";
11
11
  import { useSourceEditing } from "./useSourceEditing.mjs";
12
+ import { findCollapseInFocusTransforms, shouldHighlightForRender } from "./useCodeUtils.mjs";
13
+ import { findVariantFocusedLinesMismatches } from "./sourceLineCounts.mjs";
12
14
  export function useCode(contentProps, opts) {
13
15
  const {
14
16
  copy: copyOpts,
15
- defaultOpen = false,
16
17
  initialVariant,
17
18
  initialTransform,
18
19
  preClassName,
19
20
  fileHashMode = 'remove-hash',
20
21
  saveHashVariantToLocalStorage = 'on-interaction',
21
22
  sourceEnhancers,
22
- disabled
23
+ disabled,
24
+ onExpand,
25
+ transformDelay,
26
+ transformLayoutShift = 'selected',
27
+ strictCollapseInFocus = false,
28
+ variantLayoutShift = 'selected',
29
+ variantSwapDelay,
30
+ strictMatchingVariantFocusedLines = false
23
31
  } = opts || {};
24
32
 
25
33
  // Safely try to get context values - will be undefined if not in context
@@ -34,25 +42,68 @@ export function useCode(contentProps, opts) {
34
42
  // configure the baseline (e.g., `@highlight` / `@focus` framing) while
35
43
  // individual `useCode` callers add demo-specific extras without losing the
36
44
  // shared defaults.
45
+ // Hoist the optional controller member into a stable local so the memo's
46
+ // inferred dependency matches the source dependency. `useControlledCode()`
47
+ // always returns a fresh object, so `controllerContext` is never null but
48
+ // changes identity every render; depending on the narrowed value keeps the
49
+ // memo correct (and lets the compiler preserve the manual memoization).
50
+ const controllerEnhancers = controllerContext?.sourceEnhancers;
37
51
  const mergedEnhancers = React.useMemo(() => {
38
52
  const enhancers = [];
39
53
  if (codeContext.sourceEnhancers) {
40
54
  enhancers.push(...codeContext.sourceEnhancers);
41
55
  }
42
- if (controllerContext?.sourceEnhancers) {
43
- enhancers.push(...controllerContext.sourceEnhancers);
56
+ if (controllerEnhancers) {
57
+ enhancers.push(...controllerEnhancers);
44
58
  }
45
59
  if (sourceEnhancers) {
46
60
  enhancers.push(...sourceEnhancers);
47
61
  }
48
62
  return enhancers.length > 0 ? enhancers : undefined;
49
- }, [codeContext.sourceEnhancers, controllerContext?.sourceEnhancers, sourceEnhancers]);
63
+ }, [codeContext.sourceEnhancers, controllerEnhancers, sourceEnhancers]);
50
64
 
51
65
  // Get the effective code - context overrides contentProps if available
52
66
  const effectiveCode = React.useMemo(() => {
53
67
  return context?.code || contentProps.code || {};
54
68
  }, [context?.code, contentProps.code]);
55
- const shouldHighlight = !context?.deferHighlight;
69
+
70
+ // Opt-in development-time assertion: throw if any transform's
71
+ // `.collapse` placeholder would land inside the focus region. The
72
+ // check is purely a lookup against precomputed manifest flags (no
73
+ // tree walking) so it is cheap to run on every render; the memo
74
+ // ensures the actual scan only re-runs when `effectiveCode` changes.
75
+ // Fail-fast in render so demo authors notice the problem the first
76
+ // time they load the page instead of debugging a missing animation.
77
+ const collapseInFocusOffenders = React.useMemo(() => strictCollapseInFocus ? findCollapseInFocusTransforms(effectiveCode) : null, [strictCollapseInFocus, effectiveCode]);
78
+ if (collapseInFocusOffenders && collapseInFocusOffenders.length > 0) {
79
+ const first = collapseInFocusOffenders[0];
80
+ const extraCount = collapseInFocusOffenders.length - 1;
81
+ const suffix = extraCount > 0 ? ` (${extraCount} more offender(s) suppressed).` : `.`;
82
+ throw new Error(`[useCode] strictCollapseInFocus is enabled and transform "${first.transformKey}" on variant "${first.variantName}" file "${first.fileName}" introduces a .collapse placeholder inside the visible focus region. Narrow the focused area (e.g. tighten @focus/@padding markers or shrink the transform's edit range) so the placeholder lands outside the initially-visible window${suffix}`);
83
+ }
84
+
85
+ // Opt-in development-time assertion: throw if any two variants
86
+ // declare a file with the same name but disagree on
87
+ // `focusedLines`. Cheap precomputed-metadata lookup — the memo
88
+ // ensures the actual scan only re-runs when `effectiveCode`
89
+ // changes. Fail-fast in render so demo authors notice the problem
90
+ // the first time they load the page.
91
+ const variantFocusedLinesMismatches = React.useMemo(() => strictMatchingVariantFocusedLines ? findVariantFocusedLinesMismatches(effectiveCode) : null, [strictMatchingVariantFocusedLines, effectiveCode]);
92
+ if (variantFocusedLinesMismatches && variantFocusedLinesMismatches.length > 0) {
93
+ const first = variantFocusedLinesMismatches[0];
94
+ const extraCount = variantFocusedLinesMismatches.length - 1;
95
+ const suffix = extraCount > 0 ? ` (${extraCount} more mismatch(es) suppressed).` : `.`;
96
+ throw new Error(`[useCode] strictMatchingVariantFocusedLines is enabled and file "${first.fileName}" has ${first.focusedLinesA} focused line(s) in variant "${first.variantA}" but ${first.focusedLinesB} focused line(s) in variant "${first.variantB}". Align the @focus/@padding markers across variants so the collapsed window matches${suffix}`);
97
+ }
98
+
99
+ // Dev-only sanity check: `strictMatchingVariantFocusedLines` only
100
+ // protects against coordinated-barrier risk while the block is
101
+ // collapsed under `variantLayoutShift: 'focus'`. Enabling it in
102
+ // any other mode produces throws that don't correspond to a real
103
+ // layout-shift hazard, so warn the author once per render.
104
+ if (process.env.NODE_ENV !== 'production' && strictMatchingVariantFocusedLines && variantLayoutShift !== 'focus') {
105
+ console.warn(`[useCode] strictMatchingVariantFocusedLines is enabled but variantLayoutShift is "${variantLayoutShift}". The strict check only guards coordinated-barrier swaps under 'focus' mode; consider setting variantLayoutShift: 'focus' or disabling strictMatchingVariantFocusedLines.`);
106
+ }
56
107
 
57
108
  // Memoize userProps with auto-generated name and slug if missing
58
109
  const userProps = React.useMemo(() => {
@@ -63,6 +114,11 @@ export function useCode(contentProps, opts) {
63
114
  code,
64
115
  components,
65
116
  url: contentUrl,
117
+ // `collapseToEmpty` / `initialExpanded` are render-time display flags, not
118
+ // user-facing props — strip them (rest siblings) so they don't leak into
119
+ // the demo's props.
120
+ collapseToEmpty: collapseToEmptyContentProp,
121
+ initialExpanded: initialExpandedContentProp,
66
122
  ...userDefinedProps
67
123
  } = contentProps;
68
124
  // Get URL from context first, then fall back to contentProps
@@ -86,66 +142,238 @@ export function useCode(contentProps, opts) {
86
142
  };
87
143
  }, [contentProps, context?.url]);
88
144
 
145
+ // Resolve the render-time display flags. They must come from `contentProps`
146
+ // (threaded by the demo factory / `CodeHighlighter` / code transforms) rather
147
+ // than `useCode` opts: the loading fallback derives its own copy from the same
148
+ // `contentProps`, so a per-call opt would let the live render and the fallback
149
+ // disagree.
150
+ const collapseToEmpty = contentProps.collapseToEmpty === true;
151
+ const initialExpanded = contentProps.initialExpanded === true;
152
+
89
153
  // Sub-hook: UI State Management (needs slug to check for relevant hash)
90
154
  const uiState = useUIState({
91
- defaultOpen,
155
+ initialExpanded,
92
156
  mainSlug: userProps.slug
93
157
  });
94
158
 
159
+ // Lift `selectedFileName` state out of `useFileNavigation` so
160
+ // `useTransformManagement` *and* `useVariantSelection` can read it
161
+ // (selected-file-scoped `transformLayoutShift` /
162
+ // `variantLayoutShift` modes). `useFileNavigation` consumes the
163
+ // value + setter as controlled props. Initial value is resolved
164
+ // below once `useVariantSelection` has reported the initial
165
+ // variant.
166
+ const [selectedFileNameState, setSelectedFileNameState] = React.useState(undefined);
167
+
95
168
  // Sub-hook: Variant Selection
96
169
  const variantSelection = useVariantSelection({
97
170
  effectiveCode,
98
171
  initialVariant,
99
172
  variantType: contentProps.variantType,
100
173
  mainSlug: userProps.slug,
101
- saveHashVariantToLocalStorage
174
+ saveHashVariantToLocalStorage,
175
+ variantLayoutShift,
176
+ selectedFileName: selectedFileNameState,
177
+ expanded: uiState.expanded,
178
+ variantSwapDelay,
179
+ deferHighlight: context?.deferHighlight
180
+ });
181
+
182
+ // Seed the selected file name from the variant's main file the
183
+ // first time the variant resolves. Subsequent file selections come
184
+ // through `useFileNavigation`'s controlled setter. Set-state during
185
+ // render triggers one extra render on first mount; we accept that
186
+ // cost because the alternative (lazy `useState` initializer)
187
+ // requires resolving the variant key here, which depends on
188
+ // `useUrlHashState` / `usePreference` hooks that already live
189
+ // inside `useVariantSelection`. Duplicating them at this level
190
+ // would be worse than the extra render.
191
+ if (selectedFileNameState === undefined && variantSelection.selectedVariant?.fileName) {
192
+ setSelectedFileNameState(variantSelection.selectedVariant.fileName);
193
+ }
194
+
195
+ // Defer the outgoing `<Pre>` from rendering highlighted spans while
196
+ // a stored-preference bootstrap swap is known to be coming. See
197
+ // `shouldHighlightForRender` for the full rationale, including the
198
+ // `highlightAfter === 'init'` bypass that prevents a visible flash
199
+ // of unhighlighted code on first-paint variant swaps.
200
+ const shouldHighlight = shouldHighlightForRender({
201
+ deferHighlight: context?.deferHighlight,
202
+ highlightReady: context?.highlightReady,
203
+ pendingBootstrap: variantSelection.pendingBootstrap,
204
+ highlightAfter: context?.highlightAfter
102
205
  });
103
206
 
207
+ // The rendered tree should reflect the *committed* variant so the
208
+ // outgoing `<Pre>` stays put during `variantSwapDelay`. When no
209
+ // delay is configured these are always equal to `selectedVariant` /
210
+ // `selectedVariantKey`. Falling back to the pending value (rather
211
+ // than `null`) keeps the boot path — before the coordinator has
212
+ // committed for the first time — rendering the freshly-resolved
213
+ // variant instead of nothing.
214
+ const renderedVariant = variantSelection.committedVariant ?? variantSelection.selectedVariant;
215
+ const renderedVariantKey = variantSelection.committedVariantKey || variantSelection.selectedVariantKey;
216
+
104
217
  // Sub-hook: Transform Management
105
218
  const transformManagement = useTransformManagement({
106
219
  context,
107
220
  effectiveCode,
108
- selectedVariantKey: variantSelection.selectedVariantKey,
109
- selectedVariant: variantSelection.selectedVariant,
110
- initialTransform
221
+ selectedVariantKey: renderedVariantKey,
222
+ selectedVariant: renderedVariant,
223
+ initialTransform,
224
+ transformDelay,
225
+ transformLayoutShift,
226
+ selectedFileName: selectedFileNameState,
227
+ expanded: uiState.expanded
111
228
  });
112
229
 
113
230
  // Sub-hook: Source Editing
114
231
  const sourceEditing = useSourceEditing({
115
232
  context,
116
- selectedVariantKey: variantSelection.selectedVariantKey,
233
+ selectedVariantKey: renderedVariantKey,
117
234
  effectiveCode,
118
- selectedVariant: variantSelection.selectedVariant,
235
+ selectedVariant: renderedVariant,
119
236
  disabled
120
237
  });
121
238
 
239
+ // Combine the two animation phases into a single `transforming`
240
+ // attribute for `<Pre>`. Both phases share the `data-transforming`
241
+ // attribute and the `.collapse` placeholder bridge — the only
242
+ // difference is which delta drives the bridge. When both are
243
+ // simultaneously eligible (rare — a transform swap mid-variant-swap
244
+ // window) the variant phase takes precedence because the rendered
245
+ // tree just swapped variants and that's the larger visual change.
246
+ const transforming = variantSelection.variantSwappingPhase ?? transformManagement.transformingPhase;
247
+
248
+ // Route `<Pre>`'s readiness callback to whichever phase source owns
249
+ // the current animation window. Each source flips its own paused →
250
+ // active transition independently; we just forward the signal.
251
+ const variantPhaseActive = variantSelection.variantSwappingPhase !== null;
252
+ const notifyVariantTransitionReady = variantSelection.notifyVariantTransitionReady;
253
+ const notifyTransformTransitionReady = transformManagement.notifyTransformTransitionReady;
254
+ const onPreTransitionReady = React.useCallback(() => {
255
+ if (variantPhaseActive) {
256
+ notifyVariantTransitionReady();
257
+ } else {
258
+ notifyTransformTransitionReady();
259
+ }
260
+ }, [variantPhaseActive, notifyVariantTransitionReady, notifyTransformTransitionReady]);
261
+
262
+ // Defer `expand()` while a variant or transform swap is in flight,
263
+ // or while the currently-displayed variant's source is still being
264
+ // highlighted. Callers that pair `selectVariant(...)` /
265
+ // `selectTransform(...)` with `expand()` in the same tick (e.g.
266
+ // "show source of variant X" or "switch to JS then expand"
267
+ // affordances) would otherwise flip `expanded` mid-animation: the
268
+ // bridge `.collapse` placeholder switches metric (`focus` →
269
+ // `total`) and the previously-hidden rows pop in before the swap
270
+ // commits, producing a visible jump. When no `variantSwapDelay`
271
+ // is configured the swap commits synchronously, but the new
272
+ // variant's `parsedCode` is still computed asynchronously — the
273
+ // `deferHighlight` flag published by `CodeHighlighterClient`
274
+ // (true while `waitingForParsedCode`) keeps the gate engaged
275
+ // through that window too.
276
+ //
277
+ // `expand()` always queues through a `pendingExpand` state flag;
278
+ // a passive effect resolves it on every render where the composed
279
+ // `transforming` phase is `null` and `deferHighlight` is falsy
280
+ // (i.e. neither a variant/transform swap nor an async re-highlight
281
+ // is in flight). Using state (not a ref) keeps the drain reactive:
282
+ // a synchronous `expand()` triggers a render, the effect runs, and
283
+ // `setExpanded(true)` flushes in the same React batch — preserving
284
+ // the "expand is synchronous" semantics for the common case while
285
+ // naturally waiting on in-flight swaps. `setExpanded` stays direct
286
+ // so explicit controlled-state writes remain synchronous regardless
287
+ // of swap phase.
288
+ const setExpanded = uiState.setExpanded;
289
+ const swapInFlight = transforming !== null || !!context?.deferHighlight;
290
+ const [pendingExpand, setPendingExpand] = React.useState(false);
291
+ // Keep the latest `onExpand` in a ref so the stable `expand` callback below
292
+ // can call it without changing identity (it is forwarded down to `<Pre>`).
293
+ const onExpandRef = React.useRef(onExpand);
294
+ React.useLayoutEffect(() => {
295
+ onExpandRef.current = onExpand;
296
+ });
297
+ const expand = React.useCallback(() => {
298
+ // Notify the host synchronously, while the block is still collapsed, so it
299
+ // can capture the pre-expansion layout and engage a scroll anchor (the
300
+ // expansion itself is deferred below via `pendingExpand`). This mirrors the
301
+ // timing of clicking the expand toggle, where the host anchors the scroll
302
+ // before the layout changes.
303
+ onExpandRef.current?.();
304
+ setPendingExpand(true);
305
+ }, []);
306
+ React.useEffect(() => {
307
+ if (pendingExpand && !swapInFlight) {
308
+ /* eslint-disable react-hooks/set-state-in-effect -- intentional queue drain: commit deferred expand only after in-flight swaps settle (swapInFlight transitions false on a later render); see comment above re: flicker-avoidance and same-batch synchronous-expand semantics */
309
+ setPendingExpand(false);
310
+ setExpanded(true);
311
+ /* eslint-enable react-hooks/set-state-in-effect */
312
+ }
313
+ }, [pendingExpand, swapInFlight, setExpanded]);
314
+
315
+ // Partner variant whose per-file line counts feed `<Pre>`'s bridge
316
+ // computation. `null` when no variant swap is in flight (the bridge
317
+ // collapses to a no-op inside `<Pre>` either way; this lookup is a
318
+ // performance shortcut so we don't read the entire variant on every
319
+ // render).
320
+ const swapPartnerVariant = React.useMemo(() => {
321
+ if (!variantSelection.swapPartnerVariantKey) {
322
+ return null;
323
+ }
324
+ const variant = effectiveCode[variantSelection.swapPartnerVariantKey];
325
+ if (variant && typeof variant === 'object' && 'source' in variant) {
326
+ return variant;
327
+ }
328
+ return null;
329
+ }, [effectiveCode, variantSelection.swapPartnerVariantKey]);
330
+
331
+ // Bridge line-count metric should mirror variant layout-shift mode:
332
+ // only `'focus'` compares focused lines while collapsed; every other
333
+ // mode always compares total lines.
334
+ const variantBridgeLineMode = variantLayoutShift === 'focus' ? 'focus' : 'total';
335
+
122
336
  // Sub-hook: File Navigation
123
337
  const fileNavigation = useFileNavigation({
124
- selectedVariant: variantSelection.selectedVariant,
338
+ selectedVariant: renderedVariant,
125
339
  transformedFiles: transformManagement.transformedFiles,
126
340
  selectedTransform: transformManagement.selectedTransform,
127
341
  mainSlug: userProps.slug,
128
- selectedVariantKey: variantSelection.selectedVariantKey,
342
+ selectedVariantKey: renderedVariantKey,
129
343
  selectVariant: variantSelection.selectVariantProgrammatic,
130
344
  variantKeys: variantSelection.variantKeys,
131
345
  shouldHighlight,
132
346
  preClassName,
133
347
  setSource: sourceEditing.setSource,
348
+ editActivation: context?.editActivation,
349
+ onActivate: context?.onEditingActivated,
134
350
  effectiveCode,
135
351
  fileHashMode,
136
352
  saveHashVariantToLocalStorage,
137
353
  saveVariantToLocalStorage: variantSelection.saveVariantToLocalStorage,
138
354
  hashVariant: variantSelection.hashVariant,
139
355
  sourceEnhancers: mergedEnhancers,
356
+ fallbacks: context?.fallbacks,
140
357
  expanded: uiState.expanded,
141
- expand: uiState.expand
358
+ collapseToEmpty,
359
+ expand,
360
+ transforming,
361
+ onPreTransitionReady,
362
+ variantBridgeLineMode,
363
+ swapPartnerVariant,
364
+ selectedFileName: selectedFileNameState,
365
+ setSelectedFileName: setSelectedFileNameState
142
366
  });
143
367
 
144
368
  // Sub-hook: Copy Functionality
145
369
  const copyFunctionality = useCopyFunctionality({
146
370
  selectedFile: fileNavigation.selectedFile,
147
- selectedVariant: variantSelection.selectedVariant,
371
+ selectedVariant: renderedVariant,
148
372
  transformedFiles: transformManagement.transformedFiles,
373
+ // Per-file dictionaries for the active variant (decodes `hastCompressed`
374
+ // sources back to text); `selectedFileFallback` covers the single-file copy.
375
+ fallbacks: context?.fallbacks,
376
+ selectedFileFallback: fileNavigation.selectedFileFallback,
149
377
  title: userProps.name,
150
378
  copyOpts
151
379
  });
@@ -158,18 +386,21 @@ export function useCode(contentProps, opts) {
158
386
  selectedFileLines: fileNavigation.selectedFileLines,
159
387
  selectedFileName: fileNavigation.selectedFileName,
160
388
  selectedFileUrl: fileNavigation.selectedFileUrl,
389
+ selectedFileSlug: fileNavigation.selectedFileSlug,
161
390
  selectFileName: fileNavigation.selectFileName,
162
391
  allFilesSlugs: fileNavigation.allFilesSlugs,
163
392
  expanded: uiState.expanded,
164
- expand: uiState.expand,
165
- setExpanded: uiState.setExpanded,
393
+ expand,
394
+ setExpanded,
166
395
  copy: copyFunctionality.copy,
167
396
  copyMarkdown: copyFunctionality.copyMarkdown,
168
397
  availableTransforms: transformManagement.availableTransforms,
169
398
  selectedTransform: transformManagement.selectedTransform,
170
399
  selectTransform: transformManagement.selectTransform,
400
+ pendingTransform: transformManagement.pendingTransform,
171
401
  setSource: sourceEditing.setSource,
172
402
  reset: sourceEditing.reset,
403
+ refresh: context?.refresh,
173
404
  userProps
174
405
  };
175
406
  }
@@ -1,8 +1,14 @@
1
- import type { VariantSource, VariantCode, Code, Transforms } from "../CodeHighlighter/types.mjs";
2
- interface TransformedFile {
1
+ import type { VariantSource, VariantCode, Code, SourceComments } from "../CodeHighlighter/types.mjs";
2
+ export interface TransformedFile {
3
3
  name: string;
4
4
  originalName: string;
5
5
  source: VariantSource;
6
+ /**
7
+ * Comments map shifted onto the transformed source's line numbering.
8
+ * Set only when the variant supplied a `comments` map for this file;
9
+ * entries whose source line was wiped by the transform are dropped.
10
+ */
11
+ comments?: SourceComments;
6
12
  }
7
13
  export interface TransformedFiles {
8
14
  files: TransformedFile[];
@@ -12,32 +18,137 @@ export interface TransformedFiles {
12
18
  }
13
19
  /**
14
20
  * Pure function to get available transforms from effective code data.
15
- * Only includes transforms that have actual deltas (file changes), not just filename changes.
21
+ *
22
+ * Variant-level `transforms` is a manifest produced by `splitTransformsForEmbed`
23
+ * (or by the legacy `Transforms` shape with deltas, for back-compat). Only
24
+ * entries that produced a real source delta are reported here — rename-only
25
+ * entries (manifest entries with `hasDelta: false`, kept around so the
26
+ * runtime can still apply the rename based on user preference) are filtered
27
+ * out so the transform toggle stays hidden when nothing meaningful changes.
16
28
  *
17
29
  * @param effectiveCode - The effective code object containing all variants
18
30
  * @param selectedVariantKey - The currently selected variant key
19
- * @returns Array of available transform keys that have deltas
31
+ * @returns Array of available transform keys (toggle-visible only)
20
32
  */
21
33
  export declare function getAvailableTransforms(effectiveCode: Code, selectedVariantKey: string): string[];
22
34
  /**
23
- * Pure helper function to apply transform to a source file.
35
+ * Like `getAvailableTransforms` but also includes rename-only entries
36
+ * (manifest entries with `hasDelta: false`). Used by the transform
37
+ * resolution path so a stored preference can still apply a rename even
38
+ * when its toggle is hidden because no actual delta exists.
24
39
  *
25
- * @param source - The source code to transform
26
- * @param fileName - The filename for the source
27
- * @param transforms - Available transforms for this source
28
- * @param selectedTransform - The transform to apply
29
- * @returns Object with transformed source and name
40
+ * @param effectiveCode - The effective code object containing all variants
41
+ * @param selectedVariantKey - The currently selected variant key
42
+ * @returns Array of all applicable transform keys
30
43
  */
31
- export declare function applyTransformToSource(source: VariantSource, fileName: string, transforms: Transforms | undefined, selectedTransform: string): {
32
- transformedSource: VariantSource;
33
- transformedName: string;
34
- };
44
+ export declare function getApplicableTransforms(effectiveCode: Code, selectedVariantKey: string): string[];
35
45
  /**
36
- * Pure function to create transformed files from a variant and selected transform.
46
+ * Determines whether applying `transformKey` to `variant` would introduce
47
+ * `.collapse` placeholders into the rendered hast tree — i.e. whether the
48
+ * swap is layout-affecting and must run through the coordinated barrier.
49
+ *
50
+ * Reads the precomputed `hasCollapse` / `hasCollapseInFocus` flags
51
+ * stored on each transform entry by the pipeline (`diffHast` sets them
52
+ * directly, `splitTransformsForEmbed` propagates them onto the
53
+ * manifest). No tree walking or delta decompression happens at runtime.
54
+ *
55
+ * The `mode` option controls *which* file's transform entry is consulted:
56
+ *
57
+ * - `'selected'` (default) — Consults only the transform map for the
58
+ * file identified by `selectedFileName` (or `variant.transforms`
59
+ * when `selectedFileName === variant.fileName`). When
60
+ * `selectedFileName` is omitted, treats the variant's main file
61
+ * (`variant.fileName`) as the selection.
62
+ * - `'all'` — Iterates every transform map on the variant
63
+ * (`variant.transforms` + each `extraFiles[*].transforms`) and
64
+ * returns `true` if any one has `hasCollapse: true`. Useful for
65
+ * callers that render multiple files simultaneously and need to
66
+ * coordinate a swap whenever *any* file would shift.
67
+ * - `'focus'` — Like `'selected'`, but consults
68
+ * `hasCollapseInFocus` instead of `hasCollapse` whenever
69
+ * `expanded === false`. Lets consumers skip the coordinated
70
+ * barrier for transforms whose `.collapse` insertion lands
71
+ * outside the initially-visible region of a collapsed code block.
72
+ *
73
+ * Falls back to a conservative phase 1 classification for legacy
74
+ * payloads that carry `hasDelta: true` without the precomputed flag —
75
+ * i.e. transforms produced by an older build that predates
76
+ * `hasCollapse`, or constructed by a direct caller bypassing the
77
+ * pipeline. For `hasCollapseInFocus`, entries that lack the field fall
78
+ * back to the value of `hasCollapse` (matching the embed-side default).
79
+ *
80
+ * Returns `false` when every consulted entry has `hasCollapse: false`
81
+ * (or `hasCollapseInFocus: false` in focus mode while collapsed), is
82
+ * rename-only, is absent, or the variant is `null`.
83
+ *
84
+ * @param variant - The variant whose transforms to inspect.
85
+ * @param transformKey - The transform key to classify, or `null`.
86
+ * @param opts - Optional mode + selected-file + expanded context.
87
+ */
88
+ export declare function transformHasCollapsePlaceholder(variant: VariantCode | null, transformKey: string | null, opts?: {
89
+ mode?: 'all' | 'selected' | 'focus';
90
+ selectedFileName?: string | undefined;
91
+ expanded?: boolean;
92
+ }): boolean;
93
+ /**
94
+ * Description of a single transform entry that carries
95
+ * `hasCollapseInFocus: true`. Returned by
96
+ * `findCollapseInFocusTransforms` so callers can produce actionable
97
+ * error messages without re-walking the variant tree.
98
+ */
99
+ export interface CollapseInFocusOffender {
100
+ variantName: string;
101
+ fileName: string;
102
+ transformKey: string;
103
+ }
104
+ /**
105
+ * Walk every variant on `effectiveCode` and collect transform entries
106
+ * whose precomputed `hasCollapseInFocus` flag is `true` — i.e. the
107
+ * collapse placeholder introduced by the transform lands inside the
108
+ * focus region that is visible while the surrounding code block is
109
+ * un-expanded.
110
+ *
111
+ * Used by `useCode`'s `strictCollapseInFocus` option to throw with a
112
+ * pointer to the offending variant/file/transform so the demo author
113
+ * can narrow the `@focus` region (or the transform's edit range) until
114
+ * the placeholder lands outside the visible window.
115
+ *
116
+ * Walks main files (`variant.transforms`) and `extraFiles[*].transforms`.
117
+ * Returns an empty array when no entry has the flag set.
118
+ */
119
+ export declare function findCollapseInFocusTransforms(effectiveCode: Code): CollapseInFocusOffender[];
120
+ /**
121
+ * Decide whether the rendered `<Pre>` should emit highlighted spans on
122
+ * this render. Three gates compose:
123
+ *
124
+ * 1. `highlightReady` — the render-side readiness gate published by
125
+ * `CodeHighlighterClient`. `false` while the highlight trigger
126
+ * (`hydration` / `idle` / `visible`) hasn't fired yet *or* the
127
+ * sync `parseCode` pass hasn't resolved. The precomputed HAST on
128
+ * the published `code` would render highlighted spans on first
129
+ * paint otherwise — defeating the deferred trigger. Treated as
130
+ * `true` when undefined so legacy/test consumers without a
131
+ * surrounding context default to rendering highlighted.
132
+ * 2. `deferHighlight` — the narrower pipeline-level signal published
133
+ * while the incoming variant's parse / transform deltas are still
134
+ * in flight. Always wins: if the tree isn't ready, highlighting
135
+ * can't happen.
136
+ * 3. `pendingBootstrap` — set while a stored-preference variant swap
137
+ * is queued behind the initial mount. Suppresses the *outgoing*
138
+ * tree's highlighting so we don't burn cycles painting spans the
139
+ * user is about to swap away from.
37
140
  *
38
- * @param selectedVariant - The currently selected variant
39
- * @param selectedTransform - The transform to apply
40
- * @returns Object with transformed files and filename mapping, or undefined if no transform
141
+ * The bootstrap gate is skipped when `highlightAfter === 'init'`:
142
+ * - the precomputed HAST already carries the spans (no "wasted work"),
143
+ * and
144
+ * - leaving it on causes the *incoming* variant to render as plain
145
+ * text for the render between `pendingBootstrap` flipping and the
146
+ * bootstrap commit landing, producing a visible flash of unhighlighted
147
+ * code on first-paint variant swaps.
41
148
  */
42
- export declare function createTransformedFiles(selectedVariant: VariantCode | null, selectedTransform: string | null): TransformedFiles | undefined;
43
- export {};
149
+ export declare function shouldHighlightForRender(args: {
150
+ deferHighlight: boolean | undefined;
151
+ highlightReady?: boolean | undefined;
152
+ pendingBootstrap: boolean;
153
+ highlightAfter: 'init' | 'hydration' | 'idle' | undefined;
154
+ }): boolean;