@stream-mdx/core 0.2.0 → 0.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 CHANGED
@@ -39,11 +39,16 @@ export function makeConfig(overrides?: Partial<typeof DEFAULT_BACKPRESSURE_CONFI
39
39
 
40
40
  ## Docs
41
41
 
42
- - API reference: `docs/PUBLIC_API.md`
43
- - Security model: `docs/SECURITY_MODEL.md`
42
+ - API reference: https://github.com/kmccleary3301/stream-mdx/blob/main/docs/PUBLIC_API.md
43
+ - Security model: https://github.com/kmccleary3301/stream-mdx/blob/main/docs/SECURITY_MODEL.md
44
+ - Protocol spec (for typed stream events): https://github.com/kmccleary3301/stream-mdx/blob/main/docs/STREAMMDX_JSON_DIFF_SPEC.md
44
45
 
45
46
  ## Related packages
46
47
 
47
48
  - `@stream-mdx/react` for the React renderer
48
49
  - `@stream-mdx/worker` for hosted worker bundles
50
+ - `@stream-mdx/plugins` for worker-side plugin primitives (advanced)
51
+ - `@stream-mdx/protocol` for stable protocol/event types (e.g. TUIs)
52
+ - `@stream-mdx/tui` for NDJSON helpers + a snapshot store (terminal UIs)
49
53
  - `@stream-mdx/mermaid` for Mermaid diagram rendering (optional)
54
+ - `@stream-mdx/theme-tailwind` for an optional Tailwind-friendly theme (optional)
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Block, NodeSnapshot, InlineNode, Patch } from './types.cjs';
2
- export { ASTInlinePlugin, CoalescingMetrics, CodeHighlightOutputMode, CodeHighlightingMode, CompiledMdxModule, DiffKind, FormatAnticipationConfig, InlineHtmlDescriptor, InlinePlugin, LANGUAGE_ALIASES, LazyTokenizationPriority, MixedContentSegment, NodePath, PATCH_ROOT_ID, PatchMetrics, PerformanceMetrics, ProtectedRange, ProtectedRangeKind, RegexAnticipationPattern, RegexInlinePlugin, SetPropsBatchEntry, TokenLineV1, TokenSpan, TokenStyle, WorkerErrorPayload, WorkerIn, WorkerOut, WorkerPhase } from './types.cjs';
2
+ export { ASTInlinePlugin, CoalescingMetrics, CodeHighlightOutputMode, CodeHighlightingMode, CompiledMdxModule, DiffBlock, DiffKind, DiffLine, DiffLineKind, FormatAnticipationConfig, InlineHtmlDescriptor, InlinePlugin, LANGUAGE_ALIASES, LazyTokenizationPriority, MixedContentSegment, NodePath, PATCH_ROOT_ID, PatchMetrics, PerformanceMetrics, ProtectedRange, ProtectedRangeKind, RegexAnticipationPattern, RegexInlinePlugin, SetPropsBatchEntry, ThemedLine, ThemedToken, TocHeading, TokenLineV1, TokenSpan, TokenStyle, WorkerErrorPayload, WorkerIn, WorkerOut, WorkerPhase } from './types.cjs';
3
3
  export { HighlightedLine, dedentIndentedCode, extractCodeLines, extractCodeWrapperAttributes, extractHighlightedLines, getDefaultCodeWrapperAttributes, normalizeHighlightedLines, stripCodeFence } from './code-highlighting.cjs';
4
4
  export { PerformanceTimer, StringBuffer, applyUpdate, debounce, detectMDX, generateBlockId, getBlockKey, normalizeBlockquoteText, normalizeLang, parseCodeFenceInfo, removeHeadingMarkers } from './utils.cjs';
5
5
  export { MixedContentAutoCloseHtmlOptions, MixedContentAutoCloseMdxOptions, MixedContentOptions, extractMixedContentSegments, findClosingHtmlTag, isLikelyMdxComponent } from './mixed-content.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Block, NodeSnapshot, InlineNode, Patch } from './types.js';
