@brett_lamy/docstream 1.3.0 → 1.5.0

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 (228) hide show
  1. package/README.md +79 -5
  2. package/dist/assets.d.ts +3 -0
  3. package/dist/assets.d.ts.map +1 -0
  4. package/dist/assets.js +20 -0
  5. package/dist/assets.js.map +1 -0
  6. package/dist/demo/DemoViewer.d.ts +78 -0
  7. package/dist/demo/DemoViewer.d.ts.map +1 -0
  8. package/dist/demo/DemoViewer.js +467 -0
  9. package/dist/demo/DemoViewer.js.map +1 -0
  10. package/dist/demo/clipboard.d.ts +70 -0
  11. package/dist/demo/clipboard.d.ts.map +1 -0
  12. package/dist/demo/clipboard.js +187 -0
  13. package/dist/demo/clipboard.js.map +1 -0
  14. package/dist/demo/context.d.ts +20 -0
  15. package/dist/demo/context.d.ts.map +1 -0
  16. package/dist/demo/context.js +31 -0
  17. package/dist/demo/context.js.map +1 -0
  18. package/dist/demo/copy-demo.d.ts +23 -0
  19. package/dist/demo/copy-demo.d.ts.map +1 -0
  20. package/dist/demo/copy-demo.js +81 -0
  21. package/dist/demo/copy-demo.js.map +1 -0
  22. package/dist/demo/glob.d.ts +60 -0
  23. package/dist/demo/glob.d.ts.map +1 -0
  24. package/dist/demo/glob.js +158 -0
  25. package/dist/demo/glob.js.map +1 -0
  26. package/dist/demo/index.d.ts +16 -0
  27. package/dist/demo/index.d.ts.map +1 -0
  28. package/dist/demo/index.js +9 -0
  29. package/dist/demo/index.js.map +1 -0
  30. package/dist/demo/markdown.d.ts +60 -0
  31. package/dist/demo/markdown.d.ts.map +1 -0
  32. package/dist/demo/markdown.js +181 -0
  33. package/dist/demo/markdown.js.map +1 -0
  34. package/dist/demo/surface.d.ts +11 -0
  35. package/dist/demo/surface.d.ts.map +1 -0
  36. package/dist/demo/surface.js +69 -0
  37. package/dist/demo/surface.js.map +1 -0
  38. package/dist/demo/types.d.ts +91 -0
  39. package/dist/demo/types.d.ts.map +1 -0
  40. package/dist/demo/types.js +2 -0
  41. package/dist/demo/types.js.map +1 -0
  42. package/dist/demo/vfs.d.ts +51 -0
  43. package/dist/demo/vfs.d.ts.map +1 -0
  44. package/dist/demo/vfs.js +156 -0
  45. package/dist/demo/vfs.js.map +1 -0
  46. package/dist/docs/CollapsibleCode.d.ts +14 -0
  47. package/dist/docs/CollapsibleCode.d.ts.map +1 -0
  48. package/dist/docs/CollapsibleCode.js +19 -0
  49. package/dist/docs/CollapsibleCode.js.map +1 -0
  50. package/dist/docs/DocsRenderer.d.ts +55 -0
  51. package/dist/docs/DocsRenderer.d.ts.map +1 -0
  52. package/dist/docs/DocsRenderer.js +279 -0
  53. package/dist/docs/DocsRenderer.js.map +1 -0
  54. package/dist/docs/HighlightedCode.d.ts +6 -0
  55. package/dist/docs/HighlightedCode.d.ts.map +1 -0
  56. package/dist/docs/HighlightedCode.js +40 -0
  57. package/dist/docs/HighlightedCode.js.map +1 -0
  58. package/dist/docs/Mermaid.d.ts +7 -0
  59. package/dist/docs/Mermaid.d.ts.map +1 -0
  60. package/dist/docs/Mermaid.js +39 -0
  61. package/dist/docs/Mermaid.js.map +1 -0
  62. package/dist/docs/PageActions.d.ts +33 -0
  63. package/dist/docs/PageActions.d.ts.map +1 -0
  64. package/dist/docs/PageActions.js +115 -0
  65. package/dist/docs/PageActions.js.map +1 -0
  66. package/dist/docs/controls.d.ts +29 -0
  67. package/dist/docs/controls.d.ts.map +1 -0
  68. package/dist/docs/controls.js +46 -0
  69. package/dist/docs/controls.js.map +1 -0
  70. package/dist/docs/copy.d.ts +24 -0
  71. package/dist/docs/copy.d.ts.map +1 -0
  72. package/dist/docs/copy.js +62 -0
  73. package/dist/docs/copy.js.map +1 -0
  74. package/dist/docs/math.d.ts +3 -0
  75. package/dist/docs/math.d.ts.map +1 -0
  76. package/dist/docs/math.js +12 -0
  77. package/dist/docs/math.js.map +1 -0
  78. package/dist/docs/reference.d.ts +27 -0
  79. package/dist/docs/reference.d.ts.map +1 -0
  80. package/dist/docs/reference.js +73 -0
  81. package/dist/docs/reference.js.map +1 -0
  82. package/dist/docs/tabs-sync.d.ts +5 -0
  83. package/dist/docs/tabs-sync.d.ts.map +1 -0
  84. package/dist/docs/tabs-sync.js +58 -0
  85. package/dist/docs/tabs-sync.js.map +1 -0
  86. package/dist/gitbook/ast.d.ts +506 -0
  87. package/dist/gitbook/ast.d.ts.map +1 -0
  88. package/dist/gitbook/ast.js +8 -0
  89. package/dist/gitbook/ast.js.map +1 -0
  90. package/dist/gitbook/attrs.d.ts +14 -0
  91. package/dist/gitbook/attrs.d.ts.map +1 -0
  92. package/dist/gitbook/attrs.js +36 -0
  93. package/dist/gitbook/attrs.js.map +1 -0
  94. package/dist/gitbook/flatten.d.ts +14 -0
  95. package/dist/gitbook/flatten.d.ts.map +1 -0
  96. package/dist/gitbook/flatten.js +45 -0
  97. package/dist/gitbook/flatten.js.map +1 -0
  98. package/dist/gitbook/index.d.ts +10 -0
  99. package/dist/gitbook/index.d.ts.map +1 -0
  100. package/dist/gitbook/index.js +8 -0
  101. package/dist/gitbook/index.js.map +1 -0
  102. package/dist/gitbook/inline.d.ts +28 -0
  103. package/dist/gitbook/inline.d.ts.map +1 -0
  104. package/dist/gitbook/inline.js +956 -0
  105. package/dist/gitbook/inline.js.map +1 -0
  106. package/dist/gitbook/outline.d.ts +16 -0
  107. package/dist/gitbook/outline.d.ts.map +1 -0
  108. package/dist/gitbook/outline.js +44 -0
  109. package/dist/gitbook/outline.js.map +1 -0
  110. package/dist/gitbook/package-managers.d.ts +12 -0
  111. package/dist/gitbook/package-managers.d.ts.map +1 -0
  112. package/dist/gitbook/package-managers.js +93 -0
  113. package/dist/gitbook/package-managers.js.map +1 -0
  114. package/dist/gitbook/parse.d.ts +44 -0
  115. package/dist/gitbook/parse.d.ts.map +1 -0
  116. package/dist/gitbook/parse.js +1113 -0
  117. package/dist/gitbook/parse.js.map +1 -0
  118. package/dist/gitbook/serialize.d.ts +23 -0
  119. package/dist/gitbook/serialize.d.ts.map +1 -0
  120. package/dist/gitbook/serialize.js +498 -0
  121. package/dist/gitbook/serialize.js.map +1 -0
  122. package/dist/index.d.ts +34 -0
  123. package/dist/index.d.ts.map +1 -0
  124. package/dist/index.js +24 -0
  125. package/dist/index.js.map +1 -0
  126. package/dist/openapi/OpenApiOperation.d.ts +6 -0
  127. package/dist/openapi/OpenApiOperation.d.ts.map +1 -0
  128. package/dist/openapi/OpenApiOperation.js +112 -0
  129. package/dist/openapi/OpenApiOperation.js.map +1 -0
  130. package/dist/playground/InlineDemoPreview.d.ts +24 -0
  131. package/dist/playground/InlineDemoPreview.d.ts.map +1 -0
  132. package/dist/playground/InlineDemoPreview.js +48 -0
  133. package/dist/playground/InlineDemoPreview.js.map +1 -0
  134. package/dist/playground/PlaygroundStreamdown.d.ts +16 -0
  135. package/dist/playground/PlaygroundStreamdown.d.ts.map +1 -0
  136. package/dist/playground/PlaygroundStreamdown.js +22 -0
  137. package/dist/playground/PlaygroundStreamdown.js.map +1 -0
  138. package/dist/playground/ReactCodePreview.d.ts +64 -0
  139. package/dist/playground/ReactCodePreview.d.ts.map +1 -0
  140. package/dist/playground/ReactCodePreview.js +108 -0
  141. package/dist/playground/ReactCodePreview.js.map +1 -0
  142. package/dist/playground/filesystem.d.ts +27 -0
  143. package/dist/playground/filesystem.d.ts.map +1 -0
  144. package/dist/playground/filesystem.js +65 -0
  145. package/dist/playground/filesystem.js.map +1 -0
  146. package/dist/playground/index.d.ts +9 -0
  147. package/dist/playground/index.d.ts.map +1 -0
  148. package/dist/playground/index.js +7 -0
  149. package/dist/playground/index.js.map +1 -0
  150. package/dist/playground/project.d.ts +57 -0
  151. package/dist/playground/project.d.ts.map +1 -0
  152. package/dist/playground/project.js +137 -0
  153. package/dist/playground/project.js.map +1 -0
  154. package/dist/replay/NativeReplay.d.ts +9 -0
  155. package/dist/replay/NativeReplay.d.ts.map +1 -0
  156. package/dist/replay/NativeReplay.js +173 -0
  157. package/dist/replay/NativeReplay.js.map +1 -0
  158. package/dist/replay/ReplayPreview.d.ts +33 -0
  159. package/dist/replay/ReplayPreview.d.ts.map +1 -0
  160. package/dist/replay/ReplayPreview.js +91 -0
  161. package/dist/replay/ReplayPreview.js.map +1 -0
  162. package/dist/replay/index.d.ts +5 -0
  163. package/dist/replay/index.d.ts.map +1 -0
  164. package/dist/replay/index.js +4 -0
  165. package/dist/replay/index.js.map +1 -0
  166. package/dist/replay/sanitize.d.ts +4 -0
  167. package/dist/replay/sanitize.d.ts.map +1 -0
  168. package/dist/replay/sanitize.js +86 -0
  169. package/dist/replay/sanitize.js.map +1 -0
  170. package/dist/replay/url.d.ts +8 -0
  171. package/dist/replay/url.d.ts.map +1 -0
  172. package/dist/replay/url.js +41 -0
  173. package/dist/replay/url.js.map +1 -0
  174. package/dist/source/SourcePreview.d.ts +13 -0
  175. package/dist/source/SourcePreview.d.ts.map +1 -0
  176. package/dist/source/SourcePreview.js +47 -0
  177. package/dist/source/SourcePreview.js.map +1 -0
  178. package/dist/source/client.d.ts +7 -0
  179. package/dist/source/client.d.ts.map +1 -0
  180. package/dist/source/client.js +52 -0
  181. package/dist/source/client.js.map +1 -0
  182. package/dist/source/index.d.ts +6 -0
  183. package/dist/source/index.d.ts.map +1 -0
  184. package/dist/source/index.js +3 -0
  185. package/dist/source/index.js.map +1 -0
  186. package/dist/source/types.d.ts +33 -0
  187. package/dist/source/types.d.ts.map +1 -0
  188. package/dist/source/types.js +2 -0
  189. package/dist/source/types.js.map +1 -0
  190. package/dist/streamdown.d.ts +19 -0
  191. package/dist/streamdown.d.ts.map +1 -0
  192. package/dist/streamdown.js +15 -0
  193. package/dist/streamdown.js.map +1 -0
  194. package/dist/styles.css +2441 -0
  195. package/dist/video/VideoEmbed.d.ts +17 -0
  196. package/dist/video/VideoEmbed.d.ts.map +1 -0
  197. package/dist/video/VideoEmbed.js +12 -0
  198. package/dist/video/VideoEmbed.js.map +1 -0
  199. package/dist/video/index.d.ts +3 -0
  200. package/dist/video/index.d.ts.map +1 -0
  201. package/dist/video/index.js +2 -0
  202. package/dist/video/index.js.map +1 -0
  203. package/dist/vite/index.d.ts +21 -0
  204. package/dist/vite/index.d.ts.map +1 -0
  205. package/dist/vite/index.js +137 -0
  206. package/dist/vite/index.js.map +1 -0
  207. package/dist/viz/VizEmbed.d.ts +18 -0
  208. package/dist/viz/VizEmbed.d.ts.map +1 -0
  209. package/dist/viz/VizEmbed.js +12 -0
  210. package/dist/viz/VizEmbed.js.map +1 -0
  211. package/dist/viz/index.d.ts +4 -0
  212. package/dist/viz/index.d.ts.map +1 -0
  213. package/dist/viz/index.js +3 -0
  214. package/dist/viz/index.js.map +1 -0
  215. package/package.json +65 -32
  216. package/src/demo/DemoViewer.tsx +56 -11
  217. package/src/demo/clipboard.ts +228 -0
  218. package/src/demo/context.ts +7 -0
  219. package/src/demo/copy-demo.tsx +102 -0
  220. package/src/demo/index.ts +29 -2
  221. package/src/demo/vfs.ts +197 -0
  222. package/src/docs/DocsRenderer.tsx +13 -4
  223. package/src/docs/Mermaid.tsx +5 -3
  224. package/src/index.ts +19 -0
  225. package/src/replay/ReplayPreview.tsx +0 -1
  226. package/src/streamdown.tsx +2 -0
  227. package/src/styles.css +91 -0
  228. package/src/replay/styles.css +0 -87
