@ai-matrx/content-ir 0.18.6 → 0.19.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/dist/source.cjs CHANGED
@@ -270,12 +270,6 @@ function fenceOpenerOf(content) {
270
270
  return null;
271
271
  }
272
272
  var FenceReader = class {
273
- constructor(opener, options = {}) {
274
- this.opener = opener;
275
- this.isJson = opener.char === "`" && opener.lang === "json";
276
- this.nesting = opener.char === "`" && (options.nesting ?? fenceNestsInnerFences(opener.lang));
277
- this.tildeCloser = opener.char === "~" ? new RegExp(`^ {0,3}~{${opener.ticks},}[ \\t]*$`) : null;
278
- }
279
273
  opener;
280
274
  state = { inString: false, escaped: false };
281
275
  depth = 0;
@@ -284,6 +278,12 @@ var FenceReader = class {
284
278
  isJson;
285
279
  nesting;
286
280
  tildeCloser;
281
+ constructor(opener, options = {}) {
282
+ this.opener = opener;
283
+ this.isJson = opener.char === "`" && opener.lang === "json";
284
+ this.nesting = opener.char === "`" && (options.nesting ?? fenceNestsInnerFences(opener.lang));
285
+ this.tildeCloser = opener.char === "~" ? new RegExp(`^ {0,3}~{${opener.ticks},}[ \\t]*$`) : null;
286
+ }
287
287
  /** How many nested fences are open right now. */
288
288
  get nestedDepth() {
289
289
  return this.depth;
@@ -901,9 +901,6 @@ function isEscapedBacktick(line, offset) {
901
901
  return slashes % 2 === 1;
902
902
  }
903
903
  var XmlContainerTracker = class {
904
- constructor(rootTag) {
905
- this.rootTag = rootTag;
906
- }
907
904
  rootTag;
908
905
  depth = 0;
909
906
  inComment = false;
@@ -911,6 +908,9 @@ var XmlContainerTracker = class {
911
908
  inlineTicks = 0;
912
909
  /** The open fence, read by THE one closer (source/code-ranges.ts). */
913
910
  fence = null;
911
+ constructor(rootTag) {
912
+ this.rootTag = rootTag;
913
+ }
914
914
  consumeLine(line, startOffset = 0) {
915
915
  if (this.fence) {
916
916
  if (this.fence.feed(line)) this.fence = null;
@@ -1122,6 +1122,23 @@ function isSplitterTreeLine(line) {
1122
1122
  }
1123
1123
  var MEDIA_REF_PREFIXES = ["[Image URL:", "[Video URL:", "[Audio URL:"];
1124
1124
  var Tokenizer = class {
1125
+ text;
1126
+ streaming;
1127
+ meter;
1128
+ n;
1129
+ lineStarts = [];
1130
+ contentEnds = [];
1131
+ lineEnds = [];
1132
+ blocks = [];
1133
+ blockCache = /* @__PURE__ */ new Map();
1134
+ /** Lazily built: for line i, first line j >= i where brace net from i drops to <= 0. */
1135
+ braceStop = null;
1136
+ braceNet = null;
1137
+ /** Every occurrence offset of each needle searched so far (overlapping, like indexOf). */
1138
+ occurrences = /* @__PURE__ */ new Map();
1139
+ /** `$$` opener → closer for the pairs the core renders as math. */
1140
+ mathPairs;
1141
+ finder = (needle, from) => this.next(needle, from);
1125
1142
  constructor(text, streaming = false, meter = void 0) {
1126
1143
  this.text = text;
1127
1144
  this.streaming = streaming;
@@ -1168,23 +1185,6 @@ var Tokenizer = class {
1168
1185
  this.lineEnds.push(text.length);
1169
1186
  }
1170
1187
  }
1171
- text;
1172
- streaming;
1173
- meter;
1174
- n;
1175
- lineStarts = [];
1176
- contentEnds = [];
1177
- lineEnds = [];
1178
- blocks = [];
1179
- blockCache = /* @__PURE__ */ new Map();
1180
- /** Lazily built: for line i, first line j >= i where brace net from i drops to <= 0. */
1181
- braceStop = null;
1182
- braceNet = null;
1183
- /** Every occurrence offset of each needle searched so far (overlapping, like indexOf). */
1184
- occurrences = /* @__PURE__ */ new Map();
1185
- /** `$$` opener → closer for the pairs the core renders as math. */
1186
- mathPairs;
1187
- finder = (needle, from) => this.next(needle, from);
1188
1188
  /** Streaming: where provisional text starts (a pending `$$`), or +∞. */
1189
1189
  provisionalFrom = Number.POSITIVE_INFINITY;
1190
1190
  /** Streaming: the text ends in a lone CR whose LF has not arrived yet. */
@@ -1331,12 +1331,6 @@ var Tokenizer = class {
1331
1331
  const last = this.lineStarts.length - 1;
1332
1332
  if (last < 0) return;
1333
1333
  if (this.isOpenTail(last)) {
1334
- const lineStart = this.lineStarts[last];
1335
- for (const block2 of this.blocks) {
1336
- if (block2.kind === "prose" && block2.end > lineStart) {
1337
- block2.inlines = block2.inlines.filter((inline) => inline.end <= lineStart);
1338
- }
1339
- }
1340
1334
  let b = this.blocks.length - 1;
1341
1335
  while (b >= 0 && this.blocks[b].kind === "gap") b--;
1342
1336
  const block = this.blocks[b];
@@ -1942,7 +1936,9 @@ var Tokenizer = class {
1942
1936
  const block = this.detectBlock(this.lineStarts[k], k, false);
1943
1937
  if (block) {
1944
1938
  breakLine = k;
1945
- if (this.mayDissolve(block)) this.undecidedBreaks.add(end);
1939
+ if (this.mayDissolve(block) || this.streaming && block.start >= this.provisionalFrom) {
1940
+ this.undecidedBreaks.add(end);
1941
+ }
1946
1942
  break;
1947
1943
  }
1948
1944
  end = this.contentEnds[k];
@@ -2287,12 +2283,12 @@ function blockAt(blocks, offset) {
2287
2283
 
2288
2284
  // source/splice.ts
2289
2285
  var SourceSpliceError = class extends Error {
2286
+ code;
2290
2287
  constructor(code, message) {
2291
2288
  super(message);
2292
2289
  this.code = code;
2293
2290
  this.name = "SourceSpliceError";
2294
2291
  }
2295
- code;
2296
2292
  };
2297
2293
  function blockEdit(block, text) {
2298
2294
  return { start: block.start, end: block.end, text };