@artooi/ag-ui-web-component 0.40.0 → 0.41.0
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 +54 -1
- package/README.md +46 -24
- package/dist/ag-ui-web-component.bundle.js +118 -87
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +3 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts +25 -16
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/core/attachment.d.ts +11 -4
- package/dist/core/attachment.d.ts.map +1 -1
- package/dist/core/tool_outcome.d.ts +4 -3
- package/dist/core/tool_outcome.d.ts.map +1 -1
- package/dist/core/utils.d.ts +19 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/index.js +461 -452
- package/dist/index.js.map +4 -4
- package/dist/ui/history/conversation_history.d.ts +1 -1
- package/dist/ui/history/conversation_history.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/constants.ts +3 -2
- package/src/core/agui_client.ts +149 -131
- package/src/core/attachment.ts +13 -5
- package/src/core/tool_outcome.ts +4 -3
- package/src/core/utils.ts +23 -0
- package/src/ui/history/conversation_history.ts +25 -22
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -929,6 +929,10 @@ function answerUnansweredCalls(messages, answer, except = /* @__PURE__ */ new Se
|
|
|
929
929
|
function toolCallIds(value) {
|
|
930
930
|
return Array.isArray(value) ? value.map((call) => Object(call).id).filter((id) => typeof id === "string") : [];
|
|
931
931
|
}
|
|
932
|
+
function metadataOrTopLevel(message, key) {
|
|
933
|
+
const metadata = Object(message.metadata);
|
|
934
|
+
return metadata[key] ?? message[key];
|
|
935
|
+
}
|
|
932
936
|
|
|
933
937
|
// src/ui/ui_strings.ts
|
|
934
938
|
var DEFAULT_UI_STRINGS = {
|
|
@@ -4009,10 +4013,11 @@ var CheckpointMenu = class {
|
|
|
4009
4013
|
|
|
4010
4014
|
// src/ui/history/conversation_history.ts
|
|
4011
4015
|
import { randomUUID as randomUUID3 } from "@ag-ui/client";
|
|
4016
|
+
import { contentToText } from "@ag-ui/core";
|
|
4012
4017
|
|
|
4013
4018
|
// src/core/attachment.ts
|
|
4014
4019
|
function messageAttachments(message) {
|
|
4015
|
-
const refs = message
|
|
4020
|
+
const refs = metadataOrTopLevel(message, "attachments");
|
|
4016
4021
|
return Array.isArray(refs) ? refs.filter(isAttachmentRef) : [];
|
|
4017
4022
|
}
|
|
4018
4023
|
function isAttachmentRef(value) {
|
|
@@ -4291,7 +4296,7 @@ var ConversationHistory = class {
|
|
|
4291
4296
|
//
|
|
4292
4297
|
// All of it, even where this forks an earlier run and the server's
|
|
4293
4298
|
// snapshot stops there: what is saved is what the screen shows.
|
|
4294
|
-
follows: this.#host.client()?.
|
|
4299
|
+
follows: this.#host.client()?.messages ?? this.#restored,
|
|
4295
4300
|
onSaved: (conversation) => {
|
|
4296
4301
|
if (cleared !== this.#cleared) {
|
|
4297
4302
|
return;
|
|
@@ -4370,14 +4375,13 @@ var ConversationHistory = class {
|
|
|
4370
4375
|
const restored = answerUnansweredCalls(
|
|
4371
4376
|
messages,
|
|
4372
4377
|
// The shape the store holds for a call the client answered the same way:
|
|
4373
|
-
// its tool message, with the outcome
|
|
4374
|
-
// Cast at the AG-UI boundary, as the client's own annotation is.
|
|
4378
|
+
// its tool message, with the outcome in its metadata.
|
|
4375
4379
|
(toolCallId) => ({
|
|
4376
4380
|
id: randomUUID3(),
|
|
4377
4381
|
role: "tool",
|
|
4378
4382
|
content: unfinished,
|
|
4379
4383
|
toolCallId,
|
|
4380
|
-
outcome: TOOL_OUTCOME.INTERRUPTED
|
|
4384
|
+
metadata: { outcome: TOOL_OUTCOME.INTERRUPTED }
|
|
4381
4385
|
}),
|
|
4382
4386
|
new Set(checkpoint === null ? [] : [checkpoint.toolCallId])
|
|
4383
4387
|
);
|
|
@@ -4469,8 +4473,10 @@ var ConversationHistory = class {
|
|
|
4469
4473
|
const card = this.#host.transcript.card(message.toolCallId);
|
|
4470
4474
|
if (card !== void 0) {
|
|
4471
4475
|
card.settle(
|
|
4472
|
-
toolStatusFromOutcome(message
|
|
4473
|
-
|
|
4476
|
+
toolStatusFromOutcome(metadataOrTopLevel(message, "outcome")),
|
|
4477
|
+
// Flattened exactly as the live path flattens it, so a reload shows
|
|
4478
|
+
// the card the user watched settle.
|
|
4479
|
+
contentToText(message.content)
|
|
4474
4480
|
);
|
|
4475
4481
|
}
|
|
4476
4482
|
}
|
|
@@ -10770,7 +10776,7 @@ var AnswerActions = class {
|
|
|
10770
10776
|
}
|
|
10771
10777
|
};
|
|
10772
10778
|
|
|
10773
|
-
// node_modules/.pnpm/dompurify@3.4.
|
|
10779
|
+
// node_modules/.pnpm/dompurify@3.4.15/node_modules/dompurify/dist/purify.es.mjs
|
|
10774
10780
|
function _arrayLikeToArray(r, a) {
|
|
10775
10781
|
(null == a || a > r.length) && (a = r.length);
|
|
10776
10782
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -10779,18 +10785,18 @@ function _arrayLikeToArray(r, a) {
|
|
|
10779
10785
|
function _arrayWithHoles(r) {
|
|
10780
10786
|
if (Array.isArray(r)) return r;
|
|
10781
10787
|
}
|
|
10782
|
-
function _iterableToArrayLimit(r,
|
|
10788
|
+
function _iterableToArrayLimit(r, l) {
|
|
10783
10789
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
10784
10790
|
if (null != t) {
|
|
10785
|
-
var e, n, i,
|
|
10791
|
+
var e, n, i, u3, a = [], f2 = true, o = false;
|
|
10786
10792
|
try {
|
|
10787
|
-
if (i = (t = t.call(r)).next, 0 ===
|
|
10788
|
-
else for (; !(f2 = (e = i.call(t)).done) && (a.push(e.value), a.length !==
|
|
10793
|
+
if (i = (t = t.call(r)).next, 0 === l) ;
|
|
10794
|
+
else for (; !(f2 = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f2 = true) ;
|
|
10789
10795
|
} catch (r2) {
|
|
10790
10796
|
o = true, n = r2;
|
|
10791
10797
|
} finally {
|
|
10792
10798
|
try {
|
|
10793
|
-
if (!f2 && null != t.return && (
|
|
10799
|
+
if (!f2 && null != t.return && (u3 = t.return(), Object(u3) !== u3)) return;
|
|
10794
10800
|
} finally {
|
|
10795
10801
|
if (o) throw n;
|
|
10796
10802
|
}
|
|
@@ -10895,14 +10901,14 @@ function addToSet(set, array) {
|
|
|
10895
10901
|
if (!arrayIsArray(array)) {
|
|
10896
10902
|
return set;
|
|
10897
10903
|
}
|
|
10898
|
-
let
|
|
10899
|
-
while (
|
|
10900
|
-
let element = array[
|
|
10904
|
+
let l = array.length;
|
|
10905
|
+
while (l--) {
|
|
10906
|
+
let element = array[l];
|
|
10901
10907
|
if (typeof element === "string") {
|
|
10902
10908
|
const lcElement = transformCaseFunc(element);
|
|
10903
10909
|
if (lcElement !== element) {
|
|
10904
10910
|
if (!isFrozen(array)) {
|
|
10905
|
-
array[
|
|
10911
|
+
array[l] = lcElement;
|
|
10906
10912
|
}
|
|
10907
10913
|
element = lcElement;
|
|
10908
10914
|
}
|
|
@@ -11110,7 +11116,7 @@ var _resolveObjectOption = function _resolveObjectOption2(cfg, key, makeFallback
|
|
|
11110
11116
|
function createDOMPurify() {
|
|
11111
11117
|
let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
11112
11118
|
const DOMPurify = (root) => createDOMPurify(root);
|
|
11113
|
-
DOMPurify.version = "3.4.
|
|
11119
|
+
DOMPurify.version = "3.4.15";
|
|
11114
11120
|
DOMPurify.removed = [];
|
|
11115
11121
|
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
11116
11122
|
DOMPurify.isSupported = false;
|
|
@@ -11127,6 +11133,7 @@ function createDOMPurify() {
|
|
|
11127
11133
|
const ElementPrototype = Element2.prototype;
|
|
11128
11134
|
const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
|
11129
11135
|
const remove = lookupGetter(ElementPrototype, "remove");
|
|
11136
|
+
const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
|
|
11130
11137
|
const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
|
11131
11138
|
const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
|
11132
11139
|
const getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
|
@@ -11560,7 +11567,7 @@ function createDOMPurify() {
|
|
|
11560
11567
|
};
|
|
11561
11568
|
const _stripAttributeNode = function _stripAttributeNode2(element, attribute, name) {
|
|
11562
11569
|
try {
|
|
11563
|
-
|
|
11570
|
+
removeAttributeNode(element, attribute);
|
|
11564
11571
|
} catch (_2) {
|
|
11565
11572
|
try {
|
|
11566
11573
|
element.removeAttribute(name);
|
|
@@ -11608,7 +11615,7 @@ function createDOMPurify() {
|
|
|
11608
11615
|
});
|
|
11609
11616
|
try {
|
|
11610
11617
|
if (attr) {
|
|
11611
|
-
|
|
11618
|
+
removeAttributeNode(element, attr);
|
|
11612
11619
|
} else {
|
|
11613
11620
|
element.removeAttribute(name);
|
|
11614
11621
|
}
|
|
@@ -11796,7 +11803,16 @@ function createDOMPurify() {
|
|
|
11796
11803
|
// makes the direct read diverge from the cached read; a clean form
|
|
11797
11804
|
// (same-realm OR foreign-realm) has both reads pointing at the same
|
|
11798
11805
|
// canonical NamedNodeMap.
|
|
11799
|
-
element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" ||
|
|
11806
|
+
element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || // A form descendant named "removeAttributeNode" or "getAttributeNode"
|
|
11807
|
+
// shadows these Attr-node methods via [LegacyOverrideBuiltIns].
|
|
11808
|
+
// _removeAttribute() / _stripAttributeNode() reach for
|
|
11809
|
+
// element.removeAttributeNode(attr) first; when it is shadowed the call
|
|
11810
|
+
// throws and the name-based fallback element.removeAttribute(name)
|
|
11811
|
+
// ASCII-lowercases its lookup key in an HTML document, silently missing
|
|
11812
|
+
// a case-preserved event-handler attribute (e.g. an ONANIMATIONSTART
|
|
11813
|
+
// that reached the sanitizer through an XML/XHTML parse). Flag the form
|
|
11814
|
+
// so it is removed wholesale, exactly as for the other shadowed methods.
|
|
11815
|
+
typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
|
|
11800
11816
|
// returns the integer 1 for any Element regardless of realm; direct
|
|
11801
11817
|
// read on a clobbered form (e.g. <input name="nodeType">) returns
|
|
11802
11818
|
// the named child element. Cheap addition — nodeType is read from
|
|
@@ -12022,11 +12038,12 @@ function createDOMPurify() {
|
|
|
12022
12038
|
}
|
|
12023
12039
|
if (_isClobbered(currentNode)) {
|
|
12024
12040
|
_forceRemove(currentNode);
|
|
12025
|
-
|
|
12026
|
-
arrayPop(DOMPurify.removed);
|
|
12041
|
+
return false;
|
|
12027
12042
|
}
|
|
12043
|
+
return true;
|
|
12028
12044
|
} catch (_2) {
|
|
12029
12045
|
_removeAttribute(name, currentNode);
|
|
12046
|
+
return false;
|
|
12030
12047
|
}
|
|
12031
12048
|
};
|
|
12032
12049
|
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
@@ -12043,14 +12060,15 @@ function createDOMPurify() {
|
|
|
12043
12060
|
allowedAttributes: ALLOWED_ATTR2,
|
|
12044
12061
|
forceKeepAttr: void 0
|
|
12045
12062
|
};
|
|
12046
|
-
let
|
|
12063
|
+
let l = attributes.length;
|
|
12047
12064
|
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
12048
|
-
while (
|
|
12049
|
-
const attr = attributes[
|
|
12065
|
+
while (l--) {
|
|
12066
|
+
const attr = attributes[l];
|
|
12050
12067
|
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
12051
12068
|
const lcName = transformCaseFunc(name);
|
|
12052
12069
|
const initValue = attrValue;
|
|
12053
12070
|
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
12071
|
+
let recreatedNamedProp = false;
|
|
12054
12072
|
hookEvent.attrName = lcName;
|
|
12055
12073
|
hookEvent.attrValue = value;
|
|
12056
12074
|
hookEvent.keepAttr = true;
|
|
@@ -12060,6 +12078,7 @@ function createDOMPurify() {
|
|
|
12060
12078
|
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
12061
12079
|
_removeAttribute(name, currentNode, attr);
|
|
12062
12080
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
12081
|
+
recreatedNamedProp = true;
|
|
12063
12082
|
}
|
|
12064
12083
|
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
12065
12084
|
_removeAttribute(name, currentNode, attr);
|
|
@@ -12089,7 +12108,10 @@ function createDOMPurify() {
|
|
|
12089
12108
|
}
|
|
12090
12109
|
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
12091
12110
|
if (value !== initValue) {
|
|
12092
|
-
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
12111
|
+
const cleanWrite = _setAttributeValue(currentNode, name, namespaceURI, value);
|
|
12112
|
+
if (cleanWrite && recreatedNamedProp) {
|
|
12113
|
+
arrayPop(DOMPurify.removed);
|
|
12114
|
+
}
|
|
12093
12115
|
}
|
|
12094
12116
|
}
|
|
12095
12117
|
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
@@ -12199,9 +12221,9 @@ function createDOMPurify() {
|
|
|
12199
12221
|
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
12200
12222
|
if (inPlace) {
|
|
12201
12223
|
_neutralizePatchLinkage(dirty);
|
|
12202
|
-
const
|
|
12203
|
-
if (typeof
|
|
12204
|
-
const tagName = transformCaseFunc(
|
|
12224
|
+
const nn = _readNodeName(dirty);
|
|
12225
|
+
if (typeof nn === "string") {
|
|
12226
|
+
const tagName = transformCaseFunc(nn);
|
|
12205
12227
|
if (!ALLOWED_TAGS2[tagName] || FORBID_TAGS[tagName]) {
|
|
12206
12228
|
_neutralizeRoot(dirty);
|
|
12207
12229
|
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
@@ -12227,7 +12249,7 @@ function createDOMPurify() {
|
|
|
12227
12249
|
} else {
|
|
12228
12250
|
body.appendChild(importedNode);
|
|
12229
12251
|
}
|
|
12230
|
-
_sanitizeAttachedShadowRoots(
|
|
12252
|
+
_sanitizeAttachedShadowRoots(body);
|
|
12231
12253
|
} else {
|
|
12232
12254
|
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
|
|
12233
12255
|
dirty.indexOf("<") === -1) {
|
|
@@ -12354,38 +12376,38 @@ function createDOMPurify() {
|
|
|
12354
12376
|
}
|
|
12355
12377
|
var purify = createDOMPurify();
|
|
12356
12378
|
|
|
12357
|
-
// node_modules/.pnpm/marked@18.0.
|
|
12379
|
+
// node_modules/.pnpm/marked@18.0.12/node_modules/marked/lib/marked.esm.js
|
|
12358
12380
|
function A() {
|
|
12359
12381
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
12360
12382
|
}
|
|
12361
|
-
var
|
|
12362
|
-
function j(
|
|
12363
|
-
|
|
12383
|
+
var T = A();
|
|
12384
|
+
function j(u3) {
|
|
12385
|
+
T = u3;
|
|
12364
12386
|
}
|
|
12365
|
-
var
|
|
12366
|
-
function I(
|
|
12387
|
+
var E = { exec: () => null };
|
|
12388
|
+
function I(u3) {
|
|
12367
12389
|
let e = [];
|
|
12368
12390
|
return (t) => {
|
|
12369
12391
|
let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
|
|
12370
|
-
return s || (s =
|
|
12392
|
+
return s || (s = u3(n), e[n] = s), s;
|
|
12371
12393
|
};
|
|
12372
12394
|
}
|
|
12373
|
-
function k(
|
|
12374
|
-
let t = typeof
|
|
12375
|
-
let
|
|
12376
|
-
return
|
|
12395
|
+
function k(u3, e = "") {
|
|
12396
|
+
let t = typeof u3 == "string" ? u3 : u3.source, n = { replace: (s, r) => {
|
|
12397
|
+
let o = typeof r == "string" ? r : r.source;
|
|
12398
|
+
return o = o.replace(m.caret, "$1"), t = t.replace(s, o), n;
|
|
12377
12399
|
}, getRegex: () => new RegExp(t, e) };
|
|
12378
12400
|
return n;
|
|
12379
12401
|
}
|
|
12380
|
-
var
|
|
12402
|
+
var Te = ((u3 = "") => {
|
|
12381
12403
|
try {
|
|
12382
|
-
return !!new RegExp("(?<=1)(?<!1)" +
|
|
12404
|
+
return !!new RegExp("(?<=1)(?<!1)" + u3);
|
|
12383
12405
|
} catch {
|
|
12384
12406
|
return false;
|
|
12385
12407
|
}
|
|
12386
12408
|
})();
|
|
12387
|
-
var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (
|
|
12388
|
-
var
|
|
12409
|
+
var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (u3) => new RegExp(`^( {0,3}${u3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: I((u3) => new RegExp(`^ {0,${u3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: I((u3) => new RegExp(`^ {0,${u3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}(?:\`\`\`|~~~)`)), headingBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}#`)), htmlBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}>`)) };
|
|
12410
|
+
var Oe = /^(?:[ \t]*(?:\n|$))+/;
|
|
12389
12411
|
var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
12390
12412
|
var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
12391
12413
|
var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
@@ -12401,15 +12423,15 @@ var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[
|
|
|
12401
12423
|
var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
|
|
12402
12424
|
var Q = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
12403
12425
|
var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
12404
|
-
var
|
|
12405
|
-
var le = (
|
|
12406
|
-
var
|
|
12426
|
+
var ze = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
12427
|
+
var le = (u3) => k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", u3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
12428
|
+
var Ee = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
12407
12429
|
var Me = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
12408
12430
|
var Ae = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Me).getRegex();
|
|
12409
|
-
var J = { blockquote: Ae, code: we, def: $e, fences: ye, heading: Pe, hr: q, html:
|
|
12431
|
+
var J = { blockquote: Ae, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: ze, lheading: ae, list: Le, newline: Oe, paragraph: Ee, table: E, text: _e };
|
|
12410
12432
|
var se = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
12411
12433
|
var Ie = { ...J, lheading: Se, table: se, paragraph: k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex() };
|
|
12412
|
-
var Ce = { ...J, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences:
|
|
12434
|
+
var Ce = { ...J, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: E, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
|
|
12413
12435
|
]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
12414
12436
|
var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
12415
12437
|
var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
@@ -12423,7 +12445,7 @@ var He = /[\p{Pi}\p{Ps}"']/u;
|
|
|
12423
12445
|
var pe = /(?!~)[\p{P}\p{S}]/u;
|
|
12424
12446
|
var Ze = /(?!~)[\s\p{P}\p{S}]/u;
|
|
12425
12447
|
var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
12426
|
-
var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",
|
|
12448
|
+
var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
12427
12449
|
var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
12428
12450
|
var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
|
|
12429
12451
|
var je = k(ce, "u").replace(/punct/g, pe).getRegex();
|
|
@@ -12443,106 +12465,107 @@ var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).repl
|
|
|
12443
12465
|
var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
|
|
12444
12466
|
var it = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
12445
12467
|
var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
|
|
12446
|
-
var at = k("^comment|^</[a-zA-Z][
|
|
12447
|
-
var
|
|
12448
|
-
var
|
|
12468
|
+
var at = k("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
12469
|
+
var lt = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
|
|
12470
|
+
var G = k(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", lt).getRegex();
|
|
12471
|
+
var ut = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
12449
12472
|
var ke = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
|
|
12450
12473
|
var de = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
|
|
12451
|
-
var
|
|
12474
|
+
var pt = k("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
|
|
12452
12475
|
var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
12453
|
-
var V = { _backpedal:
|
|
12454
|
-
var
|
|
12455
|
-
var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-
|
|
12456
|
-
var
|
|
12476
|
+
var V = { _backpedal: E, anyPunctuation: st, autolink: it, blockSkip: Qe, br: ue, code: De, del: E, delLDelim: E, delRDelim: E, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: ut, nolink: de, punctuation: ve, reflink: ke, reflinkSearch: pt, tag: at, text: qe, url: E };
|
|
12477
|
+
var ct = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
|
|
12478
|
+
var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
|
|
12479
|
+
var ht = { ...F, br: k(ue).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
12457
12480
|
var H = { normal: J, gfm: Ie, pedantic: Ce };
|
|
12458
|
-
var B = { normal: V, gfm: F, breaks:
|
|
12459
|
-
var
|
|
12460
|
-
var ge = (
|
|
12461
|
-
function
|
|
12481
|
+
var B = { normal: V, gfm: F, breaks: ht, pedantic: ct };
|
|
12482
|
+
var kt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
12483
|
+
var ge = (u3) => kt[u3];
|
|
12484
|
+
function R(u3, e) {
|
|
12462
12485
|
if (e) {
|
|
12463
|
-
if (m.escapeTest.test(
|
|
12464
|
-
} else if (m.escapeTestNoEncode.test(
|
|
12465
|
-
return
|
|
12486
|
+
if (m.escapeTest.test(u3)) return u3.replace(m.escapeReplace, ge);
|
|
12487
|
+
} else if (m.escapeTestNoEncode.test(u3)) return u3.replace(m.escapeReplaceNoEncode, ge);
|
|
12488
|
+
return u3;
|
|
12466
12489
|
}
|
|
12467
|
-
function Y(
|
|
12490
|
+
function Y(u3) {
|
|
12468
12491
|
try {
|
|
12469
|
-
|
|
12492
|
+
u3 = encodeURI(u3).replace(m.percentDecode, "%");
|
|
12470
12493
|
} catch {
|
|
12471
12494
|
return null;
|
|
12472
12495
|
}
|
|
12473
|
-
return
|
|
12496
|
+
return u3;
|
|
12474
12497
|
}
|
|
12475
|
-
function ee(
|
|
12476
|
-
let t =
|
|
12477
|
-
let
|
|
12478
|
-
for (; --a >= 0 &&
|
|
12479
|
-
return
|
|
12498
|
+
function ee(u3, e) {
|
|
12499
|
+
let t = u3.replace(m.findPipe, (r, o, i) => {
|
|
12500
|
+
let l = false, a = o;
|
|
12501
|
+
for (; --a >= 0 && i[a] === "\\"; ) l = !l;
|
|
12502
|
+
return l ? "|" : " |";
|
|
12480
12503
|
}), n = t.split(m.splitPipe), s = 0;
|
|
12481
12504
|
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
|
|
12482
12505
|
else for (; n.length < e; ) n.push("");
|
|
12483
12506
|
for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
12484
12507
|
return n;
|
|
12485
12508
|
}
|
|
12486
|
-
function $(
|
|
12487
|
-
let n =
|
|
12509
|
+
function $(u3, e, t) {
|
|
12510
|
+
let n = u3.length;
|
|
12488
12511
|
if (n === 0) return "";
|
|
12489
12512
|
let s = 0;
|
|
12490
12513
|
for (; s < n; ) {
|
|
12491
|
-
let r =
|
|
12514
|
+
let r = u3.charAt(n - s - 1);
|
|
12492
12515
|
if (r === e && !t) s++;
|
|
12493
12516
|
else if (r !== e && t) s++;
|
|
12494
12517
|
else break;
|
|
12495
12518
|
}
|
|
12496
|
-
return
|
|
12519
|
+
return u3.slice(0, n - s);
|
|
12497
12520
|
}
|
|
12498
|
-
function te(
|
|
12499
|
-
let e =
|
|
12521
|
+
function te(u3) {
|
|
12522
|
+
let e = u3.split(`
|
|
12500
12523
|
`), t = e.length - 1;
|
|
12501
12524
|
for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
|
|
12502
|
-
return e.length - t <= 2 ?
|
|
12525
|
+
return e.length - t <= 2 ? u3 : e.slice(0, t + 1).join(`
|
|
12503
12526
|
`);
|
|
12504
12527
|
}
|
|
12505
|
-
function fe(
|
|
12506
|
-
if (
|
|
12528
|
+
function fe(u3, e) {
|
|
12529
|
+
if (u3.indexOf(e[1]) === -1) return -1;
|
|
12507
12530
|
let t = 0;
|
|
12508
|
-
for (let n = 0; n <
|
|
12509
|
-
else if (
|
|
12510
|
-
else if (
|
|
12531
|
+
for (let n = 0; n < u3.length; n++) if (u3[n] === "\\") n++;
|
|
12532
|
+
else if (u3[n] === e[0]) t++;
|
|
12533
|
+
else if (u3[n] === e[1] && (t--, t < 0)) return n;
|
|
12511
12534
|
return t > 0 ? -2 : -1;
|
|
12512
12535
|
}
|
|
12513
|
-
function me(
|
|
12536
|
+
function me(u3, e = 0) {
|
|
12514
12537
|
let t = e, n = "";
|
|
12515
|
-
for (let s of
|
|
12538
|
+
for (let s of u3) if (s === " ") {
|
|
12516
12539
|
let r = 4 - t % 4;
|
|
12517
12540
|
n += " ".repeat(r), t += r;
|
|
12518
12541
|
} else n += s, t++;
|
|
12519
12542
|
return n;
|
|
12520
12543
|
}
|
|
12521
|
-
function xe(
|
|
12522
|
-
let r = e.href,
|
|
12544
|
+
function xe(u3, e, t, n, s) {
|
|
12545
|
+
let r = e.href, o = e.title || null, i = u3[1].replace(s.other.outputLinkReplace, "$1"), l = u3[0].charAt(0) === "!";
|
|
12523
12546
|
n.state.inLink = true;
|
|
12524
12547
|
let a = n.state.linkEmitted, p = n.state.inRawBlock;
|
|
12525
12548
|
n.state.linkEmitted = false;
|
|
12526
|
-
let c = n.inlineTokens(
|
|
12527
|
-
if (n.state.linkEmitted = a, n.state.inLink = false, !
|
|
12549
|
+
let c = n.inlineTokens(i), h = n.state.linkEmitted;
|
|
12550
|
+
if (n.state.linkEmitted = a, n.state.inLink = false, !l) {
|
|
12528
12551
|
if (h) {
|
|
12529
12552
|
n.state.inRawBlock = p;
|
|
12530
12553
|
return;
|
|
12531
12554
|
}
|
|
12532
12555
|
n.state.linkEmitted = true;
|
|
12533
12556
|
}
|
|
12534
|
-
return { type:
|
|
12557
|
+
return { type: l ? "image" : "link", raw: t, href: r, title: o, text: i, tokens: c };
|
|
12535
12558
|
}
|
|
12536
|
-
function
|
|
12537
|
-
let n =
|
|
12559
|
+
function dt(u3, e, t) {
|
|
12560
|
+
let n = u3.match(t.other.indentCodeCompensation);
|
|
12538
12561
|
if (n === null) return e;
|
|
12539
12562
|
let s = n[1];
|
|
12540
12563
|
return e.split(`
|
|
12541
12564
|
`).map((r) => {
|
|
12542
|
-
let
|
|
12543
|
-
if (
|
|
12544
|
-
let [
|
|
12545
|
-
return
|
|
12565
|
+
let o = r.match(t.other.beginningSpace);
|
|
12566
|
+
if (o === null) return r;
|
|
12567
|
+
let [i] = o;
|
|
12568
|
+
return r.slice(Math.min(i.length, s.length));
|
|
12546
12569
|
}).join(`
|
|
12547
12570
|
`);
|
|
12548
12571
|
}
|
|
@@ -12551,7 +12574,7 @@ var y = class {
|
|
|
12551
12574
|
rules;
|
|
12552
12575
|
lexer;
|
|
12553
12576
|
constructor(e) {
|
|
12554
|
-
this.options = e ||
|
|
12577
|
+
this.options = e || T;
|
|
12555
12578
|
}
|
|
12556
12579
|
space(e) {
|
|
12557
12580
|
let t = this.rules.block.newline.exec(e);
|
|
@@ -12567,7 +12590,7 @@ var y = class {
|
|
|
12567
12590
|
fences(e) {
|
|
12568
12591
|
let t = this.rules.block.fences.exec(e);
|
|
12569
12592
|
if (t) {
|
|
12570
|
-
let n = t[0], s =
|
|
12593
|
+
let n = t[0], s = dt(n, t[3] || "", this.rules);
|
|
12571
12594
|
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
12572
12595
|
}
|
|
12573
12596
|
}
|
|
@@ -12577,7 +12600,7 @@ var y = class {
|
|
|
12577
12600
|
let n = t[2].trim();
|
|
12578
12601
|
if (this.rules.other.endingHash.test(n)) {
|
|
12579
12602
|
let s = $(n, "#");
|
|
12580
|
-
(this.options.pedantic || !s || this.rules.other.
|
|
12603
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceTabChar.test(s)) && (n = s.trim());
|
|
12581
12604
|
}
|
|
12582
12605
|
return { type: "heading", raw: $(t[0], `
|
|
12583
12606
|
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
@@ -12593,40 +12616,40 @@ var y = class {
|
|
|
12593
12616
|
if (t) {
|
|
12594
12617
|
let n = $(t[0], `
|
|
12595
12618
|
`).split(`
|
|
12596
|
-
`), s = "", r = "",
|
|
12619
|
+
`), s = "", r = "", o = [];
|
|
12597
12620
|
for (; n.length > 0; ) {
|
|
12598
|
-
let
|
|
12599
|
-
for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a]))
|
|
12600
|
-
else if (!
|
|
12621
|
+
let i = false, l = [], a;
|
|
12622
|
+
for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) l.push(n[a]), i = true;
|
|
12623
|
+
else if (!i) l.push(n[a]);
|
|
12601
12624
|
else break;
|
|
12602
12625
|
n = n.slice(a);
|
|
12603
|
-
let p =
|
|
12626
|
+
let p = l.join(`
|
|
12604
12627
|
`), c = p.replace(this.rules.other.blockquoteSetextReplace, `
|
|
12605
12628
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
12606
12629
|
s = s ? `${s}
|
|
12607
12630
|
${p}` : p, r = r ? `${r}
|
|
12608
12631
|
${c}` : c;
|
|
12609
12632
|
let h = this.lexer.state.top;
|
|
12610
|
-
if (this.lexer.state.top = true, this.lexer.blockTokens(c,
|
|
12611
|
-
let d =
|
|
12633
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, o, true), this.lexer.state.top = h, n.length === 0) break;
|
|
12634
|
+
let d = o.at(-1);
|
|
12612
12635
|
if (d?.type === "code") break;
|
|
12613
12636
|
if (d?.type === "blockquote") {
|
|
12614
12637
|
let O = d, g = n.join(`
|
|
12615
12638
|
`), w = O.raw + `
|
|
12616
|
-
` + g.replace(this.rules.other.blockquoteSetextReplace2, ""),
|
|
12617
|
-
|
|
12618
|
-
${g}`, r = r.substring(0, r.length - O.text.length) +
|
|
12639
|
+
` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), z = this.blockquote(w);
|
|
12640
|
+
o[o.length - 1] = z, s = `${s}
|
|
12641
|
+
${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
|
|
12619
12642
|
break;
|
|
12620
12643
|
} else if (d?.type === "list") {
|
|
12621
12644
|
let O = d, g = O.raw + `
|
|
12622
12645
|
` + n.join(`
|
|
12623
12646
|
`), w = this.list(g);
|
|
12624
|
-
|
|
12647
|
+
o[o.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - O.raw.length) + w.raw, n = g.substring(o.at(-1).raw.length).split(`
|
|
12625
12648
|
`);
|
|
12626
12649
|
continue;
|
|
12627
12650
|
}
|
|
12628
12651
|
}
|
|
12629
|
-
return { type: "blockquote", raw: s, tokens:
|
|
12652
|
+
return { type: "blockquote", raw: s, tokens: o, text: r };
|
|
12630
12653
|
}
|
|
12631
12654
|
}
|
|
12632
12655
|
list(e) {
|
|
@@ -12634,25 +12657,25 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12634
12657
|
if (t) {
|
|
12635
12658
|
let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
12636
12659
|
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
12637
|
-
let
|
|
12660
|
+
let o = this.rules.other.listItemRegex(n), i = false;
|
|
12638
12661
|
for (; e; ) {
|
|
12639
12662
|
let a = false, p = "", c = "";
|
|
12640
|
-
if (!(t =
|
|
12663
|
+
if (!(t = o.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
12641
12664
|
p = t[0], e = e.substring(p.length);
|
|
12642
12665
|
let h = me(t[2].split(`
|
|
12643
12666
|
`, 1)[0], t[1].length), d = e.split(`
|
|
12644
12667
|
`, 1)[0], O = !h.trim(), g = 0;
|
|
12645
12668
|
if (this.options.pedantic ? (g = 2, c = h.trimStart()) : O ? g = t[1].length + 1 : (g = h.search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = h.slice(g), g += t[1].length), O && this.rules.other.blankLine.test(d) && (p += d + `
|
|
12646
12669
|
`, e = e.substring(d.length + 1), a = true), !a) {
|
|
12647
|
-
let w = this.rules.other.nextBulletRegex(g),
|
|
12670
|
+
let w = this.rules.other.nextBulletRegex(g), z = this.rules.other.hrRegex(g), ne = this.rules.other.fencesBeginRegex(g), re = this.rules.other.headingBeginRegex(g), be = this.rules.other.htmlBeginRegex(g), Re = this.rules.other.blockquoteBeginRegex(g);
|
|
12648
12671
|
for (; e; ) {
|
|
12649
12672
|
let N = e.split(`
|
|
12650
12673
|
`, 1)[0], D;
|
|
12651
|
-
if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) ||
|
|
12674
|
+
if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) || z.test(d)) break;
|
|
12652
12675
|
if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim()) c += `
|
|
12653
12676
|
` + D.slice(g);
|
|
12654
12677
|
else {
|
|
12655
|
-
if (O || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) ||
|
|
12678
|
+
if (O || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || z.test(h)) break;
|
|
12656
12679
|
c += `
|
|
12657
12680
|
` + d;
|
|
12658
12681
|
}
|
|
@@ -12660,10 +12683,10 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12660
12683
|
`, e = e.substring(N.length + 1), h = D.slice(g);
|
|
12661
12684
|
}
|
|
12662
12685
|
}
|
|
12663
|
-
r.loose || (
|
|
12686
|
+
r.loose || (i ? r.loose = true : this.rules.other.doubleBlankLine.test(p) && (i = true)), r.items.push({ type: "list_item", raw: p, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += p;
|
|
12664
12687
|
}
|
|
12665
|
-
let
|
|
12666
|
-
if (
|
|
12688
|
+
let l = r.items.at(-1);
|
|
12689
|
+
if (l) l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
|
|
12667
12690
|
else return;
|
|
12668
12691
|
r.raw = r.raw.trimEnd();
|
|
12669
12692
|
for (let a of r.items) if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), !r.loose) {
|
|
@@ -12711,13 +12734,13 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12711
12734
|
let t = this.rules.block.table.exec(e);
|
|
12712
12735
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
12713
12736
|
let n = ee(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
12714
|
-
`) : [],
|
|
12737
|
+
`) : [], o = { type: "table", raw: $(t[0], `
|
|
12715
12738
|
`), header: [], align: [], rows: [] };
|
|
12716
12739
|
if (n.length === s.length) {
|
|
12717
|
-
for (let
|
|
12718
|
-
for (let
|
|
12719
|
-
for (let
|
|
12720
|
-
return
|
|
12740
|
+
for (let i of s) this.rules.other.tableAlignRight.test(i) ? o.align.push("right") : this.rules.other.tableAlignCenter.test(i) ? o.align.push("center") : this.rules.other.tableAlignLeft.test(i) ? o.align.push("left") : o.align.push(null);
|
|
12741
|
+
for (let i = 0; i < n.length; i++) o.header.push({ text: n[i], tokens: this.lexer.inline(n[i]), header: true, align: o.align[i] });
|
|
12742
|
+
for (let i of r) o.rows.push(ee(i, o.header.length).map((l, a) => ({ text: l, tokens: this.lexer.inline(l), header: false, align: o.align[a] })));
|
|
12743
|
+
return o;
|
|
12721
12744
|
}
|
|
12722
12745
|
}
|
|
12723
12746
|
lheading(e) {
|
|
@@ -12754,20 +12777,20 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12754
12777
|
let n = t[2].trim();
|
|
12755
12778
|
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
12756
12779
|
if (!this.rules.other.endAngleBracket.test(n)) return;
|
|
12757
|
-
let
|
|
12758
|
-
if ((n.length -
|
|
12780
|
+
let o = $(n.slice(0, -1), "\\");
|
|
12781
|
+
if ((n.length - o.length) % 2 === 0) return;
|
|
12759
12782
|
} else {
|
|
12760
|
-
let
|
|
12761
|
-
if (
|
|
12762
|
-
if (
|
|
12763
|
-
let
|
|
12764
|
-
t[2] = t[2].substring(0,
|
|
12783
|
+
let o = fe(t[2], "()");
|
|
12784
|
+
if (o === -2) return;
|
|
12785
|
+
if (o > -1) {
|
|
12786
|
+
let l = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + o;
|
|
12787
|
+
t[2] = t[2].substring(0, o), t[0] = t[0].substring(0, l).trim(), t[3] = "";
|
|
12765
12788
|
}
|
|
12766
12789
|
}
|
|
12767
12790
|
let s = t[2], r = "";
|
|
12768
12791
|
if (this.options.pedantic) {
|
|
12769
|
-
let
|
|
12770
|
-
|
|
12792
|
+
let o = this.rules.other.pedanticHrefTitle.exec(s);
|
|
12793
|
+
o && (s = o[1], r = o[3]);
|
|
12771
12794
|
} else r = t[3] ? t[3].slice(1, -1) : "";
|
|
12772
12795
|
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
|
|
12773
12796
|
}
|
|
@@ -12777,8 +12800,8 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12777
12800
|
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
12778
12801
|
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
12779
12802
|
if (!r) {
|
|
12780
|
-
let
|
|
12781
|
-
return { type: "text", raw:
|
|
12803
|
+
let o = n[0].charAt(0);
|
|
12804
|
+
return { type: "text", raw: o, text: o };
|
|
12782
12805
|
}
|
|
12783
12806
|
return xe(n, r, n[0], this.lexer, this.rules);
|
|
12784
12807
|
}
|
|
@@ -12787,25 +12810,25 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12787
12810
|
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
12788
12811
|
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
12789
12812
|
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
12790
|
-
let
|
|
12791
|
-
for (d.lastIndex = 0, t = t.slice(-1 * e.length +
|
|
12792
|
-
if (
|
|
12793
|
-
if (
|
|
12794
|
-
a +=
|
|
12813
|
+
let o = [...s[0]].length - 1, i, l, a = o, p = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
12814
|
+
for (d.lastIndex = 0, t = t.slice(-1 * e.length + o); (s = d.exec(t)) !== null; ) {
|
|
12815
|
+
if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue;
|
|
12816
|
+
if (l = [...i].length, s[3] || s[4]) {
|
|
12817
|
+
a += l;
|
|
12795
12818
|
continue;
|
|
12796
12819
|
} else if (s[5] || s[6]) {
|
|
12797
|
-
if (
|
|
12798
|
-
p +=
|
|
12820
|
+
if (o % 3 && !((o + l) % 3)) {
|
|
12821
|
+
p += l;
|
|
12799
12822
|
continue;
|
|
12800
12823
|
}
|
|
12801
12824
|
if (h) break;
|
|
12802
12825
|
}
|
|
12803
|
-
if (a -=
|
|
12804
|
-
|
|
12805
|
-
let O = [...s[0]][0].length, g = e.slice(0,
|
|
12806
|
-
if (Math.min(
|
|
12807
|
-
let
|
|
12808
|
-
return { type: "em", raw: g, text:
|
|
12826
|
+
if (a -= l, a > 0) continue;
|
|
12827
|
+
l = Math.min(l, l + a + p);
|
|
12828
|
+
let O = [...s[0]][0].length, g = e.slice(0, o + s.index + O + l);
|
|
12829
|
+
if (Math.min(o, l) % 2) {
|
|
12830
|
+
let z = g.slice(1, -1);
|
|
12831
|
+
return { type: "em", raw: g, text: z, tokens: this.lexer.inlineTokens(z) };
|
|
12809
12832
|
}
|
|
12810
12833
|
let w = g.slice(2, -2);
|
|
12811
12834
|
return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
|
|
@@ -12827,16 +12850,16 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12827
12850
|
let s = this.rules.inline.delLDelim.exec(e);
|
|
12828
12851
|
if (!s) return;
|
|
12829
12852
|
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
12830
|
-
let
|
|
12831
|
-
for (p.lastIndex = 0, t = t.slice(-1 * e.length +
|
|
12832
|
-
if (
|
|
12853
|
+
let o = [...s[0]].length - 1, i, l, a = o, p = this.rules.inline.delRDelim;
|
|
12854
|
+
for (p.lastIndex = 0, t = t.slice(-1 * e.length + o); (s = p.exec(t)) !== null; ) {
|
|
12855
|
+
if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (l = [...i].length, l !== o)) continue;
|
|
12833
12856
|
if (s[3] || s[4]) {
|
|
12834
|
-
a +=
|
|
12857
|
+
a += l;
|
|
12835
12858
|
continue;
|
|
12836
12859
|
}
|
|
12837
|
-
if (a -=
|
|
12838
|
-
|
|
12839
|
-
let c = [...s[0]][0].length, h = e.slice(0,
|
|
12860
|
+
if (a -= l, a > 0) continue;
|
|
12861
|
+
l = Math.min(l, l + a);
|
|
12862
|
+
let c = [...s[0]][0].length, h = e.slice(0, o + s.index + c + l), d = h.slice(o, -o);
|
|
12840
12863
|
return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
|
|
12841
12864
|
}
|
|
12842
12865
|
}
|
|
@@ -12845,7 +12868,7 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12845
12868
|
let t = this.rules.inline.autolink.exec(e);
|
|
12846
12869
|
if (t) {
|
|
12847
12870
|
let n, s;
|
|
12848
|
-
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
12871
|
+
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
12849
12872
|
}
|
|
12850
12873
|
}
|
|
12851
12874
|
url(e) {
|
|
@@ -12860,7 +12883,7 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12860
12883
|
while (r !== t[0]);
|
|
12861
12884
|
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
12862
12885
|
}
|
|
12863
|
-
return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
12886
|
+
return { type: "link", raw: t[0], text: n, href: s, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
12864
12887
|
}
|
|
12865
12888
|
}
|
|
12866
12889
|
inlineText(e) {
|
|
@@ -12871,14 +12894,14 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
|
12871
12894
|
}
|
|
12872
12895
|
}
|
|
12873
12896
|
};
|
|
12874
|
-
var x = class
|
|
12897
|
+
var x = class u {
|
|
12875
12898
|
tokens;
|
|
12876
12899
|
options;
|
|
12877
12900
|
state;
|
|
12878
12901
|
inlineQueue;
|
|
12879
12902
|
tokenizer;
|
|
12880
12903
|
constructor(e) {
|
|
12881
|
-
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e ||
|
|
12904
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, top: true };
|
|
12882
12905
|
let t = { other: m, block: H.normal, inline: B.normal };
|
|
12883
12906
|
this.options.pedantic ? (t.block = H.pedantic, t.inline = B.pedantic) : this.options.gfm && (t.block = H.gfm, this.options.breaks ? t.inline = B.breaks : t.inline = B.gfm), this.tokenizer.rules = t;
|
|
12884
12907
|
}
|
|
@@ -12886,10 +12909,10 @@ var x = class l {
|
|
|
12886
12909
|
return { block: H, inline: B };
|
|
12887
12910
|
}
|
|
12888
12911
|
static lex(e, t) {
|
|
12889
|
-
return new
|
|
12912
|
+
return new u(t).lex(e);
|
|
12890
12913
|
}
|
|
12891
12914
|
static lexInline(e, t) {
|
|
12892
|
-
return new
|
|
12915
|
+
return new u(t).inlineTokens(e);
|
|
12893
12916
|
}
|
|
12894
12917
|
lex(e) {
|
|
12895
12918
|
e = e.replace(m.carriageReturn, `
|
|
@@ -12910,21 +12933,21 @@ var x = class l {
|
|
|
12910
12933
|
break;
|
|
12911
12934
|
}
|
|
12912
12935
|
let r;
|
|
12913
|
-
if (this.options.extensions?.block?.some((
|
|
12936
|
+
if (this.options.extensions?.block?.some((i) => (r = i.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
|
|
12914
12937
|
if (r = this.tokenizer.space(e)) {
|
|
12915
12938
|
e = e.substring(r.raw.length);
|
|
12916
|
-
let
|
|
12917
|
-
r.raw.length === 1 &&
|
|
12939
|
+
let i = t.at(-1);
|
|
12940
|
+
r.raw.length === 1 && i !== void 0 ? i.raw += `
|
|
12918
12941
|
` : t.push(r);
|
|
12919
12942
|
continue;
|
|
12920
12943
|
}
|
|
12921
12944
|
if (r = this.tokenizer.code(e)) {
|
|
12922
12945
|
e = e.substring(r.raw.length);
|
|
12923
|
-
let
|
|
12924
|
-
|
|
12946
|
+
let i = t.at(-1);
|
|
12947
|
+
i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
|
|
12925
12948
|
`) ? "" : `
|
|
12926
|
-
`) + r.raw,
|
|
12927
|
-
` + r.text, this.inlineQueue.at(-1).src =
|
|
12949
|
+
`) + r.raw, i.text += `
|
|
12950
|
+
` + r.text, this.inlineQueue.at(-1).src = i.text) : t.push(r);
|
|
12928
12951
|
continue;
|
|
12929
12952
|
}
|
|
12930
12953
|
if (r = this.tokenizer.fences(e)) {
|
|
@@ -12953,11 +12976,11 @@ var x = class l {
|
|
|
12953
12976
|
}
|
|
12954
12977
|
if (r = this.tokenizer.def(e)) {
|
|
12955
12978
|
e = e.substring(r.raw.length);
|
|
12956
|
-
let
|
|
12957
|
-
|
|
12979
|
+
let i = t.at(-1);
|
|
12980
|
+
i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
|
|
12958
12981
|
`) ? "" : `
|
|
12959
|
-
`) + r.raw,
|
|
12960
|
-
` + r.raw, this.inlineQueue.at(-1).src =
|
|
12982
|
+
`) + r.raw, i.text += `
|
|
12983
|
+
` + r.raw, this.inlineQueue.at(-1).src = i.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
|
|
12961
12984
|
continue;
|
|
12962
12985
|
}
|
|
12963
12986
|
if (r = this.tokenizer.table(e)) {
|
|
@@ -12968,28 +12991,28 @@ var x = class l {
|
|
|
12968
12991
|
e = e.substring(r.raw.length), t.push(r);
|
|
12969
12992
|
continue;
|
|
12970
12993
|
}
|
|
12971
|
-
let
|
|
12994
|
+
let o = e;
|
|
12972
12995
|
if (this.options.extensions?.startBlock) {
|
|
12973
|
-
let
|
|
12996
|
+
let i = 1 / 0, l = e.slice(1), a;
|
|
12974
12997
|
this.options.extensions.startBlock.forEach((p) => {
|
|
12975
|
-
a = p.call({ lexer: this },
|
|
12976
|
-
}),
|
|
12998
|
+
a = p.call({ lexer: this }, l), typeof a == "number" && a >= 0 && (i = Math.min(i, a));
|
|
12999
|
+
}), i < 1 / 0 && i >= 0 && (o = e.substring(0, i + 1));
|
|
12977
13000
|
}
|
|
12978
|
-
if (this.state.top && (r = this.tokenizer.paragraph(
|
|
12979
|
-
let
|
|
12980
|
-
n &&
|
|
13001
|
+
if (this.state.top && (r = this.tokenizer.paragraph(o))) {
|
|
13002
|
+
let i = t.at(-1);
|
|
13003
|
+
n && i?.type === "paragraph" ? (i.raw += (i.raw.endsWith(`
|
|
12981
13004
|
`) ? "" : `
|
|
12982
|
-
`) + r.raw,
|
|
12983
|
-
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src =
|
|
13005
|
+
`) + r.raw, i.text += `
|
|
13006
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : t.push(r), n = o.length !== e.length, e = e.substring(r.raw.length);
|
|
12984
13007
|
continue;
|
|
12985
13008
|
}
|
|
12986
13009
|
if (r = this.tokenizer.text(e)) {
|
|
12987
13010
|
e = e.substring(r.raw.length);
|
|
12988
|
-
let
|
|
12989
|
-
|
|
13011
|
+
let i = t.at(-1);
|
|
13012
|
+
i?.type === "text" ? (i.raw += (i.raw.endsWith(`
|
|
12990
13013
|
`) ? "" : `
|
|
12991
|
-
`) + r.raw,
|
|
12992
|
-
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src =
|
|
13014
|
+
`) + r.raw, i.text += `
|
|
13015
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : t.push(r);
|
|
12993
13016
|
continue;
|
|
12994
13017
|
}
|
|
12995
13018
|
if (e) {
|
|
@@ -13016,84 +13039,84 @@ var x = class l {
|
|
|
13016
13039
|
this.tokenizer.lexer = this;
|
|
13017
13040
|
let n = e;
|
|
13018
13041
|
if (this.tokens.links && e.includes("[")) {
|
|
13019
|
-
let
|
|
13042
|
+
let i = this.tokenizer.rules.inline.reflinkSearch, l = (a) => {
|
|
13020
13043
|
let p = a.lastIndexOf("[");
|
|
13021
13044
|
if (!Object.hasOwn(this.tokens.links, a.slice(p + 1, -1))) return a;
|
|
13022
13045
|
if (p > 1 && a.charAt(0) !== "!") {
|
|
13023
13046
|
let c = a.slice(1, p - 1);
|
|
13024
|
-
if (this.linkInText(c)) return "[" + c.replace(
|
|
13047
|
+
if (this.linkInText(c)) return "[" + c.replace(i, l) + "][" + "a".repeat(a.length - p - 2) + "]";
|
|
13025
13048
|
}
|
|
13026
13049
|
return "[" + "a".repeat(a.length - 2) + "]";
|
|
13027
13050
|
};
|
|
13028
|
-
n = n.replace(
|
|
13051
|
+
n = n.replace(i, l);
|
|
13029
13052
|
}
|
|
13030
|
-
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (
|
|
13053
|
+
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (i) => "+".repeat(i.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (i, l, a) => {
|
|
13031
13054
|
let p = a ? a.length : 0;
|
|
13032
|
-
return
|
|
13055
|
+
return i.slice(0, p) + "[" + "a".repeat(i.length - p - 2) + "]";
|
|
13033
13056
|
}), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
13034
|
-
let s = false, r = "",
|
|
13057
|
+
let s = false, r = "", o = 1 / 0;
|
|
13035
13058
|
for (; e; ) {
|
|
13036
|
-
if (e.length <
|
|
13059
|
+
if (e.length < o) o = e.length;
|
|
13037
13060
|
else {
|
|
13038
13061
|
this.infiniteLoopError(e.charCodeAt(0));
|
|
13039
13062
|
break;
|
|
13040
13063
|
}
|
|
13041
13064
|
s || (r = ""), s = false;
|
|
13042
|
-
let
|
|
13043
|
-
if (this.options.extensions?.inline?.some((a) => (
|
|
13044
|
-
if (
|
|
13045
|
-
e = e.substring(
|
|
13065
|
+
let i;
|
|
13066
|
+
if (this.options.extensions?.inline?.some((a) => (i = a.call({ lexer: this }, e, t)) ? (e = e.substring(i.raw.length), t.push(i), true) : false)) continue;
|
|
13067
|
+
if (i = this.tokenizer.escape(e)) {
|
|
13068
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13046
13069
|
continue;
|
|
13047
13070
|
}
|
|
13048
|
-
if (
|
|
13049
|
-
e = e.substring(
|
|
13071
|
+
if (i = this.tokenizer.tag(e)) {
|
|
13072
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13050
13073
|
continue;
|
|
13051
13074
|
}
|
|
13052
|
-
if (
|
|
13053
|
-
e = e.substring(
|
|
13075
|
+
if (i = this.tokenizer.link(e)) {
|
|
13076
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13054
13077
|
continue;
|
|
13055
13078
|
}
|
|
13056
|
-
if (
|
|
13057
|
-
e = e.substring(
|
|
13079
|
+
if (i = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
13080
|
+
e = e.substring(i.raw.length);
|
|
13058
13081
|
let a = t.at(-1);
|
|
13059
|
-
|
|
13082
|
+
i.type === "text" && a?.type === "text" ? (a.raw += i.raw, a.text += i.text) : t.push(i);
|
|
13060
13083
|
continue;
|
|
13061
13084
|
}
|
|
13062
|
-
if (
|
|
13063
|
-
e = e.substring(
|
|
13085
|
+
if (i = this.tokenizer.emStrong(e, n, r)) {
|
|
13086
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13064
13087
|
continue;
|
|
13065
13088
|
}
|
|
13066
|
-
if (
|
|
13067
|
-
e = e.substring(
|
|
13089
|
+
if (i = this.tokenizer.codespan(e)) {
|
|
13090
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13068
13091
|
continue;
|
|
13069
13092
|
}
|
|
13070
|
-
if (
|
|
13071
|
-
e = e.substring(
|
|
13093
|
+
if (i = this.tokenizer.br(e)) {
|
|
13094
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13072
13095
|
continue;
|
|
13073
13096
|
}
|
|
13074
|
-
if (
|
|
13075
|
-
e = e.substring(
|
|
13097
|
+
if (i = this.tokenizer.del(e, n, r)) {
|
|
13098
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13076
13099
|
continue;
|
|
13077
13100
|
}
|
|
13078
|
-
if (
|
|
13079
|
-
e = e.substring(
|
|
13101
|
+
if (i = this.tokenizer.autolink(e)) {
|
|
13102
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13080
13103
|
continue;
|
|
13081
13104
|
}
|
|
13082
|
-
if (!this.state.inLink && (
|
|
13083
|
-
e = e.substring(
|
|
13105
|
+
if (!this.state.inLink && (i = this.tokenizer.url(e))) {
|
|
13106
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
13084
13107
|
continue;
|
|
13085
13108
|
}
|
|
13086
|
-
let
|
|
13109
|
+
let l = e;
|
|
13087
13110
|
if (this.options.extensions?.startInline) {
|
|
13088
13111
|
let a = 1 / 0, p = e.slice(1), c;
|
|
13089
13112
|
this.options.extensions.startInline.forEach((h) => {
|
|
13090
13113
|
c = h.call({ lexer: this }, p), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
|
|
13091
|
-
}), a < 1 / 0 && a >= 0 && (
|
|
13114
|
+
}), a < 1 / 0 && a >= 0 && (l = e.substring(0, a + 1));
|
|
13092
13115
|
}
|
|
13093
|
-
if (
|
|
13094
|
-
e = e.substring(
|
|
13116
|
+
if (i = this.tokenizer.inlineText(l)) {
|
|
13117
|
+
e = e.substring(i.raw.length), i.raw.slice(-1) !== "_" && (r = i.raw.slice(-1)), s = true;
|
|
13095
13118
|
let a = t.at(-1);
|
|
13096
|
-
a?.type === "text" ? (a.raw +=
|
|
13119
|
+
a?.type === "text" ? (a.raw += i.raw, a.text += i.text) : t.push(i);
|
|
13097
13120
|
continue;
|
|
13098
13121
|
}
|
|
13099
13122
|
if (e) {
|
|
@@ -13113,16 +13136,16 @@ var P = class {
|
|
|
13113
13136
|
options;
|
|
13114
13137
|
parser;
|
|
13115
13138
|
constructor(e) {
|
|
13116
|
-
this.options = e ||
|
|
13139
|
+
this.options = e || T;
|
|
13117
13140
|
}
|
|
13118
13141
|
space(e) {
|
|
13119
13142
|
return "";
|
|
13120
13143
|
}
|
|
13121
13144
|
code({ text: e, lang: t, escaped: n }) {
|
|
13122
|
-
let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
|
|
13123
|
-
|
|
13124
|
-
return s ? '<pre><code class="language-' +
|
|
13125
|
-
` : "<pre><code>" + (n ? r :
|
|
13145
|
+
let s = (t || "").match(m.notSpaceStart)?.[0], r = e ? e.replace(m.endingNewline, "") + `
|
|
13146
|
+
` : "";
|
|
13147
|
+
return s ? '<pre><code class="language-' + R(s) + '">' + (n ? r : R(r, true)) + `</code></pre>
|
|
13148
|
+
` : "<pre><code>" + (n ? r : R(r, true)) + `</code></pre>
|
|
13126
13149
|
`;
|
|
13127
13150
|
}
|
|
13128
13151
|
blockquote({ tokens: e }) {
|
|
@@ -13146,12 +13169,12 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
13146
13169
|
}
|
|
13147
13170
|
list(e) {
|
|
13148
13171
|
let t = e.ordered, n = e.start, s = "";
|
|
13149
|
-
for (let
|
|
13150
|
-
let
|
|
13151
|
-
s += this.listitem(
|
|
13172
|
+
for (let i = 0; i < e.items.length; i++) {
|
|
13173
|
+
let l = e.items[i];
|
|
13174
|
+
s += this.listitem(l);
|
|
13152
13175
|
}
|
|
13153
|
-
let r = t ? "ol" : "ul",
|
|
13154
|
-
return "<" + r +
|
|
13176
|
+
let r = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
13177
|
+
return "<" + r + o + `>
|
|
13155
13178
|
` + s + "</" + r + `>
|
|
13156
13179
|
`;
|
|
13157
13180
|
}
|
|
@@ -13172,9 +13195,9 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
13172
13195
|
t += this.tablerow({ text: n });
|
|
13173
13196
|
let s = "";
|
|
13174
13197
|
for (let r = 0; r < e.rows.length; r++) {
|
|
13175
|
-
let
|
|
13198
|
+
let o = e.rows[r];
|
|
13176
13199
|
n = "";
|
|
13177
|
-
for (let
|
|
13200
|
+
for (let i = 0; i < o.length; i++) n += this.tablecell(o[i]);
|
|
13178
13201
|
s += this.tablerow({ text: n });
|
|
13179
13202
|
}
|
|
13180
13203
|
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
@@ -13200,7 +13223,7 @@ ${e}</tr>
|
|
|
13200
13223
|
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
13201
13224
|
}
|
|
13202
13225
|
codespan({ text: e }) {
|
|
13203
|
-
return `<code>${
|
|
13226
|
+
return `<code>${R(e, true)}</code>`;
|
|
13204
13227
|
}
|
|
13205
13228
|
br(e) {
|
|
13206
13229
|
return "<br>";
|
|
@@ -13208,23 +13231,23 @@ ${e}</tr>
|
|
|
13208
13231
|
del({ tokens: e }) {
|
|
13209
13232
|
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
13210
13233
|
}
|
|
13211
|
-
link({ href: e, title: t,
|
|
13212
|
-
let
|
|
13213
|
-
if (
|
|
13214
|
-
e = r;
|
|
13215
|
-
let
|
|
13216
|
-
return t && (
|
|
13234
|
+
link({ href: e, title: t, text: n, tokens: s, autolink: r }) {
|
|
13235
|
+
let o = r ? R(n, true) : this.parser.parseInline(s), i = Y(e);
|
|
13236
|
+
if (i === null) return o;
|
|
13237
|
+
e = R(i, r);
|
|
13238
|
+
let l = '<a href="' + e + '"';
|
|
13239
|
+
return t && (l += ' title="' + R(t) + '"'), l += ">" + o + "</a>", l;
|
|
13217
13240
|
}
|
|
13218
13241
|
image({ href: e, title: t, text: n, tokens: s }) {
|
|
13219
13242
|
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
13220
13243
|
let r = Y(e);
|
|
13221
|
-
if (r === null) return
|
|
13244
|
+
if (r === null) return R(n);
|
|
13222
13245
|
e = r;
|
|
13223
|
-
let
|
|
13224
|
-
return t && (
|
|
13246
|
+
let o = `<img src="${R(e)}" alt="${R(n)}"`;
|
|
13247
|
+
return t && (o += ` title="${R(t)}"`), o += ">", o;
|
|
13225
13248
|
}
|
|
13226
13249
|
text(e) {
|
|
13227
|
-
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text :
|
|
13250
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : R(e.text);
|
|
13228
13251
|
}
|
|
13229
13252
|
};
|
|
13230
13253
|
var L = class {
|
|
@@ -13259,18 +13282,18 @@ var L = class {
|
|
|
13259
13282
|
return e;
|
|
13260
13283
|
}
|
|
13261
13284
|
};
|
|
13262
|
-
var b = class
|
|
13285
|
+
var b = class u2 {
|
|
13263
13286
|
options;
|
|
13264
13287
|
renderer;
|
|
13265
13288
|
textRenderer;
|
|
13266
13289
|
constructor(e) {
|
|
13267
|
-
this.options = e ||
|
|
13290
|
+
this.options = e || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
|
|
13268
13291
|
}
|
|
13269
13292
|
static parse(e, t) {
|
|
13270
|
-
return new
|
|
13293
|
+
return new u2(t).parse(e);
|
|
13271
13294
|
}
|
|
13272
13295
|
static parseInline(e, t) {
|
|
13273
|
-
return new
|
|
13296
|
+
return new u2(t).parseInline(e);
|
|
13274
13297
|
}
|
|
13275
13298
|
parse(e) {
|
|
13276
13299
|
this.renderer.parser = this;
|
|
@@ -13278,9 +13301,9 @@ var b = class l2 {
|
|
|
13278
13301
|
for (let n = 0; n < e.length; n++) {
|
|
13279
13302
|
let s = e[n];
|
|
13280
13303
|
if (this.options.extensions?.renderers?.[s.type]) {
|
|
13281
|
-
let
|
|
13282
|
-
if (
|
|
13283
|
-
t +=
|
|
13304
|
+
let o = s, i = this.options.extensions.renderers[o.type].call({ parser: this }, o);
|
|
13305
|
+
if (i !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(o.type)) {
|
|
13306
|
+
t += i || "";
|
|
13284
13307
|
continue;
|
|
13285
13308
|
}
|
|
13286
13309
|
}
|
|
@@ -13335,9 +13358,9 @@ var b = class l2 {
|
|
|
13335
13358
|
break;
|
|
13336
13359
|
}
|
|
13337
13360
|
default: {
|
|
13338
|
-
let
|
|
13339
|
-
if (this.options.silent) return console.error(
|
|
13340
|
-
throw new Error(
|
|
13361
|
+
let o = 'Token with "' + r.type + '" type was not found.';
|
|
13362
|
+
if (this.options.silent) return console.error(o), "";
|
|
13363
|
+
throw new Error(o);
|
|
13341
13364
|
}
|
|
13342
13365
|
}
|
|
13343
13366
|
}
|
|
@@ -13349,62 +13372,62 @@ var b = class l2 {
|
|
|
13349
13372
|
for (let s = 0; s < e.length; s++) {
|
|
13350
13373
|
let r = e[s];
|
|
13351
13374
|
if (this.options.extensions?.renderers?.[r.type]) {
|
|
13352
|
-
let
|
|
13353
|
-
if (
|
|
13354
|
-
n +=
|
|
13375
|
+
let i = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
13376
|
+
if (i !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
13377
|
+
n += i || "";
|
|
13355
13378
|
continue;
|
|
13356
13379
|
}
|
|
13357
13380
|
}
|
|
13358
|
-
let
|
|
13359
|
-
switch (
|
|
13381
|
+
let o = r;
|
|
13382
|
+
switch (o.type) {
|
|
13360
13383
|
case "escape": {
|
|
13361
|
-
n += t.text(
|
|
13384
|
+
n += t.text(o);
|
|
13362
13385
|
break;
|
|
13363
13386
|
}
|
|
13364
13387
|
case "html": {
|
|
13365
|
-
n += t.html(
|
|
13388
|
+
n += t.html(o);
|
|
13366
13389
|
break;
|
|
13367
13390
|
}
|
|
13368
13391
|
case "link": {
|
|
13369
|
-
n += t.link(
|
|
13392
|
+
n += t.link(o);
|
|
13370
13393
|
break;
|
|
13371
13394
|
}
|
|
13372
13395
|
case "image": {
|
|
13373
|
-
n += t.image(
|
|
13396
|
+
n += t.image(o);
|
|
13374
13397
|
break;
|
|
13375
13398
|
}
|
|
13376
13399
|
case "checkbox": {
|
|
13377
|
-
n += t.checkbox(
|
|
13400
|
+
n += t.checkbox(o);
|
|
13378
13401
|
break;
|
|
13379
13402
|
}
|
|
13380
13403
|
case "strong": {
|
|
13381
|
-
n += t.strong(
|
|
13404
|
+
n += t.strong(o);
|
|
13382
13405
|
break;
|
|
13383
13406
|
}
|
|
13384
13407
|
case "em": {
|
|
13385
|
-
n += t.em(
|
|
13408
|
+
n += t.em(o);
|
|
13386
13409
|
break;
|
|
13387
13410
|
}
|
|
13388
13411
|
case "codespan": {
|
|
13389
|
-
n += t.codespan(
|
|
13412
|
+
n += t.codespan(o);
|
|
13390
13413
|
break;
|
|
13391
13414
|
}
|
|
13392
13415
|
case "br": {
|
|
13393
|
-
n += t.br(
|
|
13416
|
+
n += t.br(o);
|
|
13394
13417
|
break;
|
|
13395
13418
|
}
|
|
13396
13419
|
case "del": {
|
|
13397
|
-
n += t.del(
|
|
13420
|
+
n += t.del(o);
|
|
13398
13421
|
break;
|
|
13399
13422
|
}
|
|
13400
13423
|
case "text": {
|
|
13401
|
-
n += t.text(
|
|
13424
|
+
n += t.text(o);
|
|
13402
13425
|
break;
|
|
13403
13426
|
}
|
|
13404
13427
|
default: {
|
|
13405
|
-
let
|
|
13406
|
-
if (this.options.silent) return console.error(
|
|
13407
|
-
throw new Error(
|
|
13428
|
+
let i = 'Token with "' + o.type + '" type was not found.';
|
|
13429
|
+
if (this.options.silent) return console.error(i), "";
|
|
13430
|
+
throw new Error(i);
|
|
13408
13431
|
}
|
|
13409
13432
|
}
|
|
13410
13433
|
}
|
|
@@ -13415,7 +13438,7 @@ var S = class {
|
|
|
13415
13438
|
options;
|
|
13416
13439
|
block;
|
|
13417
13440
|
constructor(e) {
|
|
13418
|
-
this.options = e ||
|
|
13441
|
+
this.options = e || T;
|
|
13419
13442
|
}
|
|
13420
13443
|
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
13421
13444
|
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
@@ -13457,8 +13480,8 @@ var Z = class {
|
|
|
13457
13480
|
for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
|
|
13458
13481
|
case "table": {
|
|
13459
13482
|
let r = s;
|
|
13460
|
-
for (let
|
|
13461
|
-
for (let
|
|
13483
|
+
for (let o of r.header) n = n.concat(this.walkTokens(o.tokens, t));
|
|
13484
|
+
for (let o of r.rows) for (let i of o) n = n.concat(this.walkTokens(i.tokens, t));
|
|
13462
13485
|
break;
|
|
13463
13486
|
}
|
|
13464
13487
|
case "list": {
|
|
@@ -13468,9 +13491,9 @@ var Z = class {
|
|
|
13468
13491
|
}
|
|
13469
13492
|
default: {
|
|
13470
13493
|
let r = s;
|
|
13471
|
-
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((
|
|
13472
|
-
let
|
|
13473
|
-
n = n.concat(this.walkTokens(
|
|
13494
|
+
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((o) => {
|
|
13495
|
+
let i = r[o].flat(1 / 0);
|
|
13496
|
+
n = n.concat(this.walkTokens(i, t));
|
|
13474
13497
|
}) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
|
|
13475
13498
|
}
|
|
13476
13499
|
}
|
|
@@ -13483,26 +13506,26 @@ var Z = class {
|
|
|
13483
13506
|
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
13484
13507
|
if (!r.name) throw new Error("extension name required");
|
|
13485
13508
|
if ("renderer" in r) {
|
|
13486
|
-
let
|
|
13487
|
-
|
|
13488
|
-
let
|
|
13489
|
-
return
|
|
13509
|
+
let o = t.renderers[r.name];
|
|
13510
|
+
o ? t.renderers[r.name] = function(...i) {
|
|
13511
|
+
let l = r.renderer.apply(this, i);
|
|
13512
|
+
return l === false && (l = o.apply(this, i)), l;
|
|
13490
13513
|
} : t.renderers[r.name] = r.renderer;
|
|
13491
13514
|
}
|
|
13492
13515
|
if ("tokenizer" in r) {
|
|
13493
13516
|
if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
13494
|
-
let
|
|
13495
|
-
|
|
13517
|
+
let o = t[r.level];
|
|
13518
|
+
o ? o.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
13496
13519
|
}
|
|
13497
13520
|
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
13498
13521
|
}), s.extensions = t), n.renderer) {
|
|
13499
13522
|
let r = this.defaults.renderer || new P(this.defaults);
|
|
13500
|
-
for (let
|
|
13501
|
-
if (!(
|
|
13502
|
-
if (["options", "parser"].includes(
|
|
13503
|
-
let
|
|
13504
|
-
r[
|
|
13505
|
-
let c =
|
|
13523
|
+
for (let o in n.renderer) {
|
|
13524
|
+
if (!(o in r)) throw new Error(`renderer '${o}' does not exist`);
|
|
13525
|
+
if (["options", "parser"].includes(o)) continue;
|
|
13526
|
+
let i = o, l = n.renderer[i], a = r[i];
|
|
13527
|
+
r[i] = (...p) => {
|
|
13528
|
+
let c = l.apply(r, p);
|
|
13506
13529
|
return c === false && (c = a.apply(r, p)), c || "";
|
|
13507
13530
|
};
|
|
13508
13531
|
}
|
|
@@ -13510,12 +13533,12 @@ var Z = class {
|
|
|
13510
13533
|
}
|
|
13511
13534
|
if (n.tokenizer) {
|
|
13512
13535
|
let r = this.defaults.tokenizer || new y(this.defaults);
|
|
13513
|
-
for (let
|
|
13514
|
-
if (!(
|
|
13515
|
-
if (["options", "rules", "lexer"].includes(
|
|
13516
|
-
let
|
|
13517
|
-
r[
|
|
13518
|
-
let c =
|
|
13536
|
+
for (let o in n.tokenizer) {
|
|
13537
|
+
if (!(o in r)) throw new Error(`tokenizer '${o}' does not exist`);
|
|
13538
|
+
if (["options", "rules", "lexer"].includes(o)) continue;
|
|
13539
|
+
let i = o, l = n.tokenizer[i], a = r[i];
|
|
13540
|
+
r[i] = (...p) => {
|
|
13541
|
+
let c = l.apply(r, p);
|
|
13519
13542
|
return c === false && (c = a.apply(r, p)), c;
|
|
13520
13543
|
};
|
|
13521
13544
|
}
|
|
@@ -13523,33 +13546,33 @@ var Z = class {
|
|
|
13523
13546
|
}
|
|
13524
13547
|
if (n.hooks) {
|
|
13525
13548
|
let r = this.defaults.hooks || new S();
|
|
13526
|
-
for (let
|
|
13527
|
-
if (!(
|
|
13528
|
-
if (["options", "block"].includes(
|
|
13529
|
-
let
|
|
13530
|
-
S.passThroughHooks.has(
|
|
13531
|
-
if (this.defaults.async && S.passThroughHooksRespectAsync.has(
|
|
13532
|
-
let h = await
|
|
13549
|
+
for (let o in n.hooks) {
|
|
13550
|
+
if (!(o in r)) throw new Error(`hook '${o}' does not exist`);
|
|
13551
|
+
if (["options", "block"].includes(o)) continue;
|
|
13552
|
+
let i = o, l = n.hooks[i], a = r[i];
|
|
13553
|
+
S.passThroughHooks.has(o) ? r[i] = (p) => {
|
|
13554
|
+
if (this.defaults.async && S.passThroughHooksRespectAsync.has(o)) return (async () => {
|
|
13555
|
+
let h = await l.call(r, p);
|
|
13533
13556
|
return a.call(r, h);
|
|
13534
13557
|
})();
|
|
13535
|
-
let c =
|
|
13558
|
+
let c = l.call(r, p);
|
|
13536
13559
|
return a.call(r, c);
|
|
13537
|
-
} : r[
|
|
13560
|
+
} : r[i] = (...p) => {
|
|
13538
13561
|
if (this.defaults.async) return (async () => {
|
|
13539
|
-
let h = await
|
|
13562
|
+
let h = await l.apply(r, p);
|
|
13540
13563
|
return h === false && (h = await a.apply(r, p)), h;
|
|
13541
13564
|
})();
|
|
13542
|
-
let c =
|
|
13565
|
+
let c = l.apply(r, p);
|
|
13543
13566
|
return c === false && (c = a.apply(r, p)), c;
|
|
13544
13567
|
};
|
|
13545
13568
|
}
|
|
13546
13569
|
s.hooks = r;
|
|
13547
13570
|
}
|
|
13548
13571
|
if (n.walkTokens) {
|
|
13549
|
-
let r = this.defaults.walkTokens,
|
|
13550
|
-
s.walkTokens = function(
|
|
13551
|
-
let
|
|
13552
|
-
return
|
|
13572
|
+
let r = this.defaults.walkTokens, o = n.walkTokens;
|
|
13573
|
+
s.walkTokens = function(i) {
|
|
13574
|
+
let l = [];
|
|
13575
|
+
return l.push(o.call(this, i)), r && (l = l.concat(r.call(this, i))), l;
|
|
13553
13576
|
};
|
|
13554
13577
|
}
|
|
13555
13578
|
this.defaults = { ...this.defaults, ...s };
|
|
@@ -13566,24 +13589,24 @@ var Z = class {
|
|
|
13566
13589
|
}
|
|
13567
13590
|
parseMarkdown(e) {
|
|
13568
13591
|
return (n, s) => {
|
|
13569
|
-
let r = { ...s },
|
|
13570
|
-
if (this.defaults.async === true && r.async === false) return
|
|
13571
|
-
if (typeof n > "u" || n === null) return
|
|
13572
|
-
if (typeof n != "string") return
|
|
13573
|
-
if (
|
|
13574
|
-
let
|
|
13575
|
-
|
|
13576
|
-
let d = await (
|
|
13577
|
-
return
|
|
13578
|
-
})().catch(
|
|
13592
|
+
let r = { ...s }, o = { ...this.defaults, ...r }, i = this.onError(!!o.silent, !!o.async);
|
|
13593
|
+
if (this.defaults.async === true && r.async === false) return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
13594
|
+
if (typeof n > "u" || n === null) return i(new Error("marked(): input parameter is undefined or null"));
|
|
13595
|
+
if (typeof n != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
13596
|
+
if (o.hooks && (o.hooks.options = o, o.hooks.block = e), o.async) return (async () => {
|
|
13597
|
+
let l = o.hooks ? await o.hooks.preprocess(n) : n, p = await (o.hooks ? await o.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(l, o), c = o.hooks ? await o.hooks.processAllTokens(p) : p;
|
|
13598
|
+
o.walkTokens && await Promise.all(this.walkTokens(c, o.walkTokens));
|
|
13599
|
+
let d = await (o.hooks ? await o.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, o);
|
|
13600
|
+
return o.hooks ? await o.hooks.postprocess(d) : d;
|
|
13601
|
+
})().catch(i);
|
|
13579
13602
|
try {
|
|
13580
|
-
|
|
13581
|
-
let a = (
|
|
13582
|
-
|
|
13583
|
-
let c = (
|
|
13584
|
-
return
|
|
13585
|
-
} catch (
|
|
13586
|
-
return
|
|
13603
|
+
o.hooks && (n = o.hooks.preprocess(n));
|
|
13604
|
+
let a = (o.hooks ? o.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, o);
|
|
13605
|
+
o.hooks && (a = o.hooks.processAllTokens(a)), o.walkTokens && this.walkTokens(a, o.walkTokens);
|
|
13606
|
+
let c = (o.hooks ? o.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, o);
|
|
13607
|
+
return o.hooks && (c = o.hooks.postprocess(c)), c;
|
|
13608
|
+
} catch (l) {
|
|
13609
|
+
return i(l);
|
|
13587
13610
|
}
|
|
13588
13611
|
};
|
|
13589
13612
|
}
|
|
@@ -13591,7 +13614,7 @@ var Z = class {
|
|
|
13591
13614
|
return (n) => {
|
|
13592
13615
|
if (n.message += `
|
|
13593
13616
|
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
13594
|
-
let s = "<p>An error occurred:</p><pre>" +
|
|
13617
|
+
let s = "<p>An error occurred:</p><pre>" + R(n.message + "", true) + "</pre>";
|
|
13595
13618
|
return t ? Promise.resolve(s) : s;
|
|
13596
13619
|
}
|
|
13597
13620
|
if (t) return Promise.reject(n);
|
|
@@ -13600,20 +13623,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
13600
13623
|
}
|
|
13601
13624
|
};
|
|
13602
13625
|
var M = new Z();
|
|
13603
|
-
function f(
|
|
13604
|
-
return M.parse(
|
|
13626
|
+
function f(u3, e) {
|
|
13627
|
+
return M.parse(u3, e);
|
|
13605
13628
|
}
|
|
13606
|
-
f.options = f.setOptions = function(
|
|
13607
|
-
return M.setOptions(
|
|
13629
|
+
f.options = f.setOptions = function(u3) {
|
|
13630
|
+
return M.setOptions(u3), f.defaults = M.defaults, j(f.defaults), f;
|
|
13608
13631
|
};
|
|
13609
13632
|
f.getDefaults = A;
|
|
13610
|
-
f.defaults =
|
|
13611
|
-
function
|
|
13612
|
-
return M.use(...
|
|
13633
|
+
f.defaults = T;
|
|
13634
|
+
function gt(...u3) {
|
|
13635
|
+
return M.use(...u3), f.defaults = M.defaults, j(f.defaults), f;
|
|
13613
13636
|
}
|
|
13614
|
-
f.use =
|
|
13615
|
-
f.walkTokens = function(
|
|
13616
|
-
return M.walkTokens(
|
|
13637
|
+
f.use = gt;
|
|
13638
|
+
f.walkTokens = function(u3, e) {
|
|
13639
|
+
return M.walkTokens(u3, e);
|
|
13617
13640
|
};
|
|
13618
13641
|
f.parseInline = M.parseInline;
|
|
13619
13642
|
f.Parser = b;
|
|
@@ -13625,12 +13648,12 @@ f.lexer = x.lex;
|
|
|
13625
13648
|
f.Tokenizer = y;
|
|
13626
13649
|
f.Hooks = S;
|
|
13627
13650
|
f.parse = f;
|
|
13628
|
-
var
|
|
13629
|
-
var
|
|
13630
|
-
var
|
|
13631
|
-
var
|
|
13632
|
-
var
|
|
13633
|
-
var
|
|
13651
|
+
var rn = f.options;
|
|
13652
|
+
var sn = f.setOptions;
|
|
13653
|
+
var on = f.walkTokens;
|
|
13654
|
+
var an = f.parseInline;
|
|
13655
|
+
var un = b.parse;
|
|
13656
|
+
var pn = x.lex;
|
|
13634
13657
|
|
|
13635
13658
|
// src/ui/transcript/render_markdown.ts
|
|
13636
13659
|
var parser = new Z({ gfm: true, breaks: true });
|
|
@@ -14508,6 +14531,9 @@ import {
|
|
|
14508
14531
|
buildResumeArray,
|
|
14509
14532
|
randomUUID as randomUUID4
|
|
14510
14533
|
} from "@ag-ui/client";
|
|
14534
|
+
import {
|
|
14535
|
+
contentToText as contentToText2
|
|
14536
|
+
} from "@ag-ui/core";
|
|
14511
14537
|
var ConnectionLostError = class extends Error {
|
|
14512
14538
|
constructor(message) {
|
|
14513
14539
|
super(message);
|
|
@@ -14528,29 +14554,6 @@ var AgUiClient = class {
|
|
|
14528
14554
|
* set would miss entirely.
|
|
14529
14555
|
*/
|
|
14530
14556
|
#closedMessageIds = /* @__PURE__ */ new Set();
|
|
14531
|
-
/**
|
|
14532
|
-
* How each tool call ended, keyed by call id, for the transcript this client
|
|
14533
|
-
* persists.
|
|
14534
|
-
*
|
|
14535
|
-
* A side table rather than a field written onto the message, because neither
|
|
14536
|
-
* producer of a tool message will carry it. `@ag-ui/client` builds the
|
|
14537
|
-
* server-side one by destructuring five named fields off the event, so an
|
|
14538
|
-
* `outcome` beside them is dropped before the message exists; and writing it
|
|
14539
|
-
* back onto that message afterwards would put it in `agent.messages`, which is
|
|
14540
|
-
* what the *next* request sends to the server. This keeps the annotation on
|
|
14541
|
-
* the copy handed to the store and off the wire.
|
|
14542
|
-
*
|
|
14543
|
-
* Per client, not per run: `saveMessages` rewrites the whole transcript on
|
|
14544
|
-
* every persist, so an outcome recorded in round one has to still be here in
|
|
14545
|
-
* round five or the earlier card silently reverts to a green one. Bounded by
|
|
14546
|
-
* the number of tool calls in the conversation, which the transcript beside it
|
|
14547
|
-
* already is.
|
|
14548
|
-
*
|
|
14549
|
-
* Values are `unknown` because a restored seed fills it too (see
|
|
14550
|
-
* {@link #adoptSeededOutcomes}), and a store is not trusted to hold only the
|
|
14551
|
-
* words this class writes: whatever it held is written back as it was.
|
|
14552
|
-
*/
|
|
14553
|
-
#outcomes = /* @__PURE__ */ new Map();
|
|
14554
14557
|
#connectionLostMessage;
|
|
14555
14558
|
#unfinishedMessage;
|
|
14556
14559
|
#declinedMessage;
|
|
@@ -14572,7 +14575,7 @@ var AgUiClient = class {
|
|
|
14572
14575
|
this.#declinedMessage = config.declinedMessage ?? "User declined the action.";
|
|
14573
14576
|
const rounds = config.maxToolRounds ?? MAX_TOOL_ROUNDS;
|
|
14574
14577
|
this.#maxToolRounds = rounds >= 1 ? Math.floor(rounds) : MAX_TOOL_ROUNDS;
|
|
14575
|
-
this.#
|
|
14578
|
+
this.#moveSeededKeysIntoMetadata();
|
|
14576
14579
|
const onStateChanged = config.onStateChanged;
|
|
14577
14580
|
if (onStateChanged !== void 0) {
|
|
14578
14581
|
this.#agent.subscribe({
|
|
@@ -14606,15 +14609,18 @@ var AgUiClient = class {
|
|
|
14606
14609
|
* tools (bounded by {@link AgUiClientConfig.maxToolRounds}, which defaults to
|
|
14607
14610
|
* {@link MAX_TOOL_ROUNDS}).
|
|
14608
14611
|
*
|
|
14609
|
-
* `attachments` ride
|
|
14610
|
-
*
|
|
14612
|
+
* `attachments` ride in the user message's `metadata`, under
|
|
14613
|
+
* `attachments`, which is how the server learns which files the agent can
|
|
14614
|
+
* read and how the default store round-trips them for history replay; see
|
|
14611
14615
|
* {@link messageAttachments}.
|
|
14612
14616
|
*/
|
|
14613
14617
|
async send(content, attachments = []) {
|
|
14614
|
-
const message = {
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14618
|
+
const message = {
|
|
14619
|
+
id: randomUUID4(),
|
|
14620
|
+
role: "user",
|
|
14621
|
+
content,
|
|
14622
|
+
...attachments.length > 0 ? { metadata: { attachments } } : {}
|
|
14623
|
+
};
|
|
14618
14624
|
this.#agent.addMessage(message);
|
|
14619
14625
|
this.#persist();
|
|
14620
14626
|
await this.#run();
|
|
@@ -14700,36 +14706,31 @@ var AgUiClient = class {
|
|
|
14700
14706
|
this.#handlers.onCancelled();
|
|
14701
14707
|
}
|
|
14702
14708
|
/**
|
|
14703
|
-
* Move the
|
|
14704
|
-
* messages
|
|
14709
|
+
* Move the keys a history stored by an earlier release carries at the top
|
|
14710
|
+
* level of its messages into their `metadata`, where this release writes them.
|
|
14705
14711
|
*
|
|
14706
|
-
*
|
|
14707
|
-
*
|
|
14708
|
-
*
|
|
14709
|
-
*
|
|
14710
|
-
*
|
|
14711
|
-
*
|
|
14712
|
+
* Earlier releases wrote a tool message's `outcome` and a user message's
|
|
14713
|
+
* `attachments` beside the protocol's own fields. `@ag-ui/client` 1.0 strips
|
|
14714
|
+
* every undeclared key from the input it sends, so a restored conversation
|
|
14715
|
+
* sent as it was stored would lose both on its first request: the server
|
|
14716
|
+
* would no longer be told about any file attached before the upgrade, and
|
|
14717
|
+
* each strip would print a warning. Moved rather than dropped, so the next
|
|
14718
|
+
* save writes the conversation in the shape this release reads first and a
|
|
14719
|
+
* reload after it still replays a declined card as declined.
|
|
14712
14720
|
*
|
|
14713
|
-
*
|
|
14714
|
-
*
|
|
14715
|
-
*
|
|
14716
|
-
*
|
|
14721
|
+
* Merged into the metadata a message already has, with a key already there
|
|
14722
|
+
* winning: a message carrying both was last written by the newer writer.
|
|
14723
|
+
* `ag_ui_chat_restored_outcome_wire.test.ts` reads the result off the body of
|
|
14724
|
+
* a real request. The check before `setMessages` only spares a copy when
|
|
14725
|
+
* nothing moves, which is every restore of a store this release wrote;
|
|
14726
|
+
* nothing observable depends on it.
|
|
14717
14727
|
*/
|
|
14718
|
-
#
|
|
14728
|
+
#moveSeededKeysIntoMetadata() {
|
|
14719
14729
|
const seeded = this.#agent.messages;
|
|
14720
|
-
|
|
14721
|
-
|
|
14730
|
+
const moved = seeded.map(withTopLevelKeysInMetadata);
|
|
14731
|
+
if (moved.some((message, index) => message !== seeded[index])) {
|
|
14732
|
+
this.#agent.setMessages(moved);
|
|
14722
14733
|
}
|
|
14723
|
-
this.#agent.setMessages(
|
|
14724
|
-
seeded.map((message) => {
|
|
14725
|
-
if (message.role !== "tool") {
|
|
14726
|
-
return message;
|
|
14727
|
-
}
|
|
14728
|
-
const { outcome, ...wire } = message;
|
|
14729
|
-
this.#outcomes.set(message.toolCallId, outcome);
|
|
14730
|
-
return wire;
|
|
14731
|
-
})
|
|
14732
|
-
);
|
|
14733
14734
|
}
|
|
14734
14735
|
/**
|
|
14735
14736
|
* Give every tool call in history a result, before a request carries it.
|
|
@@ -14746,17 +14747,21 @@ var AgUiClient = class {
|
|
|
14746
14747
|
* approval runs or denies them server-side, and a result here would answer
|
|
14747
14748
|
* them twice.
|
|
14748
14749
|
*
|
|
14749
|
-
* The
|
|
14750
|
-
*
|
|
14750
|
+
* The outcome rides in the result's `metadata`, where the client folds a
|
|
14751
|
+
* server's own, so the next request carries it and a reload replays it. A
|
|
14752
|
+
* server that does not read it ignores it: `metadata` is a declared field.
|
|
14751
14753
|
*/
|
|
14752
14754
|
#answerUnansweredCalls(resuming) {
|
|
14753
14755
|
const messages = this.#agent.messages;
|
|
14754
14756
|
const answered = answerUnansweredCalls(
|
|
14755
14757
|
messages,
|
|
14756
|
-
(toolCallId) => {
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14758
|
+
(toolCallId) => ({
|
|
14759
|
+
id: randomUUID4(),
|
|
14760
|
+
role: "tool",
|
|
14761
|
+
content: this.#unfinishedMessage,
|
|
14762
|
+
toolCallId,
|
|
14763
|
+
metadata: { outcome: TOOL_OUTCOME.INTERRUPTED }
|
|
14764
|
+
}),
|
|
14760
14765
|
resuming
|
|
14761
14766
|
);
|
|
14762
14767
|
if (answered !== messages) {
|
|
@@ -14783,51 +14788,43 @@ var AgUiClient = class {
|
|
|
14783
14788
|
for (const interrupt of interrupts) {
|
|
14784
14789
|
const toolCallId = interrupt.toolCallId;
|
|
14785
14790
|
if (toolCallId !== void 0 && responses[interrupt.id]?.status === "cancelled") {
|
|
14786
|
-
this.#outcomes.set(toolCallId, TOOL_OUTCOME.DENIED);
|
|
14787
14791
|
this.#agent.addMessage({
|
|
14788
14792
|
id: randomUUID4(),
|
|
14789
14793
|
role: "tool",
|
|
14790
14794
|
content: this.#declinedMessage,
|
|
14791
|
-
toolCallId
|
|
14795
|
+
toolCallId,
|
|
14796
|
+
metadata: { outcome: TOOL_OUTCOME.DENIED }
|
|
14792
14797
|
});
|
|
14793
14798
|
}
|
|
14794
14799
|
}
|
|
14795
14800
|
this.#persist();
|
|
14796
14801
|
}
|
|
14797
14802
|
/**
|
|
14798
|
-
* Hand the transcript to the host's store
|
|
14799
|
-
* knows about how each tool call ended.
|
|
14803
|
+
* Hand the transcript to the host's store.
|
|
14800
14804
|
*
|
|
14801
|
-
*
|
|
14802
|
-
*
|
|
14803
|
-
*
|
|
14805
|
+
* The list as the agent holds it, with nothing added: how each tool call
|
|
14806
|
+
* ended rides in its result's `metadata`, which the client folds in from a
|
|
14807
|
+
* server's `TOOL_CALL_RESULT` and this class writes for the results it makes
|
|
14808
|
+
* itself, so the store sees exactly what the next request sends.
|
|
14804
14809
|
*/
|
|
14805
14810
|
#persist() {
|
|
14806
|
-
this.#onPersist(this.
|
|
14811
|
+
this.#onPersist(this.#agent.messages);
|
|
14807
14812
|
}
|
|
14808
14813
|
/**
|
|
14809
|
-
* The history in the form a save writes it
|
|
14810
|
-
*
|
|
14811
|
-
* {@link AgUiClientConfig.onPersist} is handed.
|
|
14814
|
+
* The history in the form a save writes it, which is now {@link messages}
|
|
14815
|
+
* itself.
|
|
14812
14816
|
*
|
|
14813
|
-
*
|
|
14814
|
-
*
|
|
14815
|
-
*
|
|
14816
|
-
*
|
|
14817
|
-
*
|
|
14817
|
+
* It differed while this client kept how each tool call ended in a side table
|
|
14818
|
+
* and annotated a copy for the store, because `@ag-ui/client` 0.x kept nothing
|
|
14819
|
+
* but five named fields of a result. 1.0 folds a result's `metadata` onto the
|
|
14820
|
+
* message it appends, so the outcome is on the message and there is no copy
|
|
14821
|
+
* left to make.
|
|
14822
|
+
*
|
|
14823
|
+
* @deprecated Read {@link messages}. Kept so a caller written against the
|
|
14824
|
+
* getter keeps compiling and gets the same list.
|
|
14818
14825
|
*/
|
|
14819
14826
|
get annotatedMessages() {
|
|
14820
|
-
|
|
14821
|
-
if (this.#outcomes.size === 0) {
|
|
14822
|
-
return messages;
|
|
14823
|
-
}
|
|
14824
|
-
return messages.map((message) => {
|
|
14825
|
-
if (message.role !== "tool") {
|
|
14826
|
-
return message;
|
|
14827
|
-
}
|
|
14828
|
-
const outcome = this.#outcomes.get(message.toolCallId);
|
|
14829
|
-
return outcome === void 0 ? message : { ...message, outcome };
|
|
14830
|
-
});
|
|
14827
|
+
return this.messages;
|
|
14831
14828
|
}
|
|
14832
14829
|
async #runLoop() {
|
|
14833
14830
|
let resume;
|
|
@@ -14887,14 +14884,12 @@ var AgUiClient = class {
|
|
|
14887
14884
|
if (result.halt === true) {
|
|
14888
14885
|
return;
|
|
14889
14886
|
}
|
|
14890
|
-
if (result.outcome !== void 0) {
|
|
14891
|
-
this.#outcomes.set(call.id, result.outcome);
|
|
14892
|
-
}
|
|
14893
14887
|
this.#agent.addMessage({
|
|
14894
14888
|
id: randomUUID4(),
|
|
14895
14889
|
role: "tool",
|
|
14896
14890
|
content: result.content,
|
|
14897
|
-
toolCallId: call.id
|
|
14891
|
+
toolCallId: call.id,
|
|
14892
|
+
...result.outcome === void 0 ? {} : { metadata: { outcome: result.outcome } }
|
|
14898
14893
|
});
|
|
14899
14894
|
this.#persist();
|
|
14900
14895
|
executed = true;
|
|
@@ -14907,7 +14902,6 @@ var AgUiClient = class {
|
|
|
14907
14902
|
#buildSubscriber(pending, runState) {
|
|
14908
14903
|
const h = this.#handlers;
|
|
14909
14904
|
const closed = this.#closedMessageIds;
|
|
14910
|
-
const outcomes = this.#outcomes;
|
|
14911
14905
|
const cancelled = () => this.#cancelled;
|
|
14912
14906
|
const pendingDeltas = /* @__PURE__ */ new Set();
|
|
14913
14907
|
return {
|
|
@@ -14938,11 +14932,8 @@ var AgUiClient = class {
|
|
|
14938
14932
|
h.onToolCall(call);
|
|
14939
14933
|
},
|
|
14940
14934
|
onToolCallResultEvent({ event }) {
|
|
14941
|
-
const outcome = event["outcome"];
|
|
14942
|
-
|
|
14943
|
-
outcomes.set(event.toolCallId, outcome);
|
|
14944
|
-
}
|
|
14945
|
-
h.onToolResult(event.toolCallId, event.content, outcome);
|
|
14935
|
+
const outcome = event.metadata?.["outcome"];
|
|
14936
|
+
h.onToolResult(event.toolCallId, contentToText2(event.content), outcome);
|
|
14946
14937
|
},
|
|
14947
14938
|
onActivitySnapshotEvent({ event, messages }) {
|
|
14948
14939
|
const known = messages.some(
|
|
@@ -15000,9 +14991,11 @@ var AgUiClient = class {
|
|
|
15000
14991
|
}
|
|
15001
14992
|
pendingDeltas.clear();
|
|
15002
14993
|
},
|
|
15003
|
-
// `@ag-ui/client`
|
|
15004
|
-
//
|
|
15005
|
-
//
|
|
14994
|
+
// THINKING_* left the protocol in its 1.0, but `@ag-ui/client` still
|
|
14995
|
+
// converts a server's THINKING_* events onto these REASONING_* callbacks,
|
|
14996
|
+
// with a console warning, for a deprecation window it sets. Nothing in the
|
|
14997
|
+
// family emits THINKING_*: pydantic-ai has sent REASONING_* at every
|
|
14998
|
+
// protocol version django-ag-ui admits.
|
|
15006
14999
|
onReasoningStartEvent() {
|
|
15007
15000
|
h.onReasoningStart();
|
|
15008
15001
|
},
|
|
@@ -15049,6 +15042,22 @@ function isAbortError(error) {
|
|
|
15049
15042
|
}
|
|
15050
15043
|
return error.name === "AbortError" || error instanceof TypeError && /abort/i.test(error.message);
|
|
15051
15044
|
}
|
|
15045
|
+
function withTopLevelKeysInMetadata(message) {
|
|
15046
|
+
const { outcome, attachments, ...wire } = message;
|
|
15047
|
+
if (outcome === void 0 && attachments === void 0) {
|
|
15048
|
+
return message;
|
|
15049
|
+
}
|
|
15050
|
+
const existing = wire.metadata;
|
|
15051
|
+
return {
|
|
15052
|
+
...wire,
|
|
15053
|
+
metadata: {
|
|
15054
|
+
...outcome === void 0 ? {} : { outcome },
|
|
15055
|
+
...attachments === void 0 ? {} : { attachments },
|
|
15056
|
+
// `null` passes the check and spreads as nothing, which is what it means.
|
|
15057
|
+
...typeof existing === "object" ? existing : {}
|
|
15058
|
+
}
|
|
15059
|
+
};
|
|
15060
|
+
}
|
|
15052
15061
|
|
|
15053
15062
|
// src/core/conversation_store.ts
|
|
15054
15063
|
import { randomUUID as randomUUID5 } from "@ag-ui/client";
|
|
@@ -18194,7 +18203,7 @@ function setControlValue(el2, value) {
|
|
|
18194
18203
|
}
|
|
18195
18204
|
|
|
18196
18205
|
// src/version.ts
|
|
18197
|
-
var VERSION = "0.
|
|
18206
|
+
var VERSION = "0.41.0";
|
|
18198
18207
|
export {
|
|
18199
18208
|
ATTACHMENT_EVENT,
|
|
18200
18209
|
AgUiChat,
|
|
@@ -18292,6 +18301,6 @@ export {
|
|
|
18292
18301
|
/*! Bundled license information:
|
|
18293
18302
|
|
|
18294
18303
|
dompurify/dist/purify.es.mjs:
|
|
18295
|
-
(*! @license DOMPurify 3.4.
|
|
18304
|
+
(*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE *)
|
|
18296
18305
|
*/
|
|
18297
18306
|
//# sourceMappingURL=index.js.map
|