@ai-matrx/content-ir 0.16.1 → 0.17.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/index.d.cts CHANGED
@@ -7,5 +7,5 @@ export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateR
7
7
  export { ArrayItemKindBinding, BlockSchemaDraft, ConversionProblem, DroppedMetadata, FieldComparison, ItemKindRefCheck, JsonSchemaNode, KindJsonSchemaExport, KindJsonSchemaOptions, KindSchemaFromJsonResult, SavePlanEntry, SavePlanValidation, SchemaConversionResult, buildAgentSchemaWithRenderBlockSupport, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, fieldsToDbPayload, injectKindIntoObjectSchema, isDuplicateBlockSlug, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, normalizeAiSchemaInput, runSchemaConversion, validateBlockSchemaSavePlan } from './convert.cjs';
8
8
  export { AnyPartialKindEvent, IR_PARTIAL_KEY, KindVerdict, NODE_OUTCOME_KIND, NodeOutcomeWrapper, PartialKindEvent, PartialKindNode, PartialKindState, RUN_RESULT_KIND, RetractedKindEvent, RunResultWrapper, SupersededKindEvent, advancePartialKind, emitPayloadFence, emitPayloadJson, isProvisionalKind, isTerminalKindEvent, kindVerdictOf, makePartialKindStalenessGate, readNodeOutcomeValue, readOutputRef, readPartialKindEvent, readRunResultValue, rehydrateNodeOutcome, rehydrateRunResult, sanitizeInboundPartialKindMetadata, withRootKind } from './wire.cjs';
9
9
  export { ACTION_BY_CLASS, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DecodedDirective, DirectiveCapability, DirectiveClass, DirectiveDecodeError, DirectiveDisplay, DirectiveItemKindLookup, DirectiveItemsEdge, DirectiveNounCatalog, DirectiveNounEntry, DirectiveSlug, IN_CONTENT_CLASSES, ItemFact, KindDirectiveShell, RESERVED_PREFIX, SIDE_EFFECT_CLASSES, SLUG_PREFIX, asKindInstance, buildDirectiveSlug, buildKindDirective, capabilityOf, decodeDirective, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, executesAtOutputRoot, isDirectiveClass, isKindDirective, isLegacyShell, isReservedDirectiveSlug, itemFacts, itemSubtitle, itemTitle, legacyShellUses, looksLikeDirectiveHead, nounFamily, nounLabel, nounTitleColumn, parseDirectiveSlug, resetLegacyShellUses, resolvesInContent, titleCaseToken, tryDecodeDirective, tryDecodeDirectiveContent } from './directives.cjs';
10
- export { BlockIslandType, CALLOUT_NAMES, CodePointIndex, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, InlineIslandType, InnerFenceLine, IslandMeta, IslandType, MapOptions, MappedPosition, MappedRange, NESTING_FENCE_LANGUAGES, ReadXmlTag, SourceBlock, SourceBlockKind, SourceChange, SourceEdit, SourceIsland, SourceSpan, SourceSpliceError, SourceSpliceErrorCode, SpliceIntegrity, SpliceOptions, SpliceResult, TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine } from './source.cjs';
10
+ export { BlockIslandType, CALLOUT_NAMES, CodePointIndex, CodeRange, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, InlineIslandType, InnerFenceLine, IslandMeta, IslandType, MapOptions, MappedPosition, MappedRange, NESTING_FENCE_LANGUAGES, ReadXmlTag, SourceBlock, SourceBlockKind, SourceChange, SourceEdit, SourceIsland, SourceSpan, SourceSpliceError, SourceSpliceErrorCode, SpliceIntegrity, SpliceOptions, SpliceResult, TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, findCodeRanges, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine } from './source.cjs';
11
11
  import 'react';
package/dist/index.d.ts CHANGED
@@ -7,5 +7,5 @@ export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateR
7
7
  export { ArrayItemKindBinding, BlockSchemaDraft, ConversionProblem, DroppedMetadata, FieldComparison, ItemKindRefCheck, JsonSchemaNode, KindJsonSchemaExport, KindJsonSchemaOptions, KindSchemaFromJsonResult, SavePlanEntry, SavePlanValidation, SchemaConversionResult, buildAgentSchemaWithRenderBlockSupport, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, fieldsToDbPayload, injectKindIntoObjectSchema, isDuplicateBlockSlug, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, normalizeAiSchemaInput, runSchemaConversion, validateBlockSchemaSavePlan } from './convert.js';
