@ai-matrx/content-ir 0.18.4 → 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 +6 -0
- package/dist/index.cjs +175 -29
- 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 +174 -30
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +175 -29
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +24 -2
- package/dist/source.d.ts +24 -2
- package/dist/source.js +174 -30
- 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, isEscapedBracketMath, 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, isEscapedBracketMath, 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,7 @@ 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;
|
|
5770
5792
|
}
|
|
5771
5793
|
var BRACKET_TEX_SIGNAL = /\\[A-Za-z]+|[\^{}=<>+]|_\{|(?:^|[^A-Za-z0-9])[A-Za-z]_[A-Za-z0-9](?![A-Za-z0-9])/;
|
|
5772
5794
|
function isEscapedBracketMath(content, before) {
|
|
@@ -6137,18 +6159,14 @@ var Tokenizer = class {
|
|
|
6137
6159
|
/**
|
|
6138
6160
|
* Streaming: an open last line that begins with `{` is undecided — each new
|
|
6139
6161
|
* byte can balance or unbalance its braces and flip the whole line between
|
|
6140
|
-
* prose and a JSON island —
|
|
6141
|
-
* 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}.)
|
|
6142
6164
|
*/
|
|
6143
6165
|
markOpenJsonTail() {
|
|
6144
6166
|
const last = this.lineStarts.length - 1;
|
|
6145
6167
|
if (!this.isOpenTail(last)) return;
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
const oneTag = t.startsWith("<") ? readXmlTag(t, 0) : null;
|
|
6149
|
-
const loneTag = !!oneTag && oneTag.raw === t && ALLOWED_RAW_HTML_TAGS.has(oneTag.tagName.toLowerCase());
|
|
6150
|
-
if (t.startsWith("{") || loneTag) {
|
|
6151
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, start);
|
|
6168
|
+
if (this.lineText(last).trim().startsWith("{")) {
|
|
6169
|
+
this.provisionalFrom = Math.min(this.provisionalFrom, this.lineStarts[last]);
|
|
6152
6170
|
}
|
|
6153
6171
|
}
|
|
6154
6172
|
/**
|
|
@@ -6181,11 +6199,22 @@ var Tokenizer = class {
|
|
|
6181
6199
|
/** Streaming only: a paragraph ending at `pe` may still be continued by a line not yet arrived. */
|
|
6182
6200
|
paragraphMayGrow(pe) {
|
|
6183
6201
|
if (!this.streaming) return false;
|
|
6202
|
+
if (this.undecidedBreaks.has(pe)) return true;
|
|
6184
6203
|
const rest = this.n - pe;
|
|
6185
6204
|
if (rest === 0) return true;
|
|
6186
6205
|
const tail = this.text.slice(pe);
|
|
6187
|
-
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");
|
|
6188
6215
|
}
|
|
6216
|
+
/** Streaming: paragraph ends where an undecided, dissolvable block cut them short. */
|
|
6217
|
+
undecidedBreaks = /* @__PURE__ */ new Set();
|
|
6189
6218
|
/** Streaming only: the final line, still waiting for its terminator. */
|
|
6190
6219
|
isOpenTail(k) {
|
|
6191
6220
|
return this.streaming && k === this.lineStarts.length - 1 && (this.lineEnds[k] === this.contentEnds[k] || this.pendingCR);
|
|
@@ -6234,8 +6263,103 @@ var Tokenizer = class {
|
|
|
6234
6263
|
}
|
|
6235
6264
|
pos = this.paragraph(pos, li);
|
|
6236
6265
|
}
|
|
6266
|
+
if (this.streaming) this.holdUndecidedTail();
|
|
6237
6267
|
return this.blocks;
|
|
6238
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
|
+
}
|
|
6239
6363
|
push(block) {
|
|
6240
6364
|
if (block.end <= block.start) return;
|
|
6241
6365
|
if (block.kind === "prose" && this.isBlank(block.start, block.end)) {
|
|
@@ -6439,7 +6563,10 @@ var Tokenizer = class {
|
|
|
6439
6563
|
continue;
|
|
6440
6564
|
}
|
|
6441
6565
|
if (this.isOpenTail(k)) return this.heldFootnote(p, open[1]);
|
|
6442
|
-
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;
|
|
6443
6570
|
last = k;
|
|
6444
6571
|
}
|
|
6445
6572
|
const end = this.contentEnds[last];
|
|
@@ -6455,7 +6582,8 @@ var Tokenizer = class {
|
|
|
6455
6582
|
return {
|
|
6456
6583
|
count: this.lineCount,
|
|
6457
6584
|
line: (k) => this.lineText(k),
|
|
6458
|
-
openTail: (k) => this.isOpenTail(k)
|
|
6585
|
+
openTail: (k) => this.isOpenTail(k),
|
|
6586
|
+
streaming: this.streaming
|
|
6459
6587
|
};
|
|
6460
6588
|
}
|
|
6461
6589
|
/**
|
|
@@ -6515,6 +6643,10 @@ var Tokenizer = class {
|
|
|
6515
6643
|
if (fenceOpenerOf(this.lineText(j))?.char === "~") continue;
|
|
6516
6644
|
const inner = this.detectBlockUncached(start, j, false);
|
|
6517
6645
|
if (!inner) continue;
|
|
6646
|
+
if (this.streaming && inner.end >= tildeEnd && this.paragraphMayGrow(inner.end)) {
|
|
6647
|
+
this.overflowComplete = false;
|
|
6648
|
+
return this.n;
|
|
6649
|
+
}
|
|
6518
6650
|
if (inner.end > end) {
|
|
6519
6651
|
end = inner.end;
|
|
6520
6652
|
this.overflowComplete = inner.complete;
|
|
@@ -6643,12 +6775,7 @@ var Tokenizer = class {
|
|
|
6643
6775
|
return this.island("html_block", p, close.index + close[0].length, true, { tag: name });
|
|
6644
6776
|
}
|
|
6645
6777
|
const typeSix = HTML_BLOCK_LEVEL_TAGS.has(name);
|
|
6646
|
-
const
|
|
6647
|
-
if (loneTag && this.isOpenTail(li)) {
|
|
6648
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, p);
|
|
6649
|
-
return null;
|
|
6650
|
-
}
|
|
6651
|
-
const typeSeven = loneTag;
|
|
6778
|
+
const typeSeven = atParaStart && t.trimEnd() === tag.raw;
|
|
6652
6779
|
if (!typeSix && !typeSeven) return null;
|
|
6653
6780
|
let end = this.contentEnds[li];
|
|
6654
6781
|
for (let k = li + 1; k < this.lineCount && !this.lineIsBlank(k); k++) {
|
|
@@ -6706,6 +6833,13 @@ var Tokenizer = class {
|
|
|
6706
6833
|
}
|
|
6707
6834
|
return null;
|
|
6708
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
|
+
}
|
|
6709
6843
|
if (net !== 0) return null;
|
|
6710
6844
|
const end = this.contentEnds[lastLine];
|
|
6711
6845
|
const content = this.text.slice(tp, end).trim();
|
|
@@ -6740,8 +6874,10 @@ var Tokenizer = class {
|
|
|
6740
6874
|
let breakLine = -1;
|
|
6741
6875
|
for (let k = li + 1; k < this.lineCount; k++) {
|
|
6742
6876
|
if (this.lineIsBlank(k)) break;
|
|
6743
|
-
|
|
6877
|
+
const block = this.detectBlock(this.lineStarts[k], k, false);
|
|
6878
|
+
if (block) {
|
|
6744
6879
|
breakLine = k;
|
|
6880
|
+
if (this.mayDissolve(block)) this.undecidedBreaks.add(end);
|
|
6745
6881
|
break;
|
|
6746
6882
|
}
|
|
6747
6883
|
end = this.contentEnds[k];
|
|
@@ -6779,7 +6915,7 @@ var Tokenizer = class {
|
|
|
6779
6915
|
this.push({ kind: "prose", start: pos, end, island: null, inlines: scan2.inlines });
|
|
6780
6916
|
return end;
|
|
6781
6917
|
}
|
|
6782
|
-
const br = scan2.breakIsland;
|
|
6918
|
+
const br = { ...scan2.breakIsland, fromParagraph: true };
|
|
6783
6919
|
if (scan2.orphan) {
|
|
6784
6920
|
let start = pos;
|
|
6785
6921
|
while (this.blocks.length) {
|
|
@@ -6802,6 +6938,15 @@ var Tokenizer = class {
|
|
|
6802
6938
|
this.push({ kind: "island", start: br.start, end: br.end, island: br, inlines: [] });
|
|
6803
6939
|
return br.end;
|
|
6804
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
|
+
}
|
|
6805
6950
|
scanInline(ps, pe) {
|
|
6806
6951
|
const text = this.text;
|
|
6807
6952
|
const inlines = [];
|
|
@@ -6836,6 +6981,9 @@ var Tokenizer = class {
|
|
|
6836
6981
|
i = close + 2;
|
|
6837
6982
|
continue;
|
|
6838
6983
|
}
|
|
6984
|
+
if (close === -1 && this.streaming && this.paragraphMayGrow(pe)) {
|
|
6985
|
+
return { inlines, breakIsland: null, orphan: false };
|
|
6986
|
+
}
|
|
6839
6987
|
}
|
|
6840
6988
|
i += 2;
|
|
6841
6989
|
continue;
|
|
@@ -6856,17 +7004,13 @@ var Tokenizer = class {
|
|
|
6856
7004
|
i += 2;
|
|
6857
7005
|
continue;
|
|
6858
7006
|
}
|
|
6859
|
-
if (close + 2 > pe) return stop(this.
|
|
7007
|
+
if (close + 2 > pe) return stop(this.spill("math_block", i, close + 2, pe, { delimiter: "$$" }));
|
|
6860
7008
|
inlines.push(this.island("math_inline", i, close + 2, true, { delimiter: "$$" }));
|
|
6861
7009
|
i = close + 2;
|
|
6862
7010
|
continue;
|
|
6863
7011
|
}
|
|
6864
7012
|
const end = singleDollarMathEnd(text, i, pe);
|
|
6865
7013
|
this.tick(end > 0 ? end - i : Math.min(403, pe - i));
|
|
6866
|
-
if (end > 0 && this.streaming && end === this.n) {
|
|
6867
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, i);
|
|
6868
|
-
return { inlines, breakIsland: null, orphan: false };
|
|
6869
|
-
}
|
|
6870
7014
|
if (end > 0) {
|
|
6871
7015
|
inlines.push(this.island("math_inline", i, end, true, { delimiter: "$" }));
|
|
6872
7016
|
i = end;
|
|
@@ -6944,7 +7088,7 @@ var Tokenizer = class {
|
|
|
6944
7088
|
const anchor = end - i <= 64 ? PINNED_ANCHOR_RE.exec(text.slice(i, end)) : null;
|
|
6945
7089
|
const type = anchor ? "anchor" : "html_comment";
|
|
6946
7090
|
const meta = anchor ? { id: anchor[1] } : {};
|
|
6947
|
-
if (end > pe) return stop(this.
|
|
7091
|
+
if (end > pe) return stop(this.spill(type, i, end, pe, meta));
|
|
6948
7092
|
inlines.push(this.island(type, i, end, true, meta));
|
|
6949
7093
|
i = end;
|
|
6950
7094
|
continue;
|
|
@@ -6973,7 +7117,7 @@ var Tokenizer = class {
|
|
|
6973
7117
|
const blockType = isAttr ? "xml_attr" : "xml_region";
|
|
6974
7118
|
if (close === -1) return stop(this.island(blockType, i, this.n, false, { tag: name }));
|
|
6975
7119
|
const end = close + closer.length;
|
|
6976
|
-
if (end > pe) return stop(this.
|
|
7120
|
+
if (end > pe) return stop(this.spill(blockType, i, end, pe, { tag: name }));
|
|
6977
7121
|
inlines.push(this.island("xml_inline", i, end, true, { tag: name }));
|
|
6978
7122
|
i = end;
|
|
6979
7123
|
continue;
|
|
@@ -7358,6 +7502,6 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
7358
7502
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
7359
7503
|
}
|
|
7360
7504
|
|
|
7361
|
-
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, 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, 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 };
|
|
7362
7506
|
//# sourceMappingURL=index.js.map
|
|
7363
7507
|
//# sourceMappingURL=index.js.map
|