@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.dev.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;
|
|
@@ -4009,6 +4028,14 @@ var graphemeEnds = (text, base) => {
|
|
|
4009
4028
|
}
|
|
4010
4029
|
return ends;
|
|
4011
4030
|
};
|
|
4031
|
+
var RESUME_LOOKBACK = 64;
|
|
4032
|
+
var isMidSurrogatePair = (text, at) => at > 0 && at < text.length && (text.charCodeAt(at - 1) & 64512) === 55296 && (text.charCodeAt(at) & 64512) === 56320;
|
|
4033
|
+
var RI_FIRST = 127462;
|
|
4034
|
+
var RI_LAST = 127487;
|
|
4035
|
+
var isRegionalIndicatorAt = (text, at) => {
|
|
4036
|
+
const cp = text.codePointAt(at);
|
|
4037
|
+
return cp !== void 0 && cp >= RI_FIRST && cp <= RI_LAST;
|
|
4038
|
+
};
|
|
4012
4039
|
var createSmoothStreamController = (options = {}) => {
|
|
4013
4040
|
const now = options.now ?? defaultNow;
|
|
4014
4041
|
const schedule = options.schedule ?? defaultSchedule;
|
|
@@ -4017,6 +4044,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4017
4044
|
let pending = [];
|
|
4018
4045
|
let tentativeEnd = 0;
|
|
4019
4046
|
let finished = false;
|
|
4047
|
+
let seam;
|
|
4020
4048
|
let drainDeadlineAt;
|
|
4021
4049
|
let initialized = false;
|
|
4022
4050
|
let visibleCache = "";
|
|
@@ -4100,8 +4128,19 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4100
4128
|
if (!disposed && !cancelFrame && pending.length > 0) cancelFrame = schedule(tick);
|
|
4101
4129
|
};
|
|
4102
4130
|
const resegmentTail = () => {
|
|
4131
|
+
if (seam !== void 0 && seam < source.length && pending[pending.length - 1] === seam) {
|
|
4132
|
+
pending.pop();
|
|
4133
|
+
}
|
|
4103
4134
|
const from = pending.length > 0 ? pending[pending.length - 1] : visibleEnd;
|
|
4104
|
-
|
|
4135
|
+
let anchor = from;
|
|
4136
|
+
if (seam !== void 0 && from <= seam) {
|
|
4137
|
+
anchor = Math.max(0, from - RESUME_LOOKBACK);
|
|
4138
|
+
if (isMidSurrogatePair(source, anchor)) anchor -= 1;
|
|
4139
|
+
while (anchor >= 2 && isRegionalIndicatorAt(source, anchor - 2)) anchor -= 2;
|
|
4140
|
+
} else {
|
|
4141
|
+
seam = void 0;
|
|
4142
|
+
}
|
|
4143
|
+
const ends = graphemeEnds(source.slice(anchor), anchor);
|
|
4105
4144
|
if (ends.length === 0) {
|
|
4106
4145
|
tentativeEnd = from;
|
|
4107
4146
|
return;
|
|
@@ -4113,7 +4152,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4113
4152
|
if (last >= 55296 && last <= 56319) hold = 2;
|
|
4114
4153
|
}
|
|
4115
4154
|
const confirmedEnds = finished ? ends : ends.slice(0, -hold);
|
|
4116
|
-
for (const end of confirmedEnds) pending.push(end);
|
|
4155
|
+
for (const end of confirmedEnds) if (end > from) pending.push(end);
|
|
4117
4156
|
};
|
|
4118
4157
|
const snap = (next) => {
|
|
4119
4158
|
disposed = false;
|
|
@@ -4127,6 +4166,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4127
4166
|
visibleEnd = next.length;
|
|
4128
4167
|
tentativeEnd = next.length;
|
|
4129
4168
|
pending = [];
|
|
4169
|
+
seam = next.length;
|
|
4130
4170
|
credit = 0;
|
|
4131
4171
|
cancelScheduled();
|
|
4132
4172
|
if (visibleCache !== next) notify();
|
|
@@ -4161,6 +4201,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4161
4201
|
if (tentativeEnd > (pending.length > 0 ? pending[pending.length - 1] : visibleEnd)) {
|
|
4162
4202
|
pending.push(tentativeEnd);
|
|
4163
4203
|
}
|
|
4204
|
+
seam = source.length;
|
|
4164
4205
|
ensureScheduled();
|
|
4165
4206
|
},
|
|
4166
4207
|
snap,
|