acp-kernel 0.0.98-pr.473.333 → 0.0.98-pr.477.335
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -7497,12 +7497,30 @@ function parseStringCore(cleaned, callId, diag) {
|
|
|
7497
7497
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
7498
7498
|
return parseObjectValue(value, callId, diag);
|
|
7499
7499
|
}
|
|
7500
|
+
if (typeof value === "string") {
|
|
7501
|
+
const recovered2 = salvageLineFormEntries(value, callId);
|
|
7502
|
+
if (recovered2.ranges.length > 0)
|
|
7503
|
+
return finishLineFormSalvage(recovered2, diag, false);
|
|
7504
|
+
}
|
|
7500
7505
|
if (value !== void 0) {
|
|
7501
7506
|
diag.kind = "not-object";
|
|
7502
7507
|
return finish([], diag);
|
|
7503
7508
|
}
|
|
7504
|
-
|
|
7505
|
-
|
|
7509
|
+
let entries = salvageContentEntries(cleaned);
|
|
7510
|
+
let fromStringSlot = false;
|
|
7511
|
+
if (entries.length === 0) {
|
|
7512
|
+
entries = salvageStringSlotEntries(cleaned);
|
|
7513
|
+
fromStringSlot = entries.length > 0;
|
|
7514
|
+
}
|
|
7515
|
+
if (entries.length > 0) {
|
|
7516
|
+
const out = finishSalvage(entries, callId, diag, true);
|
|
7517
|
+
if (fromStringSlot && out.ranges.length > 0) diag.contentSalvage = true;
|
|
7518
|
+
return out;
|
|
7519
|
+
}
|
|
7520
|
+
const recovered = salvageLineFormEntries(cleaned, callId);
|
|
7521
|
+
if (recovered.ranges.length > 0)
|
|
7522
|
+
return finishLineFormSalvage(recovered, diag, looksTruncated(cleaned));
|
|
7523
|
+
return finishSalvage([], callId, diag, looksTruncated(cleaned));
|
|
7506
7524
|
}
|
|
7507
7525
|
function parseObjectValue(value, callId, diag) {
|
|
7508
7526
|
diag.keys = Object.keys(value);
|
|
@@ -7524,11 +7542,11 @@ function parseObjectValue(value, callId, diag) {
|
|
|
7524
7542
|
const parsed = parseContentArray(content);
|
|
7525
7543
|
if (parsed === null || parsed.entries.length === 0 && content.trim().length > 0) {
|
|
7526
7544
|
const bare = stripJsonWrapperResidue(content);
|
|
7527
|
-
const entries2 = splitLineEntries(bare);
|
|
7545
|
+
const entries2 = inlineSingleLineEntry(splitLineEntries(bare));
|
|
7528
7546
|
const { ranges: ranges2, invalid: invalid2, reasons: reasons2 } = validateEntries(entries2, callId);
|
|
7547
|
+
diag.invalidItems = invalid2;
|
|
7548
|
+
if (reasons2.length > 0) diag.invalidReasons = reasons2;
|
|
7529
7549
|
if (ranges2.length > 0) {
|
|
7530
|
-
diag.invalidItems = invalid2;
|
|
7531
|
-
if (reasons2.length > 0) diag.invalidReasons = reasons2;
|
|
7532
7550
|
diag.kind = "ok";
|
|
7533
7551
|
return finish(ranges2, diag);
|
|
7534
7552
|
}
|
|
@@ -7951,6 +7969,56 @@ function looksTruncated(s) {
|
|
|
7951
7969
|
}
|
|
7952
7970
|
return depth > 0 || inString;
|
|
7953
7971
|
}
|
|
7972
|
+
function inlineSingleLineEntry(entries) {
|
|
7973
|
+
if (entries.length !== 1) return entries;
|
|
7974
|
+
const e = entries[0];
|
|
7975
|
+
if (typeof e !== "string" || e.includes("\n")) return entries;
|
|
7976
|
+
const head = e.trim();
|
|
7977
|
+
const m = REF_PAIR_IN_LINE.exec(head) ?? SINGLE_REF_IN_LINE.exec(head);
|
|
7978
|
+
if (m === null) return entries;
|
|
7979
|
+
const rest = head.slice(m.index + m[0].length).trim();
|
|
7980
|
+
if (!/\p{L}|\p{N}/u.test(rest)) return entries;
|
|
7981
|
+
return [m[0] + "\n" + rest];
|
|
7982
|
+
}
|
|
7983
|
+
function salvageLineFormEntries(text, callId) {
|
|
7984
|
+
return validateEntries(
|
|
7985
|
+
inlineSingleLineEntry(splitLineEntries(stripJsonWrapperResidue(text))),
|
|
7986
|
+
callId
|
|
7987
|
+
);
|
|
7988
|
+
}
|
|
7989
|
+
function finishLineFormSalvage(result, diag, truncatedShape) {
|
|
7990
|
+
diag.stringSalvage = true;
|
|
7991
|
+
diag.invalidItems = result.invalid;
|
|
7992
|
+
if (result.reasons.length > 0) diag.invalidReasons = result.reasons;
|
|
7993
|
+
diag.kind = truncatedShape ? "truncated" : "ok";
|
|
7994
|
+
return finish(result.ranges, diag);
|
|
7995
|
+
}
|
|
7996
|
+
function salvageStringSlotEntries(raw) {
|
|
7997
|
+
const match = /"content"\s*:\s*"/.exec(raw);
|
|
7998
|
+
if (match === null) return [];
|
|
7999
|
+
const start = match.index + match[0].length;
|
|
8000
|
+
let i = start;
|
|
8001
|
+
let terminated = false;
|
|
8002
|
+
while (i < raw.length) {
|
|
8003
|
+
const ch = raw.charAt(i);
|
|
8004
|
+
if (ch === "\\") {
|
|
8005
|
+
i += 2;
|
|
8006
|
+
continue;
|
|
8007
|
+
}
|
|
8008
|
+
if (ch === '"') {
|
|
8009
|
+
terminated = true;
|
|
8010
|
+
break;
|
|
8011
|
+
}
|
|
8012
|
+
i++;
|
|
8013
|
+
}
|
|
8014
|
+
const body = raw.slice(start, i).replace(/\\n/g, "\n");
|
|
8015
|
+
const parts = splitLineEntries(body);
|
|
8016
|
+
if (!terminated) {
|
|
8017
|
+
if (parts.length <= 1) return [];
|
|
8018
|
+
parts.pop();
|
|
8019
|
+
}
|
|
8020
|
+
return parts;
|
|
8021
|
+
}
|
|
7954
8022
|
function salvageContentEntries(raw) {
|
|
7955
8023
|
const match = /"content"\s*:\s*\[/.exec(raw);
|
|
7956
8024
|
if (match === null) return [];
|