@ai-react-markdown/engine 2.5.0 → 2.5.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/dist/index.cjs +48 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +48 -7
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +48 -7
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +48 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -660,6 +660,7 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
660
660
|
cp.openTotal += 1;
|
|
661
661
|
}
|
|
662
662
|
};
|
|
663
|
+
const strayTablePart = (tag) => TABLE_PART_NAMES.has(tag) && (cp.tagBalance.get("table") ?? 0) === 0;
|
|
663
664
|
const commentOpenAtLineStart = cp.commentOpen;
|
|
664
665
|
const rawOpenAtLineStart = cp.commentOpen || cp.piOpen || cp.declOpen || cp.cdataOpen || cp.bogusOpen;
|
|
665
666
|
if (cp.inFence) {
|
|
@@ -988,7 +989,7 @@ ${cont(scanText)}` };
|
|
|
988
989
|
if (cp.commentOpen) continue;
|
|
989
990
|
const closing = m[1] === "/";
|
|
990
991
|
const tag = m[2].toLowerCase();
|
|
991
|
-
if (
|
|
992
|
+
if (strayTablePart(tag)) cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + m.index);
|
|
992
993
|
let attrs = m[3] ?? "";
|
|
993
994
|
if (cp.htmlFlowReal && (cp.rawTextOpen === null || closing && tag === cp.rawTextOpen)) {
|
|
994
995
|
const attrStart = m.index + 1 + (closing ? 1 : 0) + m[2].length;
|
|
@@ -1032,7 +1033,7 @@ ${cont(scanText)}` };
|
|
|
1032
1033
|
if (startMasked || wholeVisible || inRaw(mr.index) || cp.commentOpen) continue;
|
|
1033
1034
|
const closing = mr[1] === "/";
|
|
1034
1035
|
const tag = mr[2].toLowerCase();
|
|
1035
|
-
if (
|
|
1036
|
+
if (strayTablePart(tag)) cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + mr.index);
|
|
1036
1037
|
if (closing && mr[3] !== void 0 && !/^\s*$/.test(mr[3])) continue;
|
|
1037
1038
|
const selfClosing = mr[3] !== void 0 && /\/\s*$/.test(mr[3]);
|
|
1038
1039
|
if (VOID_TAGS.has(tag) || selfClosing && honoursSelfClosing(tag)) continue;
|
|
@@ -1040,7 +1041,7 @@ ${cont(scanText)}` };
|
|
|
1040
1041
|
}
|
|
1041
1042
|
}
|
|
1042
1043
|
if (cp.pendingTruncatedTags.length > 0 && ln.text.includes(">")) {
|
|
1043
|
-
if (cp.pendingTruncatedTags.some((t) =>
|
|
1044
|
+
if (cp.pendingTruncatedTags.some((t) => strayTablePart(t))) {
|
|
1044
1045
|
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
1045
1046
|
}
|
|
1046
1047
|
cp.pendingTruncatedTags = [];
|
|
@@ -1057,7 +1058,7 @@ ${cont(scanText)}` };
|
|
|
1057
1058
|
if (m2) {
|
|
1058
1059
|
const closing = m2[1] === "/";
|
|
1059
1060
|
const tag = m2[2].toLowerCase();
|
|
1060
|
-
if (
|
|
1061
|
+
if (strayTablePart(tag) && cp.htmlFlowReal) {
|
|
1061
1062
|
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + lastLt);
|
|
1062
1063
|
}
|
|
1063
1064
|
if (cp.htmlFlowReal) {
|
|
@@ -1282,6 +1283,24 @@ function rebaseDualWalk(node, segments, maxEnd, offsetDelta, lineDelta) {
|
|
|
1282
1283
|
}
|
|
1283
1284
|
}
|
|
1284
1285
|
var TABLE_PART_TAG_RE = /<(?:td|th|tr|tbody|thead|tfoot|caption|col|colgroup)\b/i;
|
|
1286
|
+
var TABLE_TOKEN_RE = /<(\/?)(table|td|th|tr|tbody|thead|tfoot|caption|col|colgroup)\b/gi;
|
|
1287
|
+
function hasStrayTablePart(values) {
|
|
1288
|
+
let depth = 0;
|
|
1289
|
+
for (const value of values) {
|
|
1290
|
+
TABLE_TOKEN_RE.lastIndex = 0;
|
|
1291
|
+
let m;
|
|
1292
|
+
while ((m = TABLE_TOKEN_RE.exec(value)) !== null) {
|
|
1293
|
+
const closing = m[1] === "/";
|
|
1294
|
+
const tag = m[2].toLowerCase();
|
|
1295
|
+
if (tag === "table") {
|
|
1296
|
+
depth = closing ? Math.max(0, depth - 1) : depth + 1;
|
|
1297
|
+
continue;
|
|
1298
|
+
}
|
|
1299
|
+
if (depth === 0) return true;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
return false;
|
|
1303
|
+
}
|
|
1285
1304
|
var STRAY_SYNTHESIZED_END_TAG_RE = /<\/(?:br|p)\b/i;
|
|
1286
1305
|
function spliceTrees(input) {
|
|
1287
1306
|
const { prevMdast, prevHast, tailMdast, tailHast, content, boundary, injectionPrefix, injectedSegments } = input;
|
|
@@ -1339,7 +1358,7 @@ function spliceTrees(input) {
|
|
|
1339
1358
|
return !(start !== void 0 && start < injectedLen);
|
|
1340
1359
|
});
|
|
1341
1360
|
const tailWrapVisible = tailMdastChildren.some((child) => !isWrapInvisible(child));
|
|
1342
|
-
if (prefixMdast.
|
|
1361
|
+
if (hasStrayTablePart(prefixMdast.flatMap((c) => c.type === "html" ? [c.value] : []))) return null;
|
|
1343
1362
|
for (const child of tailMdastChildren) {
|
|
1344
1363
|
if (isWrapInvisible(child)) continue;
|
|
1345
1364
|
if (child.type !== "html") break;
|
|
@@ -3997,6 +4016,14 @@ var graphemeEnds = (text, base) => {
|
|
|
3997
4016
|
}
|
|
3998
4017
|
return ends;
|
|
3999
4018
|
};
|
|
4019
|
+
var RESUME_LOOKBACK = 64;
|
|
4020
|
+
var isMidSurrogatePair = (text, at) => at > 0 && at < text.length && (text.charCodeAt(at - 1) & 64512) === 55296 && (text.charCodeAt(at) & 64512) === 56320;
|
|
4021
|
+
var RI_FIRST = 127462;
|
|
4022
|
+
var RI_LAST = 127487;
|
|
4023
|
+
var isRegionalIndicatorAt = (text, at) => {
|
|
4024
|
+
const cp = text.codePointAt(at);
|
|
4025
|
+
return cp !== void 0 && cp >= RI_FIRST && cp <= RI_LAST;
|
|
4026
|
+
};
|
|
4000
4027
|
var createSmoothStreamController = (options = {}) => {
|
|
4001
4028
|
const now = options.now ?? defaultNow;
|
|
4002
4029
|
const schedule = options.schedule ?? defaultSchedule;
|
|
@@ -4005,6 +4032,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4005
4032
|
let pending = [];
|
|
4006
4033
|
let tentativeEnd = 0;
|
|
4007
4034
|
let finished = false;
|
|
4035
|
+
let seam;
|
|
4008
4036
|
let drainDeadlineAt;
|
|
4009
4037
|
let initialized = false;
|
|
4010
4038
|
let visibleCache = "";
|
|
@@ -4088,8 +4116,19 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4088
4116
|
if (!disposed && !cancelFrame && pending.length > 0) cancelFrame = schedule(tick);
|
|
4089
4117
|
};
|
|
4090
4118
|
const resegmentTail = () => {
|
|
4119
|
+
if (seam !== void 0 && seam < source.length && pending[pending.length - 1] === seam) {
|
|
4120
|
+
pending.pop();
|
|
4121
|
+
}
|
|
4091
4122
|
const from = pending.length > 0 ? pending[pending.length - 1] : visibleEnd;
|
|
4092
|
-
|
|
4123
|
+
let anchor = from;
|
|
4124
|
+
if (seam !== void 0 && from <= seam) {
|
|
4125
|
+
anchor = Math.max(0, from - RESUME_LOOKBACK);
|
|
4126
|
+
if (isMidSurrogatePair(source, anchor)) anchor -= 1;
|
|
4127
|
+
while (anchor >= 2 && isRegionalIndicatorAt(source, anchor - 2)) anchor -= 2;
|
|
4128
|
+
} else {
|
|
4129
|
+
seam = void 0;
|
|
4130
|
+
}
|
|
4131
|
+
const ends = graphemeEnds(source.slice(anchor), anchor);
|
|
4093
4132
|
if (ends.length === 0) {
|
|
4094
4133
|
tentativeEnd = from;
|
|
4095
4134
|
return;
|
|
@@ -4101,7 +4140,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4101
4140
|
if (last >= 55296 && last <= 56319) hold = 2;
|
|
4102
4141
|
}
|
|
4103
4142
|
const confirmedEnds = finished ? ends : ends.slice(0, -hold);
|
|
4104
|
-
for (const end of confirmedEnds) pending.push(end);
|
|
4143
|
+
for (const end of confirmedEnds) if (end > from) pending.push(end);
|
|
4105
4144
|
};
|
|
4106
4145
|
const snap = (next) => {
|
|
4107
4146
|
disposed = false;
|
|
@@ -4115,6 +4154,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4115
4154
|
visibleEnd = next.length;
|
|
4116
4155
|
tentativeEnd = next.length;
|
|
4117
4156
|
pending = [];
|
|
4157
|
+
seam = next.length;
|
|
4118
4158
|
credit = 0;
|
|
4119
4159
|
cancelScheduled();
|
|
4120
4160
|
if (visibleCache !== next) notify();
|
|
@@ -4149,6 +4189,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4149
4189
|
if (tentativeEnd > (pending.length > 0 ? pending[pending.length - 1] : visibleEnd)) {
|
|
4150
4190
|
pending.push(tentativeEnd);
|
|
4151
4191
|
}
|
|
4192
|
+
seam = source.length;
|
|
4152
4193
|
ensureScheduled();
|
|
4153
4194
|
},
|
|
4154
4195
|
snap,
|