package/README.md CHANGED
@@ -416,6 +416,50 @@ or inline it); each inline demo boots its own container (the fullscreen overlay
416
416
  boots a second one). `preloadDemos(resolver, srcs)` settles resolver demos before
417
417
  the first render (server rendering, static export).
418
418
 
419
+ #### Copy a demo, paste it elsewhere (clipboard + demo VFS)
420
+
421
+ Every demo viewer has a **Copy demo** button. It writes one clipboard item with
422
+ three representations, through react-aria's `useClipboard`:
423
+
424
+ | Type | Content |
425
+ | --- | --- |
426
+ | `text/plain`, `text/markdown` | renderable docstream Markdown: the block with its files inline (resolver files for `src`-only demos, `meta.json` folded into the tag) |
427
+ | `application/x-docstream+json` (`DOCSTREAM_CLIPBOARD_TYPE`) | `{ kind: "docstream", version: 1, markdown, files: { [src]: DemoFile[] }, meta: { [src]: DemoMeta } }` — the exact Markdown (a `src`-only block stays `src`-only) plus every demo's files and meta |
428
+
429
+ Pasting into a docstream editor (`@brett_lamy/docstream-editor` 1.5+) recreates
430
+ the demo with its files; pasting anywhere else gets the Markdown. Where the
431
+ browser's copy command is unavailable the button copies the Markdown only
432
+ (editors still parse its inline-file demos).
433
+
434
+ Pasted demo files live in a **demo VFS** — an in-memory `{ [src]: { files, meta } }`
435
+ store. Give it to a renderer (`demoVFS`) or an editor, or share one between
436
+ several:
437
+
438
+ ```tsx
439
+ import { MarkdownContent, useDemoVFS, useDemoVFSFiles } from "@brett_lamy/docstream"
440
+
441
+ const vfs = useDemoVFS() // stable per component; createDemoVFS() outside React
442
+ const files = useDemoVFSFiles(vfs) // { [src]: DemoFile[] }, re-renders on change — persist it
443
+ <MarkdownContent markdown={page} demoResolver={demoResolver} demoRuntime={demoRuntime} demoVFS={vfs} />
444
+ ```
445
+
446
+ A demo block resolves in this order: the host `demoResolver` when it knows `src`
447
+ → the block's inline files, else the VFS files for `src`, run by the
448
+ `demoRuntime` (almost-node from `/playground` when installed) → the Code view
449
+ with the "needs runtime" note. `vfs.resolver({ resolver, runtime })` is the same
450
+ layering as a `DemoResolver` (`files` / `meta` from the host when it knows
451
+ `src`, else from the VFS; `load` runs VFS files through the runtime).
452
+ `vfs.subscribe(change => …)`, `get/set/delete/list/files()` manage it directly.
453
+
454
+ Building blocks (`@brett_lamy/docstream/demo`): `createDocstreamClipboard(doc, { lookup, serialize })`
455
+ / `createDocstreamClipboardFromMarkdown`, `docstreamClipboardItems` (react-aria
456
+ `DragItem`s), `writeDocstreamClipboard(dataTransfer, clip)`,
457
+ `readDocstreamClipboard(dataTransfer)`, `readDocstreamClipboardItems(dropItems)`,
458
+ `parseDocstreamClipboard(json)`, `docstreamPayloadFromMarkdown`,
459
+ `useDocstreamCopy` / `CopyDemoButton`, and `prefetchDemoSources(resolver, srcs)` +
460
+ `peekDemoSource(resolver, src)` to read a resolver's files synchronously (a copy
461
+ event can't wait).
462
+
419
463
  Tell docstream where demos live with a `DemoResolver`. With Vite, three
