@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.cjs
CHANGED
|
@@ -751,6 +751,7 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
751
751
|
cp.openTotal += 1;
|
|
752
752
|
}
|
|
753
753
|
};
|
|
754
|
+
const strayTablePart = (tag) => TABLE_PART_NAMES.has(tag) && (cp.tagBalance.get("table") ?? 0) === 0;
|
|
754
755
|
const commentOpenAtLineStart = cp.commentOpen;
|
|
755
756
|
const rawOpenAtLineStart = cp.commentOpen || cp.piOpen || cp.declOpen || cp.cdataOpen || cp.bogusOpen;
|
|
756
757
|
if (cp.inFence) {
|
|
@@ -1079,7 +1080,7 @@ ${cont(scanText)}` };
|
|
|
1079
1080
|
if (cp.commentOpen) continue;
|
|
1080
1081
|
const closing = m[1] === "/";
|
|
1081
1082
|
const tag = m[2].toLowerCase();
|
|
1082
|
-
if (
|
|
1083
|
+
if (strayTablePart(tag)) cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + m.index);
|
|
1083
1084
|
let attrs = m[3] ?? "";
|
|
1084
1085
|
if (cp.htmlFlowReal && (cp.rawTextOpen === null || closing && tag === cp.rawTextOpen)) {
|
|
1085
1086
|
const attrStart = m.index + 1 + (closing ? 1 : 0) + m[2].length;
|
|
@@ -1123,7 +1124,7 @@ ${cont(scanText)}` };
|
|
|
1123
1124
|
if (startMasked || wholeVisible || inRaw(mr.index) || cp.commentOpen) continue;
|
|
1124
1125
|
const closing = mr[1] === "/";
|
|
1125
1126
|
const tag = mr[2].toLowerCase();
|
|
1126
|
-
if (
|
|
1127
|
+
if (strayTablePart(tag)) cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + mr.index);
|
|
1127
1128
|
if (closing && mr[3] !== void 0 && !/^\s*$/.test(mr[3])) continue;
|
|
1128
1129
|
const selfClosing = mr[3] !== void 0 && /\/\s*$/.test(mr[3]);
|
|
1129
1130
|
if (VOID_TAGS.has(tag) || selfClosing && honoursSelfClosing(tag)) continue;
|
|
@@ -1131,7 +1132,7 @@ ${cont(scanText)}` };
|
|
|
1131
1132
|
}
|
|
1132
1133
|
}
|
|
1133
1134
|
if (cp.pendingTruncatedTags.length > 0 && ln.text.includes(">")) {
|
|
1134
|
-
if (cp.pendingTruncatedTags.some((t) =>
|
|
1135
|
+
if (cp.pendingTruncatedTags.some((t) => strayTablePart(t))) {
|
|
1135
1136
|
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
1136
1137
|
}
|
|
1137
1138
|
cp.pendingTruncatedTags = [];
|
|
@@ -1148,7 +1149,7 @@ ${cont(scanText)}` };
|
|
|
1148
1149
|
if (m2) {
|
|
1149
1150
|
const closing = m2[1] === "/";
|
|
1150
1151
|
const tag = m2[2].toLowerCase();
|
|
1151
|
-
if (
|
|
1152
|
+
if (strayTablePart(tag) && cp.htmlFlowReal) {
|
|
1152
1153
|
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + lastLt);
|
|
1153
1154
|
}
|
|
1154
1155
|
if (cp.htmlFlowReal) {
|
|
@@ -1373,6 +1374,24 @@ function rebaseDualWalk(node, segments, maxEnd, offsetDelta, lineDelta) {
|
|
|
1373
1374
|
}
|
|
1374
1375
|
}
|
|
1375
1376
|
var TABLE_PART_TAG_RE = /<(?:td|th|tr|tbody|thead|tfoot|caption|col|colgroup)\b/i;
|
|
1377
|
+
var TABLE_TOKEN_RE = /<(\/?)(table|td|th|tr|tbody|thead|tfoot|caption|col|colgroup)\b/gi;
|
|
1378
|
+
function hasStrayTablePart(values) {
|
|
1379
|
+
let depth = 0;
|
|
1380
|
+
for (const value of values) {
|
|
1381
|
+
TABLE_TOKEN_RE.lastIndex = 0;
|
|
1382
|
+
let m;
|
|
1383
|
+
while ((m = TABLE_TOKEN_RE.exec(value)) !== null) {
|
|
1384
|
+
const closing = m[1] === "/";
|
|
1385
|
+
const tag = m[2].toLowerCase();
|
|
1386
|
+
if (tag === "table") {
|
|
1387
|
+
depth = closing ? Math.max(0, depth - 1) : depth + 1;
|
|
1388
|
+
continue;
|
|
1389
|
+
}
|
|
1390
|
+
if (depth === 0) return true;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1376
1395
|
var STRAY_SYNTHESIZED_END_TAG_RE = /<\/(?:br|p)\b/i;
|
|
1377
1396
|
function spliceTrees(input) {
|
|
1378
1397
|
const { prevMdast, prevHast, tailMdast, tailHast, content, boundary, injectionPrefix, injectedSegments } = input;
|
|
@@ -1430,7 +1449,7 @@ function spliceTrees(input) {
|
|
|
1430
1449
|
return !(start !== void 0 && start < injectedLen);
|
|
1431
1450
|
});
|
|
1432
1451
|
const tailWrapVisible = tailMdastChildren.some((child) => !isWrapInvisible(child));
|
|
1433
|
-
if (prefixMdast.
|
|
1452
|
+
if (hasStrayTablePart(prefixMdast.flatMap((c) => c.type === "html" ? [c.value] : []))) return null;
|
|
1434
1453
|
for (const child of tailMdastChildren) {
|
|
1435
1454
|
if (isWrapInvisible(child)) continue;
|
|
1436
1455
|
if (child.type !== "html") break;
|
|
@@ -4100,6 +4119,14 @@ var graphemeEnds = (text, base) => {
|
|
|
4100
4119
|
}
|
|
4101
4120
|
return ends;
|
|
4102
4121
|
};
|
|
4122
|
+
var RESUME_LOOKBACK = 64;
|
|
4123
|
+
var isMidSurrogatePair = (text, at) => at > 0 && at < text.length && (text.charCodeAt(at - 1) & 64512) === 55296 && (text.charCodeAt(at) & 64512) === 56320;
|
|
4124
|
+
var RI_FIRST = 127462;
|
|
4125
|
+
var RI_LAST = 127487;
|
|
4126
|
+
var isRegionalIndicatorAt = (text, at) => {
|
|
4127
|
+
const cp = text.codePointAt(at);
|
|
4128
|
+
return cp !== void 0 && cp >= RI_FIRST && cp <= RI_LAST;
|
|
4129
|
+
};
|
|
4103
4130
|
var createSmoothStreamController = (options = {}) => {
|
|
4104
4131
|
const now = options.now ?? defaultNow;
|
|
4105
4132
|
const schedule = options.schedule ?? defaultSchedule;
|
|
@@ -4108,6 +4135,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4108
4135
|
let pending = [];
|
|
4109
4136
|
let tentativeEnd = 0;
|
|
4110
4137
|
let finished = false;
|
|
4138
|
+
let seam;
|
|
4111
4139
|
let drainDeadlineAt;
|
|
4112
4140
|
let initialized = false;
|
|
4113
4141
|
let visibleCache = "";
|
|
@@ -4191,8 +4219,19 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4191
4219
|
if (!disposed && !cancelFrame && pending.length > 0) cancelFrame = schedule(tick);
|
|
4192
4220
|
};
|
|
4193
4221
|
const resegmentTail = () => {
|
|
4222
|
+
if (seam !== void 0 && seam < source.length && pending[pending.length - 1] === seam) {
|
|
4223
|
+
pending.pop();
|
|
4224
|
+
}
|
|
4194
4225
|
const from = pending.length > 0 ? pending[pending.length - 1] : visibleEnd;
|
|
4195
|
-
|
|
4226
|
+
let anchor = from;
|
|
4227
|
+
if (seam !== void 0 && from <= seam) {
|
|
4228
|
+
anchor = Math.max(0, from - RESUME_LOOKBACK);
|
|
4229
|
+
if (isMidSurrogatePair(source, anchor)) anchor -= 1;
|
|
4230
|
+
while (anchor >= 2 && isRegionalIndicatorAt(source, anchor - 2)) anchor -= 2;
|
|
4231
|
+
} else {
|
|
4232
|
+
seam = void 0;
|
|
4233
|
+
}
|
|
4234
|
+
const ends = graphemeEnds(source.slice(anchor), anchor);
|
|
4196
4235
|
if (ends.length === 0) {
|
|
4197
4236
|
tentativeEnd = from;
|
|
4198
4237
|
return;
|
|
@@ -4204,7 +4243,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4204
4243
|
if (last >= 55296 && last <= 56319) hold = 2;
|
|
4205
4244
|
}
|
|
4206
4245
|
const confirmedEnds = finished ? ends : ends.slice(0, -hold);
|
|
4207
|
-
for (const end of confirmedEnds) pending.push(end);
|
|
4246
|
+
for (const end of confirmedEnds) if (end > from) pending.push(end);
|
|
4208
4247
|
};
|
|
4209
4248
|
const snap = (next) => {
|
|
4210
4249
|
disposed = false;
|
|
@@ -4218,6 +4257,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4218
4257
|
visibleEnd = next.length;
|
|
4219
4258
|
tentativeEnd = next.length;
|
|
4220
4259
|
pending = [];
|
|
4260
|
+
seam = next.length;
|
|
4221
4261
|
credit = 0;
|
|
4222
4262
|
cancelScheduled();
|
|
4223
4263
|
if (visibleCache !== next) notify();
|
|
@@ -4252,6 +4292,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4252
4292
|
if (tentativeEnd > (pending.length > 0 ? pending[pending.length - 1] : visibleEnd)) {
|
|
4253
4293
|
pending.push(tentativeEnd);
|
|
4254
4294
|
}
|
|
4295
|
+
seam = source.length;
|
|
4255
4296
|
ensureScheduled();
|
|
4256
4297
|
},
|
|
4257
4298
|
snap,
|