@ai-matrx/content-ir 0.18.3 → 0.18.5
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 +28 -0
- package/dist/index.cjs +184 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +182 -31
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +184 -30
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +37 -2
- package/dist/source.d.ts +37 -2
- package/dist/source.js +182 -31
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
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 { BacktickRuns, BlockIslandType, CALLOUT_NAMES, CodePointIndex, CodeRange, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceEnd, FenceLineKind, FenceLines, FenceOpener, FenceReader, 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, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine } from './source.cjs';
|
|
10
|
+
export { AFTER_WINDOW, BacktickRuns, BlockIslandType, CALLOUT_NAMES, CodePointIndex, CodeRange, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceEnd, FenceLineKind, FenceLines, FenceOpener, FenceReader, 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, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarAfter, 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 { BacktickRuns, BlockIslandType, CALLOUT_NAMES, CodePointIndex, CodeRange, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceEnd, FenceLineKind, FenceLines, FenceOpener, FenceReader, 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, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine } from './source.js';
|
|
10
|
+
export { AFTER_WINDOW, BacktickRuns, BlockIslandType, CALLOUT_NAMES, CodePointIndex, CodeRange, DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceEnd, FenceLineKind, FenceLines, FenceOpener, FenceReader, 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, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarAfter, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine } from './source.js';
|
|
11
11
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -5290,6 +5290,7 @@ var FenceReader = class {
|
|
|
5290
5290
|
function closeFence(src, open, opener) {
|
|
5291
5291
|
const first = readFence(src, open, new FenceReader(opener));
|
|
5292
5292
|
if (first.closed || !first.reader.sawNested || first.reader.nestedDepth <= 0) return { line: first.line, closed: first.closed };
|
|
5293
|
+
if (src.streaming) return { line: first.line, closed: false };
|
|
5293
5294
|
const strict = readFence(src, open, new FenceReader(opener, { nesting: false }));
|
|
5294
5295
|
return { line: strict.line, closed: strict.closed };
|
|
5295
5296
|
}
|
|
@@ -5553,6 +5554,8 @@ function fenceLineKinds(text) {
|
|
|
5553
5554
|
function pendingCodeSpanStart(text) {
|
|
5554
5555
|
const n = text.length;
|
|
5555
5556
|
if (n === 0 || /\n[ \t]*\n[ \t]*$/.test(text)) return -1;
|
|
5557
|
+
const lastLine = text.slice(text.lastIndexOf("\n") + 1);
|
|
5558
|
+
if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
|
|
5556
5559
|
const s = scan(text);
|
|
5557
5560
|
const para = s.pendingPara;
|
|
5558
5561
|
if (s.endsInFence || para === -1) return -1;
|
|
@@ -5699,13 +5702,26 @@ var MATH_SHAPE_CHARS = /^[A-Za-z0-9'\s(),.*\/-]+$/;
|
|
|
5699
5702
|
function isSingleDollarMath(content, after) {
|
|
5700
5703
|
if (!content || content.length > 400) return false;
|
|
5701
5704
|
if (/^\s/.test(content) || /\s$/.test(content)) return false;
|
|
5702
|
-
if (after !== void 0 &&
|
|
5705
|
+
if (after !== void 0 && /^[0-9]/.test(after)) return false;
|
|
5706
|
+
if (isVariableChain(content, after)) return false;
|
|
5703
5707
|
if (/(?:^|[^\\])%/.test(content)) return false;
|
|
5704
5708
|
if (/^[)\]}"/]/.test(content) || /[(\[{":;,/]$/.test(content)) return false;
|
|
5705
|
-
if (/^[0-9]/.test(content) && after !== void 0 &&
|
|
5709
|
+
if (/^[0-9]/.test(content) && after !== void 0 && /^[A-Za-z]/.test(after)) return false;
|
|
5706
5710
|
if (isMathPlaceholder(content)) return false;
|
|
5707
5711
|
return TEX_SIGNAL.test(content) || !readsAsProse(content);
|
|
5708
5712
|
}
|
|
5713
|
+
var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5714
|
+
var MATH_SUFFIX = /^(?:s|es|th|st|nd|rd)$/i;
|
|
5715
|
+
function isVariableChain(content, after) {
|
|
5716
|
+
if (/^\{[A-Za-z_][\w.]*\}$/.test(content)) return true;
|
|
5717
|
+
if (!after) return false;
|
|
5718
|
+
if (after[0] === "{") return IDENTIFIER.test(content);
|
|
5719
|
+
const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
|
|
5720
|
+
if (!run) return false;
|
|
5721
|
+
if (after.length === 1) return false;
|
|
5722
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*[.@-]$/.test(content)) return true;
|
|
5723
|
+
return IDENTIFIER.test(content) && !MATH_SUFFIX.test(run);
|
|
5724
|
+
}
|
|
5709
5725
|
var FUNCTION_NAMES = /* @__PURE__ */ new Set([
|
|
5710
5726
|
"sin",
|
|
5711
5727
|
"cos",
|
|
@@ -5749,6 +5765,12 @@ function isMathShape(content) {
|
|
|
5749
5765
|
if (/[A-Za-z]'+[A-Za-z]/.test(content) || /(?:^|[\s(,])[A-Za-z]\.(?:[A-Za-z]\.|\s|$)/.test(content)) return false;
|
|
5750
5766
|
return /[A-Za-z]'*\(|[A-Za-z]'|\b[A-Za-z]\s+[A-Za-z]\b|\([^)]*[A-Za-z][^)]*\)/.test(content);
|
|
5751
5767
|
}
|
|
5768
|
+
var AFTER_WINDOW = 32;
|
|
5769
|
+
function singleDollarAfter(text, close) {
|
|
5770
|
+
const rest = text.slice(close + 1, close + 1 + AFTER_WINDOW);
|
|
5771
|
+
return rest.length < AFTER_WINDOW ? `${rest}
|
|
5772
|
+
` : rest;
|
|
5773
|
+
}
|
|
5752
5774
|
function singleDollarMathEnd(text, open, limit = text.length) {
|
|
5753
5775
|
const bound = Math.min(limit, open + 403);
|
|
5754
5776
|
let close = -1;
|
|
@@ -5766,7 +5788,13 @@ function singleDollarMathEnd(text, open, limit = text.length) {
|
|
|
5766
5788
|
}
|
|
5767
5789
|
if (close === -1 || text[close + 1] === "$") return -1;
|
|
5768
5790
|
const content = text.slice(open + 1, close);
|
|
5769
|
-
return isSingleDollarMath(content, text
|
|
5791
|
+
return isSingleDollarMath(content, singleDollarAfter(text, close)) ? close + 1 : -1;
|
|
5792
|
+
}
|
|
5793
|
+
var BRACKET_TEX_SIGNAL = /\\[A-Za-z]+|[\^{}=<>+]|_\{|(?:^|[^A-Za-z0-9])[A-Za-z]_[A-Za-z0-9](?![A-Za-z0-9])/;
|
|
5794
|
+
function isEscapedBracketMath(content, before) {
|
|
5795
|
+
if (!content.trim()) return false;
|
|
5796
|
+
if (before !== void 0 && /[A-Za-z0-9_)\]]/.test(before)) return false;
|
|
5797
|
+
return BRACKET_TEX_SIGNAL.test(content);
|
|
5770
5798
|
}
|
|
5771
5799
|
|
|
5772
5800
|
// source/xml-tag.ts
|
|
@@ -6131,18 +6159,14 @@ var Tokenizer = class {
|
|
|
6131
6159
|
/**
|
|
6132
6160
|
* Streaming: an open last line that begins with `{` is undecided — each new
|
|
6133
6161
|
* byte can balance or unbalance its braces and flip the whole line between
|
|
6134
|
-
* prose and a JSON island —
|
|
6135
|
-
* HTML tag
|
|
6162
|
+
* prose and a JSON island — so it is provisional until it ends (G5).
|
|
6163
|
+
* (A lone HTML tag on that line is held by {@link holdUndecidedTail}.)
|
|
6136
6164
|
*/
|
|
6137
6165
|
markOpenJsonTail() {
|
|
6138
6166
|
const last = this.lineStarts.length - 1;
|
|
6139
6167
|
if (!this.isOpenTail(last)) return;
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
const oneTag = t.startsWith("<") ? readXmlTag(t, 0) : null;
|
|
6143
|
-
const loneTag = !!oneTag && oneTag.raw === t && ALLOWED_RAW_HTML_TAGS.has(oneTag.tagName.toLowerCase());
|
|
6144
|
-
if (t.startsWith("{") || loneTag) {
|
|
6145
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, start);
|
|
6168
|
+
if (this.lineText(last).trim().startsWith("{")) {
|
|
6169
|
+
this.provisionalFrom = Math.min(this.provisionalFrom, this.lineStarts[last]);
|
|
6146
6170
|
}
|
|
6147
6171
|
}
|
|
6148
6172
|
/**
|
|
@@ -6175,11 +6199,22 @@ var Tokenizer = class {
|
|
|
6175
6199
|
/** Streaming only: a paragraph ending at `pe` may still be continued by a line not yet arrived. */
|
|
6176
6200
|
paragraphMayGrow(pe) {
|
|
6177
6201
|
if (!this.streaming) return false;
|
|
6202
|
+
if (this.undecidedBreaks.has(pe)) return true;
|
|
6178
6203
|
const rest = this.n - pe;
|
|
6179
6204
|
if (rest === 0) return true;
|
|
6180
6205
|
const tail = this.text.slice(pe);
|
|
6181
|
-
return
|
|
6206
|
+
return /^(?:\r\n|\r|\n)[ \t]*$/.test(tail);
|
|
6207
|
+
}
|
|
6208
|
+
/**
|
|
6209
|
+
* Streaming: an open block that may still turn back into prose — a `$$`
|
|
6210
|
+
* pair whose closer is on the open last line (prose after it makes it
|
|
6211
|
+
* inline), or a JSON head whose braces have not balanced (it may never parse).
|
|
6212
|
+
*/
|
|
6213
|
+
mayDissolve(block) {
|
|
6214
|
+
return this.streaming && !block.complete && (block.type === "math_block" || block.type === "json");
|
|
6182
6215
|
}
|
|
6216
|
+
/** Streaming: paragraph ends where an undecided, dissolvable block cut them short. */
|
|
6217
|
+
undecidedBreaks = /* @__PURE__ */ new Set();
|
|
6183
6218
|
/** Streaming only: the final line, still waiting for its terminator. */
|
|
6184
6219
|
isOpenTail(k) {
|
|
6185
6220
|
return this.streaming && k === this.lineStarts.length - 1 && (this.lineEnds[k] === this.contentEnds[k] || this.pendingCR);
|
|
@@ -6228,8 +6263,103 @@ var Tokenizer = class {
|
|
|
6228
6263
|
}
|
|
6229
6264
|
pos = this.paragraph(pos, li);
|
|
6230
6265
|
}
|
|
6266
|
+
if (this.streaming) this.holdUndecidedTail();
|
|
6231
6267
|
return this.blocks;
|
|
6232
6268
|
}
|
|
6269
|
+
/**
|
|
6270
|
+
* Streaming: settle nothing the next bytes can still change (verify-RC-B3 F3).
|
|
6271
|
+
*
|
|
6272
|
+
* 1. A block island that ends on the open last line is undecided — the next
|
|
6273
|
+
* bytes on that line can re-read it or dissolve it (`<!--@a:k1-->` +
|
|
6274
|
+
* ` more` is an inline anchor, `<br>` + `x` is prose). It runs open to
|
|
6275
|
+
* the end of the text.
|
|
6276
|
+
* 2. A box-drawing tree still forming at the end of the text claims, as its
|
|
6277
|
+
* root label, the lines directly above its first connector (the
|
|
6278
|
+
* renderer's `findTreeBlockStart`), and the open last line itself may
|
|
6279
|
+
* become one of its connector lines — so inlines on those lines are held
|
|
6280
|
+
* back as prose until a blank line, a heading or a tree line decides.
|
|
6281
|
+
* This also holds everything a closer still able to arrive on the open
|
|
6282
|
+
* last line could change (`$x$` + `5` is currency, G4; `{{v}}` + `}`).
|
|
6283
|
+
*/
|
|
6284
|
+
holdUndecidedTail() {
|
|
6285
|
+
const last = this.lineStarts.length - 1;
|
|
6286
|
+
if (last < 0) return;
|
|
6287
|
+
if (this.isOpenTail(last)) {
|
|
6288
|
+
const lineStart = this.lineStarts[last];
|
|
6289
|
+
for (const block2 of this.blocks) {
|
|
6290
|
+
if (block2.kind === "prose" && block2.end > lineStart) {
|
|
6291
|
+
block2.inlines = block2.inlines.filter((inline) => inline.end <= lineStart);
|
|
6292
|
+
}
|
|
6293
|
+
}
|
|
6294
|
+
let b = this.blocks.length - 1;
|
|
6295
|
+
while (b >= 0 && this.blocks[b].kind === "gap") b--;
|
|
6296
|
+
const block = this.blocks[b];
|
|
6297
|
+
if (block?.island?.complete && block.island.end > this.lineStarts[last]) {
|
|
6298
|
+
block.island.complete = false;
|
|
6299
|
+
block.island.end = this.n;
|
|
6300
|
+
block.end = this.n;
|
|
6301
|
+
this.blocks.length = b + 1;
|
|
6302
|
+
}
|
|
6303
|
+
}
|
|
6304
|
+
const from = this.treeRootHoldFrom();
|
|
6305
|
+
for (let b = this.blocks.length - 1; b >= 0; b--) {
|
|
6306
|
+
const block = this.blocks[b];
|
|
6307
|
+
if (block.end <= from) break;
|
|
6308
|
+
if (block.kind === "prose") block.inlines = block.inlines.filter((inline) => inline.end <= from);
|
|
6309
|
+
if (block.island) this.blocks[b] = { kind: "prose", start: block.start, end: block.end, island: null, inlines: [] };
|
|
6310
|
+
}
|
|
6311
|
+
}
|
|
6312
|
+
/**
|
|
6313
|
+
* Streaming: where a tree that may still form at the end of the text would
|
|
6314
|
+
* start claiming lines (`n` when none can). Only paragraph lines can be
|
|
6315
|
+
* claimed — a line that starts inside an island (a fence body, an XML
|
|
6316
|
+
* region…) is never a tree line nor a root label, so it stops the walk.
|
|
6317
|
+
*/
|
|
6318
|
+
treeRootHoldFrom() {
|
|
6319
|
+
const claimable = (k2) => {
|
|
6320
|
+
for (; ; ) {
|
|
6321
|
+
const block = this.blockAt(this.lineStarts[k2]);
|
|
6322
|
+
if (!block || block.kind !== "island" || block.island?.fromParagraph === true) return true;
|
|
6323
|
+
const opened = this.lineOf(block.start);
|
|
6324
|
+
if (this.lineStarts[opened] === block.start || opened === k2) return false;
|
|
6325
|
+
k2 = opened;
|
|
6326
|
+
}
|
|
6327
|
+
};
|
|
6328
|
+
let k = this.lineCount - 1;
|
|
6329
|
+
let start = this.lineCount;
|
|
6330
|
+
if (k >= 0 && this.isOpenTail(k)) {
|
|
6331
|
+
if (!claimable(k)) return this.n;
|
|
6332
|
+
start = k;
|
|
6333
|
+
k--;
|
|
6334
|
+
}
|
|
6335
|
+
for (; k >= 0 && claimable(k); k--) {
|
|
6336
|
+
this.tick(1);
|
|
6337
|
+
if (this.lineIsBlank(k)) continue;
|
|
6338
|
+
if (!TREE_GLYPHS.test(this.lineText(k))) break;
|
|
6339
|
+
start = k;
|
|
6340
|
+
}
|
|
6341
|
+
let root = start;
|
|
6342
|
+
for (let j = start - 1; j >= 0 && claimable(j); j--) {
|
|
6343
|
+
const trimmed = this.lineText(j).trim();
|
|
6344
|
+
this.tick(trimmed.length + 1);
|
|
6345
|
+
if (!trimmed || isSplitterTreeLine(trimmed) || /^#{1,6}\s/.test(trimmed)) break;
|
|
6346
|
+
root = j;
|
|
6347
|
+
}
|
|
6348
|
+
return root < this.lineCount ? this.lineStarts[root] : this.n;
|
|
6349
|
+
}
|
|
6350
|
+
/** The block (so far) containing offset `pos`, or null. */
|
|
6351
|
+
blockAt(pos) {
|
|
6352
|
+
let lo = 0;
|
|
6353
|
+
let hi = this.blocks.length - 1;
|
|
6354
|
+
while (lo <= hi) {
|
|
6355
|
+
const mid = lo + hi >>> 1;
|
|
6356
|
+
const block = this.blocks[mid];
|
|
6357
|
+
if (pos < block.start) hi = mid - 1;
|
|
6358
|
+
else if (pos >= block.end) lo = mid + 1;
|
|
6359
|
+
else return block;
|
|
6360
|
+
}
|
|
6361
|
+
return null;
|
|
6362
|
+
}
|
|
6233
6363
|
push(block) {
|
|
6234
6364
|
if (block.end <= block.start) return;
|
|
6235
6365
|
if (block.kind === "prose" && this.isBlank(block.start, block.end)) {
|
|
@@ -6433,7 +6563,10 @@ var Tokenizer = class {
|
|
|
6433
6563
|
continue;
|
|
6434
6564
|
}
|
|
6435
6565
|
if (this.isOpenTail(k)) return this.heldFootnote(p, open[1]);
|
|
6436
|
-
if (FOOTNOTE_DEF.test(line.trimStart())
|
|
6566
|
+
if (FOOTNOTE_DEF.test(line.trimStart())) break;
|
|
6567
|
+
const block = this.detectBlock(this.lineStarts[k], k, false);
|
|
6568
|
+
if (block && this.mayDissolve(block)) return this.heldFootnote(p, open[1]);
|
|
6569
|
+
if (block) break;
|
|
6437
6570
|
last = k;
|
|
6438
6571
|
}
|
|
6439
6572
|
const end = this.contentEnds[last];
|
|
@@ -6449,7 +6582,8 @@ var Tokenizer = class {
|
|
|
6449
6582
|
return {
|
|
6450
6583
|
count: this.lineCount,
|
|
6451
6584
|
line: (k) => this.lineText(k),
|
|
6452
|
-
openTail: (k) => this.isOpenTail(k)
|
|
6585
|
+
openTail: (k) => this.isOpenTail(k),
|
|
6586
|
+
streaming: this.streaming
|
|
6453
6587
|
};
|
|
6454
6588
|
}
|
|
6455
6589
|
/**
|
|
@@ -6509,6 +6643,10 @@ var Tokenizer = class {
|
|
|
6509
6643
|
if (fenceOpenerOf(this.lineText(j))?.char === "~") continue;
|
|
6510
6644
|
const inner = this.detectBlockUncached(start, j, false);
|
|
6511
6645
|
if (!inner) continue;
|
|
6646
|
+
if (this.streaming && inner.end >= tildeEnd && this.paragraphMayGrow(inner.end)) {
|
|
6647
|
+
this.overflowComplete = false;
|
|
6648
|
+
return this.n;
|
|
6649
|
+
}
|
|
6512
6650
|
if (inner.end > end) {
|
|
6513
6651
|
end = inner.end;
|
|
6514
6652
|
this.overflowComplete = inner.complete;
|
|
@@ -6637,12 +6775,7 @@ var Tokenizer = class {
|
|
|
6637
6775
|
return this.island("html_block", p, close.index + close[0].length, true, { tag: name });
|
|
6638
6776
|
}
|
|
6639
6777
|
const typeSix = HTML_BLOCK_LEVEL_TAGS.has(name);
|
|
6640
|
-
const
|
|
6641
|
-
if (loneTag && this.isOpenTail(li)) {
|
|
6642
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, p);
|
|
6643
|
-
return null;
|
|
6644
|
-
}
|
|
6645
|
-
const typeSeven = loneTag;
|
|
6778
|
+
const typeSeven = atParaStart && t.trimEnd() === tag.raw;
|
|
6646
6779
|
if (!typeSix && !typeSeven) return null;
|
|
6647
6780
|
let end = this.contentEnds[li];
|
|
6648
6781
|
for (let k = li + 1; k < this.lineCount && !this.lineIsBlank(k); k++) {
|
|
@@ -6700,6 +6833,13 @@ var Tokenizer = class {
|
|
|
6700
6833
|
}
|
|
6701
6834
|
return null;
|
|
6702
6835
|
}
|
|
6836
|
+
if (this.isOpenTail(lastLine)) {
|
|
6837
|
+
if (isRecognizedJsonHead(this.text.slice(tp, tp + 512))) {
|
|
6838
|
+
return this.island("json", p, this.n, false, jsonMeta(this.text.slice(tp)));
|
|
6839
|
+
}
|
|
6840
|
+
this.provisionalFrom = Math.min(this.provisionalFrom, p);
|
|
6841
|
+
return null;
|
|
6842
|
+
}
|
|
6703
6843
|
if (net !== 0) return null;
|
|
6704
6844
|
const end = this.contentEnds[lastLine];
|
|
6705
6845
|
const content = this.text.slice(tp, end).trim();
|
|
@@ -6734,8 +6874,10 @@ var Tokenizer = class {
|
|
|
6734
6874
|
let breakLine = -1;
|
|
6735
6875
|
for (let k = li + 1; k < this.lineCount; k++) {
|
|
6736
6876
|
if (this.lineIsBlank(k)) break;
|
|
6737
|
-
|
|
6877
|
+
const block = this.detectBlock(this.lineStarts[k], k, false);
|
|
6878
|
+
if (block) {
|
|
6738
6879
|
breakLine = k;
|
|
6880
|
+
if (this.mayDissolve(block)) this.undecidedBreaks.add(end);
|
|
6739
6881
|
break;
|
|
6740
6882
|
}
|
|
6741
6883
|
end = this.contentEnds[k];
|
|
@@ -6773,7 +6915,7 @@ var Tokenizer = class {
|
|
|
6773
6915
|
this.push({ kind: "prose", start: pos, end, island: null, inlines: scan2.inlines });
|
|
6774
6916
|
return end;
|
|
6775
6917
|
}
|
|
6776
|
-
const br = scan2.breakIsland;
|
|
6918
|
+
const br = { ...scan2.breakIsland, fromParagraph: true };
|
|
6777
6919
|
if (scan2.orphan) {
|
|
6778
6920
|
let start = pos;
|
|
6779
6921
|
while (this.blocks.length) {
|
|
@@ -6796,6 +6938,15 @@ var Tokenizer = class {
|
|
|
6796
6938
|
this.push({ kind: "island", start: br.start, end: br.end, island: br, inlines: [] });
|
|
6797
6939
|
return br.end;
|
|
6798
6940
|
}
|
|
6941
|
+
/**
|
|
6942
|
+
* An island that opens inside a paragraph and closes past its end becomes a
|
|
6943
|
+
* block. Streaming: while the paragraph may still grow over its closer, the
|
|
6944
|
+
* island may yet be inline — undecided, so it runs open to the end (F3).
|
|
6945
|
+
*/
|
|
6946
|
+
spill(type, start, end, pe, meta) {
|
|
6947
|
+
if (this.paragraphMayGrow(pe)) return this.island(type, start, this.n, false, meta);
|
|
6948
|
+
return this.island(type, start, end, true, meta);
|
|
6949
|
+
}
|
|
6799
6950
|
scanInline(ps, pe) {
|
|
6800
6951
|
const text = this.text;
|
|
6801
6952
|
const inlines = [];
|
|
@@ -6824,11 +6975,15 @@ var Tokenizer = class {
|
|
|
6824
6975
|
const nextCh = text[i + 1];
|
|
6825
6976
|
if (nextCh === "(" || nextCh === "[") {
|
|
6826
6977
|
const close = within(nextCh === "(" ? "\\)" : "\\]", i + 2);
|
|
6827
|
-
|
|
6978
|
+
const isMath = close !== -1 && (nextCh === "(" || isEscapedBracketMath(text.slice(i + 2, close), i > 0 ? text[i - 1] : void 0));
|
|
6979
|
+
if (close !== -1 && isMath) {
|
|
6828
6980
|
inlines.push(this.island("math_inline", i, close + 2, true, { delimiter: nextCh === "(" ? "\\(" : "\\[" }));
|
|
6829
6981
|
i = close + 2;
|
|
6830
6982
|
continue;
|
|
6831
6983
|
}
|
|
6984
|
+
if (close === -1 && this.streaming && this.paragraphMayGrow(pe)) {
|
|
6985
|
+
return { inlines, breakIsland: null, orphan: false };
|
|
6986
|
+
}
|
|
6832
6987
|
}
|
|
6833
6988
|
i += 2;
|
|
6834
6989
|
continue;
|
|
@@ -6849,17 +7004,13 @@ var Tokenizer = class {
|
|
|
6849
7004
|
i += 2;
|
|
6850
7005
|
continue;
|
|
6851
7006
|
}
|
|
6852
|
-
if (close + 2 > pe) return stop(this.
|
|
7007
|
+
if (close + 2 > pe) return stop(this.spill("math_block", i, close + 2, pe, { delimiter: "$$" }));
|
|
6853
7008
|
inlines.push(this.island("math_inline", i, close + 2, true, { delimiter: "$$" }));
|
|
6854
7009
|
i = close + 2;
|
|
6855
7010
|
continue;
|
|
6856
7011
|
}
|
|
6857
7012
|
const end = singleDollarMathEnd(text, i, pe);
|
|
6858
7013
|
this.tick(end > 0 ? end - i : Math.min(403, pe - i));
|
|
6859
|
-
if (end > 0 && this.streaming && end === this.n) {
|
|
6860
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, i);
|
|
6861
|
-
return { inlines, breakIsland: null, orphan: false };
|
|
6862
|
-
}
|
|
6863
7014
|
if (end > 0) {
|
|
6864
7015
|
inlines.push(this.island("math_inline", i, end, true, { delimiter: "$" }));
|
|
6865
7016
|
i = end;
|
|
@@ -6937,7 +7088,7 @@ var Tokenizer = class {
|
|
|
6937
7088
|
const anchor = end - i <= 64 ? PINNED_ANCHOR_RE.exec(text.slice(i, end)) : null;
|
|
6938
7089
|
const type = anchor ? "anchor" : "html_comment";
|
|
6939
7090
|
const meta = anchor ? { id: anchor[1] } : {};
|
|
6940
|
-
if (end > pe) return stop(this.
|
|
7091
|
+
if (end > pe) return stop(this.spill(type, i, end, pe, meta));
|
|
6941
7092
|
inlines.push(this.island(type, i, end, true, meta));
|
|
6942
7093
|
i = end;
|
|
6943
7094
|
continue;
|
|
@@ -6966,7 +7117,7 @@ var Tokenizer = class {
|
|
|
6966
7117
|
const blockType = isAttr ? "xml_attr" : "xml_region";
|
|
6967
7118
|
if (close === -1) return stop(this.island(blockType, i, this.n, false, { tag: name }));
|
|
6968
7119
|
const end = close + closer.length;
|
|
6969
|
-
if (end > pe) return stop(this.
|
|
7120
|
+
if (end > pe) return stop(this.spill(blockType, i, end, pe, { tag: name }));
|
|
6970
7121
|
inlines.push(this.island("xml_inline", i, end, true, { tag: name }));
|
|
6971
7122
|
i = end;
|
|
6972
7123
|
continue;
|
|
@@ -7351,6 +7502,6 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
7351
7502
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
7352
7503
|
}
|
|
7353
7504
|
|
|
7354
|
-
export { ACTION_BY_CLASS, BacktickRuns, CALLOUT_NAMES, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DirectiveDecodeError, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, 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, closeFence, codeSpanText, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, decodeDirective, describeDualGateFailure, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, executesAtOutputRoot, fenceDiscriminator, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, 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, looksLikeOpenInlineMath, makePartialKindStalenessGate, mapCodeRanges, 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 };
|
|
7505
|
+
export { ACTION_BY_CLASS, AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DirectiveDecodeError, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, 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, closeFence, codeSpanText, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, decodeDirective, describeDualGateFailure, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, executesAtOutputRoot, fenceDiscriminator, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, fieldsToDbPayload, findCodeRanges, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDirectiveClass, isDuplicateBlockSlug, isEmptyResidue, isEscapedBracketMath, isIrEnvelopeCache, isJsonAnyField, isKindDirective, isLegacyShell, isMathPlaceholder, isProvisionalKind, isReservedDirectiveSlug, isScalarArrayType, isSingleDollarMath, isTerminalKindEvent, islandEdit, itemFacts, itemSubtitle, itemTitle, joinSource, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, legacyShellUses, listIslands, looksLikeDirectiveHead, looksLikeDisplayMath, looksLikeOpenInlineMath, makePartialKindStalenessGate, mapCodeRanges, 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, singleDollarAfter, singleDollarMathEnd, spliceSave, splitsSurrogatePair, storageToKindSchema, stripKindDeep, titleCaseToken, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, tryDecodeDirective, tryDecodeDirectiveContent, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
7355
7506
|
//# sourceMappingURL=index.js.map
|
|
7356
7507
|
//# sourceMappingURL=index.js.map
|