@brett_lamy/docstream 1.2.4 → 1.4.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 (216) hide show
  1. package/README.md +76 -14
  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 +64 -0
  7. package/dist/demo/DemoViewer.d.ts.map +1 -0
  8. package/dist/demo/DemoViewer.js +426 -0
  9. package/dist/demo/DemoViewer.js.map +1 -0
  10. package/dist/demo/context.d.ts +14 -0
  11. package/dist/demo/context.d.ts.map +1 -0
  12. package/dist/demo/context.js +25 -0
  13. package/dist/demo/context.js.map +1 -0
  14. package/dist/demo/glob.d.ts +60 -0
  15. package/dist/demo/glob.d.ts.map +1 -0
  16. package/dist/demo/glob.js +158 -0
  17. package/dist/demo/glob.js.map +1 -0
  18. package/dist/demo/index.d.ts +10 -0
  19. package/dist/demo/index.d.ts.map +1 -0
  20. package/dist/demo/index.js +6 -0
  21. package/dist/demo/index.js.map +1 -0
  22. package/dist/demo/markdown.d.ts +60 -0
  23. package/dist/demo/markdown.d.ts.map +1 -0
  24. package/dist/demo/markdown.js +181 -0
  25. package/dist/demo/markdown.js.map +1 -0
  26. package/dist/demo/surface.d.ts +11 -0
  27. package/dist/demo/surface.d.ts.map +1 -0
  28. package/dist/demo/surface.js +69 -0
  29. package/dist/demo/surface.js.map +1 -0
  30. package/dist/demo/types.d.ts +91 -0
  31. package/dist/demo/types.d.ts.map +1 -0
  32. package/dist/demo/types.js +2 -0
  33. package/dist/demo/types.js.map +1 -0
  34. package/dist/docs/CollapsibleCode.d.ts +14 -0
  35. package/dist/docs/CollapsibleCode.d.ts.map +1 -0
  36. package/dist/docs/CollapsibleCode.js +19 -0
  37. package/dist/docs/CollapsibleCode.js.map +1 -0
  38. package/dist/docs/DocsRenderer.d.ts +49 -0
  39. package/dist/docs/DocsRenderer.d.ts.map +1 -0
  40. package/dist/docs/DocsRenderer.js +277 -0
  41. package/dist/docs/DocsRenderer.js.map +1 -0
  42. package/dist/docs/HighlightedCode.d.ts +6 -0
  43. package/dist/docs/HighlightedCode.d.ts.map +1 -0
  44. package/dist/docs/HighlightedCode.js +40 -0
  45. package/dist/docs/HighlightedCode.js.map +1 -0
  46. package/dist/docs/Mermaid.d.ts +7 -0
  47. package/dist/docs/Mermaid.d.ts.map +1 -0
  48. package/dist/docs/Mermaid.js +39 -0
  49. package/dist/docs/Mermaid.js.map +1 -0
  50. package/dist/docs/PageActions.d.ts +33 -0
  51. package/dist/docs/PageActions.d.ts.map +1 -0
  52. package/dist/docs/PageActions.js +115 -0
  53. package/dist/docs/PageActions.js.map +1 -0
  54. package/dist/docs/controls.d.ts +29 -0
  55. package/dist/docs/controls.d.ts.map +1 -0
  56. package/dist/docs/controls.js +46 -0
  57. package/dist/docs/controls.js.map +1 -0
  58. package/dist/docs/copy.d.ts +24 -0
  59. package/dist/docs/copy.d.ts.map +1 -0
  60. package/dist/docs/copy.js +62 -0
  61. package/dist/docs/copy.js.map +1 -0
  62. package/dist/docs/math.d.ts +3 -0
  63. package/dist/docs/math.d.ts.map +1 -0
  64. package/dist/docs/math.js +12 -0
  65. package/dist/docs/math.js.map +1 -0
  66. package/dist/docs/reference.d.ts +27 -0
  67. package/dist/docs/reference.d.ts.map +1 -0
  68. package/dist/docs/reference.js +73 -0
  69. package/dist/docs/reference.js.map +1 -0
  70. package/dist/docs/tabs-sync.d.ts +5 -0
  71. package/dist/docs/tabs-sync.d.ts.map +1 -0
  72. package/dist/docs/tabs-sync.js +58 -0
  73. package/dist/docs/tabs-sync.js.map +1 -0
  74. package/dist/gitbook/ast.d.ts +506 -0
  75. package/dist/gitbook/ast.d.ts.map +1 -0
  76. package/dist/gitbook/ast.js +8 -0
  77. package/dist/gitbook/ast.js.map +1 -0
  78. package/dist/gitbook/attrs.d.ts +14 -0
  79. package/dist/gitbook/attrs.d.ts.map +1 -0
  80. package/dist/gitbook/attrs.js +36 -0
  81. package/dist/gitbook/attrs.js.map +1 -0
  82. package/dist/gitbook/flatten.d.ts +14 -0
  83. package/dist/gitbook/flatten.d.ts.map +1 -0
  84. package/dist/gitbook/flatten.js +45 -0
  85. package/dist/gitbook/flatten.js.map +1 -0
  86. package/dist/gitbook/index.d.ts +10 -0
  87. package/dist/gitbook/index.d.ts.map +1 -0
  88. package/dist/gitbook/index.js +8 -0
  89. package/dist/gitbook/index.js.map +1 -0
  90. package/dist/gitbook/inline.d.ts +28 -0
  91. package/dist/gitbook/inline.d.ts.map +1 -0
  92. package/dist/gitbook/inline.js +956 -0
  93. package/dist/gitbook/inline.js.map +1 -0
  94. package/dist/gitbook/outline.d.ts +16 -0
  95. package/dist/gitbook/outline.d.ts.map +1 -0
  96. package/dist/gitbook/outline.js +44 -0
  97. package/dist/gitbook/outline.js.map +1 -0
  98. package/dist/gitbook/package-managers.d.ts +12 -0
  99. package/dist/gitbook/package-managers.d.ts.map +1 -0
  100. package/dist/gitbook/package-managers.js +93 -0
  101. package/dist/gitbook/package-managers.js.map +1 -0
  102. package/dist/gitbook/parse.d.ts +44 -0
  103. package/dist/gitbook/parse.d.ts.map +1 -0
  104. package/dist/gitbook/parse.js +1113 -0
  105. package/dist/gitbook/parse.js.map +1 -0
  106. package/dist/gitbook/serialize.d.ts +23 -0
  107. package/dist/gitbook/serialize.d.ts.map +1 -0
  108. package/dist/gitbook/serialize.js +498 -0
  109. package/dist/gitbook/serialize.js.map +1 -0
  110. package/dist/index.d.ts +34 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +24 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/openapi/OpenApiOperation.d.ts +6 -0
  115. package/dist/openapi/OpenApiOperation.d.ts.map +1 -0
  116. package/dist/openapi/OpenApiOperation.js +112 -0
  117. package/dist/openapi/OpenApiOperation.js.map +1 -0
  118. package/dist/playground/InlineDemoPreview.d.ts +24 -0
  119. package/dist/playground/InlineDemoPreview.d.ts.map +1 -0
  120. package/dist/playground/InlineDemoPreview.js +48 -0
  121. package/dist/playground/InlineDemoPreview.js.map +1 -0
  122. package/dist/playground/PlaygroundStreamdown.d.ts +16 -0
  123. package/dist/playground/PlaygroundStreamdown.d.ts.map +1 -0
  124. package/dist/playground/PlaygroundStreamdown.js +22 -0
  125. package/dist/playground/PlaygroundStreamdown.js.map +1 -0
  126. package/dist/playground/ReactCodePreview.d.ts +64 -0
  127. package/dist/playground/ReactCodePreview.d.ts.map +1 -0
  128. package/dist/playground/ReactCodePreview.js +108 -0
  129. package/dist/playground/ReactCodePreview.js.map +1 -0
  130. package/dist/playground/filesystem.d.ts +27 -0
  131. package/dist/playground/filesystem.d.ts.map +1 -0
  132. package/dist/playground/filesystem.js +65 -0
  133. package/dist/playground/filesystem.js.map +1 -0
  134. package/dist/playground/index.d.ts +9 -0
  135. package/dist/playground/index.d.ts.map +1 -0
  136. package/dist/playground/index.js +7 -0
  137. package/dist/playground/index.js.map +1 -0
  138. package/dist/playground/project.d.ts +57 -0
  139. package/dist/playground/project.d.ts.map +1 -0
  140. package/dist/playground/project.js +137 -0
  141. package/dist/playground/project.js.map +1 -0
  142. package/dist/replay/NativeReplay.d.ts +9 -0
  143. package/dist/replay/NativeReplay.d.ts.map +1 -0
  144. package/dist/replay/NativeReplay.js +173 -0
  145. package/dist/replay/NativeReplay.js.map +1 -0
  146. package/dist/replay/ReplayPreview.d.ts +33 -0
  147. package/dist/replay/ReplayPreview.d.ts.map +1 -0
  148. package/dist/replay/ReplayPreview.js +91 -0
  149. package/dist/replay/ReplayPreview.js.map +1 -0
  150. package/dist/replay/index.d.ts +5 -0
  151. package/dist/replay/index.d.ts.map +1 -0
  152. package/dist/replay/index.js +4 -0
  153. package/dist/replay/index.js.map +1 -0
  154. package/dist/replay/sanitize.d.ts +4 -0
  155. package/dist/replay/sanitize.d.ts.map +1 -0
  156. package/dist/replay/sanitize.js +86 -0
  157. package/dist/replay/sanitize.js.map +1 -0
  158. package/dist/replay/url.d.ts +8 -0
  159. package/dist/replay/url.d.ts.map +1 -0
  160. package/dist/replay/url.js +41 -0
  161. package/dist/replay/url.js.map +1 -0
  162. package/dist/source/SourcePreview.d.ts +13 -0
  163. package/dist/source/SourcePreview.d.ts.map +1 -0
  164. package/dist/source/SourcePreview.js +47 -0
  165. package/dist/source/SourcePreview.js.map +1 -0
  166. package/dist/source/client.d.ts +7 -0
  167. package/dist/source/client.d.ts.map +1 -0
  168. package/dist/source/client.js +52 -0
  169. package/dist/source/client.js.map +1 -0
  170. package/dist/source/index.d.ts +6 -0
  171. package/dist/source/index.d.ts.map +1 -0
  172. package/dist/source/index.js +3 -0
  173. package/dist/source/index.js.map +1 -0
  174. package/dist/source/types.d.ts +33 -0
  175. package/dist/source/types.d.ts.map +1 -0
  176. package/dist/source/types.js +2 -0
  177. package/dist/source/types.js.map +1 -0
  178. package/dist/streamdown.d.ts +19 -0
  179. package/dist/streamdown.d.ts.map +1 -0
  180. package/dist/streamdown.js +15 -0
  181. package/dist/streamdown.js.map +1 -0
  182. package/dist/styles.css +2441 -0
  183. package/dist/video/VideoEmbed.d.ts +17 -0
  184. package/dist/video/VideoEmbed.d.ts.map +1 -0
  185. package/dist/video/VideoEmbed.js +12 -0
  186. package/dist/video/VideoEmbed.js.map +1 -0
  187. package/dist/video/index.d.ts +3 -0
  188. package/dist/video/index.d.ts.map +1 -0
  189. package/dist/video/index.js +2 -0
  190. package/dist/video/index.js.map +1 -0
  191. package/dist/vite/index.d.ts +21 -0
  192. package/dist/vite/index.d.ts.map +1 -0
  193. package/dist/vite/index.js +137 -0
  194. package/dist/vite/index.js.map +1 -0
  195. package/dist/viz/VizEmbed.d.ts +18 -0
  196. package/dist/viz/VizEmbed.d.ts.map +1 -0
  197. package/dist/viz/VizEmbed.js +12 -0
  198. package/dist/viz/VizEmbed.js.map +1 -0
  199. package/dist/viz/index.d.ts +4 -0
  200. package/dist/viz/index.d.ts.map +1 -0
  201. package/dist/viz/index.js +3 -0
  202. package/dist/viz/index.js.map +1 -0
  203. package/package.json +70 -34
  204. package/src/demo/types.ts +2 -2
  205. package/src/docs/DocsRenderer.tsx +31 -7
  206. package/src/docs/Mermaid.tsx +5 -3
  207. package/src/docs/math.ts +3 -0
  208. package/src/index.ts +10 -28
  209. package/src/playground/PlaygroundStreamdown.tsx +28 -61
  210. package/src/playground/filesystem.ts +10 -190
  211. package/src/playground/index.ts +4 -0
  212. package/src/playground/project.ts +194 -0
  213. package/src/replay/NativeReplay.tsx +236 -0
  214. package/src/replay/ReplayPreview.tsx +7 -226
  215. package/src/styles.css +91 -1
  216. package/src/replay/styles.css +0 -87
