@artooi/ag-ui-web-component 0.14.1 → 0.16.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 +105 -1
- package/README.md +13 -2
- package/dist/ag-ui-web-component.bundle.js +60 -59
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/core/conversation_store.d.ts.map +1 -1
- package/dist/core/remote_conversation_store.d.ts.map +1 -1
- package/dist/core/run_index.d.ts.map +1 -1
- package/dist/index.js +890 -493
- package/dist/index.js.map +4 -4
- package/dist/tools/client_tool_registry.d.ts.map +1 -1
- package/dist/tools/page_action_tools.d.ts.map +1 -1
- package/dist/tools/route_map.d.ts.map +1 -1
- package/dist/ui/attachment_tray.d.ts.map +1 -1
- package/dist/ui/checkpoint_menu.d.ts.map +1 -1
- package/dist/ui/render_markdown.d.ts.map +1 -1
- package/dist/ui/skills_menu.d.ts.map +1 -1
- package/dist/ui/thoughts_block.d.ts.map +1 -1
- package/dist/ui/thread_drawer.d.ts.map +1 -1
- package/dist/ui/tool_call_card.d.ts.map +1 -1
- package/dist/ui/ui_strings.d.ts +4 -0
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/dist/ui/voice_input.d.ts.map +1 -1
- package/package.json +11 -8
- package/src/constants.ts +10 -0
- package/src/core/ag_ui_chat.ts +86 -3
- package/src/core/remote_conversation_store.ts +2 -2
- package/src/tools/route_map.ts +5 -8
- package/src/ui/render_markdown.ts +29 -9
- package/src/ui/ui_strings.ts +7 -0
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var X_DESTRUCTIVE_KEY = "x-destructive";
|
|
|
11
11
|
var X_CONFIRM_KEY = "x-confirm";
|
|
12
12
|
var X_SUMMARY_KEY = "x-summary";
|
|
13
13
|
var X_NAVIGATES_KEY = "x-navigates";
|
|
14
|
+
var READ_PAGE_TOOL = "read_page";
|
|
14
15
|
var MAX_TOOL_ROUNDS = 10;
|
|
15
16
|
var TOOL_CALL_STATUS = {
|
|
16
17
|
PENDING: "pending",
|
|
@@ -376,14 +377,7 @@ function parseToolCatalog(data) {
|
|
|
376
377
|
// src/tools/route_map.ts
|
|
377
378
|
var PATH_PARAM_RE = /:([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
378
379
|
function pathParamNames(path) {
|
|
379
|
-
|
|
380
|
-
for (const match of path.matchAll(PATH_PARAM_RE)) {
|
|
381
|
-
const name = match[1];
|
|
382
|
-
if (name !== void 0) {
|
|
383
|
-
names.push(name);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
return names;
|
|
380
|
+
return [...path.matchAll(PATH_PARAM_RE)].map((match) => match[0].slice(1));
|
|
387
381
|
}
|
|
388
382
|
function fillPath(routeId, path, params) {
|
|
389
383
|
const leftover = { ...params };
|
|
@@ -470,6 +464,8 @@ var DEFAULT_UI_STRINGS = {
|
|
|
470
464
|
navigating: "Navigating\u2026",
|
|
471
465
|
historyCompacted: "Earlier turns condensed to fit the context window ({count} removed)",
|
|
472
466
|
usingSkill: "Using skill {name}",
|
|
467
|
+
runInterrupted: "The previous response didn\u2019t finish \u2014 the page changed before it arrived.",
|
|
468
|
+
pageMoved: "The page changed since you last looked at it. Call read_page to see the current page, then retry.",
|
|
473
469
|
skillNeeds: "\u201C{title}\u201D needs: {fields}",
|
|
474
470
|
message: "Message",
|
|
475
471
|
inputPlaceholder: "Ask anything\u2026",
|
|
@@ -1192,7 +1188,7 @@ function requestQuestion(host, request, options = {}) {
|
|
|
1192
1188
|
});
|
|
1193
1189
|
}
|
|
1194
1190
|
|
|
1195
|
-
// node_modules/.pnpm/dompurify@3.4.
|
|
1191
|
+
// node_modules/.pnpm/dompurify@3.4.13/node_modules/dompurify/dist/purify.es.mjs
|
|
1196
1192
|
function _arrayLikeToArray(r, a) {
|
|
1197
1193
|
(null == a || a > r.length) && (a = r.length);
|
|
1198
1194
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -1204,15 +1200,15 @@ function _arrayWithHoles(r) {
|
|
|
1204
1200
|
function _iterableToArrayLimit(r, l3) {
|
|
1205
1201
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
1206
1202
|
if (null != t) {
|
|
1207
|
-
var e, n, i, u, a = [],
|
|
1203
|
+
var e, n, i, u, a = [], f2 = true, o = false;
|
|
1208
1204
|
try {
|
|
1209
1205
|
if (i = (t = t.call(r)).next, 0 === l3) ;
|
|
1210
|
-
else for (; !(
|
|
1206
|
+
else for (; !(f2 = (e = i.call(t)).done) && (a.push(e.value), a.length !== l3); f2 = true) ;
|
|
1211
1207
|
} catch (r2) {
|
|
1212
1208
|
o = true, n = r2;
|
|
1213
1209
|
} finally {
|
|
1214
1210
|
try {
|
|
1215
|
-
if (!
|
|
1211
|
+
if (!f2 && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
1216
1212
|
} finally {
|
|
1217
1213
|
if (o) throw n;
|
|
1218
1214
|
}
|
|
@@ -1433,7 +1429,7 @@ var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph
|
|
|
1433
1429
|
var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
1434
1430
|
var text = freeze(["#text"]);
|
|
1435
1431
|
var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]);
|
|
1436
|
-
var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
|
|
1432
|
+
var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
|
|
1437
1433
|
var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
|
|
1438
1434
|
var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
1439
1435
|
var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
@@ -1452,6 +1448,10 @@ var ATTR_WHITESPACE = seal(
|
|
|
1452
1448
|
);
|
|
1453
1449
|
var DOCTYPE_NAME = seal(/^html$/i);
|
|
1454
1450
|
var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
1451
|
+
var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
1452
|
+
var COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
1453
|
+
var FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
1454
|
+
var SELF_CLOSING_TAG = seal(/\/>/i);
|
|
1455
1455
|
var NODE_TYPE = {
|
|
1456
1456
|
element: 1,
|
|
1457
1457
|
attribute: 2,
|
|
@@ -1461,7 +1461,7 @@ var NODE_TYPE = {
|
|
|
1461
1461
|
// Deprecated
|
|
1462
1462
|
entityNode: 6,
|
|
1463
1463
|
// Deprecated
|
|
1464
|
-
|
|
1464
|
+
processingInstruction: 7,
|
|
1465
1465
|
comment: 8,
|
|
1466
1466
|
document: 9,
|
|
1467
1467
|
documentType: 10,
|
|
@@ -1509,10 +1509,13 @@ var _createHooksMap = function _createHooksMap2() {
|
|
|
1509
1509
|
uponSanitizeShadowNode: []
|
|
1510
1510
|
};
|
|
1511
1511
|
};
|
|
1512
|
+
var _resolveSetOption = function _resolveSetOption2(cfg, key, fallback, options) {
|
|
1513
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
1514
|
+
};
|
|
1512
1515
|
function createDOMPurify() {
|
|
1513
1516
|
let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
1514
1517
|
const DOMPurify = (root) => createDOMPurify(root);
|
|
1515
|
-
DOMPurify.version = "3.4.
|
|
1518
|
+
DOMPurify.version = "3.4.13";
|
|
1516
1519
|
DOMPurify.removed = [];
|
|
1517
1520
|
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
1518
1521
|
DOMPurify.isSupported = false;
|
|
@@ -1536,6 +1539,7 @@ function createDOMPurify() {
|
|
|
1536
1539
|
const getAttributes = lookupGetter(ElementPrototype, "attributes");
|
|
1537
1540
|
const getNodeType = Node2 && Node2.prototype ? lookupGetter(Node2.prototype, "nodeType") : null;
|
|
1538
1541
|
const getNodeName = Node2 && Node2.prototype ? lookupGetter(Node2.prototype, "nodeName") : null;
|
|
1542
|
+
const getOwnerDocument = Node2 && Node2.prototype ? lookupGetter(Node2.prototype, "ownerDocument") : null;
|
|
1539
1543
|
if (typeof HTMLTemplateElement === "function") {
|
|
1540
1544
|
const template = document2.createElement("template");
|
|
1541
1545
|
if (template.content && template.content.ownerDocument) {
|
|
@@ -1544,6 +1548,39 @@ function createDOMPurify() {
|
|
|
1544
1548
|
}
|
|
1545
1549
|
let trustedTypesPolicy;
|
|
1546
1550
|
let emptyHTML = "";
|
|
1551
|
+
let defaultTrustedTypesPolicy;
|
|
1552
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
1553
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
1554
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy2() {
|
|
1555
|
+
if (IN_TRUSTED_TYPES_POLICY > 0) {
|
|
1556
|
+
throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
const _createTrustedHTML = function _createTrustedHTML2(html2) {
|
|
1560
|
+
_assertNotInTrustedTypesPolicy();
|
|
1561
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1562
|
+
try {
|
|
1563
|
+
return trustedTypesPolicy.createHTML(html2);
|
|
1564
|
+
} finally {
|
|
1565
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL2(scriptUrl) {
|
|
1569
|
+
_assertNotInTrustedTypesPolicy();
|
|
1570
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1571
|
+
try {
|
|
1572
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
1573
|
+
} finally {
|
|
1574
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy2() {
|
|
1578
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
1579
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
1580
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
1581
|
+
}
|
|
1582
|
+
return defaultTrustedTypesPolicy;
|
|
1583
|
+
};
|
|
1547
1584
|
const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
|
|
1548
1585
|
const importNode = originalDocument.importNode;
|
|
1549
1586
|
let hooks = _createHooksMap();
|
|
@@ -1598,6 +1635,8 @@ function createDOMPurify() {
|
|
|
1598
1635
|
let SAFE_FOR_XML = true;
|
|
1599
1636
|
let WHOLE_DOCUMENT = false;
|
|
1600
1637
|
let SET_CONFIG = false;
|
|
1638
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
1639
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
1601
1640
|
let FORCE_BODY = false;
|
|
1602
1641
|
let RETURN_DOM = false;
|
|
1603
1642
|
let RETURN_DOM_FRAGMENT = false;
|
|
@@ -1609,7 +1648,43 @@ function createDOMPurify() {
|
|
|
1609
1648
|
let IN_PLACE = false;
|
|
1610
1649
|
let USE_PROFILES = {};
|
|
1611
1650
|
let FORBID_CONTENTS = null;
|
|
1612
|
-
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
|
1651
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
|
1652
|
+
"annotation-xml",
|
|
1653
|
+
"audio",
|
|
1654
|
+
"colgroup",
|
|
1655
|
+
"desc",
|
|
1656
|
+
"foreignobject",
|
|
1657
|
+
"head",
|
|
1658
|
+
"iframe",
|
|
1659
|
+
"math",
|
|
1660
|
+
"mi",
|
|
1661
|
+
"mn",
|
|
1662
|
+
"mo",
|
|
1663
|
+
"ms",
|
|
1664
|
+
"mtext",
|
|
1665
|
+
"noembed",
|
|
1666
|
+
"noframes",
|
|
1667
|
+
"noscript",
|
|
1668
|
+
"plaintext",
|
|
1669
|
+
"script",
|
|
1670
|
+
// <selectedcontent> mirrors the selected <option>'s subtree, cloned by
|
|
1671
|
+
// the UA (customizable <select>) — including any on* handlers — and the
|
|
1672
|
+
// engine re-mirrors synchronously whenever a removal changes which
|
|
1673
|
+
// option/selectedcontent is current, even inside DOMPurify's inert
|
|
1674
|
+
// DOMParser document. Hoisting its children on removal re-inserts a fresh
|
|
1675
|
+
// mirror target ahead of the walk, which the engine refills, looping
|
|
1676
|
+
// forever (DoS) and amplifying output. Dropping its content on removal
|
|
1677
|
+
// (rather than hoisting) breaks that cascade; the content is a duplicate
|
|
1678
|
+
// of the option, which is sanitized on its own. See campaign-3 F1/F6.
|
|
1679
|
+
"selectedcontent",
|
|
1680
|
+
"style",
|
|
1681
|
+
"svg",
|
|
1682
|
+
"template",
|
|
1683
|
+
"thead",
|
|
1684
|
+
"title",
|
|
1685
|
+
"video",
|
|
1686
|
+
"xmp"
|
|
1687
|
+
]);
|
|
1613
1688
|
let DATA_URI_TAGS = null;
|
|
1614
1689
|
const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
1615
1690
|
let URI_SAFE_ATTRIBUTES = null;
|
|
@@ -1621,8 +1696,10 @@ function createDOMPurify() {
|
|
|
1621
1696
|
let IS_EMPTY_INPUT = false;
|
|
1622
1697
|
let ALLOWED_NAMESPACES = null;
|
|
1623
1698
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
1624
|
-
|
|
1625
|
-
let
|
|
1699
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(["mi", "mo", "mn", "ms", "mtext"]);
|
|
1700
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
1701
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
|
|
1702
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
1626
1703
|
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
|
1627
1704
|
let PARSER_MEDIA_TYPE = null;
|
|
1628
1705
|
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
@@ -1645,14 +1722,32 @@ function createDOMPurify() {
|
|
|
1645
1722
|
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
|
1646
1723
|
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
1647
1724
|
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
1648
|
-
ALLOWED_TAGS2 =
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1725
|
+
ALLOWED_TAGS2 = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, {
|
|
1726
|
+
transform: transformCaseFunc
|
|
1727
|
+
});
|
|
1728
|
+
ALLOWED_ATTR2 = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, {
|
|
1729
|
+
transform: transformCaseFunc
|
|
1730
|
+
});
|
|
1731
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, {
|
|
1732
|
+
transform: stringToString
|
|
1733
|
+
});
|
|
1734
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
1735
|
+
transform: transformCaseFunc,
|
|
1736
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
1737
|
+
});
|
|
1738
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
|
|
1739
|
+
transform: transformCaseFunc,
|
|
1740
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
1741
|
+
});
|
|
1742
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, {
|
|
1743
|
+
transform: transformCaseFunc
|
|
1744
|
+
});
|
|
1745
|
+
FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), {
|
|
1746
|
+
transform: transformCaseFunc
|
|
1747
|
+
});
|
|
1748
|
+
FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), {
|
|
1749
|
+
transform: transformCaseFunc
|
|
1750
|
+
});
|
|
1656
1751
|
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
1657
1752
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
1658
1753
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
@@ -1671,8 +1766,8 @@ function createDOMPurify() {
|
|
|
1671
1766
|
IN_PLACE = cfg.IN_PLACE || false;
|
|
1672
1767
|
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
1673
1768
|
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
1674
|
-
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({},
|
|
1675
|
-
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({},
|
|
1769
|
+
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
1770
|
+
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
1676
1771
|
const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
|
|
1677
1772
|
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
1678
1773
|
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
@@ -1684,6 +1779,7 @@ function createDOMPurify() {
|
|
|
1684
1779
|
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
|
|
1685
1780
|
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
1686
1781
|
}
|
|
1782
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
1687
1783
|
if (SAFE_FOR_TEMPLATES) {
|
|
1688
1784
|
ALLOW_DATA_ATTR = false;
|
|
1689
1785
|
}
|
|
@@ -1767,22 +1863,25 @@ function createDOMPurify() {
|
|
|
1767
1863
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
|
|
1768
1864
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
1769
1865
|
}
|
|
1866
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
1770
1867
|
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
1771
|
-
|
|
1868
|
+
try {
|
|
1869
|
+
emptyHTML = _createTrustedHTML("");
|
|
1870
|
+
} catch (error) {
|
|
1871
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
1872
|
+
throw error;
|
|
1873
|
+
}
|
|
1874
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
1875
|
+
trustedTypesPolicy = void 0;
|
|
1876
|
+
emptyHTML = "";
|
|
1772
1877
|
} else {
|
|
1773
1878
|
if (trustedTypesPolicy === void 0) {
|
|
1774
|
-
trustedTypesPolicy =
|
|
1879
|
+
trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
1775
1880
|
}
|
|
1776
|
-
if (trustedTypesPolicy
|
|
1777
|
-
emptyHTML =
|
|
1881
|
+
if (trustedTypesPolicy && typeof emptyHTML === "string") {
|
|
1882
|
+
emptyHTML = _createTrustedHTML("");
|
|
1778
1883
|
}
|
|
1779
1884
|
}
|
|
1780
|
-
if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS2 === DEFAULT_ALLOWED_TAGS) {
|
|
1781
|
-
ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
|
|
1782
|
-
}
|
|
1783
|
-
if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR2 === DEFAULT_ALLOWED_ATTR) {
|
|
1784
|
-
ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
|
|
1785
|
-
}
|
|
1786
1885
|
if (freeze) {
|
|
1787
1886
|
freeze(cfg);
|
|
1788
1887
|
}
|
|
@@ -1790,6 +1889,33 @@ function createDOMPurify() {
|
|
|
1790
1889
|
};
|
|
1791
1890
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
1792
1891
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
1892
|
+
const _checkSvgNamespace = function _checkSvgNamespace2(tagName, parent, parentTagName) {
|
|
1893
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
1894
|
+
return tagName === "svg";
|
|
1895
|
+
}
|
|
1896
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
1897
|
+
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
1898
|
+
}
|
|
1899
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
1900
|
+
};
|
|
1901
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace2(tagName, parent, parentTagName) {
|
|
1902
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
1903
|
+
return tagName === "math";
|
|
1904
|
+
}
|
|
1905
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
1906
|
+
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
1907
|
+
}
|
|
1908
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
1909
|
+
};
|
|
1910
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace2(tagName, parent, parentTagName) {
|
|
1911
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
1912
|
+
return false;
|
|
1913
|
+
}
|
|
1914
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
1915
|
+
return false;
|
|
1916
|
+
}
|
|
1917
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
1918
|
+
};
|
|
1793
1919
|
const _checkValidNamespace = function _checkValidNamespace2(element) {
|
|
1794
1920
|
let parent = getParentNode(element);
|
|
1795
1921
|
if (!parent || !parent.tagName) {
|
|
@@ -1804,31 +1930,13 @@ function createDOMPurify() {
|
|
|
1804
1930
|
return false;
|
|
1805
1931
|
}
|
|
1806
1932
|
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
1807
|
-
|
|
1808
|
-
return tagName === "svg";
|
|
1809
|
-
}
|
|
1810
|
-
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
1811
|
-
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
1812
|
-
}
|
|
1813
|
-
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
1933
|
+
return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
1814
1934
|
}
|
|
1815
1935
|
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
1816
|
-
|
|
1817
|
-
return tagName === "math";
|
|
1818
|
-
}
|
|
1819
|
-
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
1820
|
-
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
1821
|
-
}
|
|
1822
|
-
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
1936
|
+
return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
1823
1937
|
}
|
|
1824
1938
|
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
1825
|
-
|
|
1826
|
-
return false;
|
|
1827
|
-
}
|
|
1828
|
-
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
1829
|
-
return false;
|
|
1830
|
-
}
|
|
1831
|
-
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
1939
|
+
return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
1832
1940
|
}
|
|
1833
1941
|
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
1834
1942
|
return true;
|
|
@@ -1843,6 +1951,38 @@ function createDOMPurify() {
|
|
|
1843
1951
|
getParentNode(node).removeChild(node);
|
|
1844
1952
|
} catch (_2) {
|
|
1845
1953
|
remove(node);
|
|
1954
|
+
if (!getParentNode(node)) {
|
|
1955
|
+
throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
};
|
|
1959
|
+
const _neutralizeRoot = function _neutralizeRoot2(root) {
|
|
1960
|
+
_neutralizeSubtree(root);
|
|
1961
|
+
const childNodes = getChildNodes(root);
|
|
1962
|
+
if (childNodes) {
|
|
1963
|
+
const snapshot = [];
|
|
1964
|
+
arrayForEach(childNodes, (child) => {
|
|
1965
|
+
arrayPush(snapshot, child);
|
|
1966
|
+
});
|
|
1967
|
+
arrayForEach(snapshot, (child) => {
|
|
1968
|
+
try {
|
|
1969
|
+
remove(child);
|
|
1970
|
+
} catch (_2) {
|
|
1971
|
+
}
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
const attributes = getAttributes(root);
|
|
1975
|
+
if (attributes) {
|
|
1976
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
1977
|
+
const attribute = attributes[i];
|
|
1978
|
+
const name = attribute && attribute.name;
|
|
1979
|
+
if (typeof name === "string") {
|
|
1980
|
+
try {
|
|
1981
|
+
root.removeAttribute(name);
|
|
1982
|
+
} catch (_2) {
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1846
1986
|
}
|
|
1847
1987
|
};
|
|
1848
1988
|
const _removeAttribute = function _removeAttribute2(name, element) {
|
|
@@ -1872,6 +2012,75 @@ function createDOMPurify() {
|
|
|
1872
2012
|
}
|
|
1873
2013
|
}
|
|
1874
2014
|
};
|
|
2015
|
+
const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
|
|
2016
|
+
const attributes = getAttributes(element);
|
|
2017
|
+
if (!attributes) {
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
2021
|
+
const attribute = attributes[i];
|
|
2022
|
+
const name = attribute && attribute.name;
|
|
2023
|
+
if (typeof name !== "string" || ALLOWED_ATTR2[transformCaseFunc(name)]) {
|
|
2024
|
+
continue;
|
|
2025
|
+
}
|
|
2026
|
+
try {
|
|
2027
|
+
element.removeAttribute(name);
|
|
2028
|
+
} catch (_2) {
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
};
|
|
2032
|
+
const _neutralizeSubtree = function _neutralizeSubtree2(root) {
|
|
2033
|
+
const stack = [root];
|
|
2034
|
+
while (stack.length > 0) {
|
|
2035
|
+
const node = stack.pop();
|
|
2036
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
2037
|
+
if (nodeType === NODE_TYPE.element) {
|
|
2038
|
+
_stripDisallowedAttributes(node);
|
|
2039
|
+
}
|
|
2040
|
+
const childNodes = getChildNodes(node);
|
|
2041
|
+
if (childNodes) {
|
|
2042
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
2043
|
+
stack.push(childNodes[i]);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
|
|
2049
|
+
if (!SAFE_FOR_XML) {
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
const stack = [root];
|
|
2053
|
+
while (stack.length > 0) {
|
|
2054
|
+
const node = stack.pop();
|
|
2055
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
2056
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
2057
|
+
try {
|
|
2058
|
+
remove(node);
|
|
2059
|
+
} catch (_2) {
|
|
2060
|
+
}
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
if (nodeType === NODE_TYPE.element) {
|
|
2064
|
+
const element = node;
|
|
2065
|
+
const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
|
|
2066
|
+
try {
|
|
2067
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc")) {
|
|
2068
|
+
element.removeAttribute("patchsrc");
|
|
2069
|
+
}
|
|
2070
|
+
if (element.hasAttribute && element.hasAttribute("for") && lcTag !== "label" && lcTag !== "output") {
|
|
2071
|
+
element.removeAttribute("for");
|
|
2072
|
+
}
|
|
2073
|
+
} catch (_2) {
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
const childNodes = getChildNodes(node);
|
|
2077
|
+
if (childNodes) {
|
|
2078
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
2079
|
+
stack.push(childNodes[i]);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
1875
2084
|
const _initDocument = function _initDocument2(dirty) {
|
|
1876
2085
|
let doc = null;
|
|
1877
2086
|
let leadingWhitespace = null;
|
|
@@ -1884,7 +2093,7 @@ function createDOMPurify() {
|
|
|
1884
2093
|
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
|
|
1885
2094
|
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
|
|
1886
2095
|
}
|
|
1887
|
-
const dirtyPayload = trustedTypesPolicy ?
|
|
2096
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
1888
2097
|
if (NAMESPACE === HTML_NAMESPACE) {
|
|
1889
2098
|
try {
|
|
1890
2099
|
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
@@ -1908,18 +2117,27 @@ function createDOMPurify() {
|
|
|
1908
2117
|
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
1909
2118
|
};
|
|
1910
2119
|
const _createNodeIterator = function _createNodeIterator2(root) {
|
|
2120
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
1911
2121
|
return createNodeIterator.call(
|
|
1912
|
-
|
|
2122
|
+
doc || root,
|
|
1913
2123
|
root,
|
|
1914
2124
|
// eslint-disable-next-line no-bitwise
|
|
1915
2125
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
|
|
1916
2126
|
null
|
|
1917
2127
|
);
|
|
1918
2128
|
};
|
|
1919
|
-
const
|
|
2129
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
|
|
2130
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
2131
|
+
value = stringReplace(value, ERB_EXPR$1, " ");
|
|
2132
|
+
value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
|
2133
|
+
return value;
|
|
2134
|
+
};
|
|
2135
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
2136
|
+
var _node$querySelectorAl;
|
|
1920
2137
|
node.normalize();
|
|
2138
|
+
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
1921
2139
|
const walker = createNodeIterator.call(
|
|
1922
|
-
|
|
2140
|
+
doc || node,
|
|
1923
2141
|
node,
|
|
1924
2142
|
// eslint-disable-next-line no-bitwise
|
|
1925
2143
|
NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION,
|
|
@@ -1927,13 +2145,17 @@ function createDOMPurify() {
|
|
|
1927
2145
|
);
|
|
1928
2146
|
let currentNode = walker.nextNode();
|
|
1929
2147
|
while (currentNode) {
|
|
1930
|
-
|
|
1931
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
|
|
1932
|
-
data = stringReplace(data, expr, " ");
|
|
1933
|
-
});
|
|
1934
|
-
currentNode.data = data;
|
|
2148
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
1935
2149
|
currentNode = walker.nextNode();
|
|
1936
2150
|
}
|
|
2151
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
2152
|
+
if (templates) {
|
|
2153
|
+
arrayForEach(templates, (tmpl) => {
|
|
2154
|
+
if (_isDocumentFragment(tmpl.content)) {
|
|
2155
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
2156
|
+
}
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
1937
2159
|
};
|
|
1938
2160
|
const _isClobbered = function _isClobbered2(element) {
|
|
1939
2161
|
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
@@ -1989,75 +2211,103 @@ function createDOMPurify() {
|
|
|
1989
2211
|
}
|
|
1990
2212
|
};
|
|
1991
2213
|
function _executeHooks(hooks2, currentNode, data) {
|
|
2214
|
+
if (hooks2.length === 0) {
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
1992
2217
|
arrayForEach(hooks2, (hook) => {
|
|
1993
2218
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
1994
2219
|
});
|
|
1995
2220
|
}
|
|
1996
|
-
const
|
|
1997
|
-
|
|
2221
|
+
const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
|
|
2222
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
2223
|
+
return true;
|
|
2224
|
+
}
|
|
2225
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
|
|
2226
|
+
return true;
|
|
2227
|
+
}
|
|
2228
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
2229
|
+
return true;
|
|
2230
|
+
}
|
|
2231
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
|
|
2232
|
+
return true;
|
|
2233
|
+
}
|
|
2234
|
+
return false;
|
|
2235
|
+
};
|
|
2236
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
|
|
2237
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
2238
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
2239
|
+
return false;
|
|
2240
|
+
}
|
|
2241
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
2242
|
+
return false;
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
2246
|
+
const parentNode = getParentNode(currentNode);
|
|
2247
|
+
const childNodes = getChildNodes(currentNode);
|
|
2248
|
+
if (childNodes && parentNode) {
|
|
2249
|
+
const childCount = childNodes.length;
|
|
2250
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
2251
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
2252
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
_forceRemove(currentNode);
|
|
2257
|
+
return true;
|
|
2258
|
+
};
|
|
2259
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
|
|
2260
|
+
if (hookList.length === 0) {
|
|
2261
|
+
return set;
|
|
2262
|
+
}
|
|
2263
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
2264
|
+
};
|
|
2265
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
1998
2266
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
2267
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
2268
|
+
if (IN_PLACE) {
|
|
2269
|
+
_neutralizeSubtree(currentNode);
|
|
2270
|
+
}
|
|
2271
|
+
return true;
|
|
2272
|
+
}
|
|
1999
2273
|
if (_isClobbered(currentNode)) {
|
|
2000
2274
|
_forceRemove(currentNode);
|
|
2001
2275
|
return true;
|
|
2002
2276
|
}
|
|
2003
|
-
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
2277
|
+
const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
|
|
2278
|
+
ALLOWED_TAGS2 = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS2, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
2004
2279
|
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
2005
2280
|
tagName,
|
|
2006
2281
|
allowedTags: ALLOWED_TAGS2
|
|
2007
2282
|
});
|
|
2008
|
-
if (
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
|
|
2013
|
-
_forceRemove(currentNode);
|
|
2014
|
-
return true;
|
|
2015
|
-
}
|
|
2016
|
-
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
2017
|
-
_forceRemove(currentNode);
|
|
2283
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
2284
|
+
if (IN_PLACE) {
|
|
2285
|
+
_neutralizeSubtree(currentNode);
|
|
2286
|
+
}
|
|
2018
2287
|
return true;
|
|
2019
2288
|
}
|
|
2020
|
-
if (
|
|
2289
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
2021
2290
|
_forceRemove(currentNode);
|
|
2022
2291
|
return true;
|
|
2023
2292
|
}
|
|
2024
2293
|
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS2[tagName]) {
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
}
|
|
2029
|
-
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
2030
|
-
return false;
|
|
2031
|
-
}
|
|
2294
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
2295
|
+
if (removed === false) {
|
|
2296
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
2032
2297
|
}
|
|
2033
|
-
|
|
2034
|
-
const parentNode = getParentNode(currentNode);
|
|
2035
|
-
const childNodes = getChildNodes(currentNode);
|
|
2036
|
-
if (childNodes && parentNode) {
|
|
2037
|
-
const childCount = childNodes.length;
|
|
2038
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
2039
|
-
const childClone = cloneNode(childNodes[i], true);
|
|
2040
|
-
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
_forceRemove(currentNode);
|
|
2045
|
-
return true;
|
|
2298
|
+
return removed;
|
|
2046
2299
|
}
|
|
2047
2300
|
const nt2 = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
|
|
2048
2301
|
if (nt2 === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
2049
2302
|
_forceRemove(currentNode);
|
|
2050
2303
|
return true;
|
|
2051
2304
|
}
|
|
2052
|
-
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(
|
|
2305
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
2053
2306
|
_forceRemove(currentNode);
|
|
2054
2307
|
return true;
|
|
2055
2308
|
}
|
|
2056
2309
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
2057
|
-
content = currentNode.textContent;
|
|
2058
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
|
|
2059
|
-
content = stringReplace(content, expr, " ");
|
|
2060
|
-
});
|
|
2310
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
2061
2311
|
if (currentNode.textContent !== content) {
|
|
2062
2312
|
arrayPush(DOMPurify.removed, {
|
|
2063
2313
|
element: currentNode.cloneNode()
|
|
@@ -2072,13 +2322,19 @@ function createDOMPurify() {
|
|
|
2072
2322
|
if (FORBID_ATTR[lcName]) {
|
|
2073
2323
|
return false;
|
|
2074
2324
|
}
|
|
2325
|
+
if (SAFE_FOR_XML && lcName === "patchsrc") {
|
|
2326
|
+
return false;
|
|
2327
|
+
}
|
|
2328
|
+
if (SAFE_FOR_XML && lcName === "for" && lcTag !== "label" && lcTag !== "output") {
|
|
2329
|
+
return false;
|
|
2330
|
+
}
|
|
2075
2331
|
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
|
|
2076
2332
|
return false;
|
|
2077
2333
|
}
|
|
2078
2334
|
const nameIsPermitted = ALLOWED_ATTR2[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
2079
|
-
if (ALLOW_DATA_ATTR &&
|
|
2335
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ;
|
|
2080
2336
|
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
|
|
2081
|
-
else if (!nameIsPermitted
|
|
2337
|
+
else if (!nameIsPermitted) {
|
|
2082
2338
|
if (
|
|
2083
2339
|
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
2084
2340
|
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
@@ -2103,12 +2359,42 @@ function createDOMPurify() {
|
|
|
2103
2359
|
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
2104
2360
|
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
2105
2361
|
};
|
|
2362
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
|
|
2363
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) {
|
|
2364
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
2365
|
+
case "TrustedHTML": {
|
|
2366
|
+
return _createTrustedHTML(value);
|
|
2367
|
+
}
|
|
2368
|
+
case "TrustedScriptURL": {
|
|
2369
|
+
return _createTrustedScriptURL(value);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
return value;
|
|
2374
|
+
};
|
|
2375
|
+
const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
|
|
2376
|
+
try {
|
|
2377
|
+
if (namespaceURI) {
|
|
2378
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
2379
|
+
} else {
|
|
2380
|
+
currentNode.setAttribute(name, value);
|
|
2381
|
+
}
|
|
2382
|
+
if (_isClobbered(currentNode)) {
|
|
2383
|
+
_forceRemove(currentNode);
|
|
2384
|
+
} else {
|
|
2385
|
+
arrayPop(DOMPurify.removed);
|
|
2386
|
+
}
|
|
2387
|
+
} catch (_2) {
|
|
2388
|
+
_removeAttribute(name, currentNode);
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2106
2391
|
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
2107
2392
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
2108
2393
|
const attributes = currentNode.attributes;
|
|
2109
2394
|
if (!attributes || _isClobbered(currentNode)) {
|
|
2110
2395
|
return;
|
|
2111
2396
|
}
|
|
2397
|
+
ALLOWED_ATTR2 = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR2, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
2112
2398
|
const hookEvent = {
|
|
2113
2399
|
attrName: "",
|
|
2114
2400
|
attrValue: "",
|
|
@@ -2117,6 +2403,7 @@ function createDOMPurify() {
|
|
|
2117
2403
|
forceKeepAttr: void 0
|
|
2118
2404
|
};
|
|
2119
2405
|
let l3 = attributes.length;
|
|
2406
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
2120
2407
|
while (l3--) {
|
|
2121
2408
|
const attr = attributes[l3];
|
|
2122
2409
|
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
@@ -2148,50 +2435,20 @@ function createDOMPurify() {
|
|
|
2148
2435
|
_removeAttribute(name, currentNode);
|
|
2149
2436
|
continue;
|
|
2150
2437
|
}
|
|
2151
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(
|
|
2438
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
2152
2439
|
_removeAttribute(name, currentNode);
|
|
2153
2440
|
continue;
|
|
2154
2441
|
}
|
|
2155
2442
|
if (SAFE_FOR_TEMPLATES) {
|
|
2156
|
-
|
|
2157
|
-
value = stringReplace(value, expr, " ");
|
|
2158
|
-
});
|
|
2443
|
+
value = _stripTemplateExpressions(value);
|
|
2159
2444
|
}
|
|
2160
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
2161
2445
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
2162
2446
|
_removeAttribute(name, currentNode);
|
|
2163
2447
|
continue;
|
|
2164
2448
|
}
|
|
2165
|
-
|
|
2166
|
-
if (namespaceURI) ;
|
|
2167
|
-
else {
|
|
2168
|
-
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
2169
|
-
case "TrustedHTML": {
|
|
2170
|
-
value = trustedTypesPolicy.createHTML(value);
|
|
2171
|
-
break;
|
|
2172
|
-
}
|
|
2173
|
-
case "TrustedScriptURL": {
|
|
2174
|
-
value = trustedTypesPolicy.createScriptURL(value);
|
|
2175
|
-
break;
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2449
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
2180
2450
|
if (value !== initValue) {
|
|
2181
|
-
|
|
2182
|
-
if (namespaceURI) {
|
|
2183
|
-
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
2184
|
-
} else {
|
|
2185
|
-
currentNode.setAttribute(name, value);
|
|
2186
|
-
}
|
|
2187
|
-
if (_isClobbered(currentNode)) {
|
|
2188
|
-
_forceRemove(currentNode);
|
|
2189
|
-
} else {
|
|
2190
|
-
arrayPop(DOMPurify.removed);
|
|
2191
|
-
}
|
|
2192
|
-
} catch (_2) {
|
|
2193
|
-
_removeAttribute(name, currentNode);
|
|
2194
|
-
}
|
|
2451
|
+
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
2195
2452
|
}
|
|
2196
2453
|
}
|
|
2197
2454
|
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
@@ -2202,48 +2459,67 @@ function createDOMPurify() {
|
|
|
2202
2459
|
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
2203
2460
|
while (shadowNode = shadowIterator.nextNode()) {
|
|
2204
2461
|
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
2205
|
-
_sanitizeElements(shadowNode);
|
|
2462
|
+
_sanitizeElements(shadowNode, fragment);
|
|
2206
2463
|
_sanitizeAttributes(shadowNode);
|
|
2207
2464
|
if (_isDocumentFragment(shadowNode.content)) {
|
|
2208
2465
|
_sanitizeShadowDOM2(shadowNode.content);
|
|
2209
2466
|
}
|
|
2210
2467
|
const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
|
|
2211
2468
|
if (shadowNodeType === NODE_TYPE.element) {
|
|
2212
|
-
const innerSr = getShadowRoot
|
|
2469
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
2213
2470
|
if (_isDocumentFragment(innerSr)) {
|
|
2214
|
-
|
|
2471
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
2215
2472
|
_sanitizeShadowDOM2(innerSr);
|
|
2216
2473
|
}
|
|
2217
2474
|
}
|
|
2218
2475
|
}
|
|
2219
2476
|
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
2220
2477
|
};
|
|
2221
|
-
const
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2478
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots2(root) {
|
|
2479
|
+
const stack = [{
|
|
2480
|
+
node: root,
|
|
2481
|
+
shadow: null
|
|
2482
|
+
}];
|
|
2483
|
+
while (stack.length > 0) {
|
|
2484
|
+
const item = stack.pop();
|
|
2485
|
+
if (item.shadow) {
|
|
2486
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
2487
|
+
continue;
|
|
2228
2488
|
}
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2489
|
+
const node = item.node;
|
|
2490
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
2491
|
+
const isElement = nodeType === NODE_TYPE.element;
|
|
2492
|
+
const childNodes = getChildNodes(node);
|
|
2493
|
+
if (childNodes) {
|
|
2494
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
2495
|
+
stack.push({
|
|
2496
|
+
node: childNodes[i],
|
|
2497
|
+
shadow: null
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
if (isElement) {
|
|
2502
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
2503
|
+
if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
|
|
2504
|
+
const content = node.content;
|
|
2505
|
+
if (_isDocumentFragment(content)) {
|
|
2506
|
+
stack.push({
|
|
2507
|
+
node: content,
|
|
2508
|
+
shadow: null
|
|
2509
|
+
});
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
if (isElement) {
|
|
2514
|
+
const sr = getShadowRoot(node);
|
|
2515
|
+
if (_isDocumentFragment(sr)) {
|
|
2516
|
+
stack.push({
|
|
2517
|
+
node: null,
|
|
2518
|
+
shadow: sr
|
|
2519
|
+
}, {
|
|
2520
|
+
node: sr,
|
|
2521
|
+
shadow: null
|
|
2522
|
+
});
|
|
2247
2523
|
}
|
|
2248
2524
|
}
|
|
2249
2525
|
}
|
|
@@ -2267,25 +2543,40 @@ function createDOMPurify() {
|
|
|
2267
2543
|
if (!DOMPurify.isSupported) {
|
|
2268
2544
|
return dirty;
|
|
2269
2545
|
}
|
|
2270
|
-
if (
|
|
2546
|
+
if (SET_CONFIG) {
|
|
2547
|
+
ALLOWED_TAGS2 = SET_CONFIG_ALLOWED_TAGS;
|
|
2548
|
+
ALLOWED_ATTR2 = SET_CONFIG_ALLOWED_ATTR;
|
|
2549
|
+
} else {
|
|
2271
2550
|
_parseConfig(cfg);
|
|
2272
2551
|
}
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
IN_PLACE = false;
|
|
2552
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
2553
|
+
ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
|
|
2276
2554
|
}
|
|
2277
|
-
if (
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2555
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
2556
|
+
ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
|
|
2557
|
+
}
|
|
2558
|
+
DOMPurify.removed = [];
|
|
2559
|
+
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
2560
|
+
if (inPlace) {
|
|
2561
|
+
_neutralizePatchLinkage(dirty);
|
|
2562
|
+
const nn2 = getNodeName ? getNodeName(dirty) : dirty.nodeName;
|
|
2563
|
+
if (typeof nn2 === "string") {
|
|
2564
|
+
const tagName = transformCaseFunc(nn2);
|
|
2281
2565
|
if (!ALLOWED_TAGS2[tagName] || FORBID_TAGS[tagName]) {
|
|
2566
|
+
_neutralizeRoot(dirty);
|
|
2282
2567
|
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
2283
2568
|
}
|
|
2284
2569
|
}
|
|
2285
2570
|
if (_isClobbered(dirty)) {
|
|
2571
|
+
_neutralizeRoot(dirty);
|
|
2286
2572
|
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
2287
2573
|
}
|
|
2288
|
-
|
|
2574
|
+
try {
|
|
2575
|
+
_sanitizeAttachedShadowRoots(dirty);
|
|
2576
|
+
} catch (error) {
|
|
2577
|
+
_neutralizeRoot(dirty);
|
|
2578
|
+
throw error;
|
|
2579
|
+
}
|
|
2289
2580
|
} else if (_isNode(dirty)) {
|
|
2290
2581
|
body = _initDocument("<!---->");
|
|
2291
2582
|
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
@@ -2296,11 +2587,11 @@ function createDOMPurify() {
|
|
|
2296
2587
|
} else {
|
|
2297
2588
|
body.appendChild(importedNode);
|
|
2298
2589
|
}
|
|
2299
|
-
|
|
2590
|
+
_sanitizeAttachedShadowRoots(importedNode);
|
|
2300
2591
|
} else {
|
|
2301
2592
|
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
|
|
2302
2593
|
dirty.indexOf("<") === -1) {
|
|
2303
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
2594
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
2304
2595
|
}
|
|
2305
2596
|
body = _initDocument(dirty);
|
|
2306
2597
|
if (!body) {
|
|
@@ -2310,23 +2601,41 @@ function createDOMPurify() {
|
|
|
2310
2601
|
if (body && FORCE_BODY) {
|
|
2311
2602
|
_forceRemove(body.firstChild);
|
|
2312
2603
|
}
|
|
2313
|
-
const
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2604
|
+
const walkRoot = inPlace ? dirty : body;
|
|
2605
|
+
try {
|
|
2606
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
2607
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
2608
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
2609
|
+
_sanitizeAttributes(currentNode);
|
|
2610
|
+
if (_isDocumentFragment(currentNode.content)) {
|
|
2611
|
+
_sanitizeShadowDOM2(currentNode.content);
|
|
2612
|
+
}
|
|
2319
2613
|
}
|
|
2614
|
+
} catch (error) {
|
|
2615
|
+
if (inPlace) {
|
|
2616
|
+
_neutralizeRoot(dirty);
|
|
2617
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
2618
|
+
if (entry.element) {
|
|
2619
|
+
_neutralizeSubtree(entry.element);
|
|
2620
|
+
}
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
throw error;
|
|
2320
2624
|
}
|
|
2321
|
-
if (
|
|
2625
|
+
if (inPlace) {
|
|
2626
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
2627
|
+
if (entry.element) {
|
|
2628
|
+
_neutralizeSubtree(entry.element);
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2322
2631
|
if (SAFE_FOR_TEMPLATES) {
|
|
2323
|
-
|
|
2632
|
+
_scrubTemplateExpressions2(dirty);
|
|
2324
2633
|
}
|
|
2325
2634
|
return dirty;
|
|
2326
2635
|
}
|
|
2327
2636
|
if (RETURN_DOM) {
|
|
2328
2637
|
if (SAFE_FOR_TEMPLATES) {
|
|
2329
|
-
|
|
2638
|
+
_scrubTemplateExpressions2(body);
|
|
2330
2639
|
}
|
|
2331
2640
|
if (RETURN_DOM_FRAGMENT) {
|
|
2332
2641
|
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
@@ -2346,20 +2655,24 @@ function createDOMPurify() {
|
|
|
2346
2655
|
serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
2347
2656
|
}
|
|
2348
2657
|
if (SAFE_FOR_TEMPLATES) {
|
|
2349
|
-
|
|
2350
|
-
serializedHTML = stringReplace(serializedHTML, expr, " ");
|
|
2351
|
-
});
|
|
2658
|
+
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
2352
2659
|
}
|
|
2353
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
2660
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
2354
2661
|
};
|
|
2355
2662
|
DOMPurify.setConfig = function() {
|
|
2356
2663
|
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2357
2664
|
_parseConfig(cfg);
|
|
2358
2665
|
SET_CONFIG = true;
|
|
2666
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS2;
|
|
2667
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR2;
|
|
2359
2668
|
};
|
|
2360
2669
|
DOMPurify.clearConfig = function() {
|
|
2361
2670
|
CONFIG = null;
|
|
2362
2671
|
SET_CONFIG = false;
|
|
2672
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
2673
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
2674
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
2675
|
+
emptyHTML = "";
|
|
2363
2676
|
};
|
|
2364
2677
|
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
2365
2678
|
if (!CONFIG) {
|
|
@@ -2373,9 +2686,15 @@ function createDOMPurify() {
|
|
|
2373
2686
|
if (typeof hookFunction !== "function") {
|
|
2374
2687
|
return;
|
|
2375
2688
|
}
|
|
2689
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
2690
|
+
return;
|
|
2691
|
+
}
|
|
2376
2692
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
2377
2693
|
};
|
|
2378
2694
|
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
2695
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
2696
|
+
return void 0;
|
|
2697
|
+
}
|
|
2379
2698
|
if (hookFunction !== void 0) {
|
|
2380
2699
|
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
2381
2700
|
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
@@ -2383,6 +2702,9 @@ function createDOMPurify() {
|
|
|
2383
2702
|
return arrayPop(hooks[entryPoint]);
|
|
2384
2703
|
};
|
|
2385
2704
|
DOMPurify.removeHooks = function(entryPoint) {
|
|
2705
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2386
2708
|
hooks[entryPoint] = [];
|
|
2387
2709
|
};
|
|
2388
2710
|
DOMPurify.removeAllHooks = function() {
|
|
@@ -2392,23 +2714,23 @@ function createDOMPurify() {
|
|
|
2392
2714
|
}
|
|
2393
2715
|
var purify = createDOMPurify();
|
|
2394
2716
|
|
|
2395
|
-
// node_modules/.pnpm/marked@18.0.
|
|
2396
|
-
function
|
|
2717
|
+
// node_modules/.pnpm/marked@18.0.9/node_modules/marked/lib/marked.esm.js
|
|
2718
|
+
function C() {
|
|
2397
2719
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
2398
2720
|
}
|
|
2399
|
-
var
|
|
2400
|
-
function
|
|
2401
|
-
|
|
2721
|
+
var R = C();
|
|
2722
|
+
function j(l3) {
|
|
2723
|
+
R = l3;
|
|
2402
2724
|
}
|
|
2403
|
-
var
|
|
2404
|
-
function
|
|
2725
|
+
var z = { exec: () => null };
|
|
2726
|
+
function A(l3) {
|
|
2405
2727
|
let e = [];
|
|
2406
2728
|
return (t) => {
|
|
2407
2729
|
let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
|
|
2408
2730
|
return s || (s = l3(n), e[n] = s), s;
|
|
2409
2731
|
};
|
|
2410
2732
|
}
|
|
2411
|
-
function
|
|
2733
|
+
function k(l3, e = "") {
|
|
2412
2734
|
let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
|
|
2413
2735
|
let i = typeof r == "string" ? r : r.source;
|
|
2414
2736
|
return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
|
|
@@ -2422,78 +2744,87 @@ var Te = ((l3 = "") => {
|
|
|
2422
2744
|
return false;
|
|
2423
2745
|
}
|
|
2424
2746
|
})();
|
|
2425
|
-
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: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex:
|
|
2747
|
+
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: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: A((l3) => new RegExp(`^ {0,${l3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}>`)) };
|
|
2426
2748
|
var Oe = /^(?:[ \t]*(?:\n|$))+/;
|
|
2427
2749
|
var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
2428
2750
|
var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
2429
|
-
var
|
|
2751
|
+
var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
2430
2752
|
var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
2431
|
-
var
|
|
2753
|
+
var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
2432
2754
|
var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
2433
|
-
var ae =
|
|
2434
|
-
var Se =
|
|
2435
|
-
var
|
|
2436
|
-
var
|
|
2437
|
-
var
|
|
2438
|
-
var
|
|
2439
|
-
var
|
|
2440
|
-
var
|
|
2441
|
-
var
|
|
2442
|
-
var
|
|
2443
|
-
var le =
|
|
2444
|
-
var
|
|
2445
|
-
var
|
|
2446
|
-
var
|
|
2447
|
-
var
|
|
2448
|
-
var
|
|
2755
|
+
var ae = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
2756
|
+
var Se = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
2757
|
+
var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
2758
|
+
var _e = /^[^\n]+/;
|
|
2759
|
+
var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
2760
|
+
var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
2761
|
+
var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
|
|
2762
|
+
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";
|
|
2763
|
+
var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
2764
|
+
var Me = 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][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
2765
|
+
var le = (l3) => 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", l3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
2766
|
+
var ze = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
2767
|
+
var Ee = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
2768
|
+
var Ce = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ee).getRegex();
|
|
2769
|
+
var J = { blockquote: Ce, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: Me, lheading: ae, list: Le, newline: Oe, paragraph: ze, table: z, text: _e };
|
|
2770
|
+
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();
|
|
2771
|
+
var Ae = { ...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() };
|
|
2772
|
+
var Ie = { ...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: z, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
|
|
2449
2773
|
]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
2450
|
-
var
|
|
2451
|
-
var
|
|
2452
|
-
var
|
|
2453
|
-
var
|
|
2454
|
-
var
|
|
2455
|
-
var
|
|
2456
|
-
var
|
|
2457
|
-
var
|
|
2458
|
-
var
|
|
2459
|
-
var
|
|
2460
|
-
var
|
|
2461
|
-
var
|
|
2774
|
+
var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
2775
|
+
var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
2776
|
+
var pe = /^( {2,}|\\)\n(?!\s*$)/;
|
|
2777
|
+
var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
2778
|
+
var _ = /[\p{P}\p{S}]/u;
|
|
2779
|
+
var I = /[\s\p{P}\p{S}]/u;
|
|
2780
|
+
var v = /[^\s\p{P}\p{S}]/u;
|
|
2781
|
+
var ve = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, I).getRegex();
|
|
2782
|
+
var He = /[\p{Pi}\p{Ps}"']/u;
|
|
2783
|
+
var ue = /(?!~)[\p{P}\p{S}]/u;
|
|
2784
|
+
var Ze = /(?!~)[\s\p{P}\p{S}]/u;
|
|
2785
|
+
var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
2786
|
+
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();
|
|
2462
2787
|
var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
2463
|
-
var
|
|
2464
|
-
var
|
|
2788
|
+
var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
|
|
2789
|
+
var je = k(ce, "u").replace(/punct/g, ue).getRegex();
|
|
2790
|
+
var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
2791
|
+
var Ue = k(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
|
|
2465
2792
|
var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
2466
|
-
var
|
|
2467
|
-
var
|
|
2468
|
-
var
|
|
2469
|
-
var
|
|
2470
|
-
var
|
|
2471
|
-
var
|
|
2472
|
-
var
|
|
2473
|
-
var
|
|
2474
|
-
var
|
|
2475
|
-
var
|
|
2476
|
-
var
|
|
2477
|
-
var
|
|
2478
|
-
var
|
|
2479
|
-
var
|
|
2480
|
-
var
|
|
2793
|
+
var Ke = k(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
2794
|
+
var We = k(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, ue).getRegex();
|
|
2795
|
+
var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
2796
|
+
var Je = k(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
2797
|
+
var Ve = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
2798
|
+
var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
2799
|
+
var et = k(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
2800
|
+
var tt = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
|
|
2801
|
+
var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
2802
|
+
var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
2803
|
+
var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
|
|
2804
|
+
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();
|
|
2805
|
+
var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
|
|
2806
|
+
var at = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?: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();
|
|
2807
|
+
var G = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
2808
|
+
var lt = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
2809
|
+
var de = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
|
|
2810
|
+
var ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
|
|
2811
|
+
var pt = k("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", ke).getRegex();
|
|
2481
2812
|
var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
2482
|
-
var
|
|
2483
|
-
var
|
|
2484
|
-
var
|
|
2485
|
-
var
|
|
2486
|
-
var
|
|
2487
|
-
var
|
|
2488
|
-
var
|
|
2489
|
-
var ge = (l3) =>
|
|
2813
|
+
var V = { _backpedal: z, anyPunctuation: st, autolink: it, blockSkip: Qe, br: pe, code: De, del: z, delLDelim: z, delRDelim: z, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: lt, nolink: ke, punctuation: ve, reflink: de, reflinkSearch: pt, tag: at, text: qe, url: z };
|
|
2814
|
+
var ut = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
|
|
2815
|
+
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])+(?![-_])/).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() };
|
|
2816
|
+
var ct = { ...F, br: k(pe).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
2817
|
+
var H = { normal: J, gfm: Ae, pedantic: Ie };
|
|
2818
|
+
var B = { normal: V, gfm: F, breaks: ct, pedantic: ut };
|
|
2819
|
+
var ht = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
2820
|
+
var ge = (l3) => ht[l3];
|
|
2490
2821
|
function O(l3, e) {
|
|
2491
2822
|
if (e) {
|
|
2492
2823
|
if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, ge);
|
|
2493
2824
|
} else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, ge);
|
|
2494
2825
|
return l3;
|
|
2495
2826
|
}
|
|
2496
|
-
function
|
|
2827
|
+
function Y(l3) {
|
|
2497
2828
|
try {
|
|
2498
2829
|
l3 = encodeURI(l3).replace(m.percentDecode, "%");
|
|
2499
2830
|
} catch {
|
|
@@ -2501,11 +2832,11 @@ function V(l3) {
|
|
|
2501
2832
|
}
|
|
2502
2833
|
return l3;
|
|
2503
2834
|
}
|
|
2504
|
-
function
|
|
2835
|
+
function ee(l3, e) {
|
|
2505
2836
|
let t = l3.replace(m.findPipe, (r, i, o) => {
|
|
2506
|
-
let
|
|
2507
|
-
for (; --a >= 0 && o[a] === "\\"; )
|
|
2508
|
-
return
|
|
2837
|
+
let p = false, a = i;
|
|
2838
|
+
for (; --a >= 0 && o[a] === "\\"; ) p = !p;
|
|
2839
|
+
return p ? "|" : " |";
|
|
2509
2840
|
}), n = t.split(m.splitPipe), s = 0;
|
|
2510
2841
|
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
|
|
2511
2842
|
else for (; n.length < e; ) n.push("");
|
|
@@ -2524,7 +2855,7 @@ function $(l3, e, t) {
|
|
|
2524
2855
|
}
|
|
2525
2856
|
return l3.slice(0, n - s);
|
|
2526
2857
|
}
|
|
2527
|
-
function
|
|
2858
|
+
function te(l3) {
|
|
2528
2859
|
let e = l3.split(`
|
|
2529
2860
|
`), t = e.length - 1;
|
|
2530
2861
|
for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
|
|
@@ -2550,10 +2881,10 @@ function me(l3, e = 0) {
|
|
|
2550
2881
|
function xe(l3, e, t, n, s) {
|
|
2551
2882
|
let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1");
|
|
2552
2883
|
n.state.inLink = true;
|
|
2553
|
-
let
|
|
2554
|
-
return n.state.inLink = false,
|
|
2884
|
+
let p = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
|
|
2885
|
+
return n.state.inLink = false, p;
|
|
2555
2886
|
}
|
|
2556
|
-
function
|
|
2887
|
+
function dt(l3, e, t) {
|
|
2557
2888
|
let n = l3.match(t.other.indentCodeCompensation);
|
|
2558
2889
|
if (n === null) return e;
|
|
2559
2890
|
let s = n[1];
|
|
@@ -2566,12 +2897,12 @@ function st(l3, e, t) {
|
|
|
2566
2897
|
}).join(`
|
|
2567
2898
|
`);
|
|
2568
2899
|
}
|
|
2569
|
-
var
|
|
2900
|
+
var y = class {
|
|
2570
2901
|
options;
|
|
2571
2902
|
rules;
|
|
2572
2903
|
lexer;
|
|
2573
2904
|
constructor(e) {
|
|
2574
|
-
this.options = e ||
|
|
2905
|
+
this.options = e || R;
|
|
2575
2906
|
}
|
|
2576
2907
|
space(e) {
|
|
2577
2908
|
let t = this.rules.block.newline.exec(e);
|
|
@@ -2580,14 +2911,14 @@ var w = class {
|
|
|
2580
2911
|
code(e) {
|
|
2581
2912
|
let t = this.rules.block.code.exec(e);
|
|
2582
2913
|
if (t) {
|
|
2583
|
-
let n = this.options.pedantic ? t[0] :
|
|
2914
|
+
let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
2584
2915
|
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
2585
2916
|
}
|
|
2586
2917
|
}
|
|
2587
2918
|
fences(e) {
|
|
2588
2919
|
let t = this.rules.block.fences.exec(e);
|
|
2589
2920
|
if (t) {
|
|
2590
|
-
let n = t[0], s =
|
|
2921
|
+
let n = t[0], s = dt(n, t[3] || "", this.rules);
|
|
2591
2922
|
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
2592
2923
|
}
|
|
2593
2924
|
}
|
|
@@ -2615,32 +2946,33 @@ var w = class {
|
|
|
2615
2946
|
`).split(`
|
|
2616
2947
|
`), s = "", r = "", i = [];
|
|
2617
2948
|
for (; n.length > 0; ) {
|
|
2618
|
-
let o = false,
|
|
2619
|
-
for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a]))
|
|
2620
|
-
else if (!o)
|
|
2949
|
+
let o = false, p = [], a;
|
|
2950
|
+
for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) p.push(n[a]), o = true;
|
|
2951
|
+
else if (!o) p.push(n[a]);
|
|
2621
2952
|
else break;
|
|
2622
2953
|
n = n.slice(a);
|
|
2623
|
-
let
|
|
2624
|
-
`),
|
|
2954
|
+
let u = p.join(`
|
|
2955
|
+
`), c = u.replace(this.rules.other.blockquoteSetextReplace, `
|
|
2625
2956
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
2626
2957
|
s = s ? `${s}
|
|
2627
|
-
${
|
|
2628
|
-
${
|
|
2629
|
-
let
|
|
2630
|
-
if (this.lexer.state.top = true, this.lexer.blockTokens(
|
|
2631
|
-
let
|
|
2632
|
-
if (
|
|
2633
|
-
if (
|
|
2634
|
-
let
|
|
2635
|
-
` +
|
|
2636
|
-
`),
|
|
2637
|
-
i[i.length - 1] =
|
|
2958
|
+
${u}` : u, r = r ? `${r}
|
|
2959
|
+
${c}` : c;
|
|
2960
|
+
let h = this.lexer.state.top;
|
|
2961
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, i, true), this.lexer.state.top = h, n.length === 0) break;
|
|
2962
|
+
let d = i.at(-1);
|
|
2963
|
+
if (d?.type === "code") break;
|
|
2964
|
+
if (d?.type === "blockquote") {
|
|
2965
|
+
let T = d, g = n.join(`
|
|
2966
|
+
`), w = T.raw + `
|
|
2967
|
+
` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), M = this.blockquote(w);
|
|
2968
|
+
i[i.length - 1] = M, s = `${s}
|
|
2969
|
+
${g}`, r = r.substring(0, r.length - T.text.length) + M.text;
|
|
2638
2970
|
break;
|
|
2639
|
-
} else if (
|
|
2640
|
-
let
|
|
2971
|
+
} else if (d?.type === "list") {
|
|
2972
|
+
let T = d, g = T.raw + `
|
|
2641
2973
|
` + n.join(`
|
|
2642
|
-
`),
|
|
2643
|
-
i[i.length - 1] =
|
|
2974
|
+
`), w = this.list(g);
|
|
2975
|
+
i[i.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - T.raw.length) + w.raw, n = g.substring(i.at(-1).raw.length).split(`
|
|
2644
2976
|
`);
|
|
2645
2977
|
continue;
|
|
2646
2978
|
}
|
|
@@ -2655,59 +2987,59 @@ ${p}` : p;
|
|
|
2655
2987
|
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
2656
2988
|
let i = this.rules.other.listItemRegex(n), o = false;
|
|
2657
2989
|
for (; e; ) {
|
|
2658
|
-
let a = false,
|
|
2990
|
+
let a = false, u = "", c = "";
|
|
2659
2991
|
if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
2660
|
-
|
|
2661
|
-
let
|
|
2662
|
-
`, 1)[0], t[1].length),
|
|
2663
|
-
`, 1)[0],
|
|
2664
|
-
if (this.options.pedantic ? (
|
|
2665
|
-
`, e = e.substring(
|
|
2666
|
-
let
|
|
2992
|
+
u = t[0], e = e.substring(u.length);
|
|
2993
|
+
let h = me(t[2].split(`
|
|
2994
|
+
`, 1)[0], t[1].length), d = e.split(`
|
|
2995
|
+
`, 1)[0], T = !h.trim(), g = 0;
|
|
2996
|
+
if (this.options.pedantic ? (g = 2, c = h.trimStart()) : T ? 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), T && this.rules.other.blankLine.test(d) && (u += d + `
|
|
2997
|
+
`, e = e.substring(d.length + 1), a = true), !a) {
|
|
2998
|
+
let w = this.rules.other.nextBulletRegex(g), M = 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);
|
|
2667
2999
|
for (; e; ) {
|
|
2668
|
-
let
|
|
2669
|
-
`, 1)[0],
|
|
2670
|
-
if (
|
|
2671
|
-
if (
|
|
2672
|
-
` +
|
|
3000
|
+
let N = e.split(`
|
|
3001
|
+
`, 1)[0], D;
|
|
3002
|
+
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) || M.test(d)) break;
|
|
3003
|
+
if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim()) c += `
|
|
3004
|
+
` + D.slice(g);
|
|
2673
3005
|
else {
|
|
2674
|
-
if (
|
|
2675
|
-
|
|
2676
|
-
` +
|
|
3006
|
+
if (T || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || M.test(h)) break;
|
|
3007
|
+
c += `
|
|
3008
|
+
` + d;
|
|
2677
3009
|
}
|
|
2678
|
-
|
|
2679
|
-
`, e = e.substring(
|
|
3010
|
+
T = !d.trim(), u += N + `
|
|
3011
|
+
`, e = e.substring(N.length + 1), h = D.slice(g);
|
|
2680
3012
|
}
|
|
2681
3013
|
}
|
|
2682
|
-
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(
|
|
3014
|
+
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(u) && (o = true)), r.items.push({ type: "list_item", raw: u, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += u;
|
|
2683
3015
|
}
|
|
2684
|
-
let
|
|
2685
|
-
if (
|
|
3016
|
+
let p = r.items.at(-1);
|
|
3017
|
+
if (p) p.raw = p.raw.trimEnd(), p.text = p.text.trimEnd();
|
|
2686
3018
|
else return;
|
|
2687
3019
|
r.raw = r.raw.trimEnd();
|
|
2688
3020
|
for (let a of r.items) {
|
|
2689
3021
|
this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
|
|
2690
|
-
let
|
|
2691
|
-
if (a.task && (
|
|
2692
|
-
a.text = a.text.replace(this.rules.other.listReplaceTask, ""),
|
|
2693
|
-
for (let
|
|
2694
|
-
this.lexer.inlineQueue[
|
|
3022
|
+
let u = a.tokens[0];
|
|
3023
|
+
if (a.task && (u?.type === "text" || u?.type === "paragraph")) {
|
|
3024
|
+
a.text = a.text.replace(this.rules.other.listReplaceTask, ""), u.raw = u.raw.replace(this.rules.other.listReplaceTask, ""), u.text = u.text.replace(this.rules.other.listReplaceTask, "");
|
|
3025
|
+
for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
|
|
3026
|
+
this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
|
|
2695
3027
|
break;
|
|
2696
3028
|
}
|
|
2697
|
-
let
|
|
2698
|
-
if (
|
|
2699
|
-
let
|
|
2700
|
-
a.checked =
|
|
3029
|
+
let c = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
3030
|
+
if (c) {
|
|
3031
|
+
let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
|
|
3032
|
+
a.checked = h.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h);
|
|
2701
3033
|
}
|
|
2702
3034
|
} else a.task && (a.task = false);
|
|
2703
3035
|
if (!r.loose) {
|
|
2704
|
-
let
|
|
2705
|
-
r.loose =
|
|
3036
|
+
let c = a.tokens.filter((d) => d.type === "space"), h = c.length > 0 && c.some((d) => this.rules.other.anyLine.test(d.raw));
|
|
3037
|
+
r.loose = h;
|
|
2706
3038
|
}
|
|
2707
3039
|
}
|
|
2708
3040
|
if (r.loose) for (let a of r.items) {
|
|
2709
3041
|
a.loose = true;
|
|
2710
|
-
for (let
|
|
3042
|
+
for (let u of a.tokens) u.type === "text" && (u.type = "paragraph");
|
|
2711
3043
|
}
|
|
2712
3044
|
return r;
|
|
2713
3045
|
}
|
|
@@ -2715,7 +3047,7 @@ ${p}` : p;
|
|
|
2715
3047
|
html(e) {
|
|
2716
3048
|
let t = this.rules.block.html.exec(e);
|
|
2717
3049
|
if (t) {
|
|
2718
|
-
let n =
|
|
3050
|
+
let n = te(t[0]);
|
|
2719
3051
|
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
2720
3052
|
}
|
|
2721
3053
|
}
|
|
@@ -2730,13 +3062,13 @@ ${p}` : p;
|
|
|
2730
3062
|
table(e) {
|
|
2731
3063
|
let t = this.rules.block.table.exec(e);
|
|
2732
3064
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
2733
|
-
let n =
|
|
3065
|
+
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(`
|
|
2734
3066
|
`) : [], i = { type: "table", raw: $(t[0], `
|
|
2735
3067
|
`), header: [], align: [], rows: [] };
|
|
2736
3068
|
if (n.length === s.length) {
|
|
2737
3069
|
for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
|
|
2738
3070
|
for (let o = 0; o < n.length; o++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
|
|
2739
|
-
for (let o of r) i.rows.push(
|
|
3071
|
+
for (let o of r) i.rows.push(ee(o, i.header.length).map((p, a) => ({ text: p, tokens: this.lexer.inline(p), header: false, align: i.align[a] })));
|
|
2740
3072
|
return i;
|
|
2741
3073
|
}
|
|
2742
3074
|
}
|
|
@@ -2780,8 +3112,8 @@ ${p}` : p;
|
|
|
2780
3112
|
let i = fe(t[2], "()");
|
|
2781
3113
|
if (i === -2) return;
|
|
2782
3114
|
if (i > -1) {
|
|
2783
|
-
let
|
|
2784
|
-
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0,
|
|
3115
|
+
let p = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
3116
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, p).trim(), t[3] = "";
|
|
2785
3117
|
}
|
|
2786
3118
|
}
|
|
2787
3119
|
let s = t[2], r = "";
|
|
@@ -2807,25 +3139,28 @@ ${p}` : p;
|
|
|
2807
3139
|
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
2808
3140
|
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
2809
3141
|
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2810
|
-
let i = [...s[0]].length - 1, o,
|
|
2811
|
-
for (
|
|
3142
|
+
let i = [...s[0]].length - 1, o, p, a = i, u = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
3143
|
+
for (d.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = d.exec(t)) !== null; ) {
|
|
2812
3144
|
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
|
|
2813
|
-
if (
|
|
2814
|
-
a +=
|
|
2815
|
-
continue;
|
|
2816
|
-
} else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
|
|
2817
|
-
c += u;
|
|
3145
|
+
if (p = [...o].length, s[3] || s[4]) {
|
|
3146
|
+
a += p;
|
|
2818
3147
|
continue;
|
|
3148
|
+
} else if (s[5] || s[6]) {
|
|
3149
|
+
if (i % 3 && !((i + p) % 3)) {
|
|
3150
|
+
u += p;
|
|
3151
|
+
continue;
|
|
3152
|
+
}
|
|
3153
|
+
if (h) break;
|
|
2819
3154
|
}
|
|
2820
|
-
if (a -=
|
|
2821
|
-
|
|
2822
|
-
let
|
|
2823
|
-
if (Math.min(i,
|
|
2824
|
-
let
|
|
2825
|
-
return { type: "em", raw:
|
|
3155
|
+
if (a -= p, a > 0) continue;
|
|
3156
|
+
p = Math.min(p, p + a + u);
|
|
3157
|
+
let T = [...s[0]][0].length, g = e.slice(0, i + s.index + T + p);
|
|
3158
|
+
if (Math.min(i, p) % 2) {
|
|
3159
|
+
let M = g.slice(1, -1);
|
|
3160
|
+
return { type: "em", raw: g, text: M, tokens: this.lexer.inlineTokens(M) };
|
|
2826
3161
|
}
|
|
2827
|
-
let
|
|
2828
|
-
return { type: "strong", raw:
|
|
3162
|
+
let w = g.slice(2, -2);
|
|
3163
|
+
return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
|
|
2829
3164
|
}
|
|
2830
3165
|
}
|
|
2831
3166
|
}
|
|
@@ -2844,17 +3179,17 @@ ${p}` : p;
|
|
|
2844
3179
|
let s = this.rules.inline.delLDelim.exec(e);
|
|
2845
3180
|
if (!s) return;
|
|
2846
3181
|
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2847
|
-
let i = [...s[0]].length - 1, o,
|
|
2848
|
-
for (
|
|
2849
|
-
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (
|
|
3182
|
+
let i = [...s[0]].length - 1, o, p, a = i, u = this.rules.inline.delRDelim;
|
|
3183
|
+
for (u.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = u.exec(t)) !== null; ) {
|
|
3184
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (p = [...o].length, p !== i)) continue;
|
|
2850
3185
|
if (s[3] || s[4]) {
|
|
2851
|
-
a +=
|
|
3186
|
+
a += p;
|
|
2852
3187
|
continue;
|
|
2853
3188
|
}
|
|
2854
|
-
if (a -=
|
|
2855
|
-
|
|
2856
|
-
let
|
|
2857
|
-
return { type: "del", raw:
|
|
3189
|
+
if (a -= p, a > 0) continue;
|
|
3190
|
+
p = Math.min(p, p + a);
|
|
3191
|
+
let c = [...s[0]][0].length, h = e.slice(0, i + s.index + c + p), d = h.slice(i, -i);
|
|
3192
|
+
return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
|
|
2858
3193
|
}
|
|
2859
3194
|
}
|
|
2860
3195
|
}
|
|
@@ -2895,12 +3230,12 @@ var x = class l {
|
|
|
2895
3230
|
inlineQueue;
|
|
2896
3231
|
tokenizer;
|
|
2897
3232
|
constructor(e) {
|
|
2898
|
-
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e ||
|
|
2899
|
-
let t = { other: m, block:
|
|
2900
|
-
this.options.pedantic ? (t.block =
|
|
3233
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || R, 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, top: true };
|
|
3234
|
+
let t = { other: m, block: H.normal, inline: B.normal };
|
|
3235
|
+
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;
|
|
2901
3236
|
}
|
|
2902
3237
|
static get rules() {
|
|
2903
|
-
return { block:
|
|
3238
|
+
return { block: H, inline: B };
|
|
2904
3239
|
}
|
|
2905
3240
|
static lex(e, t) {
|
|
2906
3241
|
return new l(t).lex(e);
|
|
@@ -2987,9 +3322,9 @@ var x = class l {
|
|
|
2987
3322
|
}
|
|
2988
3323
|
let i = e;
|
|
2989
3324
|
if (this.options.extensions?.startBlock) {
|
|
2990
|
-
let o = 1 / 0,
|
|
2991
|
-
this.options.extensions.startBlock.forEach((
|
|
2992
|
-
a =
|
|
3325
|
+
let o = 1 / 0, p = e.slice(1), a;
|
|
3326
|
+
this.options.extensions.startBlock.forEach((u) => {
|
|
3327
|
+
a = u.call({ lexer: this }, p), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
|
|
2993
3328
|
}), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
|
|
2994
3329
|
}
|
|
2995
3330
|
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
@@ -3021,78 +3356,78 @@ var x = class l {
|
|
|
3021
3356
|
}
|
|
3022
3357
|
inlineTokens(e, t = []) {
|
|
3023
3358
|
this.tokenizer.lexer = this;
|
|
3024
|
-
let n = e
|
|
3359
|
+
let n = e;
|
|
3025
3360
|
if (this.tokens.links) {
|
|
3026
|
-
let
|
|
3027
|
-
|
|
3028
|
-
}
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
3033
|
-
let
|
|
3361
|
+
let o = Object.keys(this.tokens.links);
|
|
3362
|
+
o.length > 0 && (n = n.replace(this.tokenizer.rules.inline.reflinkSearch, (p) => o.includes(p.slice(p.lastIndexOf("[") + 1, -1)) ? "[" + "a".repeat(p.length - 2) + "]" : p));
|
|
3363
|
+
}
|
|
3364
|
+
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, "++"), n = n.replace(this.tokenizer.rules.inline.blockSkip, (o, p, a) => {
|
|
3365
|
+
let u = a ? a.length : 0;
|
|
3366
|
+
return o.slice(0, u) + "[" + "a".repeat(o.length - u - 2) + "]";
|
|
3367
|
+
}), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
3368
|
+
let s = false, r = "", i = 1 / 0;
|
|
3034
3369
|
for (; e; ) {
|
|
3035
|
-
if (e.length <
|
|
3370
|
+
if (e.length < i) i = e.length;
|
|
3036
3371
|
else {
|
|
3037
3372
|
this.infiniteLoopError(e.charCodeAt(0));
|
|
3038
3373
|
break;
|
|
3039
3374
|
}
|
|
3040
|
-
|
|
3041
|
-
let
|
|
3042
|
-
if (this.options.extensions?.inline?.some((
|
|
3043
|
-
if (
|
|
3044
|
-
e = e.substring(
|
|
3375
|
+
s || (r = ""), s = false;
|
|
3376
|
+
let o;
|
|
3377
|
+
if (this.options.extensions?.inline?.some((a) => (o = a.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
|
|
3378
|
+
if (o = this.tokenizer.escape(e)) {
|
|
3379
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3045
3380
|
continue;
|
|
3046
3381
|
}
|
|
3047
|
-
if (
|
|
3048
|
-
e = e.substring(
|
|
3382
|
+
if (o = this.tokenizer.tag(e)) {
|
|
3383
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3049
3384
|
continue;
|
|
3050
3385
|
}
|
|
3051
|
-
if (
|
|
3052
|
-
e = e.substring(
|
|
3386
|
+
if (o = this.tokenizer.link(e)) {
|
|
3387
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3053
3388
|
continue;
|
|
3054
3389
|
}
|
|
3055
|
-
if (
|
|
3056
|
-
e = e.substring(
|
|
3057
|
-
let
|
|
3058
|
-
|
|
3390
|
+
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
3391
|
+
e = e.substring(o.raw.length);
|
|
3392
|
+
let a = t.at(-1);
|
|
3393
|
+
o.type === "text" && a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
3059
3394
|
continue;
|
|
3060
3395
|
}
|
|
3061
|
-
if (
|
|
3062
|
-
e = e.substring(
|
|
3396
|
+
if (o = this.tokenizer.emStrong(e, n, r)) {
|
|
3397
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3063
3398
|
continue;
|
|
3064
3399
|
}
|
|
3065
|
-
if (
|
|
3066
|
-
e = e.substring(
|
|
3400
|
+
if (o = this.tokenizer.codespan(e)) {
|
|
3401
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3067
3402
|
continue;
|
|
3068
3403
|
}
|
|
3069
|
-
if (
|
|
3070
|
-
e = e.substring(
|
|
3404
|
+
if (o = this.tokenizer.br(e)) {
|
|
3405
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3071
3406
|
continue;
|
|
3072
3407
|
}
|
|
3073
|
-
if (
|
|
3074
|
-
e = e.substring(
|
|
3408
|
+
if (o = this.tokenizer.del(e, n, r)) {
|
|
3409
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3075
3410
|
continue;
|
|
3076
3411
|
}
|
|
3077
|
-
if (
|
|
3078
|
-
e = e.substring(
|
|
3412
|
+
if (o = this.tokenizer.autolink(e)) {
|
|
3413
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3079
3414
|
continue;
|
|
3080
3415
|
}
|
|
3081
|
-
if (!this.state.inLink && (
|
|
3082
|
-
e = e.substring(
|
|
3416
|
+
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
3417
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
3083
3418
|
continue;
|
|
3084
3419
|
}
|
|
3085
|
-
let
|
|
3420
|
+
let p = e;
|
|
3086
3421
|
if (this.options.extensions?.startInline) {
|
|
3087
|
-
let
|
|
3088
|
-
this.options.extensions.startInline.forEach((
|
|
3089
|
-
|
|
3090
|
-
}),
|
|
3091
|
-
}
|
|
3092
|
-
if (
|
|
3093
|
-
e = e.substring(
|
|
3094
|
-
let
|
|
3095
|
-
|
|
3422
|
+
let a = 1 / 0, u = e.slice(1), c;
|
|
3423
|
+
this.options.extensions.startInline.forEach((h) => {
|
|
3424
|
+
c = h.call({ lexer: this }, u), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
|
|
3425
|
+
}), a < 1 / 0 && a >= 0 && (p = e.substring(0, a + 1));
|
|
3426
|
+
}
|
|
3427
|
+
if (o = this.tokenizer.inlineText(p)) {
|
|
3428
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), s = true;
|
|
3429
|
+
let a = t.at(-1);
|
|
3430
|
+
a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
3096
3431
|
continue;
|
|
3097
3432
|
}
|
|
3098
3433
|
if (e) {
|
|
@@ -3108,11 +3443,11 @@ var x = class l {
|
|
|
3108
3443
|
else throw new Error(t);
|
|
3109
3444
|
}
|
|
3110
3445
|
};
|
|
3111
|
-
var
|
|
3446
|
+
var P = class {
|
|
3112
3447
|
options;
|
|
3113
3448
|
parser;
|
|
3114
3449
|
constructor(e) {
|
|
3115
|
-
this.options = e ||
|
|
3450
|
+
this.options = e || R;
|
|
3116
3451
|
}
|
|
3117
3452
|
space(e) {
|
|
3118
3453
|
return "";
|
|
@@ -3146,8 +3481,8 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
3146
3481
|
list(e) {
|
|
3147
3482
|
let t = e.ordered, n = e.start, s = "";
|
|
3148
3483
|
for (let o = 0; o < e.items.length; o++) {
|
|
3149
|
-
let
|
|
3150
|
-
s += this.listitem(
|
|
3484
|
+
let p = e.items[o];
|
|
3485
|
+
s += this.listitem(p);
|
|
3151
3486
|
}
|
|
3152
3487
|
let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
3153
3488
|
return "<" + r + i + `>
|
|
@@ -3208,7 +3543,7 @@ ${e}</tr>
|
|
|
3208
3543
|
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
3209
3544
|
}
|
|
3210
3545
|
link({ href: e, title: t, tokens: n }) {
|
|
3211
|
-
let s = this.parser.parseInline(n), r =
|
|
3546
|
+
let s = this.parser.parseInline(n), r = Y(e);
|
|
3212
3547
|
if (r === null) return s;
|
|
3213
3548
|
e = r;
|
|
3214
3549
|
let i = '<a href="' + e + '"';
|
|
@@ -3216,7 +3551,7 @@ ${e}</tr>
|
|
|
3216
3551
|
}
|
|
3217
3552
|
image({ href: e, title: t, text: n, tokens: s }) {
|
|
3218
3553
|
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
3219
|
-
let r =
|
|
3554
|
+
let r = Y(e);
|
|
3220
3555
|
if (r === null) return O(n);
|
|
3221
3556
|
e = r;
|
|
3222
3557
|
let i = `<img src="${e}" alt="${O(n)}"`;
|
|
@@ -3263,7 +3598,7 @@ var b = class l2 {
|
|
|
3263
3598
|
renderer;
|
|
3264
3599
|
textRenderer;
|
|
3265
3600
|
constructor(e) {
|
|
3266
|
-
this.options = e ||
|
|
3601
|
+
this.options = e || R, 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();
|
|
3267
3602
|
}
|
|
3268
3603
|
static parse(e, t) {
|
|
3269
3604
|
return new l2(t).parse(e);
|
|
@@ -3278,7 +3613,7 @@ var b = class l2 {
|
|
|
3278
3613
|
let s = e[n];
|
|
3279
3614
|
if (this.options.extensions?.renderers?.[s.type]) {
|
|
3280
3615
|
let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
3281
|
-
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
3616
|
+
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
3282
3617
|
t += o || "";
|
|
3283
3618
|
continue;
|
|
3284
3619
|
}
|
|
@@ -3349,7 +3684,7 @@ var b = class l2 {
|
|
|
3349
3684
|
let r = e[s];
|
|
3350
3685
|
if (this.options.extensions?.renderers?.[r.type]) {
|
|
3351
3686
|
let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
3352
|
-
if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
3687
|
+
if (o !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
3353
3688
|
n += o || "";
|
|
3354
3689
|
continue;
|
|
3355
3690
|
}
|
|
@@ -3410,11 +3745,11 @@ var b = class l2 {
|
|
|
3410
3745
|
return n;
|
|
3411
3746
|
}
|
|
3412
3747
|
};
|
|
3413
|
-
var
|
|
3748
|
+
var S = class {
|
|
3414
3749
|
options;
|
|
3415
3750
|
block;
|
|
3416
3751
|
constructor(e) {
|
|
3417
|
-
this.options = e ||
|
|
3752
|
+
this.options = e || R;
|
|
3418
3753
|
}
|
|
3419
3754
|
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
3420
3755
|
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
@@ -3437,17 +3772,17 @@ var P = class {
|
|
|
3437
3772
|
return e ? b.parse : b.parseInline;
|
|
3438
3773
|
}
|
|
3439
3774
|
};
|
|
3440
|
-
var
|
|
3441
|
-
defaults =
|
|
3775
|
+
var Z = class {
|
|
3776
|
+
defaults = C();
|
|
3442
3777
|
options = this.setOptions;
|
|
3443
3778
|
parse = this.parseMarkdown(true);
|
|
3444
3779
|
parseInline = this.parseMarkdown(false);
|
|
3445
3780
|
Parser = b;
|
|
3446
|
-
Renderer =
|
|
3781
|
+
Renderer = P;
|
|
3447
3782
|
TextRenderer = L;
|
|
3448
3783
|
Lexer = x;
|
|
3449
|
-
Tokenizer =
|
|
3450
|
-
Hooks =
|
|
3784
|
+
Tokenizer = y;
|
|
3785
|
+
Hooks = S;
|
|
3451
3786
|
constructor(...e) {
|
|
3452
3787
|
this.use(...e);
|
|
3453
3788
|
}
|
|
@@ -3484,8 +3819,8 @@ var q = class {
|
|
|
3484
3819
|
if ("renderer" in r) {
|
|
3485
3820
|
let i = t.renderers[r.name];
|
|
3486
3821
|
i ? t.renderers[r.name] = function(...o) {
|
|
3487
|
-
let
|
|
3488
|
-
return
|
|
3822
|
+
let p = r.renderer.apply(this, o);
|
|
3823
|
+
return p === false && (p = i.apply(this, o)), p;
|
|
3489
3824
|
} : t.renderers[r.name] = r.renderer;
|
|
3490
3825
|
}
|
|
3491
3826
|
if ("tokenizer" in r) {
|
|
@@ -3495,51 +3830,51 @@ var q = class {
|
|
|
3495
3830
|
}
|
|
3496
3831
|
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
3497
3832
|
}), s.extensions = t), n.renderer) {
|
|
3498
|
-
let r = this.defaults.renderer || new
|
|
3833
|
+
let r = this.defaults.renderer || new P(this.defaults);
|
|
3499
3834
|
for (let i in n.renderer) {
|
|
3500
3835
|
if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
|
|
3501
3836
|
if (["options", "parser"].includes(i)) continue;
|
|
3502
|
-
let o = i,
|
|
3503
|
-
r[o] = (...
|
|
3504
|
-
let
|
|
3505
|
-
return
|
|
3837
|
+
let o = i, p = n.renderer[o], a = r[o];
|
|
3838
|
+
r[o] = (...u) => {
|
|
3839
|
+
let c = p.apply(r, u);
|
|
3840
|
+
return c === false && (c = a.apply(r, u)), c || "";
|
|
3506
3841
|
};
|
|
3507
3842
|
}
|
|
3508
3843
|
s.renderer = r;
|
|
3509
3844
|
}
|
|
3510
3845
|
if (n.tokenizer) {
|
|
3511
|
-
let r = this.defaults.tokenizer || new
|
|
3846
|
+
let r = this.defaults.tokenizer || new y(this.defaults);
|
|
3512
3847
|
for (let i in n.tokenizer) {
|
|
3513
3848
|
if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
|
|
3514
3849
|
if (["options", "rules", "lexer"].includes(i)) continue;
|
|
3515
|
-
let o = i,
|
|
3516
|
-
r[o] = (...
|
|
3517
|
-
let
|
|
3518
|
-
return
|
|
3850
|
+
let o = i, p = n.tokenizer[o], a = r[o];
|
|
3851
|
+
r[o] = (...u) => {
|
|
3852
|
+
let c = p.apply(r, u);
|
|
3853
|
+
return c === false && (c = a.apply(r, u)), c;
|
|
3519
3854
|
};
|
|
3520
3855
|
}
|
|
3521
3856
|
s.tokenizer = r;
|
|
3522
3857
|
}
|
|
3523
3858
|
if (n.hooks) {
|
|
3524
|
-
let r = this.defaults.hooks || new
|
|
3859
|
+
let r = this.defaults.hooks || new S();
|
|
3525
3860
|
for (let i in n.hooks) {
|
|
3526
3861
|
if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
|
|
3527
3862
|
if (["options", "block"].includes(i)) continue;
|
|
3528
|
-
let o = i,
|
|
3529
|
-
|
|
3530
|
-
if (this.defaults.async &&
|
|
3531
|
-
let
|
|
3532
|
-
return a.call(r,
|
|
3863
|
+
let o = i, p = n.hooks[o], a = r[o];
|
|
3864
|
+
S.passThroughHooks.has(i) ? r[o] = (u) => {
|
|
3865
|
+
if (this.defaults.async && S.passThroughHooksRespectAsync.has(i)) return (async () => {
|
|
3866
|
+
let h = await p.call(r, u);
|
|
3867
|
+
return a.call(r, h);
|
|
3533
3868
|
})();
|
|
3534
|
-
let
|
|
3535
|
-
return a.call(r,
|
|
3536
|
-
} : r[o] = (...
|
|
3869
|
+
let c = p.call(r, u);
|
|
3870
|
+
return a.call(r, c);
|
|
3871
|
+
} : r[o] = (...u) => {
|
|
3537
3872
|
if (this.defaults.async) return (async () => {
|
|
3538
|
-
let
|
|
3539
|
-
return
|
|
3873
|
+
let h = await p.apply(r, u);
|
|
3874
|
+
return h === false && (h = await a.apply(r, u)), h;
|
|
3540
3875
|
})();
|
|
3541
|
-
let
|
|
3542
|
-
return
|
|
3876
|
+
let c = p.apply(r, u);
|
|
3877
|
+
return c === false && (c = a.apply(r, u)), c;
|
|
3543
3878
|
};
|
|
3544
3879
|
}
|
|
3545
3880
|
s.hooks = r;
|
|
@@ -3547,8 +3882,8 @@ var q = class {
|
|
|
3547
3882
|
if (n.walkTokens) {
|
|
3548
3883
|
let r = this.defaults.walkTokens, i = n.walkTokens;
|
|
3549
3884
|
s.walkTokens = function(o) {
|
|
3550
|
-
let
|
|
3551
|
-
return
|
|
3885
|
+
let p = [];
|
|
3886
|
+
return p.push(i.call(this, o)), r && (p = p.concat(r.call(this, o))), p;
|
|
3552
3887
|
};
|
|
3553
3888
|
}
|
|
3554
3889
|
this.defaults = { ...this.defaults, ...s };
|
|
@@ -3570,19 +3905,19 @@ var q = class {
|
|
|
3570
3905
|
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
3571
3906
|
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
3572
3907
|
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
|
|
3573
|
-
let
|
|
3574
|
-
i.walkTokens && await Promise.all(this.walkTokens(
|
|
3575
|
-
let
|
|
3576
|
-
return i.hooks ? await i.hooks.postprocess(
|
|
3908
|
+
let p = i.hooks ? await i.hooks.preprocess(n) : n, u = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(p, i), c = i.hooks ? await i.hooks.processAllTokens(u) : u;
|
|
3909
|
+
i.walkTokens && await Promise.all(this.walkTokens(c, i.walkTokens));
|
|
3910
|
+
let d = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, i);
|
|
3911
|
+
return i.hooks ? await i.hooks.postprocess(d) : d;
|
|
3577
3912
|
})().catch(o);
|
|
3578
3913
|
try {
|
|
3579
3914
|
i.hooks && (n = i.hooks.preprocess(n));
|
|
3580
3915
|
let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
|
|
3581
3916
|
i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
|
|
3582
|
-
let
|
|
3583
|
-
return i.hooks && (
|
|
3584
|
-
} catch (
|
|
3585
|
-
return o(
|
|
3917
|
+
let c = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
|
|
3918
|
+
return i.hooks && (c = i.hooks.postprocess(c)), c;
|
|
3919
|
+
} catch (p) {
|
|
3920
|
+
return o(p);
|
|
3586
3921
|
}
|
|
3587
3922
|
};
|
|
3588
3923
|
}
|
|
@@ -3598,41 +3933,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
3598
3933
|
};
|
|
3599
3934
|
}
|
|
3600
3935
|
};
|
|
3601
|
-
var
|
|
3602
|
-
function
|
|
3603
|
-
return
|
|
3936
|
+
var E = new Z();
|
|
3937
|
+
function f(l3, e) {
|
|
3938
|
+
return E.parse(l3, e);
|
|
3604
3939
|
}
|
|
3605
|
-
|
|
3606
|
-
return
|
|
3607
|
-
};
|
|
3608
|
-
g.getDefaults = M;
|
|
3609
|
-
g.defaults = T;
|
|
3610
|
-
g.use = function(...l3) {
|
|
3611
|
-
return z.use(...l3), g.defaults = z.defaults, N(g.defaults), g;
|
|
3940
|
+
f.options = f.setOptions = function(l3) {
|
|
3941
|
+
return E.setOptions(l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
3612
3942
|
};
|
|
3613
|
-
|
|
3614
|
-
|
|
3943
|
+
f.getDefaults = C;
|
|
3944
|
+
f.defaults = R;
|
|
3945
|
+
function kt(...l3) {
|
|
3946
|
+
return E.use(...l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
3947
|
+
}
|
|
3948
|
+
f.use = kt;
|
|
3949
|
+
f.walkTokens = function(l3, e) {
|
|
3950
|
+
return E.walkTokens(l3, e);
|
|
3615
3951
|
};
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
var
|
|
3627
|
-
var
|
|
3628
|
-
var
|
|
3629
|
-
var
|
|
3630
|
-
var
|
|
3631
|
-
var
|
|
3632
|
-
var Yt = x.lex;
|
|
3952
|
+
f.parseInline = E.parseInline;
|
|
3953
|
+
f.Parser = b;
|
|
3954
|
+
f.parser = b.parse;
|
|
3955
|
+
f.Renderer = P;
|
|
3956
|
+
f.TextRenderer = L;
|
|
3957
|
+
f.Lexer = x;
|
|
3958
|
+
f.lexer = x.lex;
|
|
3959
|
+
f.Tokenizer = y;
|
|
3960
|
+
f.Hooks = S;
|
|
3961
|
+
f.parse = f;
|
|
3962
|
+
var nn = f.options;
|
|
3963
|
+
var rn = f.setOptions;
|
|
3964
|
+
var sn = f.walkTokens;
|
|
3965
|
+
var on = f.parseInline;
|
|
3966
|
+
var ln = b.parse;
|
|
3967
|
+
var pn = x.lex;
|
|
3633
3968
|
|
|
3634
3969
|
// src/ui/render_markdown.ts
|
|
3635
|
-
var parser = new
|
|
3970
|
+
var parser = new Z({ gfm: true, breaks: true });
|
|
3636
3971
|
var ALLOWED_TAGS = [
|
|
3637
3972
|
"a",
|
|
3638
3973
|
"p",
|
|
@@ -6454,7 +6789,7 @@ var RemoteConversationStore = class {
|
|
|
6454
6789
|
return rows.filter((row) => !this.#dropped.has(row.thread_id)).map((row) => this.#toMeta(row));
|
|
6455
6790
|
}
|
|
6456
6791
|
async loadMessages(threadId) {
|
|
6457
|
-
const response = await this.#get(this.#url
|
|
6792
|
+
const response = await this.#get(`${this.#url}${encodeURIComponent(threadId)}/`);
|
|
6458
6793
|
if (response === null || !response.ok) {
|
|
6459
6794
|
return this.#local.loadMessages(threadId);
|
|
6460
6795
|
}
|
|
@@ -6506,7 +6841,7 @@ var RemoteConversationStore = class {
|
|
|
6506
6841
|
async #mutate(threadId, method, body) {
|
|
6507
6842
|
const headers = this.#headers();
|
|
6508
6843
|
try {
|
|
6509
|
-
await fetch(this.#url
|
|
6844
|
+
await fetch(`${this.#url}${encodeURIComponent(threadId)}/`, {
|
|
6510
6845
|
method,
|
|
6511
6846
|
headers: body === void 0 ? headers : { ...headers, "content-type": "application/json" },
|
|
6512
6847
|
body: body === void 0 ? null : JSON.stringify(body)
|
|
@@ -6874,6 +7209,10 @@ var AgUiChat = class extends HTMLElement {
|
|
|
6874
7209
|
// the Send⇄Stop button: `agent.isRunning` is false between frontend-tool
|
|
6875
7210
|
// rounds, but the user must still be able to stop there.
|
|
6876
7211
|
#running = false;
|
|
7212
|
+
// The page the current round's context describes, captured when that context
|
|
7213
|
+
// was built. `null` until the first round. Compared in `#executeTool` to
|
|
7214
|
+
// catch a page that moved under a round still in flight.
|
|
7215
|
+
#contextHref = null;
|
|
6877
7216
|
// Aborting this dismisses (declines) an open confirmation card when the run
|
|
6878
7217
|
// is cancelled while the card awaits a decision. One controller per card.
|
|
6879
7218
|
#confirmAbort = null;
|
|
@@ -6993,7 +7332,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
6993
7332
|
agent,
|
|
6994
7333
|
handlers: this.#handlers(),
|
|
6995
7334
|
getTools: () => this.getTools(),
|
|
6996
|
-
getContext: () => this
|
|
7335
|
+
getContext: () => this.#buildContext(),
|
|
6997
7336
|
executeTool: (call) => this.#executeTool(call),
|
|
6998
7337
|
resolveInterrupts: (interrupts) => this.#resolveInterrupts(interrupts),
|
|
6999
7338
|
connectionLostMessage: this.#strings.connectionLost
|
|
@@ -7072,7 +7411,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
7072
7411
|
}
|
|
7073
7412
|
return [
|
|
7074
7413
|
{
|
|
7075
|
-
name:
|
|
7414
|
+
name: READ_PAGE_TOOL,
|
|
7076
7415
|
description: "Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",
|
|
7077
7416
|
parameters: {
|
|
7078
7417
|
type: "object",
|
|
@@ -7613,7 +7952,59 @@ Use the read_attachment tool with an id to read a file's contents.`
|
|
|
7613
7952
|
const checkpoint = this.conversationStore.loadCheckpoint(this.#threadId);
|
|
7614
7953
|
if (checkpoint !== null) {
|
|
7615
7954
|
await this.#resumeFrom(checkpoint);
|
|
7955
|
+
return;
|
|
7956
|
+
}
|
|
7957
|
+
this.#noticeIfRunUnfinished(messages);
|
|
7958
|
+
}
|
|
7959
|
+
/**
|
|
7960
|
+
* Notice a previous run that never produced a response.
|
|
7961
|
+
*
|
|
7962
|
+
* {@link AgUiClient.send} persists the user's message *before* starting the
|
|
7963
|
+
* run, so a transcript whose last entry is that user message means nothing
|
|
7964
|
+
* ever came back: the page navigated or reloaded mid-run, the tab closed, or
|
|
7965
|
+
* the process died. No extra persistence is needed to detect it — the shape
|
|
7966
|
+
* of the transcript already says so, which is why this needs no
|
|
7967
|
+
* {@link ClientConversationStore} method and no `pagehide` listener (neither
|
|
7968
|
+
* of which fires on a crash or a force-quit anyway).
|
|
7969
|
+
*
|
|
7970
|
+
* The *agent*-initiated reload is not this case: a navigating tool leaves a
|
|
7971
|
+
* checkpoint and resumes, which is why the caller returns early on one before
|
|
7972
|
+
* reaching here.
|
|
7973
|
+
*
|
|
7974
|
+
* Deliberately a notice and never a resume. AG-UI has no
|
|
7975
|
+
* resume-an-aborted-run primitive; re-sending the accumulated messages is
|
|
7976
|
+
* semantically a **new** run, so any server-side tool the agent had already
|
|
7977
|
+
* executed before the interruption would run a second time. Saying plainly
|
|
7978
|
+
* that the answer was lost is the honest option, and the user can re-ask.
|
|
7979
|
+
*/
|
|
7980
|
+
/**
|
|
7981
|
+
* Build a round's context, recording which page it describes.
|
|
7982
|
+
*
|
|
7983
|
+
* The AG-UI client re-invokes this at the top of **every** tool round, not
|
|
7984
|
+
* once per `send()`, so the page map the agent sees is already refreshed
|
|
7985
|
+
* between rounds and the href captured here is the page it was shown for
|
|
7986
|
+
* *this* round. {@link #executeTool} compares against it to catch a page that
|
|
7987
|
+
* moved under a round still in flight.
|
|
7988
|
+
*/
|
|
7989
|
+
#buildContext() {
|
|
7990
|
+
this.#contextHref = window.location.href;
|
|
7991
|
+
return this.getContext();
|
|
7992
|
+
}
|
|
7993
|
+
/**
|
|
7994
|
+
* Whether the page moved since the current round's context was built.
|
|
7995
|
+
*
|
|
7996
|
+
* `null` means no round has built context yet (nothing to compare), which is
|
|
7997
|
+
* not a move.
|
|
7998
|
+
*/
|
|
7999
|
+
#pageMoved() {
|
|
8000
|
+
return this.#contextHref !== null && this.#contextHref !== window.location.href;
|
|
8001
|
+
}
|
|
8002
|
+
#noticeIfRunUnfinished(messages) {
|
|
8003
|
+
const last = messages?.at(-1);
|
|
8004
|
+
if (last === void 0 || last.role !== MESSAGE_ROLE.USER) {
|
|
8005
|
+
return;
|
|
7616
8006
|
}
|
|
8007
|
+
this.#appendNotice("\u26A0", this.#strings.runInterrupted, "interrupted");
|
|
7617
8008
|
}
|
|
7618
8009
|
/**
|
|
7619
8010
|
* Replay a restored message: text bubbles *and* tool activity. An assistant
|
|
@@ -7986,7 +8377,7 @@ Use the read_attachment tool with an id to read a file's contents.`
|
|
|
7986
8377
|
agent,
|
|
7987
8378
|
handlers: this.#handlers(),
|
|
7988
8379
|
getTools: () => this.getTools(),
|
|
7989
|
-
getContext: () => this
|
|
8380
|
+
getContext: () => this.#buildContext(),
|
|
7990
8381
|
executeTool: (call) => this.#executeTool(call),
|
|
7991
8382
|
resolveInterrupts: (interrupts) => this.#resolveInterrupts(interrupts),
|
|
7992
8383
|
onPersist: (messages) => this.conversationStore.saveMessages(this.#threadId, messages),
|
|
@@ -8030,6 +8421,12 @@ Use the read_attachment tool with an id to read a file's contents.`
|
|
|
8030
8421
|
}
|
|
8031
8422
|
return null;
|
|
8032
8423
|
}
|
|
8424
|
+
if (this.getPageMap !== null && call.name !== READ_PAGE_TOOL && !isNavigates(tool.parameters) && this.#pageMoved()) {
|
|
8425
|
+
const message = this.#strings.pageMoved;
|
|
8426
|
+
card.settle(TOOL_CALL_STATUS.ERROR, message);
|
|
8427
|
+
this.#showPending();
|
|
8428
|
+
return { content: `Error: ${message}`, error: message };
|
|
8429
|
+
}
|
|
8033
8430
|
if (await this.#needsConfirmation(call, tool)) {
|
|
8034
8431
|
const request = { toolName: call.name, args: call.args };
|
|
8035
8432
|
const confirmText = tool.parameters[X_CONFIRM_KEY];
|
|
@@ -8369,7 +8766,7 @@ function setControlValue(el, value) {
|
|
|
8369
8766
|
}
|
|
8370
8767
|
|
|
8371
8768
|
// src/version.ts
|
|
8372
|
-
var VERSION = "0.
|
|
8769
|
+
var VERSION = "0.16.0";
|
|
8373
8770
|
export {
|
|
8374
8771
|
AgUiChat,
|
|
8375
8772
|
AgUiClient,
|
|
@@ -8436,6 +8833,6 @@ export {
|
|
|
8436
8833
|
/*! Bundled license information:
|
|
8437
8834
|
|
|
8438
8835
|
dompurify/dist/purify.es.mjs:
|
|
8439
|
-
(*! @license DOMPurify 3.4.
|
|
8836
|
+
(*! @license DOMPurify 3.4.13 | (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.13/LICENSE *)
|
|
8440
8837
|
*/
|
|
8441
8838
|
//# sourceMappingURL=index.js.map
|