8
8
  export { AnyPartialKindEvent, IR_PARTIAL_KEY, KindVerdict, NODE_OUTCOME_KIND, NodeOutcomeWrapper, PartialKindEvent, PartialKindNode, PartialKindState, RUN_RESULT_KIND, RetractedKindEvent, RunResultWrapper, SupersededKindEvent, advancePartialKind, emitPayloadFence, emitPayloadJson, isProvisionalKind, isTerminalKindEvent, kindVerdictOf, makePartialKindStalenessGate, readNodeOutcomeValue, readOutputRef, readPartialKindEvent, readRunResultValue, rehydrateNodeOutcome, rehydrateRunResult, sanitizeInboundPartialKindMetadata, withRootKind } from './wire.js';
9
9
  export { ACTION_BY_CLASS, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DecodedDirective, DirectiveCapability, DirectiveClass, DirectiveDecodeError, DirectiveDisplay, DirectiveItemKindLookup, DirectiveItemsEdge, DirectiveNounCatalog, DirectiveNounEntry, DirectiveSlug, IN_CONTENT_CLASSES, ItemFact, KindDirectiveShell, RESERVED_PREFIX, SIDE_EFFECT_CLASSES, SLUG_PREFIX, asKindInstance, buildDirectiveSlug, buildKindDirective, capabilityOf, decodeDirective, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, executesAtOutputRoot, isDirectiveClass, isKindDirective, isLegacyShell, isReservedDirectiveSlug, itemFacts, itemSubtitle, itemTitle, legacyShellUses, looksLikeDirectiveHead, nounFamily, nounLabel, nounTitleColumn, parseDirectiveSlug, resetLegacyShellUses, resolvesInContent, titleCaseToken, tryDecodeDirective, tryDecodeDirectiveContent } from './directives.js';
10
- export { BlockIslandType, CALLOUT_NAMES, CodePointIndex, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, InlineIslandType, InnerFenceLine, IslandMeta, IslandType, MapOptions, MappedPosition, MappedRange, NESTING_FENCE_LANGUAGES, ReadXmlTag, SourceBlock, SourceBlockKind, SourceChange, SourceEdit, SourceIsland, SourceSpan, SourceSpliceError, SourceSpliceErrorCode, SpliceIntegrity, SpliceOptions, SpliceResult, TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine } from './source.js';
10
+ export { BlockIslandType, CALLOUT_NAMES, CodePointIndex, CodeRange, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, InlineIslandType, InnerFenceLine, IslandMeta, IslandType, MapOptions, MappedPosition, MappedRange, NESTING_FENCE_LANGUAGES, ReadXmlTag, SourceBlock, SourceBlockKind, SourceChange, SourceEdit, SourceIsland, SourceSpan, SourceSpliceError, SourceSpliceErrorCode, SpliceIntegrity, SpliceOptions, SpliceResult, TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, findCodeRanges, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine } from './source.js';
11
11
  import 'react';
package/dist/index.js CHANGED
@@ -5282,12 +5282,167 @@ function singleDollarMathEnd(text, open, limit = text.length) {
5282
5282
  return isSingleDollarMath(content, text[close + 1]) ? close + 1 : -1;
5283
5283
  }
5284
5284
 
