@stream-mdx/react 0.1.0 → 0.2.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 (47) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -0
  3. package/dist/components/index.cjs +497 -163
  4. package/dist/components/index.d.cts +1 -1
  5. package/dist/components/index.d.ts +1 -1
  6. package/dist/components/index.mjs +496 -163
  7. package/dist/{index-Bt1opGCs.d.cts → index-D0akq48G.d.cts} +24 -2
  8. package/dist/{index-Bt1opGCs.d.ts → index-D0akq48G.d.ts} +24 -2
  9. package/dist/index.cjs +3797 -2048
  10. package/dist/index.d.cts +43 -5
  11. package/dist/index.d.ts +43 -5
  12. package/dist/index.mjs +3741 -1990
  13. package/dist/mdx-client.cjs +60 -18
  14. package/dist/mdx-client.d.cts +11 -0
  15. package/dist/mdx-client.d.ts +11 -0
  16. package/dist/mdx-client.mjs +60 -18
  17. package/dist/mdx-coordinator.cjs +60 -18
  18. package/dist/mdx-coordinator.mjs +60 -18
  19. package/dist/renderer/node-views.cjs +481 -130
  20. package/dist/renderer/node-views.d.cts +1 -1
  21. package/dist/renderer/node-views.d.ts +1 -1
  22. package/dist/renderer/node-views.mjs +424 -65
  23. package/dist/renderer/patch-commit-scheduler.cjs +68 -7
  24. package/dist/renderer/patch-commit-scheduler.d.cts +6 -5
  25. package/dist/renderer/patch-commit-scheduler.d.ts +6 -5
  26. package/dist/renderer/patch-commit-scheduler.mjs +68 -7
  27. package/dist/renderer/store.cjs +481 -56
  28. package/dist/renderer/store.d.cts +2 -1
  29. package/dist/renderer/store.d.ts +2 -1
  30. package/dist/renderer/store.mjs +479 -47
  31. package/dist/renderer/virtualized-code.cjs +8 -2
  32. package/dist/renderer/virtualized-code.d.cts +4 -0
  33. package/dist/renderer/virtualized-code.d.ts +4 -0
  34. package/dist/renderer/virtualized-code.mjs +8 -2
  35. package/dist/renderer.cjs +3188 -2172
  36. package/dist/renderer.d.cts +4 -2
  37. package/dist/renderer.d.ts +4 -2
  38. package/dist/renderer.mjs +3009 -1985
  39. package/dist/streaming-markdown-Ch6PwjAa.d.cts +154 -0
  40. package/dist/streaming-markdown-tca-Mf8D.d.ts +154 -0
  41. package/dist/streaming-markdown.cjs +3929 -2202
  42. package/dist/streaming-markdown.d.cts +6 -95
  43. package/dist/streaming-markdown.d.ts +6 -95
  44. package/dist/streaming-markdown.mjs +3943 -2208
  45. package/dist/utils/inline-html.d.cts +1 -1
  46. package/dist/utils/inline-html.d.ts +1 -1
  47. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { InlineNode, CompiledMdxModule, InlineHtmlDescriptor, Block, FormatAnticipationConfig, MixedContentSegment } from '@stream-mdx/core';
1
+ import { InlineNode, TokenLineV1, CompiledMdxModule, InlineHtmlDescriptor, Block, LazyTokenizationPriority, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode, MixedContentSegment } from '@stream-mdx/core';
2
2
  import React from 'react';
3
3
 
4
4
  type GenericComponent = React.ComponentType<any>;
@@ -37,6 +37,7 @@ interface BlockComponents {
37
37
  index: number;
38
38
  text: string;
39
39
  html?: string | null;
40
+ tokens?: TokenLineV1 | null;
40
41
  }>;
41
42
  lang?: string;
42
43
  preAttrs?: Record<string, string>;
