@lofcz/streamdown 2.14.1 → 2.15.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 (37) hide show
  1. package/dist/chunk-6TBP27CO.js +2 -0
  2. package/dist/chunk-TXJ25TS2.js +51 -0
  3. package/dist/diagram-O5F65CLC.js +2 -0
  4. package/dist/highlighted-body-N5O52WFD.js +2 -0
  5. package/dist/index.d.ts +8 -4
  6. package/dist/index.js +1 -1
  7. package/dist/lib/controls.d.ts +2 -2
  8. package/dist/lib/diagram/adapter.d.ts +11 -0
  9. package/dist/lib/diagram/context.d.ts +2 -0
  10. package/dist/lib/diagram/controls.d.ts +4 -0
  11. package/dist/lib/diagram/download-button.d.ts +15 -0
  12. package/dist/lib/diagram/fullscreen-button.d.ts +23 -0
  13. package/dist/lib/diagram/index.d.ts +13 -0
  14. package/dist/lib/diagram/labels.d.ts +6 -0
  15. package/dist/lib/diagram/options.d.ts +1 -0
  16. package/dist/lib/mermaid/download-button.d.ts +1 -1
  17. package/dist/lib/mermaid/fullscreen-button.d.ts +1 -1
  18. package/dist/lib/mermaid/index.d.ts +3 -3
  19. package/dist/lib/plantuml/download-button.d.ts +1 -1
  20. package/dist/lib/plantuml/fullscreen-button.d.ts +1 -1
  21. package/dist/lib/plantuml/index.d.ts +3 -3
  22. package/dist/lib/plugin-context.d.ts +18 -1
  23. package/dist/lib/plugin-types.d.ts +95 -1
  24. package/dist/lib/preprocess-custom-tags.d.ts +5 -0
  25. package/dist/lib/streamdown-context.d.ts +37 -19
  26. package/dist/lib/tailwind-classes.d.ts +1 -1
  27. package/dist/lib/tailwind-classes.js +1 -1
  28. package/dist/lib/translations-context.d.ts +20 -0
  29. package/dist/openscad-RHDHURT6.js +2 -0
  30. package/dist/{viewer-A5T7PMUM.js → viewer-URBRVFVJ.js} +1 -1
  31. package/package.json +1 -1
  32. package/dist/chunk-EMUDB4GM.js +0 -2
  33. package/dist/chunk-FYGB27SX.js +0 -50
  34. package/dist/highlighted-body-PPVGTFLS.js +0 -2
  35. package/dist/mermaid-HNKQSOWL.js +0 -2
  36. package/dist/openscad-6N3MT4TE.js +0 -2
  37. package/dist/plantuml-GGYHKHKF.js +0 -2
@@ -1,4 +1,4 @@
1
- import type { PluginConfig } from "./plugin-types";
1
+ import type { PluginConfig, SvgDiagramPlugin } from "./plugin-types";
2
2
  /**
3
3
  * Context for Streamdown plugins
4
4
  */
@@ -19,6 +19,23 @@ export declare const useMermaidPlugin: () => import("./plugin-types").DiagramPlu
19
19
  * Hook to access the PlantUML plugin
20
20
  */
21
21
  export declare const usePlantUmlPlugin: () => import("./plugin-types").PlantUmlPlugin | null;
22
+ /**
23
+ * Hook to access the Vega plugin
24
+ */
25
+ export declare const useVegaPlugin: () => SvgDiagramPlugin | import("./plugin-types").VegaPlugin | null;
26
+ /**
27
+ * Hook to access the SMILES plugin
28
+ */
29
+ export declare const useSmilesPlugin: () => import("./plugin-types").SmilesPlugin | SvgDiagramPlugin | null;
30
+ /**
31
+ * All SVG diagram plugins, including named mermaid / plantuml / vega / smiles
32
+ * slots and extras from `plugins.diagrams`.
33
+ */
34
+ export declare const useDiagramPlugins: () => SvgDiagramPlugin[];
35
+ /**
36
+ * Find an SVG diagram plugin for a fence language.
37
+ */
38
+ export declare const useDiagramPlugin: (language: string) => SvgDiagramPlugin | null;
22
39
  /**
23
40
  * Hook to access the OpenSCAD plugin
24
41
  */
@@ -91,6 +91,62 @@ export interface DiagramPlugin {
91
91
  name: "mermaid";
92
92
  type: "diagram";
93
93
  }
