@ai-matrx/content-ir 0.18.6 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -6
- package/README.md +1 -1
- package/dist/index.cjs +131 -55
- 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 +131 -56
- package/dist/index.js.map +1 -1
- package/dist/registry.cjs +88 -0
- package/dist/registry.cjs.map +1 -1
- package/dist/registry.d.cts +104 -1
- package/dist/registry.d.ts +104 -1
- package/dist/registry.js +88 -1
- package/dist/registry.js.map +1 -1
- package/dist/source.cjs +43 -55
- package/dist/source.cjs.map +1 -1
- package/dist/source.js +43 -55
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ export { I as IrTree, a as IrTreeNode, J as JsonPath, K as KindStreamEvent, b as
|
|
|
3
3
|
export { CompleteValueEnvelopeOptions, CompliantKindSnapshot, ContentRegionInit, Fingerprinter, IR_ENVELOPE_CACHE_VERSION, InboundEnvelopeHooks, InboundEnvelopeVerdict, IrEnvelopeCache, JSON_DISCRIMINATOR, JsonStreamTokenizer, JsonToken, KindResolution, NormalizeJsonRegionOptions, Punct, RegionEndReason, RegionFormat, RegionSourceKind, SchemaLayoutMode, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, createFingerprinter, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fingerprintText, formatBlockLabel, isCanonicalBlockIR, isIrEnvelopeCache, mergeResidueIntoValue, normalizeJsonRegion, readEnvelope, reconstructRegionValue, reuseEnvelopeIfCurrent, sanitizeInboundEnvelopeMetadata, schemaLayoutMode, schemaStructureDepth, stripKindDeep, xmlDiscriminator } from './core.cjs';
|
|
4
4
|
export { A as ArrayItemScalarType, F as FieldSchema, K as KIND_KEY, a as KindSchema, R as RecordValueType, S as ScalarFieldType, i as isJsonAnyField, b as isScalarArrayType, r as readObjectKind, s as scalarArrayItemType } from './kind-schema.types-CwncWj9U.cjs';
|
|
5
5
|
export { ParseSession, ParseSessionOptions, disposeParseSession, getParseSession, openParseSession } from './session.cjs';
|
|
6
|
-
export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateResult, KindBlockProps, KindDefinition, KindEdgeSpec, KindStorageError, KindStorageShape, KindTier, LegResult, ROOT_STORAGE_NAME, StoredFieldElement, describeDualGateFailure, kindSchemaToStorage, runKindDualGate, storageToKindSchema, validateStructuralLeg } from './registry.cjs';
|
|
6
|
+
export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateResult, Json, KindBlockProps, KindDefinition, KindEdgeSpec, KindStorageError, KindStorageShape, KindTier, KindValidationResult, KindValidator, KindValidatorOptions, LegResult, ROOT_STORAGE_NAME, SchemaSourcePort, SchemaUnavailableReason, StoredFieldElement, createKindValidator, describeDualGateFailure, kindSchemaToStorage, runKindDualGate, storageToKindSchema, validateStructuralLeg } from './registry.cjs';
|
|
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';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { I as IrTree, a as IrTreeNode, J as JsonPath, K as KindStreamEvent, b as
|
|
|
3
3
|
export { CompleteValueEnvelopeOptions, CompliantKindSnapshot, ContentRegionInit, Fingerprinter, IR_ENVELOPE_CACHE_VERSION, InboundEnvelopeHooks, InboundEnvelopeVerdict, IrEnvelopeCache, JSON_DISCRIMINATOR, JsonStreamTokenizer, JsonToken, KindResolution, NormalizeJsonRegionOptions, Punct, RegionEndReason, RegionFormat, RegionSourceKind, SchemaLayoutMode, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, createFingerprinter, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fingerprintText, formatBlockLabel, isCanonicalBlockIR, isIrEnvelopeCache, mergeResidueIntoValue, normalizeJsonRegion, readEnvelope, reconstructRegionValue, reuseEnvelopeIfCurrent, sanitizeInboundEnvelopeMetadata, schemaLayoutMode, schemaStructureDepth, stripKindDeep, xmlDiscriminator } from './core.js';
|
|
4
4
|
export { A as ArrayItemScalarType, F as FieldSchema, K as KIND_KEY, a as KindSchema, R as RecordValueType, S as ScalarFieldType, i as isJsonAnyField, b as isScalarArrayType, r as readObjectKind, s as scalarArrayItemType } from './kind-schema.types-CwncWj9U.js';
|
|
5
5
|
export { ParseSession, ParseSessionOptions, disposeParseSession, getParseSession, openParseSession } from './session.js';
|
|
6
|
-
export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateResult, KindBlockProps, KindDefinition, KindEdgeSpec, KindStorageError, KindStorageShape, KindTier, LegResult, ROOT_STORAGE_NAME, StoredFieldElement, describeDualGateFailure, kindSchemaToStorage, runKindDualGate, storageToKindSchema, validateStructuralLeg } from './registry.js';
|
|
6
|
+
export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateResult, Json, KindBlockProps, KindDefinition, KindEdgeSpec, KindStorageError, KindStorageShape, KindTier, KindValidationResult, KindValidator, KindValidatorOptions, LegResult, ROOT_STORAGE_NAME, SchemaSourcePort, SchemaUnavailableReason, StoredFieldElement, createKindValidator, describeDualGateFailure, kindSchemaToStorage, runKindDualGate, storageToKindSchema, validateStructuralLeg } from './registry.js';
|
|
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';
|
package/dist/index.js
CHANGED
|
@@ -2962,6 +2962,93 @@ function describeDualGateFailure(kind, result) {
|
|
|
2962
2962
|
return `kind "${kind}" failed the dual gate \u2014 ${parts.join(" | ")}`;
|
|
2963
2963
|
}
|
|
2964
2964
|
|
|
2965
|
+
// registry/kind-validator.ts
|
|
2966
|
+
var SCHEMA_COMPILE_FAILURE_PREFIX = "emitted_json_schema failed to compile:";
|
|
2967
|
+
var DEFAULT_CACHE_TTL_MS = 3e4;
|
|
2968
|
+
function unavailableMessage(kind, reason, detail) {
|
|
2969
|
+
switch (reason) {
|
|
2970
|
+
case "kind_not_registered":
|
|
2971
|
+
return `kind "${kind}" is not registered in content_ir.kind_definition`;
|
|
2972
|
+
case "schema_unavailable":
|
|
2973
|
+
return `kind "${kind}" has no emitted_json_schema \u2014 nothing to validate against`;
|
|
2974
|
+
case "schema_invalid":
|
|
2975
|
+
return `kind "${kind}" has an uncompilable emitted_json_schema${detail ? `: ${detail}` : ""}`;
|
|
2976
|
+
case "catalog_unreachable":
|
|
2977
|
+
return `could not read the contract for kind "${kind}"${detail ? `: ${detail}` : ""}`;
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
function degraded(kind, reason, detail) {
|
|
2981
|
+
return {
|
|
2982
|
+
kind,
|
|
2983
|
+
checked: false,
|
|
2984
|
+
ok: false,
|
|
2985
|
+
errors: [unavailableMessage(kind, reason, detail)],
|
|
2986
|
+
degradedReason: reason
|
|
2987
|
+
};
|
|
2988
|
+
}
|
|
2989
|
+
function createKindValidator(source, options = {}) {
|
|
2990
|
+
const ttl = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
2991
|
+
const now = options.now ?? Date.now;
|
|
2992
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2993
|
+
async function fetchSchema(kind, signal) {
|
|
2994
|
+
const cached = cache.get(kind);
|
|
2995
|
+
if (cached && now() - cached.fetchedAt <= ttl) {
|
|
2996
|
+
return { schema: cached.schema, version: cached.version };
|
|
2997
|
+
}
|
|
2998
|
+
let answer;
|
|
2999
|
+
try {
|
|
3000
|
+
answer = await source.kindSchema(kind, signal);
|
|
3001
|
+
} catch (err) {
|
|
3002
|
+
return {
|
|
3003
|
+
unavailable: "catalog_unreachable",
|
|
3004
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
3005
|
+
};
|
|
3006
|
+
}
|
|
3007
|
+
if ("unavailable" in answer) return { unavailable: answer.unavailable };
|
|
3008
|
+
if (answer.schema == null) {
|
|
3009
|
+
return { unavailable: "schema_unavailable" };
|
|
3010
|
+
}
|
|
3011
|
+
cache.set(kind, {
|
|
3012
|
+
schema: answer.schema,
|
|
3013
|
+
version: answer.version,
|
|
3014
|
+
fetchedAt: now()
|
|
3015
|
+
});
|
|
3016
|
+
return answer;
|
|
3017
|
+
}
|
|
3018
|
+
return {
|
|
3019
|
+
async validate(value, kind, signal = new AbortController().signal) {
|
|
3020
|
+
if (!kind || typeof kind !== "string") {
|
|
3021
|
+
throw new TypeError(
|
|
3022
|
+
`validateAgainstKind: "kind" must be a non-empty slug (received ${typeof kind})`
|
|
3023
|
+
);
|
|
3024
|
+
}
|
|
3025
|
+
const fetched = await fetchSchema(kind, signal);
|
|
3026
|
+
if ("unavailable" in fetched) {
|
|
3027
|
+
return degraded(kind, fetched.unavailable, fetched.detail);
|
|
3028
|
+
}
|
|
3029
|
+
const leg = validateStructuralLeg(value, fetched.schema);
|
|
3030
|
+
if (!leg.ok && leg.detail?.startsWith(SCHEMA_COMPILE_FAILURE_PREFIX)) {
|
|
3031
|
+
return degraded(kind, "schema_invalid", leg.detail);
|
|
3032
|
+
}
|
|
3033
|
+
return {
|
|
3034
|
+
kind,
|
|
3035
|
+
checked: true,
|
|
3036
|
+
ok: leg.ok,
|
|
3037
|
+
errors: leg.ok ? [] : [leg.detail ?? "validation failed"],
|
|
3038
|
+
degradedReason: null
|
|
3039
|
+
};
|
|
3040
|
+
},
|
|
3041
|
+
async cachedSchema(kind, signal = new AbortController().signal) {
|
|
3042
|
+
const fetched = await fetchSchema(kind, signal);
|
|
3043
|
+
return "unavailable" in fetched ? null : fetched.schema;
|
|
3044
|
+
},
|
|
3045
|
+
invalidate(kind) {
|
|
3046
|
+
if (kind) cache.delete(kind);
|
|
3047
|
+
else cache.clear();
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
3051
|
+
|
|
2965
3052
|
// convert/openai-schema-converter.ts
|
|
2966
3053
|
function requiredNullableFlags(required, nullable) {
|
|
2967
3054
|
return {
|
|
@@ -5237,12 +5324,6 @@ function fenceOpenerOf(content) {
|
|
|
5237
5324
|
return null;
|
|
5238
5325
|
}
|
|
5239
5326
|
var FenceReader = class {
|
|
5240
|
-
constructor(opener, options = {}) {
|
|
5241
|
-
this.opener = opener;
|
|
5242
|
-
this.isJson = opener.char === "`" && opener.lang === "json";
|
|
5243
|
-
this.nesting = opener.char === "`" && (options.nesting ?? fenceNestsInnerFences(opener.lang));
|
|
5244
|
-
this.tildeCloser = opener.char === "~" ? new RegExp(`^ {0,3}~{${opener.ticks},}[ \\t]*$`) : null;
|
|
5245
|
-
}
|
|
5246
5327
|
opener;
|
|
5247
5328
|
state = { inString: false, escaped: false };
|
|
5248
5329
|
depth = 0;
|
|
@@ -5251,6 +5332,12 @@ var FenceReader = class {
|
|
|
5251
5332
|
isJson;
|
|
5252
5333
|
nesting;
|
|
5253
5334
|
tildeCloser;
|
|
5335
|
+
constructor(opener, options = {}) {
|
|
5336
|
+
this.opener = opener;
|
|
5337
|
+
this.isJson = opener.char === "`" && opener.lang === "json";
|
|
5338
|
+
this.nesting = opener.char === "`" && (options.nesting ?? fenceNestsInnerFences(opener.lang));
|
|
5339
|
+
this.tildeCloser = opener.char === "~" ? new RegExp(`^ {0,3}~{${opener.ticks},}[ \\t]*$`) : null;
|
|
5340
|
+
}
|
|
5254
5341
|
/** How many nested fences are open right now. */
|
|
5255
5342
|
get nestedDepth() {
|
|
5256
5343
|
return this.depth;
|
|
@@ -5555,7 +5642,7 @@ function pendingCodeSpanStart(text) {
|
|
|
5555
5642
|
const n = text.length;
|
|
5556
5643
|
if (n === 0 || /\n[ \t]*\n[ \t]*$/.test(text)) return -1;
|
|
5557
5644
|
const lastLine = text.slice(text.lastIndexOf("\n") + 1);
|
|
5558
|
-
if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
|
|
5645
|
+
if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t\r]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
|
|
5559
5646
|
const s = scan(text);
|
|
5560
5647
|
const para = s.pendingPara;
|
|
5561
5648
|
if (s.endsInFence || para === -1) return -1;
|
|
@@ -5719,7 +5806,7 @@ function isVariableChain(content, after) {
|
|
|
5719
5806
|
const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
|
|
5720
5807
|
if (!run) return false;
|
|
5721
5808
|
if (after.length === 1) return false;
|
|
5722
|
-
if (/^[A-Za-z_][A-Za-z0-9_]*[.@-]$/.test(content)) return true;
|
|
5809
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*(?:[.@-]|->|::)$/.test(content)) return true;
|
|
5723
5810
|
return IDENTIFIER.test(content) && !MATH_SUFFIX.test(run);
|
|
5724
5811
|
}
|
|
5725
5812
|
var FUNCTION_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -5868,9 +5955,6 @@ function isEscapedBacktick(line, offset) {
|
|
|
5868
5955
|
return slashes % 2 === 1;
|
|
5869
5956
|
}
|
|
5870
5957
|
var XmlContainerTracker = class {
|
|
5871
|
-
constructor(rootTag) {
|
|
5872
|
-
this.rootTag = rootTag;
|
|
5873
|
-
}
|
|
5874
5958
|
rootTag;
|
|
5875
5959
|
depth = 0;
|
|
5876
5960
|
inComment = false;
|
|
@@ -5878,6 +5962,9 @@ var XmlContainerTracker = class {
|
|
|
5878
5962
|
inlineTicks = 0;
|
|
5879
5963
|
/** The open fence, read by THE one closer (source/code-ranges.ts). */
|
|
5880
5964
|
fence = null;
|
|
5965
|
+
constructor(rootTag) {
|
|
5966
|
+
this.rootTag = rootTag;
|
|
5967
|
+
}
|
|
5881
5968
|
consumeLine(line, startOffset = 0) {
|
|
5882
5969
|
if (this.fence) {
|
|
5883
5970
|
if (this.fence.feed(line)) this.fence = null;
|
|
@@ -6089,6 +6176,23 @@ function isSplitterTreeLine(line) {
|
|
|
6089
6176
|
}
|
|
6090
6177
|
var MEDIA_REF_PREFIXES = ["[Image URL:", "[Video URL:", "[Audio URL:"];
|
|
6091
6178
|
var Tokenizer = class {
|
|
6179
|
+
text;
|
|
6180
|
+
streaming;
|
|
6181
|
+
meter;
|
|
6182
|
+
n;
|
|
6183
|
+
lineStarts = [];
|
|
6184
|
+
contentEnds = [];
|
|
6185
|
+
lineEnds = [];
|
|
6186
|
+
blocks = [];
|
|
6187
|
+
blockCache = /* @__PURE__ */ new Map();
|
|
6188
|
+
/** Lazily built: for line i, first line j >= i where brace net from i drops to <= 0. */
|
|
6189
|
+
braceStop = null;
|
|
6190
|
+
braceNet = null;
|
|
6191
|
+
/** Every occurrence offset of each needle searched so far (overlapping, like indexOf). */
|
|
6192
|
+
occurrences = /* @__PURE__ */ new Map();
|
|
6193
|
+
/** `$$` opener → closer for the pairs the core renders as math. */
|
|
6194
|
+
mathPairs;
|
|
6195
|
+
finder = (needle, from) => this.next(needle, from);
|
|
6092
6196
|
constructor(text, streaming = false, meter = void 0) {
|
|
6093
6197
|
this.text = text;
|
|
6094
6198
|
this.streaming = streaming;
|
|
@@ -6107,7 +6211,7 @@ var Tokenizer = class {
|
|
|
6107
6211
|
if (close >= span) this.provisionalFrom = Math.min(this.provisionalFrom, open);
|
|
6108
6212
|
}
|
|
6109
6213
|
}
|
|
6110
|
-
for (const pad of ["`", "``", "```", "~~~"]) {
|
|
6214
|
+
for (const pad of ["`", "``", "```", "~~~", "$"]) {
|
|
6111
6215
|
const alt = pairDisplayMath(text + pad);
|
|
6112
6216
|
for (const [open, close] of this.mathPairs) {
|
|
6113
6217
|
if (alt.get(open) !== close) this.provisionalFrom = Math.min(this.provisionalFrom, open);
|
|
@@ -6135,40 +6239,10 @@ var Tokenizer = class {
|
|
|
6135
6239
|
this.lineEnds.push(text.length);
|
|
6136
6240
|
}
|
|
6137
6241
|
}
|
|
6138
|
-
text;
|
|
6139
|
-
streaming;
|
|
6140
|
-
meter;
|
|
6141
|
-
n;
|
|
6142
|
-
lineStarts = [];
|
|
6143
|
-
contentEnds = [];
|
|
6144
|
-
lineEnds = [];
|
|
6145
|
-
blocks = [];
|
|
6146
|
-
blockCache = /* @__PURE__ */ new Map();
|
|
6147
|
-
/** Lazily built: for line i, first line j >= i where brace net from i drops to <= 0. */
|
|
6148
|
-
braceStop = null;
|
|
6149
|
-
braceNet = null;
|
|
6150
|
-
/** Every occurrence offset of each needle searched so far (overlapping, like indexOf). */
|
|
6151
|
-
occurrences = /* @__PURE__ */ new Map();
|
|
6152
|
-
/** `$$` opener → closer for the pairs the core renders as math. */
|
|
6153
|
-
mathPairs;
|
|
6154
|
-
finder = (needle, from) => this.next(needle, from);
|
|
6155
6242
|
/** Streaming: where provisional text starts (a pending `$$`), or +∞. */
|
|
6156
6243
|
provisionalFrom = Number.POSITIVE_INFINITY;
|
|
6157
6244
|
/** Streaming: the text ends in a lone CR whose LF has not arrived yet. */
|
|
6158
6245
|
pendingCR = false;
|
|
6159
|
-
/**
|
|
6160
|
-
* Streaming: an open last line that begins with `{` is undecided — each new
|
|
6161
|
-
* byte can balance or unbalance its braces and flip the whole line between
|
|
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}.)
|
|
6164
|
-
*/
|
|
6165
|
-
markOpenJsonTail() {
|
|
6166
|
-
const last = this.lineStarts.length - 1;
|
|
6167
|
-
if (!this.isOpenTail(last)) return;
|
|
6168
|
-
if (this.lineText(last).trim().startsWith("{")) {
|
|
6169
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, this.lineStarts[last]);
|
|
6170
|
-
}
|
|
6171
|
-
}
|
|
6172
6246
|
/**
|
|
6173
6247
|
* `text.indexOf(needle, from)` in O(log k): the first query for a needle
|
|
6174
6248
|
* indexes all of its occurrences once, so repeated searches for a closer
|
|
@@ -6203,7 +6277,7 @@ var Tokenizer = class {
|
|
|
6203
6277
|
const rest = this.n - pe;
|
|
6204
6278
|
if (rest === 0) return true;
|
|
6205
6279
|
const tail = this.text.slice(pe);
|
|
6206
|
-
return /^(?:\r\n|\r|\n)[ \t]*$/.test(tail);
|
|
6280
|
+
return /^(?:\r\n|\r|\n)[ \t\r]*$/.test(tail);
|
|
6207
6281
|
}
|
|
6208
6282
|
/**
|
|
6209
6283
|
* Streaming: an open block that may still turn back into prose — a `$$`
|
|
@@ -6212,7 +6286,9 @@ var Tokenizer = class {
|
|
|
6212
6286
|
* or any opener that is itself still arriving on the open last line.
|
|
6213
6287
|
*/
|
|
6214
6288
|
mayDissolve(block) {
|
|
6215
|
-
if (!this.streaming
|
|
6289
|
+
if (!this.streaming) return false;
|
|
6290
|
+
if (block.start >= this.provisionalFrom) return true;
|
|
6291
|
+
if (block.complete) return false;
|
|
6216
6292
|
if (block.type === "math_block" || block.type === "json") return true;
|
|
6217
6293
|
return this.isOpenTail(this.lineOf(block.start));
|
|
6218
6294
|
}
|
|
@@ -6251,7 +6327,6 @@ var Tokenizer = class {
|
|
|
6251
6327
|
return this.text.slice(this.lineStarts[li], this.contentEnds[li]);
|
|
6252
6328
|
}
|
|
6253
6329
|
run() {
|
|
6254
|
-
if (this.streaming) this.markOpenJsonTail();
|
|
6255
6330
|
let pos = 0;
|
|
6256
6331
|
while (pos < this.n) {
|
|
6257
6332
|
const li = this.lineOf(pos);
|
|
@@ -6298,12 +6373,6 @@ var Tokenizer = class {
|
|
|
6298
6373
|
const last = this.lineStarts.length - 1;
|
|
6299
6374
|
if (last < 0) return;
|
|
6300
6375
|
if (this.isOpenTail(last)) {
|
|
6301
|
-
const lineStart = this.lineStarts[last];
|
|
6302
|
-
for (const block2 of this.blocks) {
|
|
6303
|
-
if (block2.kind === "prose" && block2.end > lineStart) {
|
|
6304
|
-
block2.inlines = block2.inlines.filter((inline) => inline.end <= lineStart);
|
|
6305
|
-
}
|
|
6306
|
-
}
|
|
6307
6376
|
let b = this.blocks.length - 1;
|
|
6308
6377
|
while (b >= 0 && this.blocks[b].kind === "gap") b--;
|
|
6309
6378
|
const block = this.blocks[b];
|
|
@@ -6495,7 +6564,7 @@ var Tokenizer = class {
|
|
|
6495
6564
|
return { type, start, end, complete, meta };
|
|
6496
6565
|
}
|
|
6497
6566
|
frontMatter(li, t) {
|
|
6498
|
-
const fence = this.lineText(li);
|
|
6567
|
+
const fence = this.lineText(li).replace(/^\uFEFF/, "");
|
|
6499
6568
|
if (fence !== "---" && fence !== "+++" || t !== fence) return null;
|
|
6500
6569
|
const toml = fence === "+++";
|
|
6501
6570
|
let sawContent = false;
|
|
@@ -6506,9 +6575,13 @@ var Tokenizer = class {
|
|
|
6506
6575
|
}
|
|
6507
6576
|
if (!NOT_WHITESPACE.test(line)) continue;
|
|
6508
6577
|
const shaped = toml ? /^\s*(?:[A-Za-z0-9_."-]+\s*=|\[|#)/.test(line) : /^(?:[A-Za-z0-9_"'-][^:]*:(?:\s|$)|\s+\S|-\s|#)/.test(line);
|
|
6509
|
-
if (!shaped)
|
|
6578
|
+
if (!shaped) {
|
|
6579
|
+
if (this.isOpenTail(k)) break;
|
|
6580
|
+
return null;
|
|
6581
|
+
}
|
|
6510
6582
|
sawContent = true;
|
|
6511
6583
|
}
|
|
6584
|
+
if (this.streaming) return this.island("front_matter", 0, this.n, false, { format: toml ? "toml" : "yaml" });
|
|
6512
6585
|
return null;
|
|
6513
6586
|
}
|
|
6514
6587
|
/**
|
|
@@ -6909,7 +6982,9 @@ var Tokenizer = class {
|
|
|
6909
6982
|
const block = this.detectBlock(this.lineStarts[k], k, false);
|
|
6910
6983
|
if (block) {
|
|
6911
6984
|
breakLine = k;
|
|
6912
|
-
if (this.mayDissolve(block))
|
|
6985
|
+
if (this.mayDissolve(block)) {
|
|
6986
|
+
this.undecidedBreaks.add(end);
|
|
6987
|
+
}
|
|
6913
6988
|
break;
|
|
6914
6989
|
}
|
|
6915
6990
|
end = this.contentEnds[k];
|
|
@@ -7254,12 +7329,12 @@ function blockAt(blocks, offset) {
|
|
|
7254
7329
|
|
|
7255
7330
|
// source/splice.ts
|
|
7256
7331
|
var SourceSpliceError = class extends Error {
|
|
7332
|
+
code;
|
|
7257
7333
|
constructor(code, message) {
|
|
7258
7334
|
super(message);
|
|
7259
7335
|
this.code = code;
|
|
7260
7336
|
this.name = "SourceSpliceError";
|
|
7261
7337
|
}
|
|
7262
|
-
code;
|
|
7263
7338
|
};
|
|
7264
7339
|
function blockEdit(block, text) {
|
|
7265
7340
|
return { start: block.start, end: block.end, text };
|
|
@@ -7538,6 +7613,6 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
7538
7613
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
7539
7614
|
}
|
|
7540
7615
|
|
|
7541
|
-
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 };
|
|
7616
|
+
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, createKindValidator, 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 };
|
|
7542
7617
|
//# sourceMappingURL=index.js.map
|
|
7543
7618
|
//# sourceMappingURL=index.js.map
|