@@ -61,7 +62,9 @@ interface BlockComponents {
61
62
  compiledModule?: CompiledMdxModule | null;
62
63
  status?: "pending" | "compiled" | "error";
63
64
  errorMessage?: string;
65
+ raw?: string;
64
66
  }>;
67
+ hr: React.FC<React.HTMLAttributes<HTMLHRElement>>;
65
68
  table: React.FC<{
66
69
  header?: InlineNode[][];
67
70
  rows: InlineNode[][][];
@@ -125,6 +128,8 @@ interface RendererConfig {
125
128
  callouts?: boolean;
126
129
  math?: boolean;
127
130
  formatAnticipation?: FormatAnticipationConfig;
131
+ codeHighlighting?: CodeHighlightingMode;
132
+ outputMode?: CodeHighlightOutputMode;
128
133
  liveCodeHighlighting?: boolean;
129
134
  };
130
135
  performance?: {
@@ -144,6 +149,12 @@ interface RendererStore {
144
149
  getVersion(): number;
145
150
  subscribe(listener: () => void): () => void;
146
151
  }
152
+ type CodeHighlightRangeRequest = {
153
+ blockId: string;
154
+ startLine: number;
155
+ endLine: number;
156
+ priority?: LazyTokenizationPriority;
157
+ };
147
158
  interface Renderer {
148
159
  attachWorker(worker: Worker, options?: {
149
160
  skipInit?: boolean;
@@ -156,8 +167,19 @@ interface Renderer {
156
167
  setMdxComponents(map: Record<string, GenericComponent>): void;
157
168
  getComponentRegistry(): ComponentRegistry;
158
169
  getStore(): RendererStore;
170
+ requestCodeHighlightRange(request: CodeHighlightRangeRequest): void;
159
171
  }
160
172
 
173
+ type LinkSafetyModalProps = {
174
+ url: string;
175
+ isOpen: boolean;
176
+ isChecking?: boolean;
177
+ onClose: () => void;
178
+ onConfirm: () => void;
179
+ onCopy: () => void;
180
+ };
181
+ declare const DefaultLinkSafetyModal: React.FC<LinkSafetyModalProps>;
182
+
161
183
  /**
162
184
  * Render inline nodes to React elements
163
185
  */
@@ -220,4 +242,4 @@ declare class ComponentRegistry {
220
242
  declare function mapHtmlToReact(html: string, elements: HtmlElements): React.ReactNode;
221
243
  declare function renderParagraphMixedSegments(segments: MixedContentSegment[], inlineComponents: InlineComponents, inlineHtmlRenderers: InlineHtmlRendererMap): React.ReactNode[];
222
244
 
223
- export { type BlockComponents as B, ComponentRegistry as C, type HtmlElements as H, type InlineComponents as I, type Renderer as R, type TableElements as T, type InlineHtmlRenderer as a, type InlineHtmlRendererMap as b, type RendererConfig as c, defaultInlineComponents as d, defaultBlockComponents as e, renderParagraphMixedSegments as f, mapHtmlToReact as m, renderInlineNodes as r };
245
+ export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type InlineComponents as I, type LinkSafetyModalProps as L, type Renderer as R, type TableElements as T, type RendererConfig as a, type CodeHighlightRangeRequest as b, type InlineHtmlRendererMap as c, type InlineHtmlRenderer as d, defaultInlineComponents as e, defaultBlockComponents as f, renderParagraphMixedSegments as g, mapHtmlToReact as m, renderInlineNodes as r };
@@ -1,4 +1,4 @@
1
- import { InlineNode, CompiledMdxModule, InlineHtmlDescriptor, Block, FormatAnticipationConfig, MixedContentSegment } from '@stream-mdx/core';
1
+ import { InlineNode, TokenLineV1, CompiledMdxModule, InlineHtmlDescriptor, Block, LazyTokenizationPriority, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode, MixedContentSegment } from '@stream-mdx/core';
2
2
  import React from 'react';
3
3
 
4
4
  type GenericComponent = React.ComponentType<any>;
@@ -37,6 +37,7 @@ interface BlockComponents {
37
37
  index: number;
38
38
  text: string;
39
39
  html?: string | null;
40
+ tokens?: TokenLineV1 | null;
40
41
  }>;
41
42
  lang?: string;
42
43
  preAttrs?: Record<string, string>;
@@ -61,7 +62,9 @@ interface BlockComponents {
61
62
  compiledModule?: CompiledMdxModule | null;
62
63
  status?: "pending" | "compiled" | "error";
63
64
  errorMessage?: string;
65
+ raw?: string;
64
66
  }>;
67
+ hr: React.FC<React.HTMLAttributes<HTMLHRElement>>;
65
68
  table: React.FC<{
66
69
  header?: InlineNode[][];
67
70
  rows: InlineNode[][][];
@@ -125,6 +128,8 @@ interface RendererConfig {
125
128
  callouts?: boolean;
126
129
  math?: boolean;
127
130
  formatAnticipation?: FormatAnticipationConfig;
131
+ codeHighlighting?: CodeHighlightingMode;
132
+ outputMode?: CodeHighlightOutputMode;
128
133
  liveCodeHighlighting?: boolean;
129
134
  };
130
135
  performance?: {
@@ -144,6 +149,12 @@ interface RendererStore {
144
149
  getVersion(): number;
145
150
  subscribe(listener: () => void): () => void;
146
151
  }
152
+ type CodeHighlightRangeRequest = {
153
+ blockId: string;
154
+ startLine: number;
155
+ endLine: number;
156
+ priority?: LazyTokenizationPriority;
157
+ };
147
158
  interface Renderer {
148
159
  attachWorker(worker: Worker, options?: {
149
160
  skipInit?: boolean;
@@ -156,8 +167,19 @@ interface Renderer {
156
167
  setMdxComponents(map: Record<string, GenericComponent>): void;
157
168
  getComponentRegistry(): ComponentRegistry;
158
169
  getStore(): RendererStore;
170
+ requestCodeHighlightRange(request: CodeHighlightRangeRequest): void;
159
171
  }
160
172
 
173
+ type LinkSafetyModalProps = {
174
+ url: string;
175
+ isOpen: boolean;
176
+ isChecking?: boolean;
177
+ onClose: () => void;
178
+ onConfirm: () => void;
179
+ onCopy: () => void;
180
+ };
181
+ declare const DefaultLinkSafetyModal: React.FC<LinkSafetyModalProps>;
182
+
161
183
  /**
162
184
  * Render inline nodes to React elements
163
185
  */
@@ -220,4 +242,4 @@ declare class ComponentRegistry {
220
242
  declare function mapHtmlToReact(html: string, elements: HtmlElements): React.ReactNode;
221
243
  declare function renderParagraphMixedSegments(segments: MixedContentSegment[], inlineComponents: InlineComponents, inlineHtmlRenderers: InlineHtmlRendererMap): React.ReactNode[];
222
244
 
223
- export { type BlockComponents as B, ComponentRegistry as C, type HtmlElements as H, type InlineComponents as I, type Renderer as R, type TableElements as T, type InlineHtmlRenderer as a, type InlineHtmlRendererMap as b, type RendererConfig as c, defaultInlineComponents as d, defaultBlockComponents as e, renderParagraphMixedSegments as f, mapHtmlToReact as m, renderInlineNodes as r };
245
+ export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type InlineComponents as I, type LinkSafetyModalProps as L, type Renderer as R, type TableElements as T, type RendererConfig as a, type CodeHighlightRangeRequest as b, type InlineHtmlRendererMap as c, type InlineHtmlRenderer as d, defaultInlineComponents as e, defaultBlockComponents as f, renderParagraphMixedSegments as g, mapHtmlToReact as m, renderInlineNodes as r };