@ai-matrx/content-ir 0.19.0 → 0.19.1

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/index.js CHANGED
@@ -5642,7 +5642,7 @@ function pendingCodeSpanStart(text) {
5642
5642
  const n = text.length;
5643
5643
  if (n === 0 || /\n[ \t]*\n[ \t]*$/.test(text)) return -1;
5644
5644
  const lastLine = text.slice(text.lastIndexOf("\n") + 1);
5645
- if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
5645
+ if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t\r]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
5646
5646
  const s = scan(text);
5647
5647
  const para = s.pendingPara;
5648
5648
  if (s.endsInFence || para === -1) return -1;
@@ -5806,7 +5806,7 @@ function isVariableChain(content, after) {
5806
5806
  const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
5807
5807
  if (!run) return false;
5808
5808
  if (after.length === 1) return false;
5809
- if (/^[A-Za-z_][A-Za-z0-9_]*[.@-]$/.test(content)) return true;
5809
+ if (/^[A-Za-z_][A-Za-z0-9_]*(?:[.@-]|->|::)$/.test(content)) return true;
5810
5810
  return IDENTIFIER.test(content) && !MATH_SUFFIX.test(run);
5811
5811
  }
5812
5812
  var FUNCTION_NAMES = /* @__PURE__ */ new Set([
@@ -6211,7 +6211,7 @@ var Tokenizer = class {
6211
6211
  if (close >= span) this.provisionalFrom = Math.min(this.provisionalFrom, open);
6212
6212
  }
6213
6213
  }
6214
- for (const pad of ["`", "``", "```", "~~~"]) {
6214
+ for (const pad of ["`", "``", "```", "~~~", "$"]) {
6215
6215
  const alt = pairDisplayMath(text + pad);
6216
6216
  for (const [open, close] of this.mathPairs) {
6217
6217
  if (alt.get(open) !== close) this.provisionalFrom = Math.min(this.provisionalFrom, open);
@@ -6243,19 +6243,6 @@ var Tokenizer = class {
6243
6243
  provisionalFrom = Number.POSITIVE_INFINITY;
6244
6244
  /** Streaming: the text ends in a lone CR whose LF has not arrived yet. */
6245
6245
  pendingCR = false;
6246
- /**
6247
- * Streaming: an open last line that begins with `{` is undecided — each new
6248
- * byte can balance or unbalance its braces and flip the whole line between
6249
- * prose and a JSON island — so it is provisional until it ends (G5).
6250
- * (A lone HTML tag on that line is held by {@link holdUndecidedTail}.)
6251
- */
6252
- markOpenJsonTail() {
6253
- const last = this.lineStarts.length - 1;
6254
- if (!this.isOpenTail(last)) return;
6255
- if (this.lineText(last).trim().startsWith("{")) {
6256
- this.provisionalFrom = Math.min(this.provisionalFrom, this.lineStarts[last]);
6257
- }
6258
- }
6259
6246
  /**
6260
6247
  * `text.indexOf(needle, from)` in O(log k): the first query for a needle
6261
6248
  * indexes all of its occurrences once, so repeated searches for a closer
@@ -6290,7 +6277,7 @@ var Tokenizer = class {
6290
6277
  const rest = this.n - pe;
6291
6278
  if (rest === 0) return true;
6292
6279
  const tail = this.text.slice(pe);
6293
- return /^(?:\r\n|\r|\n)[ \t]*$/.test(tail);
6280
+ return /^(?:\r\n|\r|\n)[ \t\r]*$/.test(tail);
6294
6281
  }
6295
6282
  /**
6296
6283
  * Streaming: an open block that may still turn back into prose — a `$$`
@@ -6299,7 +6286,9 @@ var Tokenizer = class {
6299
6286
  * or any opener that is itself still arriving on the open last line.
6300
6287
  */
6301
6288
  mayDissolve(block) {
6302
- if (!this.streaming || block.complete) return false;
6289
+ if (!this.streaming) return false;
6290
+ if (block.start >= this.provisionalFrom) return true;
6291
+ if (block.complete) return false;
6303
6292
  if (block.type === "math_block" || block.type === "json") return true;
6304
6293
  return this.isOpenTail(this.lineOf(block.start));
6305
6294
  }
@@ -6338,7 +6327,6 @@ var Tokenizer = class {
6338
6327
  return this.text.slice(this.lineStarts[li], this.contentEnds[li]);
6339
6328
  }
6340
6329
  run() {
6341
- if (this.streaming) this.markOpenJsonTail();
6342
6330
  let pos = 0;
6343
6331
  while (pos < this.n) {
6344
6332
  const li = this.lineOf(pos);
@@ -6576,7 +6564,7 @@ var Tokenizer = class {
6576
6564
  return { type, start, end, complete, meta };
6577
6565
  }
6578
6566
  frontMatter(li, t) {
6579
- const fence = this.lineText(li);
6567
+ const fence = this.lineText(li).replace(/^\uFEFF/, "");
6580
6568
  if (fence !== "---" && fence !== "+++" || t !== fence) return null;
6581
6569
  const toml = fence === "+++";
6582
6570
  let sawContent = false;
@@ -6587,9 +6575,13 @@ var Tokenizer = class {
6587
6575
  }
6588
6576
  if (!NOT_WHITESPACE.test(line)) continue;
6589
6577
  const shaped = toml ? /^\s*(?:[A-Za-z0-9_."-]+\s*=|\[|#)/.test(line) : /^(?:[A-Za-z0-9_"'-][^:]*:(?:\s|$)|\s+\S|-\s|#)/.test(line);
6590
- if (!shaped) return null;
6578
+ if (!shaped) {
6579
+ if (this.isOpenTail(k)) break;
6580
+ return null;
6581
+ }
6591
6582
  sawContent = true;
6592
6583
  }
6584
+ if (this.streaming) return this.island("front_matter", 0, this.n, false, { format: toml ? "toml" : "yaml" });
6593
6585
  return null;
6594
6586
  }
6595
6587
  /**
@@ -6990,7 +6982,7 @@ var Tokenizer = class {
6990
6982
  const block = this.detectBlock(this.lineStarts[k], k, false);
6991
6983
  if (block) {
6992
6984
  breakLine = k;
6993
- if (this.mayDissolve(block) || this.streaming && block.start >= this.provisionalFrom) {
6985
+ if (this.mayDissolve(block)) {
6994
6986
  this.undecidedBreaks.add(end);
6995
6987
  }
6996
6988
  break;