94
+ /**
95
+ * Shared SVG diagram contract used by the generic renderer.
96
+ * Mermaid and PlantUML are adapted to this shape in core; Vega implements it
97
+ * natively. Extra engines (Graphviz, D2, …) can be passed via `plugins.diagrams`.
98
+ */
99
+ export interface SvgDiagramPlugin {
100
+ /**
101
+ * Language identifiers for code blocks
102
+ */
103
+ language: string | readonly string[];
104
+ name: string;
105
+ /**
106
+ * Render source to an SVG string. `options` is plugin-specific and may
107
+ * include a `language` field for engines that handle multiple fences.
108
+ */
109
+ render: (source: string, options?: unknown) => Promise<{
110
+ svg: string;
111
+ }>;
112
+ /**
113
+ * File extension (no dot) used when downloading the source.
114
+ * @default "txt"
115
+ */
116
+ sourceExtension?: string;
117
+ type: "diagram";
118
+ }
119
+ /**
120
+ * Structural type for Vega / Vega-Lite configuration.
121
+ * Avoids a hard dependency on `vega` / `vega-lite` in the core bundle.
122
+ */
123
+ export interface VegaConfig {
124
+ /**
125
+ * How to interpret the spec. `"auto"` uses the fence language and `$schema`.
126
+ */
127
+ mode?: "auto" | "vega" | "vega-lite";
128
+ }
129
+ export interface VegaInstance {
130
+ render: (source: string, options?: VegaConfig) => Promise<{
131
+ svg: string;
132
+ }>;
133
+ }
134
+ /**
135
+ * Plugin for diagram rendering (Vega / Vega-Lite)
136
+ */
137
+ export interface VegaPlugin {
138
+ /**
139
+ * Get the Vega instance (initialized with optional config)
140
+ */
141
+ getVega: (config?: VegaConfig) => VegaInstance;
142
+ /**
143
+ * Language identifiers for code blocks (`vega`, `vega-lite`, `vegalite`)
144
+ */
145
+ language: string | readonly string[];
146
+ name: "vega";
147
+ sourceExtension?: string;
148
+ type: "diagram";
149
+ }
94
150
  /**
95
151
  * Structural type for PlantUML configuration.
96
152
  * Avoids a hard dependency on `@plantuml/core` in the core bundle.
@@ -189,10 +245,41 @@ export interface OpenScadPlugin {
189
245
  name: "openscad";
190
246
  type: "model";
191
247
  }
248
+ /**
249
+ * Structural type for SMILES configuration.
250
+ * Avoids a hard dependency on `smiles-drawer` in the core bundle.
251
+ */
252
+ export interface SmilesConfig {
253
+ elementColors?: boolean;
254
+ height?: number;
255
+ theme?: "light" | "dark" | "oldschool" | "auto";
256
+ width?: number;
257
+ }
258
+ export interface SmilesInstance {
259
+ render: (source: string, options?: SmilesConfig) => Promise<{
260
+ svg: string;
261
+ }>;
262
+ }
263
+ /**
264
+ * Plugin for chemical structure rendering (SMILES)
265
+ */
266
+ export interface SmilesPlugin {
267
+ /**
268
+ * Get the SMILES instance (initialized with optional config)
269
+ */
270
+ getSmiles: (config?: SmilesConfig) => SmilesInstance;
271
+ /**
272
+ * Language identifiers for code blocks (`smiles`, `smi`)
273
+ */
274
+ language: string | readonly string[];
275
+ name: "smiles";
276
+ sourceExtension?: string;
277
+ type: "diagram";
278
+ }
192
279
  /**
193
280
  * Union type for all plugins
194
281
  */
