@brett_lamy/docstream 1.3.0 → 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.
- package/README.md +25 -5
- package/dist/assets.d.ts +3 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +20 -0
- package/dist/assets.js.map +1 -0
- package/dist/demo/DemoViewer.d.ts +64 -0
- package/dist/demo/DemoViewer.d.ts.map +1 -0
- package/dist/demo/DemoViewer.js +426 -0
- package/dist/demo/DemoViewer.js.map +1 -0
- package/dist/demo/context.d.ts +14 -0
- package/dist/demo/context.d.ts.map +1 -0
- package/dist/demo/context.js +25 -0
- package/dist/demo/context.js.map +1 -0
- package/dist/demo/glob.d.ts +60 -0
- package/dist/demo/glob.d.ts.map +1 -0
- package/dist/demo/glob.js +158 -0
- package/dist/demo/glob.js.map +1 -0
- package/dist/demo/index.d.ts +10 -0
- package/dist/demo/index.d.ts.map +1 -0
- package/dist/demo/index.js +6 -0
- package/dist/demo/index.js.map +1 -0
- package/dist/demo/markdown.d.ts +60 -0
- package/dist/demo/markdown.d.ts.map +1 -0
- package/dist/demo/markdown.js +181 -0
- package/dist/demo/markdown.js.map +1 -0
- package/dist/demo/surface.d.ts +11 -0
- package/dist/demo/surface.d.ts.map +1 -0
- package/dist/demo/surface.js +69 -0
- package/dist/demo/surface.js.map +1 -0
- package/dist/demo/types.d.ts +91 -0
- package/dist/demo/types.d.ts.map +1 -0
- package/dist/demo/types.js +2 -0
- package/dist/demo/types.js.map +1 -0
- package/dist/docs/CollapsibleCode.d.ts +14 -0
- package/dist/docs/CollapsibleCode.d.ts.map +1 -0
- package/dist/docs/CollapsibleCode.js +19 -0
- package/dist/docs/CollapsibleCode.js.map +1 -0
- package/dist/docs/DocsRenderer.d.ts +49 -0
- package/dist/docs/DocsRenderer.d.ts.map +1 -0
- package/dist/docs/DocsRenderer.js +277 -0
- package/dist/docs/DocsRenderer.js.map +1 -0
- package/dist/docs/HighlightedCode.d.ts +6 -0
- package/dist/docs/HighlightedCode.d.ts.map +1 -0
- package/dist/docs/HighlightedCode.js +40 -0
- package/dist/docs/HighlightedCode.js.map +1 -0
- package/dist/docs/Mermaid.d.ts +7 -0
- package/dist/docs/Mermaid.d.ts.map +1 -0
- package/dist/docs/Mermaid.js +39 -0
- package/dist/docs/Mermaid.js.map +1 -0
- package/dist/docs/PageActions.d.ts +33 -0
- package/dist/docs/PageActions.d.ts.map +1 -0
- package/dist/docs/PageActions.js +115 -0
- package/dist/docs/PageActions.js.map +1 -0
- package/dist/docs/controls.d.ts +29 -0
- package/dist/docs/controls.d.ts.map +1 -0
- package/dist/docs/controls.js +46 -0
- package/dist/docs/controls.js.map +1 -0
- package/dist/docs/copy.d.ts +24 -0
- package/dist/docs/copy.d.ts.map +1 -0
- package/dist/docs/copy.js +62 -0
- package/dist/docs/copy.js.map +1 -0
- package/dist/docs/math.d.ts +3 -0
- package/dist/docs/math.d.ts.map +1 -0
- package/dist/docs/math.js +12 -0
- package/dist/docs/math.js.map +1 -0
- package/dist/docs/reference.d.ts +27 -0
- package/dist/docs/reference.d.ts.map +1 -0
- package/dist/docs/reference.js +73 -0
- package/dist/docs/reference.js.map +1 -0
- package/dist/docs/tabs-sync.d.ts +5 -0
- package/dist/docs/tabs-sync.d.ts.map +1 -0
- package/dist/docs/tabs-sync.js +58 -0
- package/dist/docs/tabs-sync.js.map +1 -0
- package/dist/gitbook/ast.d.ts +506 -0
- package/dist/gitbook/ast.d.ts.map +1 -0
- package/dist/gitbook/ast.js +8 -0
- package/dist/gitbook/ast.js.map +1 -0
- package/dist/gitbook/attrs.d.ts +14 -0
- package/dist/gitbook/attrs.d.ts.map +1 -0
- package/dist/gitbook/attrs.js +36 -0
- package/dist/gitbook/attrs.js.map +1 -0
- package/dist/gitbook/flatten.d.ts +14 -0
- package/dist/gitbook/flatten.d.ts.map +1 -0
- package/dist/gitbook/flatten.js +45 -0
- package/dist/gitbook/flatten.js.map +1 -0
- package/dist/gitbook/index.d.ts +10 -0
- package/dist/gitbook/index.d.ts.map +1 -0
- package/dist/gitbook/index.js +8 -0
- package/dist/gitbook/index.js.map +1 -0
- package/dist/gitbook/inline.d.ts +28 -0
- package/dist/gitbook/inline.d.ts.map +1 -0
- package/dist/gitbook/inline.js +956 -0
- package/dist/gitbook/inline.js.map +1 -0
- package/dist/gitbook/outline.d.ts +16 -0
- package/dist/gitbook/outline.d.ts.map +1 -0
- package/dist/gitbook/outline.js +44 -0
- package/dist/gitbook/outline.js.map +1 -0
- package/dist/gitbook/package-managers.d.ts +12 -0
- package/dist/gitbook/package-managers.d.ts.map +1 -0
- package/dist/gitbook/package-managers.js +93 -0
- package/dist/gitbook/package-managers.js.map +1 -0
- package/dist/gitbook/parse.d.ts +44 -0
- package/dist/gitbook/parse.d.ts.map +1 -0
- package/dist/gitbook/parse.js +1113 -0
- package/dist/gitbook/parse.js.map +1 -0
- package/dist/gitbook/serialize.d.ts +23 -0
- package/dist/gitbook/serialize.d.ts.map +1 -0
- package/dist/gitbook/serialize.js +498 -0
- package/dist/gitbook/serialize.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi/OpenApiOperation.d.ts +6 -0
- package/dist/openapi/OpenApiOperation.d.ts.map +1 -0
- package/dist/openapi/OpenApiOperation.js +112 -0
- package/dist/openapi/OpenApiOperation.js.map +1 -0
- package/dist/playground/InlineDemoPreview.d.ts +24 -0
- package/dist/playground/InlineDemoPreview.d.ts.map +1 -0
- package/dist/playground/InlineDemoPreview.js +48 -0
- package/dist/playground/InlineDemoPreview.js.map +1 -0
- package/dist/playground/PlaygroundStreamdown.d.ts +16 -0
- package/dist/playground/PlaygroundStreamdown.d.ts.map +1 -0
- package/dist/playground/PlaygroundStreamdown.js +22 -0
- package/dist/playground/PlaygroundStreamdown.js.map +1 -0
- package/dist/playground/ReactCodePreview.d.ts +64 -0
- package/dist/playground/ReactCodePreview.d.ts.map +1 -0
- package/dist/playground/ReactCodePreview.js +108 -0
- package/dist/playground/ReactCodePreview.js.map +1 -0
- package/dist/playground/filesystem.d.ts +27 -0
- package/dist/playground/filesystem.d.ts.map +1 -0
- package/dist/playground/filesystem.js +65 -0
- package/dist/playground/filesystem.js.map +1 -0
- package/dist/playground/index.d.ts +9 -0
- package/dist/playground/index.d.ts.map +1 -0
- package/dist/playground/index.js +7 -0
- package/dist/playground/index.js.map +1 -0
- package/dist/playground/project.d.ts +57 -0
- package/dist/playground/project.d.ts.map +1 -0
- package/dist/playground/project.js +137 -0
- package/dist/playground/project.js.map +1 -0
- package/dist/replay/NativeReplay.d.ts +9 -0
- package/dist/replay/NativeReplay.d.ts.map +1 -0
- package/dist/replay/NativeReplay.js +173 -0
- package/dist/replay/NativeReplay.js.map +1 -0
- package/dist/replay/ReplayPreview.d.ts +33 -0
- package/dist/replay/ReplayPreview.d.ts.map +1 -0
- package/dist/replay/ReplayPreview.js +91 -0
- package/dist/replay/ReplayPreview.js.map +1 -0
- package/dist/replay/index.d.ts +5 -0
- package/dist/replay/index.d.ts.map +1 -0
- package/dist/replay/index.js +4 -0
- package/dist/replay/index.js.map +1 -0
- package/dist/replay/sanitize.d.ts +4 -0
- package/dist/replay/sanitize.d.ts.map +1 -0
- package/dist/replay/sanitize.js +86 -0
- package/dist/replay/sanitize.js.map +1 -0
- package/dist/replay/url.d.ts +8 -0
- package/dist/replay/url.d.ts.map +1 -0
- package/dist/replay/url.js +41 -0
- package/dist/replay/url.js.map +1 -0
- package/dist/source/SourcePreview.d.ts +13 -0
- package/dist/source/SourcePreview.d.ts.map +1 -0
- package/dist/source/SourcePreview.js +47 -0
- package/dist/source/SourcePreview.js.map +1 -0
- package/dist/source/client.d.ts +7 -0
- package/dist/source/client.d.ts.map +1 -0
- package/dist/source/client.js +52 -0
- package/dist/source/client.js.map +1 -0
- package/dist/source/index.d.ts +6 -0
- package/dist/source/index.d.ts.map +1 -0
- package/dist/source/index.js +3 -0
- package/dist/source/index.js.map +1 -0
- package/dist/source/types.d.ts +33 -0
- package/dist/source/types.d.ts.map +1 -0
- package/dist/source/types.js +2 -0
- package/dist/source/types.js.map +1 -0
- package/dist/streamdown.d.ts +19 -0
- package/dist/streamdown.d.ts.map +1 -0
- package/dist/streamdown.js +15 -0
- package/dist/streamdown.js.map +1 -0
- package/dist/styles.css +2441 -0
- package/dist/video/VideoEmbed.d.ts +17 -0
- package/dist/video/VideoEmbed.d.ts.map +1 -0
- package/dist/video/VideoEmbed.js +12 -0
- package/dist/video/VideoEmbed.js.map +1 -0
- package/dist/video/index.d.ts +3 -0
- package/dist/video/index.d.ts.map +1 -0
- package/dist/video/index.js +2 -0
- package/dist/video/index.js.map +1 -0
- package/dist/vite/index.d.ts +21 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +137 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/viz/VizEmbed.d.ts +18 -0
- package/dist/viz/VizEmbed.d.ts.map +1 -0
- package/dist/viz/VizEmbed.js +12 -0
- package/dist/viz/VizEmbed.js.map +1 -0
- package/dist/viz/index.d.ts +4 -0
- package/dist/viz/index.d.ts.map +1 -0
- package/dist/viz/index.js +3 -0
- package/dist/viz/index.js.map +1 -0
- package/package.json +62 -32
- package/src/docs/Mermaid.tsx +5 -3
- package/src/replay/ReplayPreview.tsx +0 -1
- package/src/styles.css +91 -0
- package/src/replay/styles.css +0 -87
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
export interface VideoEmbedProps {
|
|
3
|
+
/** A direct media asset or a public player URL. */
|
|
4
|
+
src: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
/** CSS aspect-ratio for iframe embeds. Defaults to 16 / 9. */
|
|
8
|
+
aspectRatio?: CSSProperties["aspectRatio"];
|
|
9
|
+
controls?: boolean;
|
|
10
|
+
autoplay?: boolean;
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
muted?: boolean;
|
|
13
|
+
poster?: string;
|
|
14
|
+
allowFullScreen?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function VideoEmbed({ src, title, className, aspectRatio, controls, autoplay, loop, muted, poster, allowFullScreen, }: VideoEmbedProps): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=VideoEmbed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoEmbed.d.ts","sourceRoot":"","sources":["../../src/video/VideoEmbed.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAMD,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,KAAe,EACf,SAAS,EACT,WAAsB,EACtB,QAAe,EACf,QAAgB,EAChB,IAAY,EACZ,KAAa,EACb,MAAM,EACN,eAAsB,GACvB,EAAE,eAAe,+BA6BjB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
function isDirectVideo(src) {
|
|
3
|
+
return /\.(?:mp4|webm|ogg)(?:[?#]|$)/i.test(src);
|
|
4
|
+
}
|
|
5
|
+
export function VideoEmbed({ src, title = "Video", className, aspectRatio = "16 / 9", controls = true, autoplay = false, loop = false, muted = false, poster, allowFullScreen = true, }) {
|
|
6
|
+
const mediaClass = `video-embed__media ${className ?? ""}`.trim();
|
|
7
|
+
if (isDirectVideo(src)) {
|
|
8
|
+
return (_jsx("video", { className: mediaClass, src: src, title: title, controls: controls, autoPlay: autoplay, loop: loop, muted: muted, poster: poster, playsInline: true }));
|
|
9
|
+
}
|
|
10
|
+
return (_jsx("iframe", { className: mediaClass, src: src, title: title, loading: "lazy", allow: "autoplay; fullscreen", allowFullScreen: allowFullScreen, style: { aspectRatio }, referrerPolicy: "strict-origin-when-cross-origin" }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=VideoEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoEmbed.js","sourceRoot":"","sources":["../../src/video/VideoEmbed.tsx"],"names":[],"mappings":";AAiBA,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,+BAA+B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EACzB,GAAG,EACH,KAAK,GAAG,OAAO,EACf,SAAS,EACT,WAAW,GAAG,QAAQ,EACtB,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,KAAK,EACZ,KAAK,GAAG,KAAK,EACb,MAAM,EACN,eAAe,GAAG,IAAI,GACN;IAChB,MAAM,UAAU,GAAG,sBAAsB,SAAS,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACjE,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,CACL,gBACE,SAAS,EAAE,UAAU,EACrB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,WAAW,SACX,CACH,CAAA;IACH,CAAC;IACD,OAAO,CACL,iBACE,SAAS,EAAE,UAAU,EACrB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,OAAO,EAAC,MAAM,EACd,KAAK,EAAC,sBAAsB,EAC5B,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,EAAE,WAAW,EAAE,EACtB,cAAc,EAAC,iCAAiC,GAChD,CACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/video/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/video/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
export interface DocstreamSourceMount {
|
|
3
|
+
/** Stable name used by Markdown source references. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Real source directory. Relative paths are resolved from the Vite root. */
|
|
6
|
+
root: string;
|
|
7
|
+
/** Allow PUT requests to edit files in this mount. Defaults to true. */
|
|
8
|
+
writable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DocstreamSourcesOptions {
|
|
11
|
+
mounts: readonly DocstreamSourceMount[];
|
|
12
|
+
/** HTTP endpoint prefix. Defaults to `/@docstream`. */
|
|
13
|
+
apiBase?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Mount real source directories behind safe Vite dev-server endpoints.
|
|
17
|
+
* Markdown references import live modules from these files, and editor writes
|
|
18
|
+
* go back to disk so Vite's normal watcher/HMR pipeline remains authoritative.
|
|
19
|
+
*/
|
|
20
|
+
export declare function docstreamSources(options: DocstreamSourcesOptions): Plugin;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAA;AAEjD,MAAM,WAAW,oBAAoB;IACnC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAA;IACZ,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAA;IACvC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AA6GD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAgCzE"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const VIRTUAL_ID = "virtual:docstream-sources";
|
|
4
|
+
const RESOLVED_VIRTUAL_ID = "\0virtual:docstream-sources";
|
|
5
|
+
function send(response, status, body, type = "application/json; charset=utf-8") {
|
|
6
|
+
response.statusCode = status;
|
|
7
|
+
response.setHeader("content-type", type);
|
|
8
|
+
response.setHeader("cache-control", "no-store");
|
|
9
|
+
response.end(body);
|
|
10
|
+
}
|
|
11
|
+
function requestUrl(request) {
|
|
12
|
+
return new URL(request.url ?? "/", "http://docstream.local");
|
|
13
|
+
}
|
|
14
|
+
async function requestBody(request) {
|
|
15
|
+
const chunks = [];
|
|
16
|
+
for await (const chunk of request)
|
|
17
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
18
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
19
|
+
}
|
|
20
|
+
function normalizeRelativePath(value) {
|
|
21
|
+
const source = value.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
22
|
+
if (!source || source.startsWith("/") || source.split("/").some((part) => part === ".." || part === "")) {
|
|
23
|
+
throw new Error(`Invalid mounted source path: ${value}`);
|
|
24
|
+
}
|
|
25
|
+
return source;
|
|
26
|
+
}
|
|
27
|
+
function sourcePath(mount, requestedPath) {
|
|
28
|
+
const relativePath = normalizeRelativePath(requestedPath);
|
|
29
|
+
const absolutePath = path.resolve(mount.root, relativePath);
|
|
30
|
+
const prefix = mount.root.endsWith(path.sep) ? mount.root : `${mount.root}${path.sep}`;
|
|
31
|
+
if (!absolutePath.startsWith(prefix))
|
|
32
|
+
throw new Error(`Source path escapes mount ${mount.name}: ${requestedPath}`);
|
|
33
|
+
return { relativePath, absolutePath };
|
|
34
|
+
}
|
|
35
|
+
function provenance(url, mount, relativePath, absolutePath, mtimeMs) {
|
|
36
|
+
return {
|
|
37
|
+
mount: mount.name,
|
|
38
|
+
path: relativePath,
|
|
39
|
+
exportName: url.searchParams.get("export") || "default",
|
|
40
|
+
kind: url.searchParams.get("kind") === "story" ? "story" : "component",
|
|
41
|
+
absolutePath,
|
|
42
|
+
mtimeMs,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function findMount(url, mounts) {
|
|
46
|
+
const name = url.searchParams.get("mount") ?? "";
|
|
47
|
+
const mount = mounts.find((candidate) => candidate.name === name);
|
|
48
|
+
if (!mount)
|
|
49
|
+
throw new Error(`Unknown Docstream source mount: ${name}`);
|
|
50
|
+
return mount;
|
|
51
|
+
}
|
|
52
|
+
function errorMessage(error) {
|
|
53
|
+
return error instanceof Error ? error.message : String(error);
|
|
54
|
+
}
|
|
55
|
+
function installMiddleware(server, apiBase, viteBase, mounts) {
|
|
56
|
+
server.middlewares.use(async (request, response, next) => {
|
|
57
|
+
const url = requestUrl(request);
|
|
58
|
+
if (url.pathname !== `${apiBase}/source` && url.pathname !== `${apiBase}/module`)
|
|
59
|
+
return next();
|
|
60
|
+
try {
|
|
61
|
+
const mount = findMount(url, mounts);
|
|
62
|
+
const requestedPath = url.searchParams.get("path") ?? "";
|
|
63
|
+
const { relativePath, absolutePath } = sourcePath(mount, requestedPath);
|
|
64
|
+
if (url.pathname === `${apiBase}/module`) {
|
|
65
|
+
if (request.method !== "GET")
|
|
66
|
+
return send(response, 405, "Method not allowed", "text/plain; charset=utf-8");
|
|
67
|
+
await fs.access(absolutePath);
|
|
68
|
+
const sourceUrl = `${viteBase.replace(/\/$/, "")}/@fs/${absolutePath.replaceAll(path.sep, "/")}?docstream=${Date.now()}`;
|
|
69
|
+
const module = `import * as source from ${JSON.stringify(sourceUrl)};\nexport default source;\n`;
|
|
70
|
+
return send(response, 200, module, "text/javascript; charset=utf-8");
|
|
71
|
+
}
|
|
72
|
+
if (request.method === "GET") {
|
|
73
|
+
const [content, stat] = await Promise.all([fs.readFile(absolutePath, "utf8"), fs.stat(absolutePath)]);
|
|
74
|
+
return send(response, 200, JSON.stringify({ content, provenance: provenance(url, mount, relativePath, absolutePath, stat.mtimeMs) }));
|
|
75
|
+
}
|
|
76
|
+
if (request.method === "PUT") {
|
|
77
|
+
if (!mount.writable)
|
|
78
|
+
return send(response, 403, `Source mount ${mount.name} is read-only`, "text/plain; charset=utf-8");
|
|
79
|
+
await fs.access(absolutePath);
|
|
80
|
+
const parsed = JSON.parse(await requestBody(request));
|
|
81
|
+
if (typeof parsed.content !== "string")
|
|
82
|
+
return send(response, 400, "Expected a JSON string field named content", "text/plain; charset=utf-8");
|
|
83
|
+
await fs.writeFile(absolutePath, parsed.content, "utf8");
|
|
84
|
+
const stat = await fs.stat(absolutePath);
|
|
85
|
+
server.watcher.add(absolutePath);
|
|
86
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
87
|
+
return send(response, 200, JSON.stringify({ content: parsed.content, provenance: provenance(url, mount, relativePath, absolutePath, stat.mtimeMs) }));
|
|
88
|
+
}
|
|
89
|
+
return send(response, 405, "Method not allowed", "text/plain; charset=utf-8");
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const status = error && typeof error === "object" && "code" in error && error.code === "ENOENT" ? 404 : 400;
|
|
93
|
+
return send(response, status, errorMessage(error), "text/plain; charset=utf-8");
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Mount real source directories behind safe Vite dev-server endpoints.
|
|
99
|
+
* Markdown references import live modules from these files, and editor writes
|
|
100
|
+
* go back to disk so Vite's normal watcher/HMR pipeline remains authoritative.
|
|
101
|
+
*/
|
|
102
|
+
export function docstreamSources(options) {
|
|
103
|
+
const apiBase = `/${(options.apiBase ?? "/@docstream").replace(/^\/+|\/+$/g, "")}`;
|
|
104
|
+
let mounts = [];
|
|
105
|
+
let viteBase = "/";
|
|
106
|
+
return {
|
|
107
|
+
name: "docstream-sources",
|
|
108
|
+
enforce: "pre",
|
|
109
|
+
configResolved(config) {
|
|
110
|
+
viteBase = config.base || "/";
|
|
111
|
+
const names = new Set();
|
|
112
|
+
mounts = options.mounts.map((mount) => {
|
|
113
|
+
if (!mount.name || names.has(mount.name))
|
|
114
|
+
throw new Error(`Docstream source mount names must be unique: ${mount.name}`);
|
|
115
|
+
names.add(mount.name);
|
|
116
|
+
return {
|
|
117
|
+
name: mount.name,
|
|
118
|
+
root: path.resolve(config.root, mount.root),
|
|
119
|
+
writable: mount.writable !== false,
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
configureServer(server) {
|
|
124
|
+
installMiddleware(server, apiBase, viteBase, mounts);
|
|
125
|
+
},
|
|
126
|
+
resolveId(id) {
|
|
127
|
+
if (id === VIRTUAL_ID)
|
|
128
|
+
return RESOLVED_VIRTUAL_ID;
|
|
129
|
+
},
|
|
130
|
+
load(id) {
|
|
131
|
+
if (id !== RESOLVED_VIRTUAL_ID)
|
|
132
|
+
return;
|
|
133
|
+
return `export const apiBase = ${JSON.stringify(apiBase)};\nexport const mounts = ${JSON.stringify(options.mounts.map(({ name, writable = true }) => ({ name, writable })))};\n`;
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAyB5B,MAAM,UAAU,GAAG,2BAA2B,CAAA;AAC9C,MAAM,mBAAmB,GAAG,6BAA6B,CAAA;AAEzD,SAAS,IAAI,CAAC,QAAwB,EAAE,MAAc,EAAE,IAAY,EAAE,IAAI,GAAG,iCAAiC;IAC5G,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IACxC,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;IAC/C,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACpB,CAAC;AAED,SAAS,UAAU,CAAC,OAAwB;IAC1C,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,EAAE,wBAAwB,CAAC,CAAA;AAC9D,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,OAAwB;IACjD,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACnG,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC/C,CAAC;AAED,SAAS,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E,KAAK,CAAC,QAAQ,KAAK,KAAK;iBACnC,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,eAAe,CAAC,MAAM;YACpB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;QACtD,CAAC;QACD,SAAS,CAAC,EAAE;YACV,IAAI,EAAE,KAAK,UAAU;gBAAE,OAAO,mBAAmB,CAAA;QACnD,CAAC;QACD,IAAI,CAAC,EAAE;YACL,IAAI,EAAE,KAAK,mBAAmB;gBAAE,OAAM;YACtC,OAAO,0BAA0B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;QAClL,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PlayerAudio, VideoScene } from "@brett_lamy/viz-engine";
|
|
2
|
+
export interface VizEmbedProps {
|
|
3
|
+
scene: VideoScene;
|
|
4
|
+
audio?: PlayerAudio;
|
|
5
|
+
title?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
autoplay?: boolean;
|
|
8
|
+
loop?: boolean;
|
|
9
|
+
showCaptions?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Mount a deterministic VizEngine scene inside a Docstream document. This is
|
|
13
|
+
* intentionally a component API rather than a markdown escape hatch: callers
|
|
14
|
+
* choose the scene and its evidence, while Docstream supplies document chrome
|
|
15
|
+
* and accessible figure semantics.
|
|
16
|
+
*/
|
|
17
|
+
export declare function VizEmbed({ scene, audio, title, className, autoplay, loop, showCaptions, }: VizEmbedProps): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=VizEmbed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VizEmbed.d.ts","sourceRoot":"","sources":["../../src/viz/VizEmbed.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGrE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,UAAU,CAAA;IACjB,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAe,EACf,IAAW,EACX,YAAoB,GACrB,EAAE,aAAa,+BAcf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { VizPlayer } from "@brett_lamy/viz-engine";
|
|
3
|
+
/**
|
|
4
|
+
* Mount a deterministic VizEngine scene inside a Docstream document. This is
|
|
5
|
+
* intentionally a component API rather than a markdown escape hatch: callers
|
|
6
|
+
* choose the scene and its evidence, while Docstream supplies document chrome
|
|
7
|
+
* and accessible figure semantics.
|
|
8
|
+
*/
|
|
9
|
+
export function VizEmbed({ scene, audio, title, className, autoplay = true, loop = true, showCaptions = false, }) {
|
|
10
|
+
return (_jsxs("figure", { className: `docstream-viz ${className ?? ""}`.trim(), children: [_jsx(VizPlayer, { scene: scene, ...(audio === undefined ? {} : { audio }), autoplay: autoplay, loop: loop, showCaptions: showCaptions, className: "docstream-viz__player" }), title && _jsx("figcaption", { children: title })] }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=VizEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VizEmbed.js","sourceRoot":"","sources":["../../src/viz/VizEmbed.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAYlD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,KAAK,EACL,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,GAAG,IAAI,EACf,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,KAAK,GACN;IACd,OAAO,CACL,kBAAQ,SAAS,EAAE,iBAAiB,SAAS,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,aAC1D,KAAC,SAAS,IACR,KAAK,EAAE,KAAK,KACR,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAC1C,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAC,uBAAuB,GACjC,EACD,KAAK,IAAI,+BAAa,KAAK,GAAc,IACnC,CACV,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/viz/index.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/viz/index.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brett_lamy/docstream",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "GitBook-aware readonly markdown and AI stream renderer.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
|
+
"build": "node scripts/build.mjs",
|
|
10
11
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
11
|
-
"test": "vitest run"
|
|
12
|
+
"test": "npm run build && vitest run",
|
|
13
|
+
"prepack": "npm run build"
|
|
12
14
|
},
|
|
13
|
-
"main": "./
|
|
14
|
-
"types": "./
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
15
17
|
"files": [
|
|
18
|
+
"dist",
|
|
16
19
|
"src",
|
|
17
20
|
"!src/**/*.test.ts",
|
|
18
21
|
"!src/**/*.test.tsx",
|
|
@@ -24,58 +27,84 @@
|
|
|
24
27
|
],
|
|
25
28
|
"exports": {
|
|
26
29
|
".": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
30
|
+
"source": "./src/index.ts",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
29
34
|
},
|
|
30
35
|
"./gitbook": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
36
|
+
"source": "./src/gitbook/index.ts",
|
|
37
|
+
"types": "./dist/gitbook/index.d.ts",
|
|
38
|
+
"import": "./dist/gitbook/index.js",
|
|
39
|
+
"default": "./dist/gitbook/index.js"
|
|
33
40
|
},
|
|
34
41
|
"./streamdown": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
42
|
+
"source": "./src/streamdown.tsx",
|
|
43
|
+
"types": "./dist/streamdown.d.ts",
|
|
44
|
+
"import": "./dist/streamdown.js",
|
|
45
|
+
"default": "./dist/streamdown.js"
|
|
37
46
|
},
|
|
38
47
|
"./reference": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
48
|
+
"source": "./src/docs/reference.tsx",
|
|
49
|
+
"types": "./dist/docs/reference.d.ts",
|
|
50
|
+
"import": "./dist/docs/reference.js",
|
|
51
|
+
"default": "./dist/docs/reference.js"
|
|
41
52
|
},
|
|
42
53
|
"./assets": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
54
|
+
"source": "./src/assets.ts",
|
|
55
|
+
"types": "./dist/assets.d.ts",
|
|
56
|
+
"import": "./dist/assets.js",
|
|
57
|
+
"default": "./dist/assets.js"
|
|
45
58
|
},
|
|
46
59
|
"./openapi": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
60
|
+
"source": "./src/openapi/OpenApiOperation.tsx",
|
|
61
|
+
"types": "./dist/openapi/OpenApiOperation.d.ts",
|
|
62
|
+
"import": "./dist/openapi/OpenApiOperation.js",
|
|
63
|
+
"default": "./dist/openapi/OpenApiOperation.js"
|
|
49
64
|
},
|
|
50
65
|
"./replay": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
66
|
+
"source": "./src/replay/index.ts",
|
|
67
|
+
"types": "./dist/replay/index.d.ts",
|
|
68
|
+
"import": "./dist/replay/index.js",
|
|
69
|
+
"default": "./dist/replay/index.js"
|
|
53
70
|
},
|
|
54
71
|
"./video": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
72
|
+
"source": "./src/video/index.ts",
|
|
73
|
+
"types": "./dist/video/index.d.ts",
|
|
74
|
+
"import": "./dist/video/index.js",
|
|
75
|
+
"default": "./dist/video/index.js"
|
|
57
76
|
},
|
|
58
77
|
"./viz": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
78
|
+
"source": "./src/viz/index.ts",
|
|
79
|
+
"types": "./dist/viz/index.d.ts",
|
|
80
|
+
"import": "./dist/viz/index.js",
|
|
81
|
+
"default": "./dist/viz/index.js"
|
|
61
82
|
},
|
|
62
83
|
"./playground": {
|
|
63
|
-
"
|
|
64
|
-
"
|
|
84
|
+
"source": "./src/playground/index.ts",
|
|
85
|
+
"types": "./dist/playground/index.d.ts",
|
|
86
|
+
"import": "./dist/playground/index.js",
|
|
87
|
+
"default": "./dist/playground/index.js"
|
|
65
88
|
},
|
|
66
89
|
"./source": {
|
|
67
|
-
"
|
|
68
|
-
"
|
|
90
|
+
"source": "./src/source/index.ts",
|
|
91
|
+
"types": "./dist/source/index.d.ts",
|
|
92
|
+
"import": "./dist/source/index.js",
|
|
93
|
+
"default": "./dist/source/index.js"
|
|
69
94
|
},
|
|
70
95
|
"./demo": {
|
|
71
|
-
"
|
|
72
|
-
"
|
|
96
|
+
"source": "./src/demo/index.ts",
|
|
97
|
+
"types": "./dist/demo/index.d.ts",
|
|
98
|
+
"import": "./dist/demo/index.js",
|
|
99
|
+
"default": "./dist/demo/index.js"
|
|
73
100
|
},
|
|
74
101
|
"./vite": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
102
|
+
"source": "./src/vite/index.ts",
|
|
103
|
+
"types": "./dist/vite/index.d.ts",
|
|
104
|
+
"import": "./dist/vite/index.js",
|
|
105
|
+
"default": "./dist/vite/index.js"
|
|
77
106
|
},
|
|
78
|
-
"./styles.css": "./
|
|
107
|
+
"./styles.css": "./dist/styles.css"
|
|
79
108
|
},
|
|
80
109
|
"dependencies": {
|
|
81
110
|
"framer-motion": "^13.1.1",
|
|
@@ -116,5 +145,6 @@
|
|
|
116
145
|
"typescript": "^5.5.4",
|
|
117
146
|
"vite": "^7.0.0",
|
|
118
147
|
"vitest": "^3.2.4"
|
|
119
|
-
}
|
|
148
|
+
},
|
|
149
|
+
"module": "./dist/index.js"
|
|
120
150
|
}
|
package/src/docs/Mermaid.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useId,
|
|
1
|
+
import { useEffect, useId, useState, type CSSProperties } from "react"
|
|
2
2
|
import { HighlightedCode } from "./HighlightedCode"
|
|
3
3
|
|
|
4
4
|
let seq = 0
|
|
@@ -17,7 +17,6 @@ export function Mermaid({ code, collapsedCodeLines = 3, expandedCodeLines = 30 }
|
|
|
17
17
|
const [svg, setSvg] = useState<string | null>(null)
|
|
18
18
|
const [error, setError] = useState<string | null>(null)
|
|
19
19
|
const [codeExpanded, setCodeExpanded] = useState(false)
|
|
20
|
-
const idRef = useRef(`mermaid-${++seq}`)
|
|
21
20
|
const codePanelId = useId()
|
|
22
21
|
const collapsedLines = positiveLineCount(collapsedCodeLines, 3)
|
|
23
22
|
const expandedLines = Math.max(collapsedLines, positiveLineCount(expandedCodeLines, 30))
|
|
@@ -27,7 +26,10 @@ export function Mermaid({ code, collapsedCodeLines = 3, expandedCodeLines = 30 }
|
|
|
27
26
|
import("mermaid")
|
|
28
27
|
.then(async ({ default: mermaid }) => {
|
|
29
28
|
mermaid.initialize({ startOnLoad: false, securityLevel: "strict" })
|
|
30
|
-
|
|
29
|
+
// A fresh id per render: mermaid.render removes any element with the id it is given,
|
|
30
|
+
// so reusing one (StrictMode's double effect, a code change) deleted the diagram an
|
|
31
|
+
// earlier render had already mounted.
|
|
32
|
+
const { svg } = await mermaid.render(`mermaid-${++seq}`, code)
|
|
31
33
|
if (!cancelled) setSvg(svg)
|
|
32
34
|
})
|
|
33
35
|
.catch((e) => {
|
package/src/styles.css
CHANGED
|
@@ -2343,6 +2343,97 @@
|
|
|
2343
2343
|
}
|
|
2344
2344
|
}
|
|
2345
2345
|
|
|
2346
|
+
/* Replay embeds (ReplayPreview / ReplayEmbed). Part of the one package stylesheet so no
|
|
2347
|
+
module imports CSS on the eager path: the root entry stays importable from Node
|
|
2348
|
+
(SSR, vitest) without a CSS loader. */
|
|
2349
|
+
.replay-preview {
|
|
2350
|
+
width: 100%;
|
|
2351
|
+
min-width: 0;
|
|
2352
|
+
color: var(--replay-preview-fg, #e5e7eb);
|
|
2353
|
+
background: var(--replay-preview-bg, #0f172a);
|
|
2354
|
+
border: 1px solid var(--replay-preview-border, rgba(148, 163, 184, 0.28));
|
|
2355
|
+
border-radius: 12px;
|
|
2356
|
+
overflow: hidden;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
.replay-preview__frame {
|
|
2360
|
+
display: block;
|
|
2361
|
+
width: 100%;
|
|
2362
|
+
aspect-ratio: 16 / 9;
|
|
2363
|
+
border: 0;
|
|
2364
|
+
background: #0f172a;
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
.replay-preview__invalid,
|
|
2368
|
+
.replay-preview__empty,
|
|
2369
|
+
.replay-preview__error {
|
|
2370
|
+
display: flex;
|
|
2371
|
+
align-items: center;
|
|
2372
|
+
justify-content: center;
|
|
2373
|
+
min-height: 140px;
|
|
2374
|
+
padding: 20px;
|
|
2375
|
+
color: var(--replay-preview-muted, #94a3b8);
|
|
2376
|
+
font: 13px/1.5 ui-sans-serif, system-ui, sans-serif;
|
|
2377
|
+
text-align: center;
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
.replay-preview__invalid {
|
|
2381
|
+
color: var(--replay-preview-link, #7dd3fc);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
.replay-preview__error {
|
|
2385
|
+
color: #fda4af;
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
.replay-preview__native {
|
|
2389
|
+
width: 100%;
|
|
2390
|
+
background: #0f172a;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
.replay-preview__stage {
|
|
2394
|
+
position: relative;
|
|
2395
|
+
width: 100%;
|
|
2396
|
+
min-height: 160px;
|
|
2397
|
+
overflow: hidden;
|
|
2398
|
+
background: #020617;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
.replay-preview__scaler {
|
|
2402
|
+
position: absolute;
|
|
2403
|
+
inset: 0 auto auto 0;
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
.replay-preview__player {
|
|
2407
|
+
position: relative;
|
|
2408
|
+
overflow: hidden;
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
.replay-preview__controls {
|
|
2412
|
+
display: flex;
|
|
2413
|
+
align-items: center;
|
|
2414
|
+
gap: 8px;
|
|
2415
|
+
padding: 8px 10px;
|
|
2416
|
+
border-top: 1px solid rgba(148, 163, 184, 0.2);
|
|
2417
|
+
background: #111827;
|
|
2418
|
+
font: 12px/1.2 ui-sans-serif, system-ui, sans-serif;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
.replay-preview__controls button,
|
|
2422
|
+
.replay-preview__controls select {
|
|
2423
|
+
border: 1px solid rgba(148, 163, 184, 0.3);
|
|
2424
|
+
border-radius: 6px;
|
|
2425
|
+
padding: 5px 8px;
|
|
2426
|
+
color: inherit;
|
|
2427
|
+
background: #1e293b;
|
|
2428
|
+
cursor: pointer;
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
.replay-preview__controls input[type='range'] {
|
|
2432
|
+
min-width: 60px;
|
|
2433
|
+
flex: 1;
|
|
2434
|
+
accent-color: #38bdf8;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2346
2437
|
/* Keep every rendered table variant flush, after the shared block spacing rules. */
|
|
2347
2438
|
:is([data-docstream], .docs-article) [data-docstream-blocks] > :is(.docs-table, table, .docs-cards) {
|
|
2348
2439
|
margin-block-start: 0;
|