2
- export { ASTInlinePlugin, CoalescingMetrics, CodeHighlightOutputMode, CodeHighlightingMode, CompiledMdxModule, DiffKind, FormatAnticipationConfig, InlineHtmlDescriptor, InlinePlugin, LANGUAGE_ALIASES, LazyTokenizationPriority, MixedContentSegment, NodePath, PATCH_ROOT_ID, PatchMetrics, PerformanceMetrics, ProtectedRange, ProtectedRangeKind, RegexAnticipationPattern, RegexInlinePlugin, SetPropsBatchEntry, TokenLineV1, TokenSpan, TokenStyle, WorkerErrorPayload, WorkerIn, WorkerOut, WorkerPhase } from './types.js';
2
+ export { ASTInlinePlugin, CoalescingMetrics, CodeHighlightOutputMode, CodeHighlightingMode, CompiledMdxModule, DiffBlock, DiffKind, DiffLine, DiffLineKind, FormatAnticipationConfig, InlineHtmlDescriptor, InlinePlugin, LANGUAGE_ALIASES, LazyTokenizationPriority, MixedContentSegment, NodePath, PATCH_ROOT_ID, PatchMetrics, PerformanceMetrics, ProtectedRange, ProtectedRangeKind, RegexAnticipationPattern, RegexInlinePlugin, SetPropsBatchEntry, ThemedLine, ThemedToken, TocHeading, TokenLineV1, TokenSpan, TokenStyle, WorkerErrorPayload, WorkerIn, WorkerOut, WorkerPhase } from './types.js';
3
3
  export { HighlightedLine, dedentIndentedCode, extractCodeLines, extractCodeWrapperAttributes, extractHighlightedLines, getDefaultCodeWrapperAttributes, normalizeHighlightedLines, stripCodeFence } from './code-highlighting.js';
4
4
  export { PerformanceTimer, StringBuffer, applyUpdate, debounce, detectMDX, generateBlockId, getBlockKey, normalizeBlockquoteText, normalizeLang, parseCodeFenceInfo, removeHeadingMarkers } from './utils.js';
5
5
  export { MixedContentAutoCloseHtmlOptions, MixedContentAutoCloseMdxOptions, MixedContentOptions, extractMixedContentSegments, findClosingHtmlTag, isLikelyMdxComponent } from './mixed-content.js';
package/dist/types.d.cts CHANGED
@@ -128,6 +128,29 @@ type TokenLineV1 = {
128
128
  spans: TokenSpan[];
129
129
  };
130
130
  type DiffKind = "add" | "remove" | "context" | "hunk" | "meta";
131
+ type DiffLineKind = "meta" | "hunk" | "add" | "del" | "context";
132
+ type ThemedToken = {
133
+ content: string;
134
+ color?: string | null;
135
+ fontStyle?: number | null;
136
+ };
137
+ type ThemedLine = ThemedToken[];
138
+ type DiffLine = {
139
+ kind: DiffLineKind;
140
+ oldNo?: number | null;
141
+ newNo?: number | null;
142
+ raw: string;
143
+ tokens?: ThemedLine | null;
144
+ };
145
+ type DiffBlock = {
146
+ kind: "diff";
147
+ filePath?: string | null;
148
+ language?: string | null;
149
+ lines: DiffLine[];
150
+ additions?: number | null;
151
+ deletions?: number | null;
152
+ unified?: string | null;
153
+ };
131
154
  type LazyTokenizationPriority = "visible" | "prefetch";