195
- export type StreamdownPlugin = CodeHighlighterPlugin | DiagramPlugin | PlantUmlPlugin | MathPlugin | CjkPlugin | OpenScadPlugin;
282
+ export type StreamdownPlugin = CodeHighlighterPlugin | DiagramPlugin | PlantUmlPlugin | VegaPlugin | SmilesPlugin | SvgDiagramPlugin | MathPlugin | CjkPlugin | OpenScadPlugin;
196
283
  export interface CustomRendererProps {
197
284
  code: string;
198
285
  isIncomplete: boolean;
@@ -212,9 +299,16 @@ export interface CustomRenderer {
212
299
  export interface PluginConfig {
213
300
  cjk?: CjkPlugin;
214
301
  code?: CodeHighlighterPlugin;
302
+ /**
303
+ * Extra SVG diagram engines, looked up by fence language after the named
304
+ * mermaid / plantuml / vega / smiles slots.
305
+ */
306
+ diagrams?: SvgDiagramPlugin[];
215
307
  math?: MathPlugin;
216
308
  mermaid?: DiagramPlugin;
217
309
  openscad?: OpenScadPlugin;
218
310
  plantuml?: PlantUmlPlugin;
219
311
  renderers?: CustomRenderer[];
312
+ smiles?: SmilesPlugin | SvgDiagramPlugin;
313
+ vega?: VegaPlugin | SvgDiagramPlugin;
220
314
  }
@@ -43,4 +43,9 @@
43
43
  * 6. **Tags inside code** (fenced blocks, inline code spans) are ignored in
44
44
  * every pass — they are examples being shown, not markup being used.
45
45
  */
46
+ /**
47
+ * Rewrite `<tag ... />` to `<tag ...></tag>` so rehype-raw does not treat
48
+ * unknown custom tags as non-void containers that swallow following text.
49
+ */
50
+ export declare const rewriteSelfClosingCustomTags: (markdown: string, tagNames: string[]) => string;
46
51
  export declare const preprocessCustomTags: (markdown: string, tagNames: string[]) => string;
@@ -1,7 +1,7 @@
1
1
  import { type ComponentProps, type ComponentType, type CSSProperties } from "react";
2
2
  import type { PluggableList } from "unified";
3
3
  import type { Components } from "./markdown";
4
- import type { MermaidConfig, OpenScadConfig, PlantUmlConfig, ThemeInput } from "./plugin-types";
4
+ import type { MermaidConfig, OpenScadConfig, PlantUmlConfig, SmilesConfig, ThemeInput, VegaConfig } from "./plugin-types";
5
5
  import type { CSVSeparator } from "./table/utils";
6
6
  export type DownloadControlConfig = boolean | {
7
7
  filename: string;
@@ -11,6 +11,12 @@ export type CopyControlConfig<TOnCopy = () => void> = boolean | {
11
11
  onCopy?: TOnCopy;
12
12
  onError?: (error: Error) => void;
13
13
  };
14
+ export type DiagramControls = boolean | {
15
+ download?: DownloadControlConfig;
16
+ copy?: CopyControlConfig;
17
+ fullscreen?: boolean;
18
+ panZoom?: boolean;
19
+ };
14
20
  export type ControlsConfig = boolean | {
15
21
  table?: boolean | {
16
22
  copy?: CopyControlConfig<(format: TableCopyFormat) => void>;
@@ -22,18 +28,15 @@ export type ControlsConfig = boolean | {
22
28
  copy?: CopyControlConfig;
23
29
  download?: DownloadControlConfig;
24
30
  };
25
- mermaid?: boolean | {
26
- download?: DownloadControlConfig;
27
- copy?: CopyControlConfig;
28
- fullscreen?: boolean;
29
- panZoom?: boolean;
30
- };
31
- plantuml?: boolean | {
32
- download?: DownloadControlConfig;
33
- copy?: CopyControlConfig;
34
- fullscreen?: boolean;
35
- panZoom?: boolean;
36
- };
31
+ mermaid?: DiagramControls;
32
+ plantuml?: DiagramControls;
33
+ smiles?: DiagramControls;
34
+ vega?: DiagramControls;
35
+ /**
36
+ * Per-engine controls for extra SVG diagrams registered via
37
+ * `plugins.diagrams`, keyed by plugin `name`.
38
+ */
39
+ diagrams?: Record<string, DiagramControls>;
37
40
  openscad?: boolean | {
38
41
  download?: DownloadControlConfig;
39
42
  copy?: CopyControlConfig;
@@ -55,24 +58,35 @@ export interface LinkSafetyConfig {
55
58
  onLinkCheck?: (url: string) => Promise<boolean> | boolean;
56
59
  renderModal?: (props: LinkSafetyModalProps) => React.ReactNode;
57
60
  }
58
- export interface MermaidErrorComponentProps {
61
+ export interface DiagramErrorComponentProps {
59
62
  chart: string;
60
63
  error: string;
61
64
  retry: () => void;
62
65
  }
66
+ export interface DiagramOptions {
67
+ config?: unknown;
68
+ errorComponent?: React.ComponentType<DiagramErrorComponentProps>;
69
+ }
70
+ export type MermaidErrorComponentProps = DiagramErrorComponentProps;
63
71
  export interface MermaidOptions {
64
72
  config?: MermaidConfig;
65
73
  errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
66
74
  }
67
- export interface PlantUmlErrorComponentProps {
68
- chart: string;
69
- error: string;
70
- retry: () => void;
71
- }
75
+ export type PlantUmlErrorComponentProps = DiagramErrorComponentProps;
72
76
  export interface PlantUmlOptions {
73
77
  config?: PlantUmlConfig;
74
78
  errorComponent?: React.ComponentType<PlantUmlErrorComponentProps>;
75
79
  }
80
+ export type VegaErrorComponentProps = DiagramErrorComponentProps;
81
+ export interface VegaOptions {
82
+ config?: VegaConfig;
83
+ errorComponent?: React.ComponentType<VegaErrorComponentProps>;
84
+ }
85
+ export type SmilesErrorComponentProps = DiagramErrorComponentProps;
86
+ export interface SmilesOptions {
87
+ config?: SmilesConfig;
88
+ errorComponent?: React.ComponentType<SmilesErrorComponentProps>;
89
+ }
76
90
  export interface OpenScadErrorComponentProps {
77
91
  code: string;
78
92
  error: string;
@@ -128,6 +142,8 @@ export interface StreamdownContextType {
128
142
  /** Merged components/plugins so custom renderers (e.g. callout body) can re-parse nested markdown identically to the outer pass. */
129
143
  components?: Components;
130
144
  controls: ControlsConfig;
145
+ /** Per-engine options for extra SVG diagrams, keyed by plugin `name`. */
146
+ diagrams?: Record<string, DiagramOptions>;
131
147
  isAnimating: boolean;
132
148
  /** Show line numbers in code blocks. @default true */
133
149
  lineNumbers: boolean;
@@ -145,8 +161,10 @@ export interface StreamdownContextType {
145
161
  /** Component used for horizontal-scroll regions (code body, table). @default plain div */
146
162
  scrollable?: ScrollableComponent;
147
163
  shikiTheme: [ThemeInput, ThemeInput];
164
+ smiles?: SmilesOptions;
148
165
  /** Max height for tables (px number or CSS length). `0` / `Infinity` disables. @default 300 */
149
166
  tableMaxHeight?: number | string;
167
+ vega?: VegaOptions;
150
168
  }
151
169
  export declare const defaultStreamdownContext: StreamdownContextType;
152
170
  export declare const StreamdownContext: import("react").Context<StreamdownContextType>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Complete list of Tailwind CSS utility classes used by streamdown and its
3
3
  * official plugins (@streamdown/code, @streamdown/math, @streamdown/mermaid,
4
- * @streamdown/plantuml, @streamdown/cjk).
4
+ * @streamdown/plantuml, @streamdown/vega, @streamdown/smiles, @streamdown/cjk).
5
5
  *
6
6
  * Use this list to configure Tailwind v4's `@source inline()` directive when
7
7
  * you need a custom prefix. See the README for details.
@@ -1,2 +1,2 @@
1
- var s=["-mt-10","[&>p]:inline","[&>p:last-child]:mb-0","[&>svg]:inline-block","[&_svg]:h-auto","[&_svg]:w-auto","[counter-increment:line_0]","[counter-reset:line]","[li_&]:pl-6","absolute","animate-spin","appearance-none","backdrop-blur-sm","before:[counter-increment:line]","before:content-[counter(line)]","before:font-mono","before:inline-block","before:mr-4","before:select-none","before:text-[13px]","before:text-muted-foreground/50","before:text-right","before:w-6","bg-[var(--sdm-bg,inherit)]","bg-[var(--sdm-tbg)]","bg-background","bg-background/50","bg-background/80","bg-background/90","bg-background/95","bg-black/10","bg-muted","bg-muted/40","bg-muted/80","bg-primary","bg-red-100","bg-red-50","bg-sidebar","bg-sidebar/80","block","border","border-b","border-b-2","border-border","border-collapse","border-current","border-l-4","border-muted-foreground/30","border-red-200","border-sidebar","border-t","bottom-2","bottom-4","break-all","cursor-pointer","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]","dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]","disabled:cursor-not-allowed","disabled:opacity-50","divide-border","divide-y","duration-150","duration-200","ease-out","fixed","flex","flex-1","flex-col","font-medium","font-mono","font-semibold","gap-1","gap-2","gap-4","group","group-hover:block","group-hover:opacity-100","h-4","h-8","h-[400px]","h-[46px]","h-auto","h-full","hidden","hover:bg-background","hover:bg-muted","hover:bg-muted/40","hover:bg-primary/90","hover:text-foreground","inline-block","inset-0","italic","items-center","justify-between","justify-center","justify-end","left-2","left-4","line-clamp-2","list-decimal","list-disc","list-inside","lowercase","max-h-32","max-w-full","max-w-md","mb-2","min-h-28","min-h-[200px]","min-w-0","min-w-[120px]","ml-1","mt-1","mt-2","mt-6","mx-4","my-4","my-6","opacity-0","origin-center","overflow-hidden","overflow-x-auto","overflow-y-auto","overscroll-y-auto","p-1","p-1.5","p-2","p-3","p-4","p-6","pl-4","pointer-events-auto","pointer-events-none","px-1.5","px-3","px-4","py-0.5","py-1","py-2","relative","right-0","right-2","right-4","rounded","rounded-full","rounded-lg","rounded-md","rounded-r-md","rounded-xl","shadow-lg","shadow-sm","shrink-0","size-4","size-full","space-x-2","space-y-2","space-y-4","sticky","table-fixed","supports-[backdrop-filter]:backdrop-blur","supports-[backdrop-filter]:backdrop-blur-sm","supports-[backdrop-filter]:bg-background/70","supports-[backdrop-filter]:bg-sidebar/70","text-2xl","text-3xl","text-[var(--sdm-c,inherit)]","text-base","text-left","text-lg","text-muted-foreground","text-primary","text-primary-foreground","text-red-600","text-red-700","text-red-800","text-sm","text-xl","text-xs","top-2","top-4","top-full","transition-all","transition-colors","transition-transform","w-4","w-8","w-full","whitespace-normal","wrap-anywhere","z-10","z-50"];function a(r){let i=[...s],d=e=>r?`${r}:${e}`:e,t=[],n=[];for(let e of i)e.includes(",")?n.push(e):t.push(e);let o=[];if(t.length>0){let e=r?`${r}:{${t.join(",")}}`:`{${t.join(",")}}`;o.push(`@source inline("${e}");`);}for(let e of n)o.push(`@source inline("${d(e)}");`);return o.join(`
1
+ var s=["-mt-10","[&>p]:inline","[&>p:last-child]:mb-0","[&>svg]:inline-block","[&_svg]:h-auto","[&_svg]:w-auto","[counter-increment:line_0]","[counter-reset:line]","[li_&]:pl-6","absolute","animate-spin","appearance-none","backdrop-blur-sm","before:[counter-increment:line]","before:content-[counter(line)]","before:font-mono","before:inline-block","before:mr-4","before:select-none","before:text-[13px]","before:text-muted-foreground/50","before:text-right","before:w-6","bg-[var(--sdm-bg,inherit)]","bg-[var(--sdm-tbg)]","bg-background","bg-background/50","bg-background/80","bg-background/90","bg-background/95","bg-black/10","bg-muted","bg-muted/40","bg-muted/80","bg-primary","bg-red-100","bg-red-50","bg-sidebar","bg-sidebar/80","block","border","border-b","border-b-2","border-border","border-collapse","border-current","border-l-4","border-muted-foreground/30","border-red-200","border-sidebar","border-t","bottom-2","bottom-4","break-all","cursor-pointer","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]","dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]","disabled:cursor-not-allowed","disabled:opacity-50","divide-border","divide-y","duration-150","duration-200","ease-out","fixed","flex","flex-1","flex-col","font-medium","font-mono","font-semibold","gap-1","gap-2","gap-4","group","group-hover:block","group-hover:opacity-100","h-4","h-8","h-[400px]","h-[46px]","h-auto","h-full","hidden","hover:bg-background","hover:bg-muted","hover:bg-muted/40","hover:bg-primary/90","hover:text-foreground","inline-block","inset-0","italic","items-center","justify-between","justify-center","justify-end","left-2","left-4","line-clamp-2","list-decimal","list-disc","list-inside","lowercase","max-h-32","max-h-[min(70vh,40rem)]","max-w-full","max-w-md","mb-2","min-h-28","min-h-[200px]","min-w-0","min-w-[120px]","ml-1","mt-1","mt-2","mt-6","mx-4","my-4","my-6","opacity-0","origin-center","overflow-hidden","overflow-x-auto","overflow-y-auto","overscroll-y-auto","p-1","p-1.5","p-2","p-3","p-4","p-6","pl-4","pointer-events-auto","pointer-events-none","px-1.5","px-3","px-4","py-0.5","py-1","py-2","relative","right-0","right-2","right-4","rounded","rounded-full","rounded-lg","rounded-md","rounded-r-md","rounded-xl","shadow-lg","shadow-sm","shrink-0","size-4","size-full","space-x-2","space-y-2","space-y-4","sticky","table-fixed","supports-[backdrop-filter]:backdrop-blur","supports-[backdrop-filter]:backdrop-blur-sm","supports-[backdrop-filter]:bg-background/70","supports-[backdrop-filter]:bg-sidebar/70","text-2xl","text-3xl","text-[var(--sdm-c,inherit)]","text-base","text-left","text-lg","text-muted-foreground","text-primary","text-primary-foreground","text-red-600","text-red-700","text-red-800","text-sm","text-xl","text-xs","top-2","top-4","top-full","transition-all","transition-colors","transition-transform","w-4","w-8","w-full","whitespace-normal","wrap-anywhere","z-10","z-50"];function a(r){let i=[...s],d=e=>r?`${r}:${e}`:e,t=[],n=[];for(let e of i)e.includes(",")?n.push(e):t.push(e);let o=[];if(t.length>0){let e=r?`${r}:{${t.join(",")}}`:`{${t.join(",")}}`;o.push(`@source inline("${e}");`);}for(let e of n)o.push(`@source inline("${d(e)}");`);return o.join(`
2
2
  `)}export{s as STREAMDOWN_CLASSES,a as getSourceInline};
@@ -14,11 +14,19 @@ export interface StreamdownTranslations {
14
14
  copyTableAsCsv: string;
15
15
  copyTableAsMarkdown: string;
16
16
  copyTableAsTsv: string;
17
+ diagramChart: string;
18
+ diagramErrorLabel: string;
19
+ diagramFormatSource: string;
17
20
  diagramLoading: string;
21
+ diagramPluginMissing: string;
22
+ diagramRenderFailed: string;
18
23
  downloadDiagram: string;
24
+ downloadDiagramAsJson: string;
19
25
  downloadDiagramAsMmd: string;
20
26
  downloadDiagramAsPng: string;
21
27
  downloadDiagramAsPuml: string;
28
+ downloadDiagramAsSmi: string;
29
+ downloadDiagramAsSource: string;
22
30
  downloadDiagramAsSvg: string;
23
31
  downloadFile: string;
24
32
  downloadImage: string;
@@ -59,9 +67,21 @@ export interface StreamdownTranslations {
59
67
  plantumlRenderFailed: string;
60
68
  resetView: string;
61
69
  showCode: string;
70
+ smilesChart: string;
71
+ smilesErrorLabel: string;
72
+ smilesFormatSmi: string;
73
+ smilesPluginMissing: string;
74
+ smilesRenderFailed: string;
62
75
  tableFormatCsv: string;
63
76
  tableFormatMarkdown: string;
64
77
  tableFormatTsv: string;
78
+ vegaChart: string;
79
+ vegaErrorLabel: string;
80
+ vegaFormatJson: string;
81
+ vegaFormatPng: string;
82
+ vegaFormatSvg: string;
83
+ vegaPluginMissing: string;
84
+ vegaRenderFailed: string;
65
85
  viewFullscreen: string;
66
86
  zoomIn: string;
67
87
  zoomOut: string;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{p as OpenScad}from'./chunk-TXJ25TS2.js';import'./chunk-6TBP27CO.js';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {f,i}from'./chunk-EMUDB4GM.js';import {useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var z=p=>{p.traverse(i=>{let o=i;if(o.geometry&&o.geometry.dispose(),Array.isArray(o.material))for(let u of o.material)u.dispose();else o.material&&o.material.dispose();});},q=({className:p,data:i$1,format:o,fullscreen:u=false})=>{let P=f(),R=i(),b=useRef(null);return useEffect(()=>{let m=b.current;if(!m)return;let y=false,g=()=>{};return (async()=>{let e=await import('three'),[{STLLoader:j},{ThreeMFLoader:E},{OrbitControls:V}]=await Promise.all([import('three/examples/jsm/loaders/STLLoader.js'),import('three/examples/jsm/loaders/3MFLoader.js'),import('three/examples/jsm/controls/OrbitControls.js')]);if(y)return;let n=new e.WebGLRenderer({alpha:true,antialias:true});n.setPixelRatio(window.devicePixelRatio),m.appendChild(n.domElement);let c=new e.Scene,t=new e.PerspectiveCamera(45,1,.1,2e3),x=new e.Vector3(50,40,60).normalize();t.position.copy(x.clone().multiplyScalar(100));let s=new V(t,n.domElement);s.enableDamping=true,s.dampingFactor=.08;let A=new e.HemisphereLight(16777215,3159357,1.5);c.add(A);let M=new e.DirectionalLight(16777215,2.6);M.position.set(1,1.7,1.2),c.add(M);let v=new e.DirectionalLight(16777215,.7);v.position.set(-1,.5,-1),c.add(v);let r=new e.Group;c.add(r);let C=()=>{for(;r.children.length>0;){let a=r.children[0];r.remove(a),z(a);}let l=i$1.buffer.slice(i$1.byteOffset,i$1.byteOffset+i$1.byteLength);if(o==="3mf"){let a=new E().parse(l);r.add(a);}else {let a=new j().parse(l);a.computeVertexNormals();let F=new e.MeshStandardMaterial({color:9081504,roughness:.55,metalness:.1});r.add(new e.Mesh(a,F));}let d=new e.Box3().setFromObject(r),h=d.getSize(new e.Vector3),w=Math.max(h.x,h.y,h.z)||1,L=d.getCenter(new e.Vector3),T=w*2.2,f=t.position.clone().sub(s.target).normalize();(!Number.isFinite(f.x)||f.lengthSq()===0)&&f.copy(x),s.target.copy(L),t.position.copy(L).add(f.multiplyScalar(T)),t.near=Math.max(w/1e3,.01),t.far=Math.max(w*100,1e3),t.updateProjectionMatrix(),s.update();},O=()=>{let{clientHeight:l,clientWidth:d}=m;d===0||l===0||(t.aspect=d/l,t.updateProjectionMatrix(),n.setSize(d,l));},D=new ResizeObserver(O);D.observe(m),O(),C(),n.setAnimationLoop(()=>{s.update(),n.render(c,t);}),g=()=>{D.disconnect(),n.setAnimationLoop(null),s.dispose(),z(r),c.clear(),n.dispose(),n.domElement.remove();};})().catch(()=>{}),()=>{y=true,g();}},[i$1,o]),jsx("div",{"aria-label":R.openscadModel,className:P(u?"size-full":"h-[400px] w-full",p),"data-streamdown":"openscad-viewer",ref:b,role:"img"})};export{q as OpenScadViewer};
2
+ import {f,i}from'./chunk-6TBP27CO.js';import {useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var z=p=>{p.traverse(i=>{let o=i;if(o.geometry&&o.geometry.dispose(),Array.isArray(o.material))for(let u of o.material)u.dispose();else o.material&&o.material.dispose();});},q=({className:p,data:i$1,format:o,fullscreen:u=false})=>{let P=f(),R=i(),b=useRef(null);return useEffect(()=>{let m=b.current;if(!m)return;let y=false,g=()=>{};return (async()=>{let e=await import('three'),[{STLLoader:j},{ThreeMFLoader:E},{OrbitControls:V}]=await Promise.all([import('three/examples/jsm/loaders/STLLoader.js'),import('three/examples/jsm/loaders/3MFLoader.js'),import('three/examples/jsm/controls/OrbitControls.js')]);if(y)return;let n=new e.WebGLRenderer({alpha:true,antialias:true});n.setPixelRatio(window.devicePixelRatio),m.appendChild(n.domElement);let c=new e.Scene,t=new e.PerspectiveCamera(45,1,.1,2e3),x=new e.Vector3(50,40,60).normalize();t.position.copy(x.clone().multiplyScalar(100));let s=new V(t,n.domElement);s.enableDamping=true,s.dampingFactor=.08;let A=new e.HemisphereLight(16777215,3159357,1.5);c.add(A);let M=new e.DirectionalLight(16777215,2.6);M.position.set(1,1.7,1.2),c.add(M);let v=new e.DirectionalLight(16777215,.7);v.position.set(-1,.5,-1),c.add(v);let r=new e.Group;c.add(r);let C=()=>{for(;r.children.length>0;){let a=r.children[0];r.remove(a),z(a);}let l=i$1.buffer.slice(i$1.byteOffset,i$1.byteOffset+i$1.byteLength);if(o==="3mf"){let a=new E().parse(l);r.add(a);}else {let a=new j().parse(l);a.computeVertexNormals();let F=new e.MeshStandardMaterial({color:9081504,roughness:.55,metalness:.1});r.add(new e.Mesh(a,F));}let d=new e.Box3().setFromObject(r),h=d.getSize(new e.Vector3),w=Math.max(h.x,h.y,h.z)||1,L=d.getCenter(new e.Vector3),T=w*2.2,f=t.position.clone().sub(s.target).normalize();(!Number.isFinite(f.x)||f.lengthSq()===0)&&f.copy(x),s.target.copy(L),t.position.copy(L).add(f.multiplyScalar(T)),t.near=Math.max(w/1e3,.01),t.far=Math.max(w*100,1e3),t.updateProjectionMatrix(),s.update();},O=()=>{let{clientHeight:l,clientWidth:d}=m;d===0||l===0||(t.aspect=d/l,t.updateProjectionMatrix(),n.setSize(d,l));},D=new ResizeObserver(O);D.observe(m),O(),C(),n.setAnimationLoop(()=>{s.update(),n.render(c,t);}),g=()=>{D.disconnect(),n.setAnimationLoop(null),s.dispose(),z(r),c.clear(),n.dispose(),n.domElement.remove();};})().catch(()=>{}),()=>{y=true,g();}},[i$1,o]),jsx("div",{"aria-label":R.openscadModel,className:P(u?"size-full":"h-[400px] w-full",p),"data-streamdown":"openscad-viewer",ref:b,role:"img"})};export{q as OpenScadViewer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown",
3
- "version": "2.14.1",
3
+ "version": "2.15.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,2 +0,0 @@
1
- "use client";
2
- import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {createContext,useContext}from'react';var t=(...n)=>twMerge(clsx(n)),D=n=>{if(n!==void 0)return typeof n=="number"?!Number.isFinite(n)||n<=0?void 0:`${n}px`:n},g=(n,a)=>{if(!n||!a)return a;let r=`${n}:`;return a.split(/\s+/).filter(Boolean).map(o=>o.startsWith(r)?o:`${n}:${o}`).join(" ")},S=n=>n?(...a)=>g(n,twMerge(clsx(a))):t,y=(n,a,r)=>{let o=typeof a=="string"&&r.startsWith("text/csv")?"\uFEFF":"",s=typeof a=="string"?new Blob([o+a],{type:r}):a,i=URL.createObjectURL(s),e=document.createElement("a");e.href=i,e.download=n,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(i);};var c=createContext(t),T=()=>useContext(c);var C={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",copyDiagram:"Copy diagram",copyModel:"Copy model",downloadFile:"Download file",mermaidChart:"Mermaid chart",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",downloadDiagramAsPuml:"Download diagram as PlantUML",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",diagramLoading:"Loading diagram...",showCode:"Show Code",mermaidErrorLabel:"Mermaid Error",mermaidPluginMissing:"Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.",mermaidRenderFailed:"Failed to render Mermaid chart",plantumlChart:"PlantUML chart",plantumlErrorLabel:"PlantUML Error",plantumlPluginMissing:"PlantUML plugin not available. Please add the plantuml plugin to enable diagram rendering.",plantumlRenderFailed:"Failed to render PlantUML chart",openscadErrorLabel:"OpenSCAD Error",openscadModel:"OpenSCAD model",openscadLoading:"Loading OpenSCAD engine and rendering model...",openscadPluginMissing:"OpenSCAD plugin not available. Please add the openscad plugin to enable model rendering.",openscadRenderFailed:"Failed to render model",openscadWriting:"Waiting for the model code...",downloadModel:"Download model",downloadModelAsScad:"Download model as SCAD",downloadModelAsStl:"Download model as STL",downloadModelAs3mf:"Download model as 3MF",openscadFormatScad:"SCAD",openscadFormatStl:"STL",openscadFormat3mf:"3MF",plantumlFormatSvg:"SVG",plantumlFormatPng:"PNG",plantumlFormatPuml:"PUML",zoomIn:"Zoom in",zoomOut:"Zoom out",resetView:"Reset zoom and pan",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},b=createContext(C),x=()=>useContext(b);export{t as a,D as b,S as c,y as d,c as e,T as f,C as g,b as h,x as i};