@@ -0,0 +1,91 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Suspense, lazy, useEffect, useState } from 'react';
3
+ import { normalizeReplayEmbedUrl } from './url.js';
4
+ const DEFAULT_SPEEDS = [0.5, 1, 2, 4, 8];
5
+ function sourcePage(source) {
6
+ if (typeof source === 'string')
7
+ return { kind: 'url', url: source };
8
+ if (Array.isArray(source))
9
+ return null;
10
+ return source.kind === 'url' ? source : null;
11
+ }
12
+ function sourceEvents(source) {
13
+ if (Array.isArray(source))
14
+ return { kind: 'events', events: source };
15
+ if (typeof source === 'string')
16
+ return null;
17
+ return source.kind === 'events' ? source : null;
18
+ }
19
+ function sourceEventsUrl(source) {
20
+ if (Array.isArray(source) || typeof source === 'string')
21
+ return null;
22
+ return source.kind === 'events-url' ? source : null;
23
+ }
24
+ function ReplayFrame({ source, title }) {
25
+ const url = normalizeReplayEmbedUrl(source.url);
26
+ if (!url) {
27
+ return (_jsx("a", { className: "replay-preview__invalid", href: source.url, target: "_blank", rel: "noreferrer", children: "Open replay" }));
28
+ }
29
+ return (_jsx("iframe", { className: "replay-preview__frame", src: url, title: title ?? source.title ?? 'Replay preview', loading: "lazy", allow: "autoplay; fullscreen", allowFullScreen: true, referrerPolicy: "strict-origin-when-cross-origin" }));
30
+ }
31
+ // rrweb (and its stylesheet) load on first use of an event-based source.
32
+ const LazyNativeReplay = lazy(() => import('./NativeReplay.js'));
33
+ function NativeReplay(props) {
34
+ return (_jsx(Suspense, { fallback: _jsx("div", { className: "replay-preview__empty", children: "Loading replay\u2026" }), children: _jsx(LazyNativeReplay, { ...props }) }));
35
+ }
36
+ function RemoteReplay({ source, autoplay, loop, speeds, }) {
37
+ const [events, setEvents] = useState(null);
38
+ const [error, setError] = useState(null);
39
+ useEffect(() => {
40
+ const controller = new AbortController();
41
+ setEvents(null);
42
+ setError(null);
43
+ fetch(source.url, { ...source.fetchInit, signal: controller.signal })
44
+ .then(async (response) => {
45
+ if (!response.ok)
46
+ throw new Error(`Replay event request failed (${response.status})`);
47
+ const body = (await response.json());
48
+ const value = Array.isArray(body)
49
+ ? body
50
+ : body && typeof body === 'object' && Array.isArray(body.events)
51
+ ? body.events
52
+ : null;
53
+ if (!value)
54
+ throw new Error('Replay event endpoint must return an event array or { events }');
55
+ return value;
56
+ })
57
+ .then(setEvents)
58
+ .catch((reason) => {
59
+ if (reason instanceof DOMException && reason.name === 'AbortError')
60
+ return;
61
+ setError(reason instanceof Error ? reason.message : 'Unable to load replay data');
62
+ });
63
+ return () => controller.abort();
64
+ }, [source.url, source.fetchInit]);
65
+ if (error)
66
+ return _jsx("div", { className: "replay-preview__error", role: "alert", children: error });
67
+ if (!events)
68
+ return _jsx("div", { className: "replay-preview__empty", children: "Loading replay\u2026" });
69
+ return _jsx(NativeReplay, { events: events, autoplay: autoplay, loop: loop, speeds: speeds });
70
+ }
71
+ export function ReplayPreview({ source, active = true, autoplay = false, loop = false, className, title, speeds = DEFAULT_SPEEDS, }) {
72
+ if (!active)
73
+ return _jsx("div", { className: `replay-preview ${className ?? ''}`.trim(), "data-replay-preview": "paused" });
74
+ const page = sourcePage(source);
75
+ const events = sourceEvents(source);
76
+ const eventsUrl = sourceEventsUrl(source);
77
+ const rootClass = `replay-preview ${className ?? ''}`.trim();
78
+ if (page) {
79
+ return (_jsx("div", { className: rootClass, "data-replay-preview": "iframe", children: _jsx(ReplayFrame, { source: page, title: title }) }));
80
+ }
81
+ if (events) {
82
+ return (_jsx("div", { className: rootClass, "data-replay-preview": "rrweb", children: _jsx(NativeReplay, { events: events.events, autoplay: autoplay, loop: loop, speeds: speeds }) }));
83
+ }
84
+ if (eventsUrl) {
85
+ return (_jsx("div", { className: rootClass, "data-replay-preview": "rrweb", children: _jsx(RemoteReplay, { source: eventsUrl, autoplay: autoplay, loop: loop, speeds: speeds }) }));
86
+ }
87
+ return null;
88
+ }
89
+ /** Semantic alias for markdown/document renderers. */
90
+ export const ReplayEmbed = ReplayPreview;
91
+ //# sourceMappingURL=ReplayPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReplayPreview.js","sourceRoot":"","sources":["../../src/replay/ReplayPreview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAwChD,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEzC,SAAS,UAAU,CAAC,MAAoB;IACtC,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACpE,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,SAAS,YAAY,CAAC,MAAoB;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACr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AAC;IAE7D,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,yBAAsB,QAAQ,YACrD,KAAC,WAAW,IAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAI,GACvC,CACP,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,yBAAsB,OAAO,YACpD,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAI,GACnF,CACP,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,yBAAsB,OAAO,YACpD,KAAC,YAAY,IAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAI,GAC/E,CACP,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { ReplayEmbed, ReplayPreview } from './ReplayPreview.js';
2
+ export type { ReplayEventsSource, ReplayEventsUrlSource, ReplayPageSource, ReplayPreviewProps, ReplaySource, } from './ReplayPreview.js';
3
+ export { isReplayQaUrl, normalizeReplayEmbedUrl } from './url.js';
4
+ export { sanitizeReplayEvent } from './sanitize.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7D,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ReplayEmbed, ReplayPreview } from './ReplayPreview.js';
2
+ export { isReplayQaUrl, normalizeReplayEmbedUrl } from './url.js';
3
+ export { sanitizeReplayEvent } from './sanitize.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQ7D,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { eventWithTime } from 'rrweb';
2
+ /** Prevent a replay iframe from making the viewer fetch localhost/private assets. */
3
+ export declare function sanitizeReplayEvent(event: eventWithTime): eventWithTime;
4
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/replay/sanitize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAyD3C,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAuBvE"}
@@ -0,0 +1,86 @@
1
+ import { EventType, IncrementalSource } from 'rrweb';
2
+ const TRANSPARENT_PIXEL = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
3
+ const EMPTY_STYLESHEET = 'data:text/css,';
4
+ function isLocalNetworkUrl(value) {
5
+ let url;
6
+ try {
7
+ url = new URL(value);
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ if (url.protocol !== 'http:' && url.protocol !== 'https:')
13
+ return false;
14
+ const host = url.hostname.toLowerCase().replace(/^\[|\]$/g, '');
15
+ if (host === 'localhost' || host.endsWith('.localhost') || host.endsWith('.local'))
16
+ return true;
17
+ if (host === '0.0.0.0' || host === '::1' || host.startsWith('127.') || host.startsWith('10.')) {
18
+ return true;
19
+ }
20
+ if (host.startsWith('192.168.'))
21
+ return true;
22
+ const private172 = host.match(/^172\.(\d{1,3})\./);
23
+ if (private172 && Number(private172[1]) >= 16 && Number(private172[1]) <= 31)
24
+ return true;
25
+ return host.includes(':') && (host.startsWith('fc') || host.startsWith('fd'));
26
+ }
27
+ function sanitizeCss(value) {
28
+ return value.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (whole, quote, raw) => isLocalNetworkUrl(raw.trim()) ? `url(${quote}${TRANSPARENT_PIXEL}${quote})` : whole);
29
+ }
30
+ function sanitizeAttributes(attributes) {
31
+ for (const key of Object.keys(attributes)) {
32
+ const value = attributes[key];
33
+ if (typeof value !== 'string')
34
+ continue;
35
+ const lower = key.toLowerCase();
36
+ if (lower === 'src' || lower === 'poster' || lower === 'background') {
37
+ if (isLocalNetworkUrl(value))
38
+ attributes[key] = TRANSPARENT_PIXEL;
39
+ }
40
+ else if (lower === 'data') {
41
+ if (isLocalNetworkUrl(value))
42
+ attributes[key] = 'about:blank';
43
+ }
44
+ else if (lower === 'style' || lower === '_csstext') {
45
+ attributes[key] = sanitizeCss(value);
46
+ }
47
+ else if (lower === 'href' || lower === 'xlink:href') {
48
+ if (isLocalNetworkUrl(value))
49
+ attributes[key] = EMPTY_STYLESHEET;
50
+ }
51
+ }
52
+ }
53
+ function walkNode(node) {
54
+ if (!node || typeof node !== 'object')
55
+ return;
56
+ const value = node;
57
+ if (value.attributes && typeof value.attributes === 'object') {
58
+ sanitizeAttributes(value.attributes);
59
+ }
60
+ if (Array.isArray(value.childNodes))
61
+ value.childNodes.forEach(walkNode);
62
+ }
63
+ /** Prevent a replay iframe from making the viewer fetch localhost/private assets. */
64
+ export function sanitizeReplayEvent(event) {
65
+ try {
66
+ if (event.type === EventType.FullSnapshot) {
67
+ walkNode(event.data.node);
68
+ }
69
+ else if (event.type === EventType.IncrementalSnapshot) {
70
+ const data = event.data;
71
+ if (data.source === IncrementalSource.Mutation) {
72
+ data.adds?.forEach((item) => walkNode(item.node));
73
+ data.attributes?.forEach((item) => {
74
+ if (item.attributes && typeof item.attributes === 'object') {
75
+ sanitizeAttributes(item.attributes);
76
+ }
77
+ });
78
+ }
79
+ }
80
+ }
81
+ catch {
82
+ // A malformed asset must never take down the player.
83
+ }
84
+ return event;
85
+ }
86
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../src/replay/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGrD,MAAM,iBAAiB,GACrB,4EAA4E,CAAC;AAC/E,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACxE,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAChE,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ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EAAE,CAAC;YAC1C,QAAQ,CAAE,KAAK,CAAC,IAA2B,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,mBAAmB,EAAE,CAAC;YACxD,MAAM,IAAI,GAAG,KAAK,CAAC,IAIlB,CAAC;YACF,IAAI,IAAI,CAAC,MAAM,KAAK,iBAAiB,CAAC,QAAQ,EAAE,CAAC;gBAC/C,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAClD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBAChC,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;wBAC3D,kBAAkB,CAAC,IAAI,CAAC,UAAqC,CAAC,CAAC;oBACjE,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qDAAqD;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Convert a normal Loop QA project URL to its chrome-free public embed route.
3
+ * The application owns auth/public-access decisions; this helper only changes
4
+ * the route shape that Loop QA already exposes for cross-site iframes.
5
+ */
6
+ export declare function normalizeReplayEmbedUrl(input: string): string | null;
7
+ export declare function isReplayQaUrl(input: string): boolean;
8
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/replay/url.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwBpE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CASpD"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Convert a normal Loop QA project URL to its chrome-free public embed route.
3
+ * The application owns auth/public-access decisions; this helper only changes
4
+ * the route shape that Loop QA already exposes for cross-site iframes.
5
+ */
6
+ export function normalizeReplayEmbedUrl(input) {
7
+ let url;
8
+ try {
9
+ url = new URL(input);
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ if (url.protocol !== 'http:' && url.protocol !== 'https:')
15
+ return null;
16
+ const parts = url.pathname.split('/').filter(Boolean);
17
+ if (parts[0] === 'projects' && parts.length >= 4) {
18
+ const projectId = decodeURIComponent(parts[1] ?? '');
19
+ const kind = parts[2] === 'explorations' ? 'tasks' : parts[2];
20
+ const resourceId = decodeURIComponent(parts[3] ?? '');
21
+ if (projectId &&
22
+ resourceId &&
23
+ (kind === 'tasks' || kind === 'journeys' || kind === 'test-runs')) {
24
+ url.pathname = `/p/${encodeURIComponent(projectId)}/${kind}/${encodeURIComponent(resourceId)}`;
25
+ }
26
+ }
27
+ return url.toString();
28
+ }
29
+ export function isReplayQaUrl(input) {
30
+ const normalized = normalizeReplayEmbedUrl(input);
31
+ if (!normalized)
32
+ return false;
33
+ try {
34
+ const url = new URL(normalized);
35
+ return url.pathname.startsWith('/p/') || url.hostname.endsWith('.replay.io');
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
41
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/replay/url.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KA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M,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type ReactNode } from "react";
2
+ import type { SourceRefNode } from "../gitbook/ast.js";
3
+ import type { SourceReferenceClient } from "./types.js";
4
+ export interface SourcePreviewProps {
5
+ reference: SourceRefNode;
6
+ client: SourceReferenceClient;
7
+ className?: string;
8
+ fallback?: ReactNode;
9
+ onError?: (error: Error) => void;
10
+ }
11
+ /** Render a component or CSF story directly from a Vite-mounted source file. */
12
+ export declare function SourcePreview({ reference, client, className, fallback, onError }: SourcePreviewProps): import("react").JSX.Element;
13
+ //# sourceMappingURL=SourcePreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourcePreview.d.ts","sourceRoot":"","sources":["../../src/source/SourcePreview.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAgB,qBAAqB,EAA4B,MAAM,SAAS,CAAA;AAE5F,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,aAAa,CAAA;IACxB,MAAM,EAAE,qBAAqB,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACjC;AAoBD,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAA4B,EAAE,OAAO,EAAE,EAAE,kBAAkB,+BAqCxH"}
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createElement, useEffect, useState } from "react";
3
+ function componentFrom(module, reference) {
4
+ if (reference.kind === "component") {
5
+ const candidate = reference.exportName === "default" ? module.default : module[reference.exportName];
6
+ if (typeof candidate !== "function")
7
+ throw new Error(`${reference.path} does not export component ${reference.exportName}`);
8
+ return { component: candidate, props: {} };
9
+ }
10
+ const meta = (module.default ?? {});
11
+ const story = module[reference.exportName];
12
+ if (!story)
13
+ throw new Error(`${reference.path} does not export story ${reference.exportName}`);
14
+ const component = story.render ?? meta.render ?? meta.component;
15
+ if (typeof component !== "function")
16
+ throw new Error(`${reference.path}#${reference.exportName} has no renderable component`);
17
+ return {
18
+ component: component,
19
+ props: { ...(meta.args ?? {}), ...(story.args ?? {}) },
20
+ };
21
+ }
22
+ /** Render a component or CSF story directly from a Vite-mounted source file. */
23
+ export function SourcePreview({ reference, client, className, fallback = "Loading source…", onError }) {
24
+ const [renderable, setRenderable] = useState(null);
25
+ const [error, setError] = useState(null);
26
+ useEffect(() => {
27
+ let cancelled = false;
28
+ setRenderable(null);
29
+ setError(null);
30
+ void client.importModule(reference).then((module) => {
31
+ if (!cancelled)
32
+ setRenderable(componentFrom(module, reference));
33
+ }, (cause) => {
34
+ const next = cause instanceof Error ? cause : new Error(String(cause));
35
+ if (!cancelled) {
36
+ setError(next);
37
+ onError?.(next);
38
+ }
39
+ });
40
+ return () => {
41
+ cancelled = true;
42
+ };
43
+ }, [client, onError, reference]);
44
+ const wrapper = className ? `docs-source-preview ${className}` : "docs-source-preview";
45
+ return (_jsxs("section", { className: wrapper, "data-docstream-source-preview": "", "data-source-path": reference.path, children: [_jsxs("header", { className: "docs-source-preview-header", children: [_jsx("span", { children: reference.title ?? `${reference.path}#${reference.exportName}` }), _jsxs("code", { children: [reference.mount, ":", reference.path] })] }), _jsx("div", { className: "docs-source-preview-body", children: error ? _jsx("pre", { className: "docs-source-preview-error", children: error.message }) : renderable ? createElement(renderable.component, renderable.props) : fallback })] }));
46
+ }
47
+ //# sourceMappingURL=SourcePreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourcePreview.js","sourceRoot":"","sources":["../../src/source/SourcePreview.tsx"],"names":[],"mappings":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C,EAAE,sBAAmB,SAAS,CAAC,IAAI,aAC5F,kBAAQ,SAAS,EAAC,4BAA4B,aAC5C,yBAAO,SAAS,CAAC,KAAK,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,UAAU,EAAE,GAAQ,EAC7E,2BAAO,SAAS,CAAC,KAAK,OAAG,SAAS,CAAC,IAAI,IAAQ,IACxC,EACT,cAAK,SAAS,EAAC,0BAA0B,YACtC,KAAK,CAAC,CAAC,CAAC,cAAK,SAAS,EAAC,2BAA2B,YAAE,KAAK,CAAC,OAAO,GAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GACrJ,IACE,CACX,CAAA;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { SourceReferenceClient, SourceModule } from "./types.js";
2
+ export type BundledSourceModule = SourceModule | (() => SourceModule | Promise<SourceModule>);
3
+ /** Create a browser client for the endpoints installed by `docstreamSources()`. */
4
+ export declare function createViteSourceClient(apiBase?: string): SourceReferenceClient;
5
+ /** Create a read-only source client for modules included in a production bundle. */
6
+ export declare function createBundledSourceClient(modules: Record<string, BundledSourceModule>): SourceReferenceClient;
7
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/source/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,qBAAqB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtF,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;AAgB7F,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,OAAO,SAAgB,GAAG,qBAAqB,CAqBrF;AAED,oFAAoF;AACpF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,qBAAqB,CAc7G"}
@@ -0,0 +1,52 @@
1
+ function params(reference) {
2
+ return new URLSearchParams({
3
+ mount: reference.mount,
4
+ path: reference.path,
5
+ export: reference.exportName,
6
+ kind: reference.kind,
7
+ });
8
+ }
9
+ async function json(response) {
10
+ if (!response.ok)
11
+ throw new Error((await response.text()) || `Docstream source request failed (${response.status})`);
12
+ return response.json();
13
+ }
14
+ /** Create a browser client for the endpoints installed by `docstreamSources()`. */
15
+ export function createViteSourceClient(apiBase = "/@docstream") {
16
+ const base = apiBase.replace(/\/$/, "");
17
+ return {
18
+ async read(reference) {
19
+ return json(await fetch(`${base}/source?${params(reference)}`));
20
+ },
21
+ async write(reference, content) {
22
+ return json(await fetch(`${base}/source?${params(reference)}`, {
23
+ method: "PUT",
24
+ headers: { "content-type": "application/json" },
25
+ body: JSON.stringify({ content }),
26
+ }));
27
+ },
28
+ async importModule(reference) {
29
+ const url = `${base}/module?${params(reference)}&t=${Date.now()}`;
30
+ const loaded = await import(/* @vite-ignore */ url);
31
+ return loaded.default ?? loaded;
32
+ },
33
+ };
34
+ }
35
+ /** Create a read-only source client for modules included in a production bundle. */
36
+ export function createBundledSourceClient(modules) {
37
+ return {
38
+ async read() {
39
+ throw new Error("Source text is unavailable in a bundled source client.");
40
+ },
41
+ async write() {
42
+ throw new Error("Bundled source previews are read-only.");
43
+ },
44
+ async importModule(reference) {
45
+ const entry = modules[`${reference.mount}:${reference.path}`] ?? modules[reference.path];
46
+ if (!entry)
47
+ throw new Error(`No bundled source module found for ${reference.mount}:${reference.path}`);
48
+ return typeof entry === "function" ? entry() : entry;
49
+ },
50
+ };
51
+ }
52
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/source/client.ts"],"names":[],"mappings":"AAKA,SAAS,MAAM,CAAC,SAAwB;IACtC,OAAO,IAAI,eAAe,CAAC;QACzB,KAAK,EAA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C,kBAAkB,CAAC,GAAG,CAA+B,CAAA;YACjF,OAAO,MAAM,CAAC,OAAO,IAAK,MAAuB,CAAA;QACnD,CAAC;KACF,CAAA;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,yBAAyB,CAAC,OAA4C;IACpF,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;QAC3E,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAC3D,CAAC;QACD,KAAK,CAAC,YAAY,CAAC,SAAS;YAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YACxF,IAAI,CAAC,KAAK;gBAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;YACtG,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;QACtD,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { createBundledSourceClient, createViteSourceClient } from "./client.js";
2
+ export type { BundledSourceModule } from "./client.js";
3
+ export { SourcePreview } from "./SourcePreview.js";
4
+ export type { SourcePreviewProps } from "./SourcePreview.js";
5
+ export type { SourceFileSnapshot, SourceModule, SourceProvenance, SourceReferenceClient, StoryLike, StoryMetaLike, } from "./types.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAC5E,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACT,aAAa,GACd,MAAM,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { createBundledSourceClient, createViteSourceClient } from "./client.js";
2
+ export { SourcePreview } from "./SourcePreview.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,33 @@
1
+ import type { ComponentType } from "react";
2
+ import type { SourceRefNode } from "../gitbook/ast.js";
3
+ export interface SourceProvenance {
4
+ mount: string;
5
+ path: string;
6
+ exportName: string;
7
+ kind: SourceRefNode["kind"];
8
+ absolutePath?: string;
9
+ mtimeMs?: number;
10
+ }
11
+ export interface SourceFileSnapshot {
12
+ content: string;
13
+ provenance: SourceProvenance;
14
+ }
15
+ export interface SourceModule {
16
+ default?: unknown;
17
+ [exportName: string]: unknown;
18
+ }
19
+ export interface SourceReferenceClient {
20
+ read(reference: SourceRefNode): Promise<SourceFileSnapshot>;
21
+ write(reference: SourceRefNode, content: string): Promise<SourceFileSnapshot>;
22
+ importModule(reference: SourceRefNode): Promise<SourceModule>;
23
+ }
24
+ export interface StoryLike {
25
+ args?: Record<string, unknown>;
26
+ render?: ComponentType<Record<string, unknown>> | ((args: Record<string, unknown>) => unknown);
27
+ }
28
+ export interface StoryMetaLike {
29
+ args?: Record<string, unknown>;
30
+ component?: ComponentType<Record<string, unknown>>;
31
+ render?: ComponentType<Record<string, unknown>> | ((args: Record<string, unknown>) => unknown);
32
+ }
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/source/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,gBAAgB,CAAA;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAA;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,SAAS,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC3D,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC7E,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;CAC9D;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,CAAA;CAC/F;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAClD,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,CAAA;CAC/F"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/source/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { type DocRenderOptions, type LivePreviewRenderer, type SourceReferenceRenderer } from "./docs/DocsRenderer.js";
2
+ export { CitationSources, DocstreamRefContext, InlineReference } from "./docs/reference.js";
3
+ export { DocPageActions } from "./docs/PageActions.js";
4
+ export type { DocPageAction, DocPageActionsOptions, DocPageActionsProps } from "./docs/PageActions.js";
5
+ export type { DocRenderOptions } from "./docs/DocsRenderer.js";
6
+ export { DocstreamDemoContext, DocstreamDemoRuntimeContext, DemoFullscreen, DemoViewer } from "./demo/index.js";
7
+ export type { DemoFile, DemoMeta, DemoResolver, DemoVariant, InlineDemoRuntime, InlineDemoRuntimeProps } from "./demo/index.js";
8
+ export type { CitationPreview, CitationPreviewResolver, DocstreamRefContextValue } from "./docs/reference.js";
9
+ export interface GitbookStreamdownProps extends DocRenderOptions {
10
+ children?: string;
11
+ liveRenderer?: LivePreviewRenderer;
12
+ sourceRenderer?: SourceReferenceRenderer;
13
+ className?: string;
14
+ isAnimating?: boolean;
15
+ isStreaming?: boolean;
16
+ markdown?: string;
17
+ }
18
+ export declare function GitbookStreamdown({ children, className, isAnimating, isStreaming, markdown, liveRenderer, sourceRenderer, demoResolver, demoRuntime, demoDependencies, pageActions, }: GitbookStreamdownProps): import("react").JSX.Element;
19
+ //# sourceMappingURL=streamdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamdown.d.ts","sourceRoot":"","sources":["../src/streamdown.tsx"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAKjI,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACnG,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACtG,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AACtH,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAE1G,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,mBAAmB,CAAA;IAClC,cAAc,CAAC,EAAE,uBAAuB,CAAA;IACxC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAmB,EACnB,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,WAAW,GACZ,EAAE,sBAAsB,+BA0BxB"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { DocsRenderer } from "./docs/DocsRenderer.js";
4
+ import { parseMarkdown, trimPartialInlineToken } from "./gitbook/parse.js";
5
+ // Re-exported so markdown-only consumers of ./streamdown can wire chip
6
+ // click handling without importing the heavy root entry.
7
+ export { CitationSources, DocstreamRefContext, InlineReference } from "./docs/reference.js";
8
+ export { DocPageActions } from "./docs/PageActions.js";
9
+ export { DocstreamDemoContext, DocstreamDemoRuntimeContext, DemoFullscreen, DemoViewer } from "./demo/index.js";
10
+ export function GitbookStreamdown({ children, className, isAnimating, isStreaming = false, markdown, liveRenderer, sourceRenderer, demoResolver, demoRuntime, demoDependencies, pageActions, }) {
11
+ const content = markdown ?? children ?? "";
12
+ const gitbookDoc = useMemo(() => parseMarkdown(isStreaming ? trimPartialInlineToken(content) : content), [content, isStreaming]);
13
+ return (_jsx("div", { "aria-busy": isAnimating ?? isStreaming, className: className, "data-docstream": "", "data-streaming": isStreaming ? "" : undefined, children: _jsx(DocsRenderer, { doc: gitbookDoc, markdown: content, liveRenderer: liveRenderer, sourceRenderer: sourceRenderer, demoResolver: demoResolver, demoRuntime: demoRuntime, demoDependencies: demoDependencies, pageActions: isStreaming ? false : pageActions }) }));
14
+ }
15
+ //# sourceMappingURL=streamdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamdown.js","sourceRoot":"","sources":["../src/streamdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAiF,MAAM,qBAAqB,CAAA;AACjI,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAEvE,uEAAuE;AACvE,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