420
464
  `import.meta.glob` maps are enough:
421
465
 
@@ -632,21 +676,51 @@ import { ReactDemo } from "@brett_lamy/docstream/playground"
632
676
 
633
677
  ## Bundler Notes
634
678
 
635
- This release ships TypeScript and TSX source through ESM exports:
679
+ Since 1.4 the package ships compiled ES modules (ES2022, `react-jsx`) with type
680
+ declarations and declaration maps — one file per source module in `dist/`,
681
+ dependencies left as imports, lazy features (Mermaid, KaTeX, rrweb, the
682
+ playground's almost-node) still behind dynamic `import()`:
636
683
 
637
684
  ```json
638
685
  {
639
686
  "exports": {
640
687
  ".": {
641
- "types": "./src/index.ts",
642
- "import": "./src/index.ts"
688
+ "source": "./src/index.ts",
689
+ "types": "./dist/index.d.ts",
690
+ "import": "./dist/index.js",
691
+ "default": "./dist/index.js"
643
692
  },
644
- "./styles.css": "./src/styles.css"
693
+ "./styles.css": "./dist/styles.css"
645
694
  }
646
695
  }
647
696
  ```
648
697
 
649
- It is validated with Vite and modern TypeScript `moduleResolution: "Bundler"`. Plain Node.js, CommonJS, or tooling that does not transpile TypeScript in dependencies may need a future precompiled JS build.
698
+ No bundler configuration is needed: Vite pre-bundles docstream like any other
699
+ dependency (no `optimizeDeps` entries), Next.js and webpack consume it as plain
700
+ ESM, and your type-check reads `.d.ts` files instead of docstream's sources. The
701
+ `@brett_lamy/docstream/vite` entry is a Node-only Vite plugin; import it from
702
+ `vite.config.ts`, never from browser code.
703
+
704
+ The TypeScript sources are published too, behind a `source` export condition, for
705
+ monorepos that want to compile docstream from source (e.g. Vite
706
+ `resolve.conditions: ["source", ...]` or TypeScript `customConditions`).
707
+
708
+ ## Migrating to 1.5
709
+
710
+ No breaking changes. New: **Copy demo** (clipboard with the demo's files and an
711
+ `application/x-docstream+json` payload), the demo VFS (`demoVFS` on the
712
+ renderers, `createDemoVFS` / `useDemoVFS`), and the clipboard helpers above.
713
+ `react-aria` is now a dependency (for `useClipboard`); hosts on
714
+ `react-aria-components` share it. The single-file demo card gains the Copy demo
715
+ button; the multi-file viewer's "Copy demo as Markdown" is now "Copy demo" (the
716
+ same Markdown as `text/plain`, plus the payload).
717
+
718
+ ## Migrating to 1.4
719
+
720
+ No API changes. Exports now resolve to `dist/*.js` + `dist/*.d.ts` instead of
721
+ `src/*.ts(x)`; drop any `optimizeDeps.include` / `exclude` or
722
+ `transpilePackages` entries you added for docstream, and any `lib` / `types`
723
+ settings you added only so your type-check could compile docstream's sources.
650
724
 