132
155
  /**
133
156
  * Worker communication protocol
@@ -147,6 +170,9 @@ type WorkerIn = {
147
170
  codeHighlighting?: CodeHighlightingMode;
148
171
  outputMode?: CodeHighlightOutputMode;
149
172
  liveCodeHighlighting?: boolean;
173
+ liveTokenization?: boolean;
174
+ emitHighlightTokens?: boolean;
175
+ emitDiffBlocks?: boolean;
150
176
  mdxComponentNames?: string[];
151
177
  lazyTokenization?: {
152
178
  enabled?: boolean;
@@ -163,6 +189,8 @@ type WorkerIn = {
163
189
  type: "FINALIZE";
164
190
  } | {
165
191
  type: "DEBUG_STATE";
192
+ } | {
193
+ type: "DUMP_BLOCKS";
166
194
  } | {
167
195
  type: "TOKENIZE_RANGE";
168
196
  blockId: string;
@@ -190,6 +218,8 @@ interface WorkerErrorPayload {
190
218
  type WorkerOut = {
191
219
  type: "INITIALIZED";
192
220
  blocks: Block[];
221
+ } | {
222
+ type: "FINALIZED";
193
223
  } | {
194
224
  type: "PATCH";
195
225
  tx: number;
@@ -201,6 +231,10 @@ type WorkerOut = {
201
231
  } | {
202
232
  type: "METRICS";
203
233
  metrics: PerformanceMetrics;
234
+ } | {
235
+ type: "DUMP_BLOCKS";
236
+ blocks: Block[];
237
+ tocHeadings?: TocHeading[];
204
238
  } | {
205
239
  type: "DEBUG_STATE";
206
240
  state: {
@@ -322,6 +356,12 @@ interface NodePath {
322
356
  nodeId?: string;
323
357
  indexPath?: number[];
324
358
  }
359
+ interface TocHeading {
360
+ id: string;
361
+ text: string;
362
+ level: number;
363
+ blockId: string;
364
+ }
325
365
  type Patch = {
326
366
  op: "insertChild";
327
367
  at: NodePath;
@@ -397,4 +437,4 @@ interface CoalescingMetrics {
397
437
  insertChildCoalesced: number;
398
438
  }
399
439
 
400
- export { type ASTInlinePlugin, type Block, type CoalescingMetrics, type CodeHighlightOutputMode, type CodeHighlightingMode, type CompiledMdxModule, type DiffKind, type FormatAnticipationConfig, type InlineHtmlDescriptor, type InlineNode, type InlinePlugin, LANGUAGE_ALIASES, type LazyTokenizationPriority, type MixedContentSegment, type NodePath, type NodeSnapshot, PATCH_ROOT_ID, type Patch, type PatchMetrics, type PerformanceMetrics, type ProtectedRange, type ProtectedRangeKind, type RegexAnticipationPattern, type RegexInlinePlugin, type SetPropsBatchEntry, type TokenLineV1, type TokenSpan, type TokenStyle, type WorkerErrorPayload, type WorkerIn, type WorkerOut, type WorkerPhase };
440
+ export { type ASTInlinePlugin, type Block, type CoalescingMetrics, type CodeHighlightOutputMode, type CodeHighlightingMode, type CompiledMdxModule, type DiffBlock, type DiffKind, type DiffLine, type DiffLineKind, type FormatAnticipationConfig, type InlineHtmlDescriptor, type InlineNode, type InlinePlugin, LANGUAGE_ALIASES, type LazyTokenizationPriority, type MixedContentSegment, type NodePath, type NodeSnapshot, PATCH_ROOT_ID, type Patch, type PatchMetrics, type PerformanceMetrics, type ProtectedRange, type ProtectedRangeKind, type RegexAnticipationPattern, type RegexInlinePlugin, type SetPropsBatchEntry, type ThemedLine, type ThemedToken, type TocHeading, type TokenLineV1, type TokenSpan, type TokenStyle, type WorkerErrorPayload, type WorkerIn, type WorkerOut, type WorkerPhase };
package/dist/types.d.ts CHANGED
@@ -128,6 +128,29 @@ type TokenLineV1 = {
128
128
  spans: TokenSpan[];
129
129
  };
130
130
  type DiffKind = "add" | "remove" | "context" | "hunk" | "meta";
131
+ type DiffLineKind = "meta" | "hunk" | "add" | "del" | "context";
132
+ type ThemedToken = {
133
+ content: string;
134
+ color?: string | null;
135
+ fontStyle?: number | null;
136
+ };
137
+ type ThemedLine = ThemedToken[];
138
+ type DiffLine = {
139
+ kind: DiffLineKind;
140
+ oldNo?: number | null;
141
+ newNo?: number | null;
142
+ raw: string;
143
+ tokens?: ThemedLine | null;
144
+ };
145
+ type DiffBlock = {
146
+ kind: "diff";
147
+ filePath?: string | null;
148
+ language?: string | null;
149
+ lines: DiffLine[];
150
+ additions?: number | null;
151
+ deletions?: number | null;
152
+ unified?: string | null;
153
+ };
131
154
  type LazyTokenizationPriority = "visible" | "prefetch";
132
155
  /**
133
156
  * Worker communication protocol
@@ -147,6 +170,9 @@ type WorkerIn = {
147
170
  codeHighlighting?: CodeHighlightingMode;
148
171
  outputMode?: CodeHighlightOutputMode;
149
172
  liveCodeHighlighting?: boolean;
173
+ liveTokenization?: boolean;
174
+ emitHighlightTokens?: boolean;
175
+ emitDiffBlocks?: boolean;
150
176
  mdxComponentNames?: string[];
151
177
  lazyTokenization?: {
152
178
  enabled?: boolean;
@@ -163,6 +189,8 @@ type WorkerIn = {
163
189
  type: "FINALIZE";
164
190
  } | {
165
191
  type: "DEBUG_STATE";
192
+ } | {
193
+ type: "DUMP_BLOCKS";
166
194
  } | {
167
195
  type: "TOKENIZE_RANGE";
168
196
  blockId: string;
@@ -190,6 +218,8 @@ interface WorkerErrorPayload {
190
218
  type WorkerOut = {
191
219
  type: "INITIALIZED";
192
220
  blocks: Block[];
221
+ } | {
222
+ type: "FINALIZED";
193
223
  } | {
194
224
  type: "PATCH";
195
225
  tx: number;
@@ -201,6 +231,10 @@ type WorkerOut = {
201
231
  } | {
202
232
  type: "METRICS";
203
233
  metrics: PerformanceMetrics;
234
+ } | {
235
+ type: "DUMP_BLOCKS";
236
+ blocks: Block[];
237
+ tocHeadings?: TocHeading[];
204
238
  } | {
205
239
  type: "DEBUG_STATE";
206
240
  state: {
@@ -322,6 +356,12 @@ interface NodePath {
322
356
  nodeId?: string;
323
357
  indexPath?: number[];
324
358
  }
359
+ interface TocHeading {
360
+ id: string;
361
+ text: string;
362
+ level: number;
363
+ blockId: string;
364
+ }
325
365
  type Patch = {
326
366
  op: "insertChild";
327
367
  at: NodePath;
@@ -397,4 +437,4 @@ interface CoalescingMetrics {
397
437
  insertChildCoalesced: number;
398
438
  }
399
439
 
400
- export { type ASTInlinePlugin, type Block, type CoalescingMetrics, type CodeHighlightOutputMode, type CodeHighlightingMode, type CompiledMdxModule, type DiffKind, type FormatAnticipationConfig, type InlineHtmlDescriptor, type InlineNode, type InlinePlugin, LANGUAGE_ALIASES, type LazyTokenizationPriority, type MixedContentSegment, type NodePath, type NodeSnapshot, PATCH_ROOT_ID, type Patch, type PatchMetrics, type PerformanceMetrics, type ProtectedRange, type ProtectedRangeKind, type RegexAnticipationPattern, type RegexInlinePlugin, type SetPropsBatchEntry, type TokenLineV1, type TokenSpan, type TokenStyle, type WorkerErrorPayload, type WorkerIn, type WorkerOut, type WorkerPhase };
440
+ export { type ASTInlinePlugin, type Block, type CoalescingMetrics, type CodeHighlightOutputMode, type CodeHighlightingMode, type CompiledMdxModule, type DiffBlock, type DiffKind, type DiffLine, type DiffLineKind, type FormatAnticipationConfig, type InlineHtmlDescriptor, type InlineNode, type InlinePlugin, LANGUAGE_ALIASES, type LazyTokenizationPriority, type MixedContentSegment, type NodePath, type NodeSnapshot, PATCH_ROOT_ID, type Patch, type PatchMetrics, type PerformanceMetrics, type ProtectedRange, type ProtectedRangeKind, type RegexAnticipationPattern, type RegexInlinePlugin, type SetPropsBatchEntry, type ThemedLine, type ThemedToken, type TocHeading, type TokenLineV1, type TokenSpan, type TokenStyle, type WorkerErrorPayload, type WorkerIn, type WorkerOut, type WorkerPhase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-mdx/core",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Core types, snapshot utilities, and perf helpers for the Streaming Markdown V2 stack",
5
5
  "license": "MIT",
6
6
  "repository": {