5285
+ // source/code-ranges.ts
5286
+ function findCodeRanges(text) {
5287
+ const ranges = [];
5288
+ const n = text.length;
5289
+ let fence = null;
5290
+ let para = -1;
5291
+ const spans = (from, to) => {
5292
+ const runs = [];
5293
+ for (let k = from; k < to; ) {
5294
+ if (text.charCodeAt(k) !== 96) {
5295
+ k++;
5296
+ continue;
5297
+ }
5298
+ let len = 1;
5299
+ while (k + len < to && text.charCodeAt(k + len) === 96) len++;
5300
+ runs.push([k, len]);
5301
+ k += len;
5302
+ }
5303
+ const nextSame = new Array(runs.length).fill(-1);
5304
+ const last = /* @__PURE__ */ new Map();
5305
+ for (let r = runs.length - 1; r >= 0; r--) {
5306
+ const len = runs[r][1];
5307
+ nextSame[r] = last.get(len) ?? -1;
5308
+ last.set(len, r);
5309
+ }
5310
+ for (let r = 0; r < runs.length; ) {
5311
+ const j = nextSame[r];
5312
+ if (j === -1) {
5313
+ r++;
5314
+ continue;
5315
+ }
5316
+ const [s0] = runs[r];
5317
+ const [s1, l1] = runs[j];
5318
+ ranges.push({ start: s0, end: s1 + l1, kind: "span" });
5319
+ r = j + 1;
5320
+ }
5321
+ };
5322
+ let pos = 0;
5323
+ while (pos <= n) {
5324
+ const nl = text.indexOf("\n", pos);
5325
+ const lineEnd = nl === -1 ? n : nl;
5326
+ const line = text.slice(pos, lineEnd);
5327
+ let indent = 0;
5328
+ while (indent < line.length && line[indent] === " ") indent++;
5329
+ const body = line.slice(indent);
5330
+ if (fence) {
5331
+ const trimmed = trimFenceLine(line);
5332
+ let closes = false;
5333
+ if (fence.char === "`") {
5334
+ const kind = classifyInnerFenceLine(trimmed, fence.len, fence.nests, fence.depth);
5335
+ if (kind === "open-nested") fence.depth++;
5336
+ else if (kind === "close-nested") fence.depth--;
5337
+ else if (kind === "close-outer") closes = indent <= 3;
5338
+ } else {
5339
+ let t = 0;
5340
+ while (t < trimmed.length && trimmed[t] === "~") t++;
5341
+ closes = indent <= 3 && t >= fence.len && trimFenceLine(trimmed.slice(t)) === "";
5342
+ }
5343
+ if (closes) {
5344
+ ranges.push({ start: fence.start, end: lineEnd, kind: "fence" });
5345
+ fence = null;
5346
+ }
5347
+ } else {
5348
+ const opener = indent <= 3 ? /^(`{3,}|~{3,})(.*)$/.exec(body) : null;
5349
+ const info = opener ? opener[2] : "";
5350
+ if (opener && !(opener[1][0] === "`" && info.includes("`"))) {
5351
+ if (para !== -1) spans(para, pos);
5352
+ para = -1;
5353
+ const char = opener[1][0];
5354
+ const parsed = char === "`" ? parseFenceOpener(line) : null;
5355
+ fence = { char, len: opener[1].length, start: pos, nests: fenceNestsInnerFences(parsed?.lang), depth: 0 };
5356
+ } else if (body.trim() === "") {
5357
+ if (para !== -1) spans(para, pos);
5358
+ para = -1;
5359
+ } else if (para === -1) para = pos;
5360
+ }
5361
+ if (nl === -1) break;
5362
+ pos = nl + 1;
5363
+ }
5364
+ if (fence) ranges.push({ start: fence.start, end: n, kind: "fence" });
5365
+ else if (para !== -1) spans(para, n);
5366
+ return ranges.sort((a, b) => a.start - b.start);
5367
+ }
5368
+ function pendingCodeSpanStart(text) {
5369
+ const n = text.length;
5370
+ if (n === 0 || /\n[ \t]*\n[ \t]*$/.test(text)) return -1;
5371
+ let fence = null;
5372
+ let para = -1;
5373
+ let pos = 0;
5374
+ while (pos <= n) {
5375
+ const nl = text.indexOf("\n", pos);
5376
+ const lineEnd = nl === -1 ? n : nl;
5377
+ const line = text.slice(pos, lineEnd);
5378
+ let indent = 0;
5379
+ while (indent < line.length && line[indent] === " ") indent++;
5380
+ const body = line.slice(indent);
5381
+ if (fence) {
5382
+ const trimmed = trimFenceLine(line);
5383
+ let closes = false;
5384
+ if (fence.char === "`") {
5385
+ const kind = classifyInnerFenceLine(trimmed, fence.len, fence.nests, fence.depth);
5386
+ if (kind === "open-nested") fence.depth++;
5387
+ else if (kind === "close-nested") fence.depth--;
5388
+ else if (kind === "close-outer") closes = indent <= 3;
5389
+ } else {
5390
+ let t = 0;
5391
+ while (t < trimmed.length && trimmed[t] === "~") t++;
5392
+ closes = indent <= 3 && t >= fence.len && trimFenceLine(trimmed.slice(t)) === "";
5393
+ }
5394
+ if (closes) fence = null;
5395
+ } else {
5396
+ const opener = indent <= 3 ? /^(`{3,}|~{3,})(.*)$/.exec(body) : null;
5397
+ const info = opener ? opener[2] : "";
5398
+ if (opener && !(opener[1][0] === "`" && info.includes("`"))) {
5399
+ para = -1;
5400
+ const char = opener[1][0];
5401
+ const parsed = char === "`" ? parseFenceOpener(line) : null;
5402
+ fence = { char, len: opener[1].length, nests: fenceNestsInnerFences(parsed?.lang), depth: 0 };
5403
+ } else if (body.trim() === "") {
5404
+ if (!(nl === -1 && line === "")) para = -1;
5405
+ } else if (para === -1) para = pos;
5406
+ }
5407
+ if (nl === -1) break;
5408
+ pos = nl + 1;
5409
+ }
5410
+ if (fence || para === -1) return -1;
5411
+ const runs = [];
5412
+ for (let k = para; k < n; ) {
5413
+ if (text.charCodeAt(k) !== 96) {
5414
+ k++;
5415
+ continue;
5416
+ }
5417
+ let len = 1;
5418
+ while (k + len < n && text.charCodeAt(k + len) === 96) len++;
5419
+ runs.push([k, len]);
5420
+ k += len;
5421
+ }
5422
+ const growing = (r) => {
5423
+ const [start, len] = runs[r];
5424
+ return start + len === n;
5425
+ };
5426
+ for (let r = 0; r < runs.length; ) {
5427
+ if (growing(r)) return runs[r][0];
5428
+ const len = runs[r][1];
5429
+ let j = r + 1;
5430
+ while (j < runs.length && (runs[j][1] !== len || growing(j))) j++;
5431
+ if (j >= runs.length) return runs[r][0];
5432
+ r = j + 1;
5433
+ }
5434
+ return -1;
5435
+ }
5436
+
5285
5437
  // source/math-pairs.ts
