@ai-matrx/content-ir 0.18.5 → 0.18.6
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 +58 -3
- package/README.md +3 -1
- package/dist/index.cjs +50 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -14
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +50 -14
- package/dist/source.cjs.map +1 -1
- package/dist/source.js +50 -14
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6208,10 +6208,13 @@ var Tokenizer = class {
|
|
|
6208
6208
|
/**
|
|
6209
6209
|
* Streaming: an open block that may still turn back into prose — a `$$`
|
|
6210
6210
|
* pair whose closer is on the open last line (prose after it makes it
|
|
6211
|
-
* inline),
|
|
6211
|
+
* inline), a JSON head whose braces have not balanced (it may never parse),
|
|
6212
|
+
* or any opener that is itself still arriving on the open last line.
|
|
6212
6213
|
*/
|
|
6213
6214
|
mayDissolve(block) {
|
|
6214
|
-
|
|
6215
|
+
if (!this.streaming || block.complete) return false;
|
|
6216
|
+
if (block.type === "math_block" || block.type === "json") return true;
|
|
6217
|
+
return this.isOpenTail(this.lineOf(block.start));
|
|
6215
6218
|
}
|
|
6216
6219
|
/** Streaming: paragraph ends where an undecided, dissolvable block cut them short. */
|
|
6217
6220
|
undecidedBreaks = /* @__PURE__ */ new Set();
|
|
@@ -6232,6 +6235,12 @@ var Tokenizer = class {
|
|
|
6232
6235
|
}
|
|
6233
6236
|
return lo;
|
|
6234
6237
|
}
|
|
6238
|
+
/** How many whitespace characters open the text at `from` (up to `to`). */
|
|
6239
|
+
leadingSpace(from, to) {
|
|
6240
|
+
let k = from;
|
|
6241
|
+
while (k < to && /\s/.test(this.text[k])) k++;
|
|
6242
|
+
return k - from;
|
|
6243
|
+
}
|
|
6235
6244
|
isBlank(from, to) {
|
|
6236
6245
|
return !NOT_WHITESPACE.test(this.text.slice(from, to));
|
|
6237
6246
|
}
|
|
@@ -6256,6 +6265,10 @@ var Tokenizer = class {
|
|
|
6256
6265
|
break;
|
|
6257
6266
|
}
|
|
6258
6267
|
const island = this.detectBlock(pos, li, true);
|
|
6268
|
+
if (island && pos + this.leadingSpace(pos, this.contentEnds[li]) >= this.provisionalFrom) {
|
|
6269
|
+
this.push({ kind: "prose", start: pos, end: this.n, island: null, inlines: [] });
|
|
6270
|
+
break;
|
|
6271
|
+
}
|
|
6259
6272
|
if (island) {
|
|
6260
6273
|
this.push({ kind: "island", start: island.start, end: island.end, island, inlines: [] });
|
|
6261
6274
|
pos = island.end;
|
|
@@ -6316,36 +6329,55 @@ var Tokenizer = class {
|
|
|
6316
6329
|
* region…) is never a tree line nor a root label, so it stops the walk.
|
|
6317
6330
|
*/
|
|
6318
6331
|
treeRootHoldFrom() {
|
|
6319
|
-
const
|
|
6332
|
+
const claimFrom = (k2) => {
|
|
6333
|
+
const lineStart = this.lineStarts[k2];
|
|
6334
|
+
const lineEnd = this.contentEnds[k2];
|
|
6335
|
+
let pos = lineStart;
|
|
6320
6336
|
for (; ; ) {
|
|
6321
|
-
const block = this.blockAt(
|
|
6322
|
-
if (!block || block.kind !== "island" || block.island
|
|
6323
|
-
|
|
6324
|
-
if (
|
|
6325
|
-
|
|
6337
|
+
const block = this.blockAt(pos);
|
|
6338
|
+
if (!block || block.kind !== "island" || !block.island) return pos;
|
|
6339
|
+
if (block.island.fromParagraph === true || this.mayDissolve(block.island)) return pos;
|
|
6340
|
+
if (block.start < lineStart) {
|
|
6341
|
+
const opened = this.lineOf(block.start);
|
|
6342
|
+
if (this.lineStarts[opened] !== block.start && claimFrom(opened) !== -1) return pos;
|
|
6343
|
+
if (block.end >= lineEnd) return -1;
|
|
6344
|
+
pos = block.end;
|
|
6345
|
+
continue;
|
|
6346
|
+
}
|
|
6347
|
+
if (block.end >= lineEnd) return -1;
|
|
6348
|
+
pos = block.end;
|
|
6326
6349
|
}
|
|
6327
6350
|
};
|
|
6328
6351
|
let k = this.lineCount - 1;
|
|
6329
6352
|
let start = this.lineCount;
|
|
6353
|
+
let startPos = this.n;
|
|
6330
6354
|
if (k >= 0 && this.isOpenTail(k)) {
|
|
6331
|
-
|
|
6355
|
+
const at = claimFrom(k);
|
|
6356
|
+
if (at === -1) return this.n;
|
|
6332
6357
|
start = k;
|
|
6358
|
+
startPos = at;
|
|
6333
6359
|
k--;
|
|
6334
6360
|
}
|
|
6335
|
-
for (; k >= 0
|
|
6361
|
+
for (; k >= 0; k--) {
|
|
6336
6362
|
this.tick(1);
|
|
6363
|
+
const at = claimFrom(k);
|
|
6364
|
+
if (at === -1) break;
|
|
6337
6365
|
if (this.lineIsBlank(k)) continue;
|
|
6338
6366
|
if (!TREE_GLYPHS.test(this.lineText(k))) break;
|
|
6339
6367
|
start = k;
|
|
6368
|
+
startPos = at;
|
|
6340
6369
|
}
|
|
6341
|
-
let
|
|
6342
|
-
for (let j = start - 1; j >= 0
|
|
6370
|
+
let rootPos = startPos;
|
|
6371
|
+
for (let j = start - 1; j >= 0; j--) {
|
|
6372
|
+
const at = claimFrom(j);
|
|
6373
|
+
if (at === -1) break;
|
|
6343
6374
|
const trimmed = this.lineText(j).trim();
|
|
6344
6375
|
this.tick(trimmed.length + 1);
|
|
6345
6376
|
if (!trimmed || isSplitterTreeLine(trimmed) || /^#{1,6}\s/.test(trimmed)) break;
|
|
6346
|
-
|
|
6377
|
+
rootPos = at;
|
|
6378
|
+
if (at > this.lineStarts[j]) break;
|
|
6347
6379
|
}
|
|
6348
|
-
return
|
|
6380
|
+
return rootPos;
|
|
6349
6381
|
}
|
|
6350
6382
|
/** The block (so far) containing offset `pos`, or null. */
|
|
6351
6383
|
blockAt(pos) {
|
|
@@ -7115,6 +7147,10 @@ var Tokenizer = class {
|
|
|
7115
7147
|
const closer = `</${name}>`;
|
|
7116
7148
|
const close = this.next(closer, tagEnd);
|
|
7117
7149
|
const blockType = isAttr ? "xml_attr" : "xml_region";
|
|
7150
|
+
if (close === -1 && isThinking && !this.streaming) {
|
|
7151
|
+
i = tagEnd;
|
|
7152
|
+
continue;
|
|
7153
|
+
}
|
|
7118
7154
|
if (close === -1) return stop(this.island(blockType, i, this.n, false, { tag: name }));
|
|
7119
7155
|
const end = close + closer.length;
|
|
7120
7156
|
if (end > pe) return stop(this.spill(blockType, i, end, pe, { tag: name }));
|