@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
@@ -0,0 +1,127 @@
1
+ import * as React from 'react';
2
+ import { buildChunkRenderInputs } from "./buildChunkRenderInputs.mjs";
3
+ import { resolveChunkRender } from "./resolveChunkRender.mjs";
4
+ import { ChunkServerLoader } from "./ChunkServerLoader.mjs";
5
+ import { CoordinatedLazyClient } from "./CoordinatedLazyClient.mjs";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ function RenderNull() {
8
+ return null;
9
+ }
10
+
11
+ /**
12
+ * Build a self-loading {@link CoordinatedLazy} component. The returned component
13
+ * is **isomorphic**: per render it evaluates {@link buildChunkRenderInputs} and
14
+ * routes via `resolveChunkRender`, so one component covers build, server,
15
+ * and client loading, and server or client rendering:
16
+ *
17
+ * - **content** (preloaded/controlled) - renders `ChunkContent` directly, so
18
+ * build-precomputed data lands in the server HTML. `ChunkContent` may be a
19
+ * server OR client component here.
20
+ * - **server-loader / server-initial** - renders the server `ChunkServerLoader`
21
+ * under a Suspense boundary (server `Loader`/`InitialLoader` or a server-side
22
+ * `data`-mode load), so content loads and renders on the server and streams
23
+ * in. Requires a server (RSC) render context; supports server-component content.
24
+ * - **client modes** (async/initial/null) - delegates to the `'use client'`
25
+ * {@link CoordinatedLazyClient}, which loads on the client and swaps the
26
+ * fallback to content. `ChunkContent` here must be a client component.
27
+ *
28
+ * The client-mode branch hands the (function-bearing) `config` to a `'use client'`
29
+ * component, so a client-loaded chunk must render inside a client subtree - call
30
+ * `createCoordinatedLazy` from a client module, or wrap it in a client provider
31
+ * (e.g. `abstractCreateStream`'s `ClientProvider`). Server-loaded and
32
+ * preloaded/precomputed chunks have no such constraint - they render entirely on
33
+ * the server path.
34
+ *
35
+ * The user's generic props `T` flow through to both components; `data` (type
36
+ * `P`) is the loaded value (or the initial value while loading). Use it
37
+ * standalone for any deferred piece (a demo, a chart, a code frame); `useStream`
38
+ * renders a streamed list of them.
39
+ */
40
+ export function createCoordinatedLazy(config) {
41
+ const ChunkContent = config.ChunkContent;
42
+ const ChunkLoading = config.ChunkLoading ?? RenderNull;
43
+ function CoordinatedLazyContent(props) {
44
+ const decision = resolveChunkRender(buildChunkRenderInputs(config, props));
45
+ const userProps = props.userProps ?? {};
46
+
47
+ // Render the content directly so it is part of the server HTML (no framework
48
+ // swap):
49
+ // - `content` (loaded/precomputed/controlled): settled, not loading.
50
+ // - `content-initial`: the initial paint is in hand and there is no full
51
+ // loader, so render the content from the initial (still `loading`). The
52
+ // content owns any further client-side load + swap itself.
53
+ if (decision.mode === 'content' || decision.mode === 'content-initial') {
54
+ // Spreading the generic `T` alongside fixed fields needs an assertion; the
55
+ // shape matches `ChunkContentProps<T, P>`.
56
+ const contentProps = {
57
+ ...userProps,
58
+ data: props.preloaded,
59
+ loading: decision.loading
60
+ };
61
+ return /*#__PURE__*/_jsx(ChunkContent, {
62
+ ...contentProps
63
+ });
64
+ }
65
+
66
+ // Server load (server `Loader`/`InitialLoader` or a server-side `data` load).
67
+ // `ChunkServerLoader` is a plain async component; this branch is taken only
68
+ // when a server loader is configured.
69
+ if (decision.mode === 'server-loader' || decision.mode === 'server-initial') {
70
+ const serverLoader = /*#__PURE__*/_jsx(ChunkServerLoader, {
71
+ config: config,
72
+ props: props,
73
+ initial: decision.mode === 'server-initial'
74
+ });
75
+ // `awaitServerLoad` blocks the server render on the loader (no Suspense) so
76
+ // its content lands in the initial HTML; otherwise stream a fallback.
77
+ if (props.awaitServerLoad) {
78
+ return serverLoader;
79
+ }
80
+ const loadingProps = {
81
+ ...userProps,
82
+ data: props.preloaded,
83
+ loading: true
84
+ };
85
+ return /*#__PURE__*/_jsx(React.Suspense, {
86
+ fallback: /*#__PURE__*/_jsx(ChunkLoading, {
87
+ ...loadingProps
88
+ }),
89
+ children: serverLoader
90
+ });
91
+ }
92
+
93
+ // Client-driven mode (attempt-initial-client, or a forceClient opt-out).
94
+ // When the content manages its own client load + swap, render it directly
95
+ // (loading) rather than wrapping it in the framework's load+swap, so it is
96
+ // not double-swapped.
97
+ if (config.contentManagesSwap) {
98
+ const contentProps = {
99
+ ...userProps,
100
+ data: props.preloaded,
101
+ loading: true
102
+ };
103
+ return /*#__PURE__*/_jsx(ChunkContent, {
104
+ ...contentProps
105
+ });
106
+ }
107
+
108
+ // Otherwise load on the client and swap via the framework. Strip the
109
+ // server-only loader functions (`source`/`Loader`/`InitialLoader`) so they can
110
+ // never be serialized into the 'use client' `CoordinatedLazyClient` - the RSC
111
+ // "Functions cannot be passed to Client Components" guard, enforced by its
112
+ // `ClientChunkConfig` param. A client-loaded chunk gets its source from a
113
+ // surrounding `ChunkProvider` instead.
114
+ const {
115
+ source,
116
+ Loader,
117
+ InitialLoader,
118
+ ...clientConfig
119
+ } = config;
120
+ return /*#__PURE__*/_jsx(CoordinatedLazyClient, {
121
+ config: clientConfig,
122
+ props: props
123
+ });
124
+ }
125
+ CoordinatedLazyContent.displayName = 'CoordinatedLazyContent';
126
+ return CoordinatedLazyContent;
127
+ }
@@ -0,0 +1,14 @@
1
+ export { CoordinatedLazy } from "./CoordinatedLazy.mjs";
2
+ export { createCoordinatedLazy } from "./createCoordinatedLazy.mjs";
3
+ export { useChunk } from "./useChunk.mjs";
4
+ export { useCoordinatedSwap } from "./useCoordinatedSwap.mjs";
5
+ export { useCoordinatedFallback } from "./useCoordinatedFallback.mjs";
6
+ export { LazyContent } from "./LazyContent.mjs";
7
+ export { LazyContentServer } from "./LazyContentServer.mjs";
8
+ export { ChunkServerLoader } from "./ChunkServerLoader.mjs";
9
+ export { resolveChunkRender } from "./resolveChunkRender.mjs";
10
+ export { CoordinatedFallbackContext } from "./CoordinatedFallbackContext.mjs";
11
+ export { CoordinatedContentContext, useCoordinatedContent } from "./CoordinatedContentContext.mjs";
12
+ export { CoordinatedGateContext, useCoordinatedGate } from "./CoordinatedGateContext.mjs";
13
+ export type { UseChunkResult } from "./useChunk.mjs";
14
+ export type { CoordinatedLazyProps, CoordinatedFallbackContextValue, CoordinatedContentContextValue, UseCoordinatedFallbackResult, UseCoordinatedSwapOptions, UseCoordinatedSwapResult, ChunkContentProps, ChunkLoadingProps, ChunkComponentProps, StreamSource, StreamUrlsResult, ChunkSwapConfig, CreateChunkConfig, IsLoaded, IsInitial, ChunkRenderMode, ChunkRenderInputs, ChunkRenderDecision, LazyContentProps, LazyComponentImport } from "./types.mjs";
@@ -0,0 +1,18 @@
1
+ // The coordinated fallback<->content swap, plus the self-loading factory built
2
+ // on it: `createCoordinatedLazy` produces one deferred piece (a demo, a chart, a
3
+ // code frame). To stream a _list_ of pieces in on the client, use the separate
4
+ // `@mui/internal-docs-infra/useStream` export. The server render functions
5
+ // (`ChunkServerLoader`, `LazyContentServer`) are plain async components with no
6
+ // Node-only imports, so they ship from this same entry - inert on the client.
7
+ export { CoordinatedLazy } from "./CoordinatedLazy.mjs";
8
+ export { createCoordinatedLazy } from "./createCoordinatedLazy.mjs";
9
+ export { useChunk } from "./useChunk.mjs";
10
+ export { useCoordinatedSwap } from "./useCoordinatedSwap.mjs";
11
+ export { useCoordinatedFallback } from "./useCoordinatedFallback.mjs";
12
+ export { LazyContent } from "./LazyContent.mjs";
13
+ export { LazyContentServer } from "./LazyContentServer.mjs";
14
+ export { ChunkServerLoader } from "./ChunkServerLoader.mjs";
15
+ export { resolveChunkRender } from "./resolveChunkRender.mjs";
16
+ export { CoordinatedFallbackContext } from "./CoordinatedFallbackContext.mjs";
17
+ export { CoordinatedContentContext, useCoordinatedContent } from "./CoordinatedContentContext.mjs";
18
+ export { CoordinatedGateContext, useCoordinatedGate } from "./CoordinatedGateContext.mjs";
@@ -0,0 +1,26 @@
1
+ import type { ChunkRenderDecision, ChunkRenderInputs } from "./types.mjs";
2
+ /**
3
+ * Pure render-decision for a chunk. Given already-evaluated inputs (so it is
4
+ * decoupled from the config shape and the `isLoaded`/`isInitial` predicate
5
+ * signatures), picks which branch to render.
6
+ *
7
+ * The key distinction is between *having* a paint and *fetching* one:
8
+ *
9
+ * - `isLoaded` -> the full content is in hand -> render it (not loading).
10
+ * - `isInitial` -> the **initial paint is already in hand** (but not the full
11
+ * content). The initial is the fallback, so we never fetch another one; we
12
+ * load the full content behind it (a server loader: `Loader` or a data
13
+ * `source.load`), or, when there is none, render the content directly and let
14
+ * it own the client swap (`content-initial`).
15
+ * - otherwise (no paint in hand at all) -> render a quick initial first on the
16
+ * server (server `InitialLoader` or data `source.initial`), else load the full
17
+ * on the server, else let the client attempt it (loading via a `ChunkProvider`).
18
+ *
19
+ * The loader functions on the config (`source`/`Loader`/`InitialLoader`) all run
20
+ * on the SERVER (`buildChunkRenderInputs` folds a `data`-mode `source` into the
21
+ * server flags), so a source never produces a client mode; `attempt-initial-client`
22
+ * is reached only when no server provider applies, and it loads from a
23
+ * `ChunkProvider` source on the client. `isLoaded` wins over everything; a quick
24
+ * initial wins over the full load so the user sees something fast.
25
+ */
26
+ export declare function resolveChunkRender(inputs: ChunkRenderInputs): ChunkRenderDecision;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Pure render-decision for a chunk. Given already-evaluated inputs (so it is
3
+ * decoupled from the config shape and the `isLoaded`/`isInitial` predicate
4
+ * signatures), picks which branch to render.
5
+ *
6
+ * The key distinction is between *having* a paint and *fetching* one:
7
+ *
8
+ * - `isLoaded` -> the full content is in hand -> render it (not loading).
9
+ * - `isInitial` -> the **initial paint is already in hand** (but not the full
10
+ * content). The initial is the fallback, so we never fetch another one; we
11
+ * load the full content behind it (a server loader: `Loader` or a data
12
+ * `source.load`), or, when there is none, render the content directly and let
13
+ * it own the client swap (`content-initial`).
14
+ * - otherwise (no paint in hand at all) -> render a quick initial first on the
15
+ * server (server `InitialLoader` or data `source.initial`), else load the full
16
+ * on the server, else let the client attempt it (loading via a `ChunkProvider`).
17
+ *
18
+ * The loader functions on the config (`source`/`Loader`/`InitialLoader`) all run
19
+ * on the SERVER (`buildChunkRenderInputs` folds a `data`-mode `source` into the
20
+ * server flags), so a source never produces a client mode; `attempt-initial-client`
21
+ * is reached only when no server provider applies, and it loads from a
22
+ * `ChunkProvider` source on the client. `isLoaded` wins over everything; a quick
23
+ * initial wins over the full load so the user sees something fast.
24
+ */
25
+ export function resolveChunkRender(inputs) {
26
+ const {
27
+ isLoaded,
28
+ isInitial,
29
+ hasServerInitial,
30
+ hasServerLoader
31
+ } = inputs;
32
+ if (isLoaded) {
33
+ return {
34
+ mode: 'content',
35
+ loading: false
36
+ };
37
+ }
38
+
39
+ // The initial paint is already in hand: it is the fallback. Load the full
40
+ // content behind it on the server, or render the content (loading) and let it
41
+ // own the swap.
42
+ if (isInitial) {
43
+ if (hasServerLoader) {
44
+ return {
45
+ mode: 'server-loader',
46
+ loading: true
47
+ };
48
+ }
49
+ return {
50
+ mode: 'content-initial',
51
+ loading: true
52
+ };
53
+ }
54
+
55
+ // Nothing in hand: render a quick initial on the server if we can, else load
56
+ // the full on the server, else let the client attempt it.
57
+ if (hasServerInitial) {
58
+ return {
59
+ mode: 'server-initial',
60
+ loading: true
61
+ };
62
+ }
63
+ if (hasServerLoader) {
64
+ return {
65
+ mode: 'server-loader',
66
+ loading: true
67
+ };
68
+ }
69
+ return {
70
+ mode: 'attempt-initial-client',
71
+ loading: true
72
+ };
73
+ }
@@ -0,0 +1,408 @@
1
+ import type * as React from 'react';
2
+ import type { SettleGate } from "../useCoordinated/createSettleGate.mjs";
3
+ /**
4
+ * Provided by a {@link CoordinatedLazy} to its fallback subtree while the
5
+ * fallback is shown. Carries the upward hoist channel and the
6
+ * nested-suppression flag. Generalizes `CodeHighlighterFallbackContext`
7
+ * (`{ extraVariants, setFallbackHasts, onHookCalled }`).
8
+ */
9
+ export interface CoordinatedFallbackContextValue {
10
+ /**
11
+ * Hoist a keyed value up to the swap so it can be folded into the consumer's
12
+ * `ready` decision and handed down to the full content via
13
+ * {@link CoordinatedContentContextValue}. Generalizes `setFallbackHasts`.
14
+ */
15
+ hoist?: (key: string, value: unknown) => void;
16
+ /**
17
+ * Signal that the fallback's hoist hook ran. The generic swap force-mounts
18
+ * the fallback on its own, so this is optional - consumers (e.g.
19
+ * `CodeHighlighter`) use it to validate that the loading component wired its
20
+ * hoist hook. Generalizes `onHookCalled`.
21
+ */
22
+ onReady?: () => void;
23
+ /**
24
+ * `true` when this instance is nested inside an outer `CoordinatedLazy` still
25
+ * showing its own fallback. The inner stays in fallback while set, collapsing
26
+ * a "fallback -> content -> fallback -> content" flicker into one transition.
27
+ * Generalizes `isNestedInsideOuterFallback`.
28
+ */
29
+ isNested?: boolean;
30
+ /** Arbitrary parent->fallback data (generalizes `extraVariants`). */
31
+ data?: Record<string, unknown>;
32
+ }
33
+ /**
34
+ * The data the fallback hoisted, handed down to the full content so it can use
35
+ * what the fallback fetched (e.g. a DEFLATE dictionary). Read via
36
+ * {@link useCoordinatedContent}.
37
+ */
38
+ export interface CoordinatedContentContextValue {
39
+ hoisted: Record<string, unknown>;
40
+ /**
41
+ * The content calls this once it has loaded (its dynamic import resolved), so
42
+ * the swap can register readiness with the settle gate. Used by `LazyContent`.
43
+ */
44
+ reportReady?: () => void;
45
+ /**
46
+ * The loading fallback to show *while a dynamically-imported content loads*.
47
+ * After the swap reveals the content, a `LazyContent` shows this as its own
48
+ * Suspense fallback during the `import()` - so the same placeholder the swap
49
+ * showed keeps covering the load, with no empty flash. Generalizes "hand the
50
+ * `ContentLoading` to the lazy content".
51
+ */
52
+ fallback?: React.ReactNode;
53
+ }
54
+ /** Result of {@link useCoordinatedFallback}. */
55
+ export interface UseCoordinatedFallbackResult {
56
+ /** Parent->fallback data provided via {@link CoordinatedFallbackContextValue.data}. */
57
+ data?: Record<string, unknown>;
58
+ /** Whether this fallback's `CoordinatedLazy` is nested inside an outer, still-loading one. */
59
+ isNested: boolean;
60
+ }
61
+ /** Options for {@link useCoordinatedSwap}. */
62
+ export interface UseCoordinatedSwapOptions {
63
+ /** Whether the content's data is ready to display. */
64
+ ready: boolean;
65
+ /** Hold the swap while real async work is still in flight even though `ready`. */
66
+ defer?: boolean;
67
+ /**
68
+ * Hold the settle gate open WITHOUT re-showing the fallback - the content stays
69
+ * rendered while the page-wide coordination waits. Unlike `defer` (which holds
70
+ * the rendered fallback), this only affects gate registration, for content that
71
+ * has swapped in but is still finishing deferred work it gates internally (e.g.
72
+ * the code highlighter rendering plain text, then highlighting in place).
73
+ */
74
+ holdGate?: boolean;
75
+ /** Whether a fallback element exists to show. */
76
+ hasFallback: boolean;
77
+ /** Skip the fallback entirely. */
78
+ skipFallback?: boolean;
79
+ /** Additionally hold the swap until the fallback hoists at least once. */
80
+ requireHoist?: boolean;
81
+ /**
82
+ * Hold the swap until the content reports it has loaded. The consumer mounts
83
+ * the content (e.g. a `LazyContent`) while the fallback is shown so it can
84
+ * load in the background, returning `null` until ready and then calling the
85
+ * content context's `reportReady` - so a code-split content component loads
86
+ * behind the placeholder and reveals only once its chunk has arrived.
87
+ */
88
+ awaitContent?: boolean;
89
+ /**
90
+ * Settle gate to register this swap with. When omitted, the ambient gate from
91
+ * a surrounding coordinator (e.g. the `useStream` controller, via
92
+ * {@link CoordinatedGateContext}) is used instead. The page-global gate is
93
+ * always registered on top of either, so a page-wide coordinated commit waits
94
+ * for the swap regardless.
95
+ */
96
+ gate?: SettleGate;
97
+ /** Arbitrary parent->fallback data exposed via the fallback context. */
98
+ data?: Record<string, unknown>;
99
+ /**
100
+ * Fired as soon as the fallback hoists data, with the hoisted map. Lets the
101
+ * consumer kick off dynamic `import()`s of heavy helpers it can tell from the
102
+ * data it will need - in parallel with loading the full content, instead of
103
+ * the content mounting and then requesting them in a serial roundtrip. Should
104
+ * be idempotent (the module cache dedups within a graph); cross-instance
105
+ * dedup is the layout provider's job.
106
+ */
107
+ preload?: (hoisted: Record<string, unknown>) => void;
108
+ }
109
+ /** Result of {@link useCoordinatedSwap}. */
110
+ export interface UseCoordinatedSwapResult {
111
+ /** Whether the fallback branch should mount this render. */
112
+ showFallback: boolean;
113
+ /** Context value to provide to the fallback subtree. */
114
+ fallbackContext: CoordinatedFallbackContextValue;
115
+ /** Data hoisted up from the fallback so far, keyed. */
116
+ hoisted: Record<string, unknown>;
117
+ /** `true` while the fallback is being shown. */
118
+ loading: boolean;
119
+ /** In `awaitContent` mode, whether the content has reported it loaded. */
120
+ contentReady: boolean;
121
+ /** Passed to the content (via the content context) so it can report it loaded. */
122
+ reportContentReady: () => void;
123
+ /**
124
+ * Hoist a keyed value up to the swap directly (the same channel the fallback's
125
+ * `useCoordinatedFallback` uses). Lets the consumer populate the hoisted map
126
+ * from outside the fallback subtree - e.g. a client-loaded data path that has
127
+ * no fallback mounted but still needs to feed the hoisted dictionary.
128
+ */
129
+ hoist: (key: string, value: unknown) => void;
130
+ }
131
+ /** Props for {@link CoordinatedLazy}. */
132
+ export interface CoordinatedLazyProps {
133
+ /** Full content, shown after the swap. Pre-rendered on the server. */
134
+ content: React.ReactNode;
135
+ /** Loading placeholder; force-mounted once so its hoist hook runs. */
136
+ fallback?: React.ReactNode;
137
+ /** Whether the content's data is ready to display. */
138
+ ready: boolean;
139
+ /** Hold the swap while real async work is in flight even though `ready`. */
140
+ defer?: boolean;
141
+ /**
142
+ * Hold the settle gate open without re-showing the fallback (content stays
143
+ * rendered). See {@link UseCoordinatedSwapOptions.holdGate}.
144
+ */
145
+ holdGate?: boolean;
146
+ /** Skip the fallback entirely. */
147
+ skipFallback?: boolean;
148
+ /** Hold the swap until the fallback hoists at least once. */
149
+ requireHoist?: boolean;
150
+ /**
151
+ * Hold the swap until the content reports it has loaded, mounting the content
152
+ * behind the fallback so a code-split (e.g. `LazyContent`) content can load in
153
+ * the background and reveal only once its chunk has arrived. See
154
+ * {@link UseCoordinatedSwapOptions.awaitContent}.
155
+ */
156
+ awaitContent?: boolean;
157
+ /**
158
+ * Settle gate to register this swap with. When omitted, the ambient gate from
159
+ * a surrounding coordinator (e.g. the `useStream` controller, via
160
+ * {@link CoordinatedGateContext}) is used instead. The page-global gate is
161
+ * always registered on top of either, so a page-wide coordinated commit waits
162
+ * for the swap regardless.
163
+ */
164
+ gate?: SettleGate;
165
+ /** Arbitrary parent->fallback data exposed to the fallback subtree. */
166
+ data?: Record<string, unknown>;
167
+ /**
168
+ * Speculative preload hook. See {@link UseCoordinatedSwapOptions.preload}:
169
+ * fired with the hoisted data so the consumer can start dynamic imports of
170
+ * helpers in parallel with loading the full content.
171
+ */
172
+ preload?: (hoisted: Record<string, unknown>) => void;
173
+ }
174
+ /**
175
+ * A dynamic import of a component, in the standard `() => import('./X')` shape.
176
+ * The imported module's `default` export is the component. The component may be
177
+ * authored as a server OR client component: on the client it is only ever
178
+ * rendered when the consumer routed to the client path, and a server-only
179
+ * component should resolve (via a conditional export) to a client stub that
180
+ * throws if rendered - so importing it is harmless, only execution is guarded.
181
+ */
182
+ export type LazyComponentImport<T> = () => Promise<{
183
+ default: React.ComponentType<T>;
184
+ }>;
185
+ /**
186
+ * Props the full chunk content receives. Mirrors `ContentProps<T>`: the user's
187
+ * generic props `T` are merged in, plus the resolved `data` (of type `P`) and a
188
+ * `loading` flag (`false` once the full data is in).
189
+ */
190
+ export type ChunkContentProps<T extends {} = {}, P = unknown> = {
191
+ data?: P;
192
+ loading: boolean;
193
+ /**
194
+ * Re-run the chunk's `data`-mode loader and swap in fresh data, keeping the
195
+ * current data visible meanwhile (stale-while-revalidate). Client-only; a
196
+ * no-op for non-`data` sources. Provided by the framework's client renderer.
197
+ */
198
+ refresh?: () => Promise<void>;
199
+ /** `true` while a background refresh is in flight (the current data stays). */
200
+ revalidating?: boolean;
201
+ } & T;
202
+ /**
203
+ * Props the loading placeholder receives. Mirrors `ContentLoadingProps<T>`:
204
+ * `loading` is always `true`, and `data` carries whatever initial/preloaded
205
+ * value is available (of type `P`).
206
+ */
207
+ export type ChunkLoadingProps<T extends {} = {}, P = unknown> = {
208
+ data?: P;
209
+ loading: true;
210
+ } & T;
211
+ /** Decide whether the preloaded value is enough to render the full content. */
212
+ export type IsLoaded<P = unknown> = (preloaded: P | undefined) => boolean;
213
+ /** Decide whether the preloaded value is enough to render the initial state. */
214
+ export type IsInitial<P = unknown> = (preloaded: P | undefined) => boolean;
215
+ /**
216
+ * Result of a `urls`-mode loader: the chunk URLs to load individually, rather
217
+ * than the data itself. `lastChunk` marks the final URL for last-chunk
218
+ * completion when the total isn't known up front.
219
+ */
220
+ export interface StreamUrlsResult {
221
+ chunks: URL[];
222
+ lastChunk?: boolean;
223
+ }
224
+ /**
225
+ * Where a chunk's data comes from - a **discriminated union** on `mode`, so
226
+ * each strategy is strongly typed with no overloads or runtime return-type
227
+ * sniffing:
228
+ *
229
+ * - `'data'` - load the chunk's data directly (optionally with a quick
230
+ * `initial` value first).
231
+ * - `'urls'` - split into per-chunk URLs (`loadUrls`), then load each URL's
232
+ * data (`loadChunk`); supports an initial pass.
233
+ * - `'stream'` - push chunks into the passed array over time and `yield` after
234
+ * each, for progressive reveal (the generator's return is the last-chunk
235
+ * signal).
236
+ */
237
+ export type StreamSource<P = unknown, O = unknown> = {
238
+ mode: 'data';
239
+ /** Load the chunk's full data. */
240
+ load: (options: O, signal: AbortSignal) => Promise<P>;
241
+ /** Optional quick initial value rendered before the full load resolves. */
242
+ initial?: (options: O) => P;
243
+ } | {
244
+ mode: 'urls';
245
+ /** Resolve the per-chunk URLs (not the data) for the full content. */
246
+ loadUrls: (options: O, signal: AbortSignal) => Promise<StreamUrlsResult>;
247
+ /** Load one chunk's data from its URL. */
248
+ loadChunk: (url: URL, options: O, signal: AbortSignal) => Promise<P>;
249
+ /** Optional initial URL set for a quick first paint. */
250
+ initialUrls?: (options: O) => StreamUrlsResult;
251
+ /** Optional initial loader for a single chunk URL. */
252
+ initialChunk?: (url: URL, options: O) => P;
253
+ } | {
254
+ mode: 'stream';
255
+ /**
256
+ * Push chunks into `chunks` and `yield` after each; returning ends the
257
+ * stream (last-chunk completion). Runs on the client (incremental
258
+ * `setState`) and as the isomorphic driver the server awaits.
259
+ */
260
+ stream: (chunks: P[], options: O, signal: AbortSignal) => AsyncGenerator<void, void, void>;
261
+ };
262
+ /** Swap timing forwarded to the underlying `CoordinatedLazy`. */
263
+ export interface ChunkSwapConfig {
264
+ defer?: boolean;
265
+ requireHoist?: boolean;
266
+ channelKey?: string | null;
267
+ }
268
+ /** Configuration for {@link createCoordinatedLazy}. */
269
+ export interface CreateChunkConfig<T extends {} = {}, P = unknown, O = unknown> {
270
+ /** The full content component. */
271
+ ChunkContent: React.ComponentType<ChunkContentProps<T, P>>;
272
+ /** The loading placeholder. Defaults to a component that renders `null`. */
273
+ ChunkLoading?: React.ComponentType<ChunkLoadingProps<T, P>>;
274
+ /** Whether the preloaded value suffices for the full content. */
275
+ isLoaded?: IsLoaded<P>;
276
+ /** Whether the preloaded value suffices for the initial state. */
277
+ isInitial?: IsInitial<P>;
278
+ /**
279
+ * Data source (discriminated by `mode`). Its loader functions run **on the
280
+ * server only** - a `data`-mode source is executed by `ChunkServerLoader`
281
+ * (`source.load` for the full content, `source.initial` for a quick streamed
282
+ * paint) and never serialized into a Client Component. To load on the *client*,
283
+ * supply the source through a {@link ChunkProvider} (which lazily imports it)
284
+ * rather than this field. (Calling `useChunk` directly inside your own client
285
+ * component with a `source` is still fine - no server/client boundary is
286
+ * crossed there.)
287
+ */
288
+ source?: StreamSource<P, O>;
289
+ /**
290
+ * Server component rendered (under Suspense) to produce the full content.
291
+ * Always dynamically imported, and only imported when the render decision
292
+ * routes to it - so it never reaches the client bundle.
293
+ */
294
+ Loader?: LazyComponentImport<ChunkContentProps<T, P>>;
295
+ /** Server component rendered (under Suspense) to produce the initial state. */
296
+ InitialLoader?: LazyComponentImport<ChunkContentProps<T, P>>;
297
+ /** Swap timing forwarded to `CoordinatedLazy`. */
298
+ swap?: ChunkSwapConfig;
299
+ /** Default options passed to the source loaders. */
300
+ loaderOptions?: O;
301
+ /**
302
+ * The `ChunkContent` component performs its own client-side loading and
303
+ * fallback->content swap. When set, the client-driven render modes render
304
+ * `ChunkContent` directly (with `loading: true`) instead of wrapping it in the
305
+ * framework's {@link useChunk}+swap (`CoordinatedLazyClient`) - so a
306
+ * self-managing content (e.g. one already built on `useCoordinatedSwap`) is not
307
+ * double-swapped. Server and content/`content-initial` modes are unaffected.
308
+ */
309
+ contentManagesSwap?: boolean;
310
+ /**
311
+ * Opt into stale-while-revalidate: once the chunk has loaded, automatically
312
+ * re-run the loader once on the first idle period (via `requestIdleCallback`)
313
+ * to refresh potentially-stale data in the background. Client-only. The chunk
314
+ * keeps showing its current data while the refresh is in flight.
315
+ */
316
+ revalidateOnIdle?: boolean;
317
+ }
318
+ /**
319
+ * The chunk config without the server-only loader functions
320
+ * (`source`/`Loader`/`InitialLoader`). This is what the `'use client'`
321
+ * {@link CoordinatedLazyClient} accepts: `createCoordinatedLazy` strips those
322
+ * fields before constructing the client element, so the type system guarantees
323
+ * no loader function is ever serialized across the server/client boundary. A
324
+ * client-loaded chunk gets its source from a {@link ChunkProvider} in context,
325
+ * not from this config.
326
+ */
327
+ export type ClientChunkConfig<T extends {} = {}, P = unknown, O = unknown> = Omit<CreateChunkConfig<T, P, O>, 'source' | 'Loader' | 'InitialLoader'>;
328
+ /** The branch of the render decision that applies for a chunk. */
329
+ export type ChunkRenderMode = 'content' | 'content-initial' | 'server-initial' | 'server-loader' | 'attempt-initial-client';
330
+ /** Already-evaluated inputs to `resolveChunkRender` (decoupled from config shape). */
331
+ export interface ChunkRenderInputs {
332
+ /** Evaluated `isLoaded(preloaded)` (or the controlled override). */
333
+ isLoaded: boolean;
334
+ /** Evaluated `isInitial(preloaded)`. */
335
+ isInitial: boolean;
336
+ /** A server initial is configured: an `InitialLoader`, or a `data`-mode `source.initial`. */
337
+ hasServerInitial: boolean;
338
+ /** A server full loader is configured: a `Loader`, or a `data`-mode `source.load`. */
339
+ hasServerLoader: boolean;
340
+ }
341
+ /** Result of `resolveChunkRender`. */
342
+ export interface ChunkRenderDecision {
343
+ mode: ChunkRenderMode;
344
+ loading: boolean;
345
+ }
346
+ /** Props accepted by the component returned from {@link createCoordinatedLazy}. */
347
+ export interface ChunkComponentProps<T extends {} = {}, P = unknown, O = unknown> {
348
+ /** Build-time/precomputed value for this chunk. */
349
+ preloaded?: P;
350
+ /** Authoritative/controlled value: render content directly, never the loaders. */
351
+ controlled?: boolean;
352
+ /**
353
+ * Force client-side rendering: ignore the server `Loader`/`InitialLoader` for
354
+ * this render so the decision routes to a content/client branch instead. Lets
355
+ * a consumer that *configures* server loaders statically opt out of them
356
+ * per-render (e.g. when no server loading functions are available, or the
357
+ * caller explicitly wants the client to drive). Has no effect once
358
+ * `isLoaded`/`controlled` already render the content.
359
+ */
360
+ forceClient?: boolean;
361
+ /**
362
+ * Per-render override for the `isInitial` decision input (whether the initial
363
+ * paint is already in hand). Mirrors how `controlled` overrides `isLoaded`:
364
+ * lets a consumer whose initial-readiness depends on per-render context it
365
+ * cannot express as a pure `config.isInitial(preloaded)` predicate compute it
366
+ * in its own router and pass the result. Takes precedence over
367
+ * `config.isInitial`.
368
+ */
369
+ isInitial?: boolean;
370
+ /**
371
+ * For the server render modes (`server-loader`/`server-initial`), block the
372
+ * server render on the loader instead of streaming a fallback: render the
373
+ * server loader *without* a Suspense boundary, so its content lands in the
374
+ * initial HTML (e.g. for no-JS / crawler SSR). When unset (the default) the
375
+ * loader streams under Suspense, showing `ChunkLoading` until it resolves.
376
+ */
377
+ awaitServerLoad?: boolean;
378
+ /**
379
+ * Skip the initial-loader stage: ignore the `InitialLoader` / source-`initial`
380
+ * for this render so a not-yet-loaded chunk loads the full content directly
381
+ * rather than fetching a quick initial first. For consumers that have no
382
+ * loading UI to show an initial paint into (so a 2-stage initial->full load
383
+ * would be wasted).
384
+ */
385
+ skipInitialLoad?: boolean;
386
+ /** Per-render loader options (merged over the config's `loaderOptions`). */
387
+ loaderOptions?: O;
388
+ /** User generic props forwarded to `ChunkContent` / `ChunkLoading`. */
389
+ userProps?: T;
390
+ /** Settle gate to register with (defaults to the surrounding controller / page). */
391
+ gate?: SettleGate;
392
+ }
393
+ /** Props for `LazyContent` / `LazyContentServer`. */
394
+ export interface LazyContentProps<T extends {} = {}> {
395
+ /** Dynamic import of the component to render. */
396
+ content: LazyComponentImport<T>;
397
+ /** Props forwarded to the imported component. */
398
+ props?: T;
399
+ /** Placeholder shown while the module loads. Defaults to `null`. */
400
+ fallback?: React.ReactNode;
401
+ /**
402
+ * Additional settle gate to report readiness to once the component has loaded
403
+ * and mounted (e.g. a `useStream` controller gate). The page-global gate is
404
+ * always registered too. Client path only - the server path streams via
405
+ * Suspense and has no client gate to report to.
406
+ */
407
+ gate?: SettleGate;
408
+ }
@@ -0,0 +1 @@
1
+ export {};