5286
5438
  var MAX_MATH_SPAN = 600;
5287
5439
  var STRUCTURAL_MARKDOWN = /\]\(|https?:\/\/|\*\*|(?:^|\n)[ \t]{0,3}#{1,6}[ \t]|(?:^|\n)[ \t]*[-*+][ \t]+|(?:^|\n)[ \t]*\d+[.)][ \t]/;
5288
5440
  var LATEX_COMMAND = /\\[a-zA-Z]/;
5289
5441
  var PROSE_WORD = /[A-Za-z]{3,}/g;
5290
5442
  var PROSE_WORD_LIMIT = 6;
5443
+ function isMathPlaceholder(inner) {
5444
+ return /^[\s.…·⋯_-]*$/.test(inner) && /[.…·⋯]/.test(inner);
5445
+ }
5291
5446
  function opensFlowBlock(text, open) {
5292
5447
  for (let k = open - 1; k >= 0 && text[k] !== "\n"; k--) if (text[k] !== " " && text[k] !== " ") return false;
5293
5448
  for (let k = open + 2; k < text.length && text[k] !== "\n"; k++) if (text[k] !== " " && text[k] !== " " && text[k] !== "\r") return false;
@@ -5305,15 +5460,7 @@ function looksLikeDisplayMath(inner, flow = false) {
5305
5460
  return (s.match(PROSE_WORD) ?? []).length < PROSE_WORD_LIMIT;
5306
5461
  }
5307
5462
  function codeRanges(text) {
5308
- const ranges = [];
5309
- for (const re of [/```[\s\S]*?(?:```|$)/g, /~~~[\s\S]*?(?:~~~|$)/g, /`[^`\n]*`/g]) {
5310
- let m;
5311
- while ((m = re.exec(text)) !== null) {
5312
- ranges.push([m.index, m.index + m[0].length]);
5313
- if (m[0].length === 0) re.lastIndex++;
5314
- }
5315
- }
5316
- return ranges.sort((a, b) => a[0] - b[0]);
5463
+ return findCodeRanges(text).map((r) => [r.start, r.end]);
5317
5464
  }
5318
5465
  function pendingDisplayMathOpener(text) {
5319
5466
  if (!text.includes("$$")) return -1;
@@ -5335,6 +5482,10 @@ function pendingDisplayMathOpener(text) {
5335
5482
  const open = tokens[j];
5336
5483
  const close = tokens[j + 1];
5337
5484
  if (close === void 0) break;
5485
+ if (isMathPlaceholder(text.slice(open + 2, close))) {
5486
+ j += 2;
5487
+ continue;
5488
+ }
5338
5489
  if (looksLikeDisplayMath(text.slice(open + 2, close), opensFlowBlock(text, open))) {
5339
5490
  paired.add(open);
5340
5491
  paired.add(close);
@@ -5379,6 +5530,10 @@ function pairDisplayMath(text) {
5379
5530
  const open = tokens[j];
5380
5531
  const close = tokens[j + 1];
5381
5532
  if (close === void 0) break;
5533
+ if (isMathPlaceholder(text.slice(open + 2, close))) {
5534
+ j += 2;
5535
+ continue;
5536
+ }
5382
5537
  if (looksLikeDisplayMath(text.slice(open + 2, close), opensFlowBlock(text, open))) {
5383
5538
  pairs.set(open, close);
5384
5539
  j += 2;
@@ -5716,6 +5871,27 @@ var Tokenizer = class {
5716
5871
  this.mathPairs = pairDisplayMath(text);
5717
5872
  this.provisionalFrom = streaming ? pendingDisplayMathOpener(text) : -1;
5718
5873
  if (this.provisionalFrom === -1) this.provisionalFrom = Number.POSITIVE_INFINITY;
5874
+ if (streaming && text.includes("$$")) {
5875
+ const span = pendingCodeSpanStart(text);
5876
+ if (span !== -1) {
5877
+ const firstToken = text.indexOf("$$", span);
5878
+ if (firstToken !== -1) this.provisionalFrom = Math.min(this.provisionalFrom, firstToken);
5879
+ for (const [open, close] of this.mathPairs) {
5880
+ if (close >= span) this.provisionalFrom = Math.min(this.provisionalFrom, open);
5881
+ }
5882
+ }
5883
+ for (const pad of ["`", "``", "```", "~~~"]) {
5884
+ const alt = pairDisplayMath(text + pad);
5885
+ for (const [open, close] of this.mathPairs) {
5886
+ if (alt.get(open) !== close) this.provisionalFrom = Math.min(this.provisionalFrom, open);
5887
+ }
5888
+ for (const [open, close] of alt) {
5889
+ if (close < text.length && this.mathPairs.get(open) !== close) {
5890
+ this.provisionalFrom = Math.min(this.provisionalFrom, open);
5891
+ }
5892
+ }
5893
+ }
5894
+ }
5719
5895
  let start = 0;
5720
5896
  for (let i = 0; i < text.length; i++) {
5721
5897
  if (text.charCodeAt(i) === 10) {
@@ -5756,13 +5932,17 @@ var Tokenizer = class {
5756
5932
  /**
5757
5933
  * Streaming: an open last line that begins with `{` is undecided — each new
5758
5934
  * byte can balance or unbalance its braces and flip the whole line between
5759
- * prose and a JSON island — so it is provisional until it ends (G5).
5935
+ * prose and a JSON island — and so is a line that is exactly one allowed
5936
+ * HTML tag so far; both are provisional until they end (G5).
5760
5937
  */
5761
5938
  markOpenJsonTail() {
5762
5939
  const last = this.lineStarts.length - 1;
5763
5940
  if (!this.isOpenTail(last)) return;
5764
5941
  const start = this.lineStarts[last];
5765
- if (this.lineText(last).trimStart().startsWith("{")) {
5942
+ const t = this.lineText(last).trim();
5943
+ const oneTag = t.startsWith("<") ? readXmlTag(t, 0) : null;
5944
+ const loneTag = !!oneTag && oneTag.raw === t && ALLOWED_RAW_HTML_TAGS.has(oneTag.tagName.toLowerCase());
5945
+ if (t.startsWith("{") || loneTag) {
5766
5946
  this.provisionalFrom = Math.min(this.provisionalFrom, start);
5767
5947
  }
5768
5948
  }
@@ -6055,11 +6235,17 @@ var Tokenizer = class {
6055
6235
  last = k;
6056
6236
  continue;
6057
6237
  }
6238
+ if (this.isOpenTail(k)) return this.heldFootnote(p, open[1]);
6058
6239
  if (FOOTNOTE_DEF.test(line.trimStart()) || this.detectBlock(this.lineStarts[k], k, false)) break;
6059
- if (this.isOpenTail(k)) break;
6060
6240
  last = k;
6061
6241
  }
6062
- return this.island("footnote_def", p, this.contentEnds[last], true, { id: open[1] });
6242
+ const end = this.contentEnds[last];
6243
+ if (this.paragraphMayGrow(end)) return this.heldFootnote(p, open[1]);
6244
+ return this.island("footnote_def", p, end, true, { id: open[1] });
6245
+ }
6246
+ /** A footnote whose continuation is still arriving: open to the end of the text. */
6247
+ heldFootnote(p, id) {
6248
+ return this.island("footnote_def", p, this.n, false, { id });
6063
6249
  }
6064
6250
  /**
6065
6251
  * Backtick fence — the renderer splitter's close rules: JSON-string aware for
@@ -6303,7 +6489,12 @@ var Tokenizer = class {
6303
6489
  return this.island("html_block", p, close.index + close[0].length, true, { tag: name });
6304
6490
  }
6305
6491
  const typeSix = HTML_BLOCK_LEVEL_TAGS.has(name);
6306
- const typeSeven = atParaStart && t.trimEnd() === tag.raw && !this.isOpenTail(li);
6492
+ const loneTag = atParaStart && t.trimEnd() === tag.raw;
6493
+ if (loneTag && this.isOpenTail(li)) {
6494
+ this.provisionalFrom = Math.min(this.provisionalFrom, p);
6495
+ return null;
6496
+ }
6497
+ const typeSeven = loneTag;
6307
6498
  if (!typeSix && !typeSeven) return null;
6308
6499
  let end = this.contentEnds[li];
6309
6500
  for (let k = li + 1; k < this.lineCount && !this.lineIsBlank(k); k++) {
@@ -6395,10 +6586,6 @@ var Tokenizer = class {
6395
6586
  let breakLine = -1;
6396
6587
  for (let k = li + 1; k < this.lineCount; k++) {
6397
6588
  if (this.lineIsBlank(k)) break;
6398
- if (this.lineStarts[k] >= this.provisionalFrom) {
6399
- end = this.n;
6400
- break;
6401
- }
6402
6589
  if (this.detectBlock(this.lineStarts[k], k, false)) {
6403
6590
  breakLine = k;
6404
6591
  break;
@@ -6541,7 +6728,11 @@ var Tokenizer = class {
6541
6728
  }
6542
6729
  const end = singleDollarMathEnd(text, i, pe);
6543
6730
  this.tick(end > 0 ? end - i : Math.min(403, pe - i));
6544
- if (end > 0 && !(this.streaming && end === this.n)) {
6731
+ if (end > 0 && this.streaming && end === this.n) {
6732
+ this.provisionalFrom = Math.min(this.provisionalFrom, i);
6733
+ return { inlines, breakIsland: null, orphan: false };
6734
+ }
6735
+ if (end > 0) {
6545
6736
  inlines.push(this.island("math_inline", i, end, true, { delimiter: "$" }));
6546
6737
  i = end;
6547
6738
  continue;
@@ -7032,6 +7223,6 @@ function mapRange(changes, start, end, unit = "utf16") {
7032
7223
  return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
7033
7224
  }
7034
7225
 
7035
- export { ACTION_BY_CLASS, CALLOUT_NAMES, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DirectiveDecodeError, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, IN_CONTENT_CLASSES, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, IrTree, JSON_DISCRIMINATOR, JsonStreamTokenizer, KIND_KEY, KindStorageError, KindStreamParser, NESTING_FENCE_LANGUAGES, NODE_OUTCOME_KIND, ParseSession, RESERVED_PREFIX, ROOT_STORAGE_NAME, RUN_RESULT_KIND, SIDE_EFFECT_CLASSES, SLUG_PREFIX, SourceSpliceError, XmlContainerTracker, advancePartialKind, asKindInstance, blockAt, blockEdit, blockRangeEdit, buildAgentSchemaWithRenderBlockSupport, buildCodePointIndex, buildCompliantKindSnapshot, buildDirectiveSlug, buildKindDirective, capabilityOf, classifyInboundEnvelopeMetadata, classifyInnerFenceLine, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, decodeDirective, describeDualGateFailure, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, executesAtOutputRoot, fenceDiscriminator, fenceNestsInnerFences, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDirectiveClass, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isKindDirective, isLegacyShell, isProvisionalKind, isReservedDirectiveSlug, isScalarArrayType, isSingleDollarMath, isTerminalKindEvent, islandEdit, itemFacts, itemSubtitle, itemTitle, joinSource, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, legacyShellUses, listIslands, looksLikeDirectiveHead, looksLikeDisplayMath, makePartialKindStalenessGate, mapPosition, mapRange, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, nounFamily, nounLabel, nounTitleColumn, openParseSession, pairDisplayMath, parseDirectiveSlug, parseFenceOpener, pendingDisplayMathOpener, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, readXmlTag, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, resetLegacyShellUses, resolvesInContent, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, singleDollarMathEnd, spliceSave, splitsSurrogatePair, storageToKindSchema, stripKindDeep, titleCaseToken, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, tryDecodeDirective, tryDecodeDirectiveContent, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
7226
+ export { ACTION_BY_CLASS, CALLOUT_NAMES, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DirectiveDecodeError, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, IN_CONTENT_CLASSES, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, IrTree, JSON_DISCRIMINATOR, JsonStreamTokenizer, KIND_KEY, KindStorageError, KindStreamParser, NESTING_FENCE_LANGUAGES, NODE_OUTCOME_KIND, ParseSession, RESERVED_PREFIX, ROOT_STORAGE_NAME, RUN_RESULT_KIND, SIDE_EFFECT_CLASSES, SLUG_PREFIX, SourceSpliceError, XmlContainerTracker, advancePartialKind, asKindInstance, blockAt, blockEdit, blockRangeEdit, buildAgentSchemaWithRenderBlockSupport, buildCodePointIndex, buildCompliantKindSnapshot, buildDirectiveSlug, buildKindDirective, capabilityOf, classifyInboundEnvelopeMetadata, classifyInnerFenceLine, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, decodeDirective, describeDualGateFailure, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, executesAtOutputRoot, fenceDiscriminator, fenceNestsInnerFences, fieldsToDbPayload, findCodeRanges, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDirectiveClass, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isKindDirective, isLegacyShell, isMathPlaceholder, isProvisionalKind, isReservedDirectiveSlug, isScalarArrayType, isSingleDollarMath, isTerminalKindEvent, islandEdit, itemFacts, itemSubtitle, itemTitle, joinSource, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, legacyShellUses, listIslands, looksLikeDirectiveHead, looksLikeDisplayMath, makePartialKindStalenessGate, mapPosition, mapRange, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, nounFamily, nounLabel, nounTitleColumn, openParseSession, pairDisplayMath, parseDirectiveSlug, parseFenceOpener, pendingDisplayMathOpener, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, readXmlTag, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, resetLegacyShellUses, resolvesInContent, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, singleDollarMathEnd, spliceSave, splitsSurrogatePair, storageToKindSchema, stripKindDeep, titleCaseToken, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, tryDecodeDirective, tryDecodeDirectiveContent, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
7036
7227
  //# sourceMappingURL=index.js.map
7037
7228
  //# sourceMappingURL=index.js.map