@ai-matrx/rich-content 0.2.84 → 0.2.85
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/CHANGELOG.md +18 -0
- package/dist/display/chat-markdown/render-block-to-content-block.js +3 -1
- package/dist/display/markdown-classification/processors/utils/block-splitter.d.ts +35 -0
- package/dist/display/markdown-classification/processors/utils/block-splitter.js +35 -0
- package/dist/display/markdown-classification/processors/utils/content-splitter-core.js +8 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.85
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/rich-content/v0.2.84..npm/rich-content/v0.2.85 -- apps/shared/rich-content`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
3
9
|
## 0.2.84
|
|
4
10
|
|
|
5
11
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
12
|
`git diff npm/rich-content/v0.2.83..npm/rich-content/v0.2.84 -- apps/shared/rich-content`).
|
|
7
13
|
No source changes intended and no consumer action required.
|
|
8
14
|
|
|
15
|
+
## 0.2.83
|
|
16
|
+
|
|
17
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
18
|
+
`git diff npm/rich-content/v0.2.82..npm/rich-content/v0.2.83 -- apps/shared/rich-content`).
|
|
19
|
+
No source changes intended and no consumer action required.
|
|
20
|
+
|
|
21
|
+
## 0.2.82
|
|
22
|
+
|
|
23
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
24
|
+
`git diff npm/rich-content/v0.2.81..npm/rich-content/v0.2.82 -- apps/shared/rich-content`).
|
|
25
|
+
No source changes intended and no consumer action required.
|
|
26
|
+
|
|
9
27
|
## 0.2.81
|
|
10
28
|
|
|
11
29
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
@@ -20,7 +20,9 @@ function renderBlockToContentBlock(rb) {
|
|
|
20
20
|
content: rb.type === "artifact" ? artifactBodyOf(rb.content ?? "") : rb.content ?? "",
|
|
21
21
|
serverData: rb.data ?? void 0,
|
|
22
22
|
metadata: rb.metadata,
|
|
23
|
-
language
|
|
23
|
+
// A typed block's fence language rides beside `data` (the live driver never builds a
|
|
24
|
+
// `data` object for it — that would read as server-typed data).
|
|
25
|
+
language: rb.data?.language ?? rb.language,
|
|
24
26
|
src: rb.data?.src,
|
|
25
27
|
alt: rb.data?.alt,
|
|
26
28
|
isStreamingBlock: rb.status === "streaming"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE ONE BLOCK SPLITTER — text in, typed render blocks out, for every renderer.
|
|
3
|
+
*
|
|
4
|
+
* One function serves the live stream and reload (Audit B family 1, chair ruling 2026-10-08:
|
|
5
|
+
* "live and reload must always draw the same blocks"). Reload is all the text in one chunk; a
|
|
6
|
+
* stream appends chunks. The reading is the reload splitter's (`splitContentIntoBlocksWith`,
|
|
7
|
+
* content-splitter-core.ts), so a stream can never draw a layout its own reload does not.
|
|
8
|
+
*
|
|
9
|
+
* WHY EVERY APPEND READS THE WHOLE RUN (measured 2026-10-08, not assumed): a prefix's reading is
|
|
10
|
+
* not stable under extension, so no block can be frozen early without drawing something the
|
|
11
|
+
* one-shot reading of the same text does not. Real cases from the corpus: a ```markdown fence
|
|
12
|
+
* that holds nested fences reads CLOSED at its first inner ``` and open again once its real
|
|
13
|
+
* closer arrives (saved answer b30bab96 — a tail-only re-split diverged on 907 streamed
|
|
14
|
+
* prefixes); an orphan `</think>` re-types the text before it as reasoning. Cost: ~0.08 ms per
|
|
15
|
+
* KB per append (70 KB in ~6 ms), and the live caller appends once per animation frame.
|
|
16
|
+
*/
|
|
17
|
+
import { type SplitterBlock, type SplitterEnvelopes } from "./content-splitter-core.js";
|
|
18
|
+
export interface BlockSplitterOptions {
|
|
19
|
+
/** Kind-envelope hooks (content-splitter-v2's client entry binds the host's). */
|
|
20
|
+
envelopes?: SplitterEnvelopes;
|
|
21
|
+
}
|
|
22
|
+
export declare class BlockSplitter {
|
|
23
|
+
private source;
|
|
24
|
+
private current;
|
|
25
|
+
private readonly envelopes;
|
|
26
|
+
constructor(options?: BlockSplitterOptions);
|
|
27
|
+
/** Every character appended so far. */
|
|
28
|
+
get text(): string;
|
|
29
|
+
/** Append a chunk; returns the blocks of all text so far — equal to a one-shot split of it. */
|
|
30
|
+
append(chunk: string): SplitterBlock[];
|
|
31
|
+
/** The blocks of all text so far. */
|
|
32
|
+
blocks(): SplitterBlock[];
|
|
33
|
+
}
|
|
34
|
+
/** The one-shot reading: every block of `text` (what reload draws). */
|
|
35
|
+
export declare function splitBlocks(text: string, envelopes?: SplitterEnvelopes): SplitterBlock[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NO_SPLITTER_ENVELOPES,
|
|
3
|
+
splitContentIntoBlocksWith
|
|
4
|
+
} from "./content-splitter-core.js";
|
|
5
|
+
class BlockSplitter {
|
|
6
|
+
source = "";
|
|
7
|
+
current = [];
|
|
8
|
+
envelopes;
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this.envelopes = options.envelopes ?? NO_SPLITTER_ENVELOPES;
|
|
11
|
+
}
|
|
12
|
+
/** Every character appended so far. */
|
|
13
|
+
get text() {
|
|
14
|
+
return this.source;
|
|
15
|
+
}
|
|
16
|
+
/** Append a chunk; returns the blocks of all text so far — equal to a one-shot split of it. */
|
|
17
|
+
append(chunk) {
|
|
18
|
+
if (chunk) {
|
|
19
|
+
this.source += chunk;
|
|
20
|
+
this.current = splitContentIntoBlocksWith(this.source, this.envelopes);
|
|
21
|
+
}
|
|
22
|
+
return this.current;
|
|
23
|
+
}
|
|
24
|
+
/** The blocks of all text so far. */
|
|
25
|
+
blocks() {
|
|
26
|
+
return this.current;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function splitBlocks(text, envelopes = NO_SPLITTER_ENVELOPES) {
|
|
30
|
+
return new BlockSplitter({ envelopes }).append(text);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
BlockSplitter,
|
|
34
|
+
splitBlocks
|
|
35
|
+
};
|
|
@@ -1444,6 +1444,14 @@ ${extraction.content}
|
|
|
1444
1444
|
if (openerIdx >= 0 && /<\/(?:thinking|think|reasoning)>/.test(currentText.slice(openerIdx + openerLen))) {
|
|
1445
1445
|
openerIdx = -1;
|
|
1446
1446
|
}
|
|
1447
|
+
if (openerIdx >= 0) {
|
|
1448
|
+
const lineStart = currentText.lastIndexOf("\n", openerIdx - 1) + 1;
|
|
1449
|
+
if (currentText.slice(lineStart, openerIdx).trim()) {
|
|
1450
|
+
currentText += processedLine + (i < lines.length - 1 ? "\n" : "");
|
|
1451
|
+
i++;
|
|
1452
|
+
continue;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1447
1455
|
let regionText = currentText;
|
|
1448
1456
|
if (openerIdx >= 0) {
|
|
1449
1457
|
const proseBefore = currentText.slice(0, openerIdx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/rich-content",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.85",
|
|
4
4
|
"description": "The AI Matrx formatted-text engine: the one markdown renderer, streaming markdown, the block splitter and renderer, the generic blocks, <RichContent> levels, the rich-document action registry and menus, copy, and the selection toolbar — as portable React.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -136,14 +136,14 @@
|
|
|
136
136
|
"@ai-matrx/content-ir": "latest",
|
|
137
137
|
"@ai-matrx/content-ir-react": "latest",
|
|
138
138
|
"@ai-matrx/data": "latest",
|
|
139
|
+
"@ai-matrx/design-system": "latest",
|
|
139
140
|
"@ai-matrx/diff": "latest",
|
|
140
141
|
"@ai-matrx/icons": "latest",
|
|
141
|
-
"@ai-matrx/
|
|
142
|
-
"@ai-matrx/
|
|
142
|
+
"@ai-matrx/kit": "latest",
|
|
143
|
+
"@ai-matrx/media": "latest",
|
|
143
144
|
"@ai-matrx/records": "latest",
|
|
144
145
|
"@ai-matrx/records-ui": "latest",
|
|
145
|
-
"@ai-matrx/
|
|
146
|
-
"@ai-matrx/kit": "latest"
|
|
146
|
+
"@ai-matrx/print": "latest"
|
|
147
147
|
},
|
|
148
148
|
"peerDependencies": {
|
|
149
149
|
"react": ">=19.0.0",
|
|
@@ -204,5 +204,5 @@
|
|
|
204
204
|
"verify:modules-tarball": "node ./scripts/verify-modules-tarball.mjs",
|
|
205
205
|
"verify:tarball": "node ./scripts/verify-tarball.mjs"
|
|
206
206
|
},
|
|
207
|
-
"gitHead": "
|
|
207
|
+
"gitHead": "733bfce3e3c27f189228edf916f8774f047d79b9"
|
|
208
208
|
}
|