651
725
  ## Migrating to 1.3
652
726
 
@@ -0,0 +1,3 @@
1
+ export declare function setAssetBase(repo: string | null, branch: string | null, filePath: string | null): void;
2
+ export declare function resolveAsset(src: string): string;
3
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,QAO/F;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD"}
package/dist/assets.js ADDED
@@ -0,0 +1,20 @@
1
+ // Resolves repo-relative image paths (e.g. "readme-assets/logo.svg") against
2
+ // the raw.githubusercontent.com URL of the file being edited. The AST keeps
3
+ // the original relative src; only rendering resolves it.
4
+ let assetBase = null;
5
+ export function setAssetBase(repo, branch, filePath) {
6
+ if (!repo || !branch || !filePath) {
7
+ assetBase = null;
8
+ return;
9
+ }
10
+ const dir = filePath.includes("/") ? filePath.slice(0, filePath.lastIndexOf("/") + 1) : "";
11
+ assetBase = `https://raw.githubusercontent.com/${repo}/${branch}/${dir}`;
12
+ }
13
+ export function resolveAsset(src) {
14
+ if (!src || /^(https?:|data:|blob:)/i.test(src))
15
+ return src;
16
+ if (!assetBase)
17
+ return src;
18
+ return assetBase + src.replace(/^\.\//, "");
19
+ }
20
+ //# sourceMappingURL=assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,yDAAyD;AAEzD,IAAI,SAAS,GAAkB,IAAI,CAAA;AAEnC,MAAM,UAAU,YAAY,CAAC,IAAmB,EAAE,MAAqB,EAAE,QAAuB;IAC9F,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,SAAS,GAAG,IAAI,CAAA;QAChB,OAAM;IACR,CAAC;IACD,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC1F,SAAS,GAAG,qCAAqC,IAAI,IAAI,MAAM,IAAI,GAAG,EAAE,CAAA;AAC1E,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,IAAI,CAAC,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAA;IAC3D,IAAI,CAAC,SAAS;QAAE,OAAO,GAAG,CAAA;IAC1B,OAAO,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AAC7C,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { type CSSProperties } from "react";
2
+ import type { DemoLayout, DemoNode, DemoViewport } from "../gitbook/ast.js";
3
+ import { type DemoSourceSnapshot } from "./clipboard.js";
4
+ import { type DemoVFS } from "./vfs.js";
5
+ import type { DemoFile, DemoResolver, DemoVariant, InlineDemoRuntime } from "./types.js";
6
+ export interface DemoViewerProps {
7
+ /** `<page>/<example>` id handed to the resolver. */
8
+ src: string;
9
+ /** Defaults to the nearest `demoResolver` provided to a renderer. */
10
+ resolver?: DemoResolver;
11
+ title?: string;
12
+ description?: string;
13
+ /** Preview height (px number, digits, or any CSS length). */
14
+ height?: number | string;
15
+ layout?: DemoLayout;
16
+ variants?: DemoVariant[];
17
+ /** Initial viewport of the multi-file preview. */
18
+ viewport?: DemoViewport;
19
+ /**
20
+ * Files carried inline by the block (entry first unless `entry` says otherwise). Used when
21
+ * no resolver knows `src`, or the resolver fails for it.
22
+ */
23
+ files?: DemoFile[];
24
+ /** Entry among `files`. Defaults to the first file. */
25
+ entry?: string;
26
+ /** The block is still streaming in: show its code, but don't run it yet. */
27
+ streaming?: boolean;
28
+ /** Runs inline files in the Preview. Defaults to the runtime in context (`demoRuntime`). */
29
+ runtime?: InlineDemoRuntime;
30
+ /** Extra npm dependencies for the runtime, merged over `demoDependencies` from context. */
31
+ dependencies?: Record<string, string>;
32
+ /**
33
+ * Demo files held in memory by `src` (pasted demos). Used, like inline files, when the block
34
+ * has none of its own and no resolver knows `src`. Defaults to the VFS in context (`demoVFS`).
35
+ */
36
+ vfs?: DemoVFS;
37
+ /** Class on the viewer's outer element. (The preview canvas's class is `canvasClassName`.) */
38
+ className?: string;
39
+ /** Status shown in the header (`meta.status`). */
40
+ status?: string;
41
+ /** Full-bleed canvas without the padded surface (`meta.bleed`). */
42
+ bleed?: boolean;
43
+ /** Extra class on the preview canvas (`meta.className`). */
44
+ canvasClassName?: string;
45
+ /** Canvas inline style: an object like `meta.surface`, or CSS declarations as in the tag's `surface`. */
46
+ surface?: Record<string, string | number> | string;
47
+ /** Width of the variant switch (`meta.variantsWidth`). */
48
+ variantsWidth?: number | string;
49
+ }
50
+ /**
51
+ * Resolve demos ahead of rendering (meta, files and component), so the first render — including
52
+ * server rendering and static export — shows them resolved instead of loading. Failures are
53
+ * remembered too, so inline-file fallbacks apply immediately.
54
+ */
55
+ export declare function preloadDemos(resolver: DemoResolver, srcs: string[]): Promise<void>;
56
+ /**
57
+ * Fetch demos' meta and files (not their components) into the viewer's cache, so
58
+ * `peekDemoSource` can answer synchronously — e.g. when a copy event needs a demo's files.
59
+ */
60
+ export declare function prefetchDemoSources(resolver: DemoResolver, srcs: string[]): Promise<void>;
61
+ /** A demo's files (and meta) if the resolver has already delivered them (viewer, `preloadDemos`, `prefetchDemoSources`). */
62
+ export declare function peekDemoSource(resolver: DemoResolver, src: string): DemoSourceSnapshot | undefined;
63
+ export declare const NO_RUNTIME_NOTE = "Live preview needs the playground runtime. The code is shown instead.";
64
+ export declare function DemoViewer(props: DemoViewerProps): import("react").JSX.Element;
65
+ /** Renders a parsed `{% demo %}` block with the resolver and runtime from context. */
66
+ export declare function DemoBlock({ node }: {
67
+ node: DemoNode;
68
+ }): import("react").JSX.Element;
69
+ export interface DemoFullscreenProps {
70
+ src: string;
71
+ resolver?: DemoResolver;
72
+ variant?: string;
73
+ className?: string;
74
+ style?: CSSProperties;
75
+ }
76
+ /** One demo filling the viewport, for a `?demo=<src>` deep link the host routes. */
77
+ export declare function DemoFullscreen({ src, resolver: override, variant, className, style }: DemoFullscreenProps): import("react").JSX.Element;
78
+ //# sourceMappingURL=DemoViewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DemoViewer.d.ts","sourceRoot":"","sources":["../../src/demo/DemoViewer.tsx"],"names":[],"mappings":"AAcA,OAAO,EAQL,KAAK,aAAa,EAKnB,MAAM,OAAO,CAAA;AAId,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAOxE,OAAO,EAA4B,KAAK,kBAAkB,EAA2B,MAAM,aAAa,CAAA;AAGxG,OAAO,EAAsC,KAAK,OAAO,EAAE,MAAM,OAAO,CAAA;AAExE,OAAO,KAAK,EAAiB,QAAQ,EAAY,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE9G,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,GAAG,EAAE,MAAM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