@liip/liipgpt 3.10.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -88
- package/NOTICE +22 -0
- package/button/liipgpt-button.iife.js +1 -0
- package/button/liipgpt-button.js +1 -0
- package/chat/liipgpt-chat.iife.js +2 -1
- package/chat/liipgpt-chat.js +2 -1
- package/config/index.cjs +2 -0
- package/config/index.d.ts +30 -0
- package/config/index.js +3 -0
- package/configurator/_app/env.js +1 -1
- package/configurator/_app/immutable/chunks/{DoB1D_8H.js → B1_pfFrT.js} +1 -1
- package/configurator/_app/immutable/chunks/{C3nFRFkd.js → BCwS08XI.js} +2 -2
- package/configurator/_app/immutable/chunks/{DkBX8x2a.js → BJUZhA68.js} +1 -1
- package/configurator/_app/immutable/chunks/{Bp2fQKa2.js → BKIpM6Uh.js} +1 -1
- package/configurator/_app/immutable/chunks/{DGoyvn3J.js → BqUlvFpk.js} +1 -1
- package/configurator/_app/immutable/chunks/{cTsTcg30.js → C89VvXMY.js} +1 -1
- package/configurator/_app/immutable/chunks/{CQKQgM16.js → CCYtl4Cx.js} +1 -1
- package/configurator/_app/immutable/chunks/{IH_3DU1Z.js → CMvCHhSP.js} +1 -1
- package/configurator/_app/immutable/chunks/{BE15eIcX.js → Ck-AVw0N.js} +2 -2
- package/configurator/_app/immutable/chunks/D3wB30_g.js +1 -0
- package/configurator/_app/immutable/chunks/{N6jOC-pH.js → ZTjVhqEP.js} +1 -1
- package/configurator/_app/immutable/chunks/{cZD35eXJ.js → _oGHvI2z.js} +1 -1
- package/configurator/_app/immutable/chunks/{C5-Xjgie.js → avJin-Fq.js} +1 -1
- package/configurator/_app/immutable/chunks/{DCaDs1kM.js → eDqi3535.js} +1 -1
- package/configurator/_app/immutable/chunks/{CehiXGW0.js → pHVM4a9g.js} +1 -1
- package/configurator/_app/immutable/chunks/s8dY_eYY.js +1 -0
- package/configurator/_app/immutable/entry/{app.C8tlSXPA.js → app.DeI6KmEL.js} +2 -2
- package/configurator/_app/immutable/entry/start.B2WsGlY5.js +1 -0
- package/configurator/_app/immutable/nodes/{0.DCB0I300.js → 0.BT5ERCvw.js} +1 -1
- package/configurator/_app/immutable/nodes/{1.B1zFGe7K.js → 1.Ck4X0PzJ.js} +1 -1
- package/configurator/_app/immutable/nodes/{2.CrdD7F_a.js → 2.DH-Gvey4.js} +3 -3
- package/configurator/_app/immutable/nodes/{3.W2IWRGSL.js → 3.CeOJQlnp.js} +1 -1
- package/configurator/_app/version.json +1 -1
- package/configurator/index.html +6 -6
- package/configurator/sidebar.html +6 -6
- package/index.cjs +287 -281
- package/index.d.ts +114 -0
- package/index.js +287 -280
- package/package.json +4 -2
- package/search-summary/liipgpt-search-summary.iife.js +2 -1
- package/search-summary/liipgpt-search-summary.js +4 -3
- package/search-summary/{load-chat-config-D1K0jXrB.js → load-chat-config-BnSgm085.js} +2 -1
- package/search-summary/translations-utils-J0hLe4am.js +2 -0
- package/configurator/_app/immutable/chunks/BDBbhPa3.js +0 -1
- package/configurator/_app/immutable/chunks/Dgkk1Fhx.js +0 -1
- package/configurator/_app/immutable/entry/start.CuNeX-jt.js +0 -1
- package/search-summary/translations-utils-E4InubIu.js +0 -1
package/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/*! @liip/liipgpt | Copyright 2025-2026 Liip AG | Apache-2.0 | see LICENSE and NOTICE */
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -18,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
18
19
|
return cached;
|
|
19
20
|
}
|
|
20
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
23
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
24
|
for (let key of __getOwnPropNames(mod))
|
|
24
25
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -114,17 +115,17 @@ var {
|
|
|
114
115
|
construct
|
|
115
116
|
} = typeof Reflect !== "undefined" && Reflect;
|
|
116
117
|
if (!freeze) {
|
|
117
|
-
freeze = function
|
|
118
|
+
freeze = function freeze(x) {
|
|
118
119
|
return x;
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
122
|
if (!seal) {
|
|
122
|
-
seal = function
|
|
123
|
+
seal = function seal(x) {
|
|
123
124
|
return x;
|
|
124
125
|
};
|
|
125
126
|
}
|
|
126
127
|
if (!apply) {
|
|
127
|
-
apply = function
|
|
128
|
+
apply = function apply(func, thisArg) {
|
|
128
129
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2;_key < _len; _key++) {
|
|
129
130
|
args[_key - 2] = arguments[_key];
|
|
130
131
|
}
|
|
@@ -132,7 +133,7 @@ if (!apply) {
|
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
135
|
if (!construct) {
|
|
135
|
-
construct = function
|
|
136
|
+
construct = function construct(Func) {
|
|
136
137
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++) {
|
|
137
138
|
args[_key2 - 1] = arguments[_key2];
|
|
138
139
|
}
|
|
@@ -284,10 +285,10 @@ var NODE_TYPE = {
|
|
|
284
285
|
documentFragment: 11,
|
|
285
286
|
notation: 12
|
|
286
287
|
};
|
|
287
|
-
var getGlobal = function
|
|
288
|
+
var getGlobal = function getGlobal() {
|
|
288
289
|
return typeof window === "undefined" ? null : window;
|
|
289
290
|
};
|
|
290
|
-
var _createTrustedTypesPolicy = function
|
|
291
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
291
292
|
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
|
|
292
293
|
return null;
|
|
293
294
|
}
|
|
@@ -299,8 +300,8 @@ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes
|
|
|
299
300
|
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
300
301
|
try {
|
|
301
302
|
return trustedTypes.createPolicy(policyName, {
|
|
302
|
-
createHTML(
|
|
303
|
-
return
|
|
303
|
+
createHTML(html) {
|
|
304
|
+
return html;
|
|
304
305
|
},
|
|
305
306
|
createScriptURL(scriptUrl) {
|
|
306
307
|
return scriptUrl;
|
|
@@ -311,7 +312,7 @@ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes
|
|
|
311
312
|
return null;
|
|
312
313
|
}
|
|
313
314
|
};
|
|
314
|
-
var _createHooksMap = function
|
|
315
|
+
var _createHooksMap = function _createHooksMap() {
|
|
315
316
|
return {
|
|
316
317
|
afterSanitizeAttributes: [],
|
|
317
318
|
afterSanitizeElements: [],
|
|
@@ -375,14 +376,14 @@ function createDOMPurify() {
|
|
|
375
376
|
let hooks = _createHooksMap();
|
|
376
377
|
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== undefined;
|
|
377
378
|
const {
|
|
378
|
-
MUSTACHE_EXPR
|
|
379
|
-
ERB_EXPR
|
|
380
|
-
TMPLIT_EXPR
|
|
381
|
-
DATA_ATTR
|
|
382
|
-
ARIA_ATTR
|
|
383
|
-
IS_SCRIPT_OR_DATA
|
|
384
|
-
ATTR_WHITESPACE
|
|
385
|
-
CUSTOM_ELEMENT
|
|
379
|
+
MUSTACHE_EXPR,
|
|
380
|
+
ERB_EXPR,
|
|
381
|
+
TMPLIT_EXPR,
|
|
382
|
+
DATA_ATTR,
|
|
383
|
+
ARIA_ATTR,
|
|
384
|
+
IS_SCRIPT_OR_DATA,
|
|
385
|
+
ATTR_WHITESPACE,
|
|
386
|
+
CUSTOM_ELEMENT
|
|
386
387
|
} = EXPRESSIONS;
|
|
387
388
|
let {
|
|
388
389
|
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
@@ -467,10 +468,10 @@ function createDOMPurify() {
|
|
|
467
468
|
let transformCaseFunc = null;
|
|
468
469
|
let CONFIG = null;
|
|
469
470
|
const formElement = document2.createElement("form");
|
|
470
|
-
const isRegexOrFunction = function
|
|
471
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
471
472
|
return testValue instanceof RegExp || testValue instanceof Function;
|
|
472
473
|
};
|
|
473
|
-
const _parseConfig = function
|
|
474
|
+
const _parseConfig = function _parseConfig() {
|
|
474
475
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
475
476
|
if (CONFIG && CONFIG === cfg) {
|
|
476
477
|
return;
|
|
@@ -623,7 +624,7 @@ function createDOMPurify() {
|
|
|
623
624
|
};
|
|
624
625
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
625
626
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
626
|
-
const _checkValidNamespace = function
|
|
627
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
627
628
|
let parent = getParentNode(element);
|
|
628
629
|
if (!parent || !parent.tagName) {
|
|
629
630
|
parent = {
|
|
@@ -668,7 +669,7 @@ function createDOMPurify() {
|
|
|
668
669
|
}
|
|
669
670
|
return false;
|
|
670
671
|
};
|
|
671
|
-
const _forceRemove = function
|
|
672
|
+
const _forceRemove = function _forceRemove(node) {
|
|
672
673
|
arrayPush(DOMPurify.removed, {
|
|
673
674
|
element: node
|
|
674
675
|
});
|
|
@@ -678,7 +679,7 @@ function createDOMPurify() {
|
|
|
678
679
|
remove(node);
|
|
679
680
|
}
|
|
680
681
|
};
|
|
681
|
-
const _removeAttribute = function
|
|
682
|
+
const _removeAttribute = function _removeAttribute(name, element) {
|
|
682
683
|
try {
|
|
683
684
|
arrayPush(DOMPurify.removed, {
|
|
684
685
|
attribute: element.getAttributeNode(name),
|
|
@@ -703,7 +704,7 @@ function createDOMPurify() {
|
|
|
703
704
|
}
|
|
704
705
|
}
|
|
705
706
|
};
|
|
706
|
-
const _initDocument = function
|
|
707
|
+
const _initDocument = function _initDocument(dirty) {
|
|
707
708
|
let doc = null;
|
|
708
709
|
let leadingWhitespace = null;
|
|
709
710
|
if (FORCE_BODY) {
|
|
@@ -736,21 +737,21 @@ function createDOMPurify() {
|
|
|
736
737
|
}
|
|
737
738
|
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
738
739
|
};
|
|
739
|
-
const _createNodeIterator = function
|
|
740
|
+
const _createNodeIterator = function _createNodeIterator(root) {
|
|
740
741
|
return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
741
742
|
};
|
|
742
|
-
const _isClobbered = function
|
|
743
|
+
const _isClobbered = function _isClobbered(element) {
|
|
743
744
|
return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
|
|
744
745
|
};
|
|
745
|
-
const _isNode = function
|
|
746
|
+
const _isNode = function _isNode(value) {
|
|
746
747
|
return typeof Node2 === "function" && value instanceof Node2;
|
|
747
748
|
};
|
|
748
|
-
function _executeHooks(
|
|
749
|
-
arrayForEach(
|
|
749
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
750
|
+
arrayForEach(hooks, (hook) => {
|
|
750
751
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
751
752
|
});
|
|
752
753
|
}
|
|
753
|
-
const _sanitizeElements = function
|
|
754
|
+
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
754
755
|
let content = null;
|
|
755
756
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
756
757
|
if (_isClobbered(currentNode)) {
|
|
@@ -808,7 +809,7 @@ function createDOMPurify() {
|
|
|
808
809
|
}
|
|
809
810
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
810
811
|
content = currentNode.textContent;
|
|
811
|
-
arrayForEach([
|
|
812
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {
|
|
812
813
|
content = stringReplace(content, expr, " ");
|
|
813
814
|
});
|
|
814
815
|
if (currentNode.textContent !== content) {
|
|
@@ -821,16 +822,16 @@ function createDOMPurify() {
|
|
|
821
822
|
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
822
823
|
return false;
|
|
823
824
|
};
|
|
824
|
-
const _isValidAttribute = function
|
|
825
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
825
826
|
if (FORBID_ATTR[lcName]) {
|
|
826
827
|
return false;
|
|
827
828
|
}
|
|
828
829
|
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && ((value in document2) || (value in formElement))) {
|
|
829
830
|
return false;
|
|
830
831
|
}
|
|
831
|
-
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(
|
|
832
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName))
|
|
832
833
|
;
|
|
833
|
-
else if (ALLOW_ARIA_ATTR && regExpTest(
|
|
834
|
+
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName))
|
|
834
835
|
;
|
|
835
836
|
else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag))
|
|
836
837
|
;
|
|
@@ -842,21 +843,21 @@ function createDOMPurify() {
|
|
|
842
843
|
}
|
|
843
844
|
} else if (URI_SAFE_ATTRIBUTES[lcName])
|
|
844
845
|
;
|
|
845
|
-
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value,
|
|
846
|
+
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, "")))
|
|
846
847
|
;
|
|
847
848
|
else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag])
|
|
848
849
|
;
|
|
849
|
-
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(
|
|
850
|
+
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, "")))
|
|
850
851
|
;
|
|
851
852
|
else if (value) {
|
|
852
853
|
return false;
|
|
853
854
|
}
|
|
854
855
|
return true;
|
|
855
856
|
};
|
|
856
|
-
const _isBasicCustomElement = function
|
|
857
|
-
return tagName !== "annotation-xml" && stringMatch(tagName,
|
|
857
|
+
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
858
|
+
return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT);
|
|
858
859
|
};
|
|
859
|
-
const _sanitizeAttributes = function
|
|
860
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
860
861
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
861
862
|
const {
|
|
862
863
|
attributes
|
|
@@ -912,7 +913,7 @@ function createDOMPurify() {
|
|
|
912
913
|
continue;
|
|
913
914
|
}
|
|
914
915
|
if (SAFE_FOR_TEMPLATES) {
|
|
915
|
-
arrayForEach([
|
|
916
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {
|
|
916
917
|
value = stringReplace(value, expr, " ");
|
|
917
918
|
});
|
|
918
919
|
}
|
|
@@ -956,7 +957,7 @@ function createDOMPurify() {
|
|
|
956
957
|
}
|
|
957
958
|
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
958
959
|
};
|
|
959
|
-
const _sanitizeShadowDOM = function
|
|
960
|
+
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
960
961
|
let shadowNode = null;
|
|
961
962
|
const shadowIterator = _createNodeIterator(fragment);
|
|
962
963
|
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
@@ -965,7 +966,7 @@ function createDOMPurify() {
|
|
|
965
966
|
_sanitizeElements(shadowNode);
|
|
966
967
|
_sanitizeAttributes(shadowNode);
|
|
967
968
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
968
|
-
|
|
969
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
969
970
|
}
|
|
970
971
|
}
|
|
971
972
|
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
@@ -1060,7 +1061,7 @@ function createDOMPurify() {
|
|
|
1060
1061
|
` + serializedHTML;
|
|
1061
1062
|
}
|
|
1062
1063
|
if (SAFE_FOR_TEMPLATES) {
|
|
1063
|
-
arrayForEach([
|
|
1064
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {
|
|
1064
1065
|
serializedHTML = stringReplace(serializedHTML, expr, " ");
|
|
1065
1066
|
});
|
|
1066
1067
|
}
|
|
@@ -1337,17 +1338,17 @@ var escapeReplacements = {
|
|
|
1337
1338
|
"'": "'"
|
|
1338
1339
|
};
|
|
1339
1340
|
var getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
1340
|
-
function escape2(
|
|
1341
|
+
function escape2(html2, encode) {
|
|
1341
1342
|
if (encode) {
|
|
1342
|
-
if (other.escapeTest.test(
|
|
1343
|
-
return
|
|
1343
|
+
if (other.escapeTest.test(html2)) {
|
|
1344
|
+
return html2.replace(other.escapeReplace, getEscapeReplacement);
|
|
1344
1345
|
}
|
|
1345
1346
|
} else {
|
|
1346
|
-
if (other.escapeTestNoEncode.test(
|
|
1347
|
-
return
|
|
1347
|
+
if (other.escapeTestNoEncode.test(html2)) {
|
|
1348
|
+
return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
|
|
1348
1349
|
}
|
|
1349
1350
|
}
|
|
1350
|
-
return
|
|
1351
|
+
return html2;
|
|
1351
1352
|
}
|
|
1352
1353
|
function cleanUrl(href) {
|
|
1353
1354
|
try {
|
|
@@ -1432,26 +1433,26 @@ function findClosingBracket(str, b) {
|
|
|
1432
1433
|
function outputLink(cap, link2, raw, lexer2, rules) {
|
|
1433
1434
|
const href = link2.href;
|
|
1434
1435
|
const title = link2.title || null;
|
|
1435
|
-
const
|
|
1436
|
+
const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
|
|
1436
1437
|
lexer2.state.inLink = true;
|
|
1437
1438
|
const token = {
|
|
1438
1439
|
type: cap[0].charAt(0) === "!" ? "image" : "link",
|
|
1439
1440
|
raw,
|
|
1440
1441
|
href,
|
|
1441
1442
|
title,
|
|
1442
|
-
text
|
|
1443
|
-
tokens: lexer2.inlineTokens(
|
|
1443
|
+
text,
|
|
1444
|
+
tokens: lexer2.inlineTokens(text)
|
|
1444
1445
|
};
|
|
1445
1446
|
lexer2.state.inLink = false;
|
|
1446
1447
|
return token;
|
|
1447
1448
|
}
|
|
1448
|
-
function indentCodeCompensation(raw,
|
|
1449
|
+
function indentCodeCompensation(raw, text, rules) {
|
|
1449
1450
|
const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
|
|
1450
1451
|
if (matchIndentToCode === null) {
|
|
1451
|
-
return
|
|
1452
|
+
return text;
|
|
1452
1453
|
}
|
|
1453
1454
|
const indentToCode = matchIndentToCode[1];
|
|
1454
|
-
return
|
|
1455
|
+
return text.split(`
|
|
1455
1456
|
`).map((node) => {
|
|
1456
1457
|
const matchIndentInNode = node.match(rules.other.beginningSpace);
|
|
1457
1458
|
if (matchIndentInNode === null) {
|
|
@@ -1484,13 +1485,13 @@ var _Tokenizer = class {
|
|
|
1484
1485
|
code(src) {
|
|
1485
1486
|
const cap = this.rules.block.code.exec(src);
|
|
1486
1487
|
if (cap) {
|
|
1487
|
-
const
|
|
1488
|
+
const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
|
|
1488
1489
|
return {
|
|
1489
1490
|
type: "code",
|
|
1490
1491
|
raw: cap[0],
|
|
1491
1492
|
codeBlockStyle: "indented",
|
|
1492
|
-
text: !this.options.pedantic ? rtrim(
|
|
1493
|
-
`) :
|
|
1493
|
+
text: !this.options.pedantic ? rtrim(text, `
|
|
1494
|
+
`) : text
|
|
1494
1495
|
};
|
|
1495
1496
|
}
|
|
1496
1497
|
}
|
|
@@ -1498,33 +1499,33 @@ var _Tokenizer = class {
|
|
|
1498
1499
|
const cap = this.rules.block.fences.exec(src);
|
|
1499
1500
|
if (cap) {
|
|
1500
1501
|
const raw = cap[0];
|
|
1501
|
-
const
|
|
1502
|
+
const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
|
|
1502
1503
|
return {
|
|
1503
1504
|
type: "code",
|
|
1504
1505
|
raw,
|
|
1505
1506
|
lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
|
|
1506
|
-
text
|
|
1507
|
+
text
|
|
1507
1508
|
};
|
|
1508
1509
|
}
|
|
1509
1510
|
}
|
|
1510
1511
|
heading(src) {
|
|
1511
1512
|
const cap = this.rules.block.heading.exec(src);
|
|
1512
1513
|
if (cap) {
|
|
1513
|
-
let
|
|
1514
|
-
if (this.rules.other.endingHash.test(
|
|
1515
|
-
const trimmed = rtrim(
|
|
1514
|
+
let text = cap[2].trim();
|
|
1515
|
+
if (this.rules.other.endingHash.test(text)) {
|
|
1516
|
+
const trimmed = rtrim(text, "#");
|
|
1516
1517
|
if (this.options.pedantic) {
|
|
1517
|
-
|
|
1518
|
+
text = trimmed.trim();
|
|
1518
1519
|
} else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
|
|
1519
|
-
|
|
1520
|
+
text = trimmed.trim();
|
|
1520
1521
|
}
|
|
1521
1522
|
}
|
|
1522
1523
|
return {
|
|
1523
1524
|
type: "heading",
|
|
1524
1525
|
raw: cap[0],
|
|
1525
1526
|
depth: cap[1].length,
|
|
1526
|
-
text
|
|
1527
|
-
tokens: this.lexer.inline(
|
|
1527
|
+
text,
|
|
1528
|
+
tokens: this.lexer.inline(text)
|
|
1528
1529
|
};
|
|
1529
1530
|
}
|
|
1530
1531
|
}
|
|
@@ -1545,7 +1546,7 @@ var _Tokenizer = class {
|
|
|
1545
1546
|
`).split(`
|
|
1546
1547
|
`);
|
|
1547
1548
|
let raw = "";
|
|
1548
|
-
let
|
|
1549
|
+
let text = "";
|
|
1549
1550
|
const tokens = [];
|
|
1550
1551
|
while (lines.length > 0) {
|
|
1551
1552
|
let inBlockquote = false;
|
|
@@ -1568,7 +1569,7 @@ var _Tokenizer = class {
|
|
|
1568
1569
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1569
1570
|
raw = raw ? `${raw}
|
|
1570
1571
|
${currentRaw}` : currentRaw;
|
|
1571
|
-
|
|
1572
|
+
text = text ? `${text}
|
|
1572
1573
|
${currentText}` : currentText;
|
|
1573
1574
|
const top = this.lexer.state.top;
|
|
1574
1575
|
this.lexer.state.top = true;
|
|
@@ -1588,7 +1589,7 @@ ${currentText}` : currentText;
|
|
|
1588
1589
|
const newToken = this.blockquote(newText);
|
|
1589
1590
|
tokens[tokens.length - 1] = newToken;
|
|
1590
1591
|
raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
|
|
1591
|
-
|
|
1592
|
+
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
|
|
1592
1593
|
break;
|
|
1593
1594
|
} else if (lastToken?.type === "list") {
|
|
1594
1595
|
const oldToken = lastToken;
|
|
@@ -1598,7 +1599,7 @@ ${currentText}` : currentText;
|
|
|
1598
1599
|
const newToken = this.list(newText);
|
|
1599
1600
|
tokens[tokens.length - 1] = newToken;
|
|
1600
1601
|
raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
|
|
1601
|
-
|
|
1602
|
+
text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
|
|
1602
1603
|
lines = newText.substring(tokens.at(-1).raw.length).split(`
|
|
1603
1604
|
`);
|
|
1604
1605
|
continue;
|
|
@@ -1608,7 +1609,7 @@ ${currentText}` : currentText;
|
|
|
1608
1609
|
type: "blockquote",
|
|
1609
1610
|
raw,
|
|
1610
1611
|
tokens,
|
|
1611
|
-
text
|
|
1612
|
+
text
|
|
1612
1613
|
};
|
|
1613
1614
|
}
|
|
1614
1615
|
}
|
|
@@ -1877,13 +1878,13 @@ ${currentText}` : currentText;
|
|
|
1877
1878
|
paragraph(src) {
|
|
1878
1879
|
const cap = this.rules.block.paragraph.exec(src);
|
|
1879
1880
|
if (cap) {
|
|
1880
|
-
const
|
|
1881
|
+
const text = cap[1].charAt(cap[1].length - 1) === `
|
|
1881
1882
|
` ? cap[1].slice(0, -1) : cap[1];
|
|
1882
1883
|
return {
|
|
1883
1884
|
type: "paragraph",
|
|
1884
1885
|
raw: cap[0],
|
|
1885
|
-
text
|
|
1886
|
-
tokens: this.lexer.inline(
|
|
1886
|
+
text,
|
|
1887
|
+
tokens: this.lexer.inline(text)
|
|
1887
1888
|
};
|
|
1888
1889
|
}
|
|
1889
1890
|
}
|
|
@@ -1987,11 +1988,11 @@ ${currentText}` : currentText;
|
|
|
1987
1988
|
const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
|
|
1988
1989
|
const link2 = links[linkString.toLowerCase()];
|
|
1989
1990
|
if (!link2) {
|
|
1990
|
-
const
|
|
1991
|
+
const text = cap[0].charAt(0);
|
|
1991
1992
|
return {
|
|
1992
1993
|
type: "text",
|
|
1993
|
-
raw:
|
|
1994
|
-
text
|
|
1994
|
+
raw: text,
|
|
1995
|
+
text
|
|
1995
1996
|
};
|
|
1996
1997
|
}
|
|
1997
1998
|
return outputLink(cap, link2, cap[0], this.lexer, this.rules);
|
|
@@ -2031,20 +2032,20 @@ ${currentText}` : currentText;
|
|
|
2031
2032
|
const lastCharLength = [...match[0]][0].length;
|
|
2032
2033
|
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
|
|
2033
2034
|
if (Math.min(lLength, rLength) % 2) {
|
|
2034
|
-
const
|
|
2035
|
+
const text2 = raw.slice(1, -1);
|
|
2035
2036
|
return {
|
|
2036
2037
|
type: "em",
|
|
2037
2038
|
raw,
|
|
2038
|
-
text:
|
|
2039
|
-
tokens: this.lexer.inlineTokens(
|
|
2039
|
+
text: text2,
|
|
2040
|
+
tokens: this.lexer.inlineTokens(text2)
|
|
2040
2041
|
};
|
|
2041
2042
|
}
|
|
2042
|
-
const
|
|
2043
|
+
const text = raw.slice(2, -2);
|
|
2043
2044
|
return {
|
|
2044
2045
|
type: "strong",
|
|
2045
2046
|
raw,
|
|
2046
|
-
text
|
|
2047
|
-
tokens: this.lexer.inlineTokens(
|
|
2047
|
+
text,
|
|
2048
|
+
tokens: this.lexer.inlineTokens(text)
|
|
2048
2049
|
};
|
|
2049
2050
|
}
|
|
2050
2051
|
}
|
|
@@ -2052,16 +2053,16 @@ ${currentText}` : currentText;
|
|
|
2052
2053
|
codespan(src) {
|
|
2053
2054
|
const cap = this.rules.inline.code.exec(src);
|
|
2054
2055
|
if (cap) {
|
|
2055
|
-
let
|
|
2056
|
-
const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(
|
|
2057
|
-
const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(
|
|
2056
|
+
let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
|
|
2057
|
+
const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
|
|
2058
|
+
const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
|
|
2058
2059
|
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
2059
|
-
|
|
2060
|
+
text = text.substring(1, text.length - 1);
|
|
2060
2061
|
}
|
|
2061
2062
|
return {
|
|
2062
2063
|
type: "codespan",
|
|
2063
2064
|
raw: cap[0],
|
|
2064
|
-
text
|
|
2065
|
+
text
|
|
2065
2066
|
};
|
|
2066
2067
|
}
|
|
2067
2068
|
}
|
|
@@ -2088,24 +2089,24 @@ ${currentText}` : currentText;
|
|
|
2088
2089
|
autolink(src) {
|
|
2089
2090
|
const cap = this.rules.inline.autolink.exec(src);
|
|
2090
2091
|
if (cap) {
|
|
2091
|
-
let
|
|
2092
|
+
let text, href;
|
|
2092
2093
|
if (cap[2] === "@") {
|
|
2093
|
-
|
|
2094
|
-
href = "mailto:" +
|
|
2094
|
+
text = cap[1];
|
|
2095
|
+
href = "mailto:" + text;
|
|
2095
2096
|
} else {
|
|
2096
|
-
|
|
2097
|
-
href =
|
|
2097
|
+
text = cap[1];
|
|
2098
|
+
href = text;
|
|
2098
2099
|
}
|
|
2099
2100
|
return {
|
|
2100
2101
|
type: "link",
|
|
2101
2102
|
raw: cap[0],
|
|
2102
|
-
text
|
|
2103
|
+
text,
|
|
2103
2104
|
href,
|
|
2104
2105
|
tokens: [
|
|
2105
2106
|
{
|
|
2106
2107
|
type: "text",
|
|
2107
|
-
raw:
|
|
2108
|
-
text
|
|
2108
|
+
raw: text,
|
|
2109
|
+
text
|
|
2109
2110
|
}
|
|
2110
2111
|
]
|
|
2111
2112
|
};
|
|
@@ -2114,17 +2115,17 @@ ${currentText}` : currentText;
|
|
|
2114
2115
|
url(src) {
|
|
2115
2116
|
let cap;
|
|
2116
2117
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
2117
|
-
let
|
|
2118
|
+
let text, href;
|
|
2118
2119
|
if (cap[2] === "@") {
|
|
2119
|
-
|
|
2120
|
-
href = "mailto:" +
|
|
2120
|
+
text = cap[0];
|
|
2121
|
+
href = "mailto:" + text;
|
|
2121
2122
|
} else {
|
|
2122
2123
|
let prevCapZero;
|
|
2123
2124
|
do {
|
|
2124
2125
|
prevCapZero = cap[0];
|
|
2125
2126
|
cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
|
|
2126
2127
|
} while (prevCapZero !== cap[0]);
|
|
2127
|
-
|
|
2128
|
+
text = cap[0];
|
|
2128
2129
|
if (cap[1] === "www.") {
|
|
2129
2130
|
href = "http://" + cap[0];
|
|
2130
2131
|
} else {
|
|
@@ -2134,13 +2135,13 @@ ${currentText}` : currentText;
|
|
|
2134
2135
|
return {
|
|
2135
2136
|
type: "link",
|
|
2136
2137
|
raw: cap[0],
|
|
2137
|
-
text
|
|
2138
|
+
text,
|
|
2138
2139
|
href,
|
|
2139
2140
|
tokens: [
|
|
2140
2141
|
{
|
|
2141
2142
|
type: "text",
|
|
2142
|
-
raw:
|
|
2143
|
-
text
|
|
2143
|
+
raw: text,
|
|
2144
|
+
text
|
|
2144
2145
|
}
|
|
2145
2146
|
]
|
|
2146
2147
|
};
|
|
@@ -2528,9 +2529,9 @@ var _Renderer = class {
|
|
|
2528
2529
|
space(token) {
|
|
2529
2530
|
return "";
|
|
2530
2531
|
}
|
|
2531
|
-
code({ text
|
|
2532
|
+
code({ text, lang, escaped }) {
|
|
2532
2533
|
const langString = (lang || "").match(other.notSpaceStart)?.[0];
|
|
2533
|
-
const code =
|
|
2534
|
+
const code = text.replace(other.endingNewline, "") + `
|
|
2534
2535
|
`;
|
|
2535
2536
|
if (!langString) {
|
|
2536
2537
|
return "<pre><code>" + (escaped ? code : escape2(code, true)) + `</code></pre>
|
|
@@ -2545,8 +2546,8 @@ var _Renderer = class {
|
|
|
2545
2546
|
${body}</blockquote>
|
|
2546
2547
|
`;
|
|
2547
2548
|
}
|
|
2548
|
-
html({ text
|
|
2549
|
-
return
|
|
2549
|
+
html({ text }) {
|
|
2550
|
+
return text;
|
|
2550
2551
|
}
|
|
2551
2552
|
heading({ tokens, depth }) {
|
|
2552
2553
|
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
|
|
@@ -2628,9 +2629,9 @@ ${body}</blockquote>
|
|
|
2628
2629
|
` + body + `</table>
|
|
2629
2630
|
`;
|
|
2630
2631
|
}
|
|
2631
|
-
tablerow({ text
|
|
2632
|
+
tablerow({ text }) {
|
|
2632
2633
|
return `<tr>
|
|
2633
|
-
${
|
|
2634
|
+
${text}</tr>
|
|
2634
2635
|
`;
|
|
2635
2636
|
}
|
|
2636
2637
|
tablecell(token) {
|
|
@@ -2646,8 +2647,8 @@ ${text2}</tr>
|
|
|
2646
2647
|
em({ tokens }) {
|
|
2647
2648
|
return `<em>${this.parser.parseInline(tokens)}</em>`;
|
|
2648
2649
|
}
|
|
2649
|
-
codespan({ text
|
|
2650
|
-
return `<code>${escape2(
|
|
2650
|
+
codespan({ text }) {
|
|
2651
|
+
return `<code>${escape2(text, true)}</code>`;
|
|
2651
2652
|
}
|
|
2652
2653
|
br(token) {
|
|
2653
2654
|
return "<br>";
|
|
@@ -2656,29 +2657,29 @@ ${text2}</tr>
|
|
|
2656
2657
|
return `<del>${this.parser.parseInline(tokens)}</del>`;
|
|
2657
2658
|
}
|
|
2658
2659
|
link({ href, title, tokens }) {
|
|
2659
|
-
const
|
|
2660
|
+
const text = this.parser.parseInline(tokens);
|
|
2660
2661
|
const cleanHref = cleanUrl(href);
|
|
2661
2662
|
if (cleanHref === null) {
|
|
2662
|
-
return
|
|
2663
|
+
return text;
|
|
2663
2664
|
}
|
|
2664
2665
|
href = cleanHref;
|
|
2665
2666
|
let out = '<a href="' + href + '"';
|
|
2666
2667
|
if (title) {
|
|
2667
2668
|
out += ' title="' + escape2(title) + '"';
|
|
2668
2669
|
}
|
|
2669
|
-
out += ">" +
|
|
2670
|
+
out += ">" + text + "</a>";
|
|
2670
2671
|
return out;
|
|
2671
2672
|
}
|
|
2672
|
-
image({ href, title, text
|
|
2673
|
+
image({ href, title, text, tokens }) {
|
|
2673
2674
|
if (tokens) {
|
|
2674
|
-
|
|
2675
|
+
text = this.parser.parseInline(tokens, this.parser.textRenderer);
|
|
2675
2676
|
}
|
|
2676
2677
|
const cleanHref = cleanUrl(href);
|
|
2677
2678
|
if (cleanHref === null) {
|
|
2678
|
-
return escape2(
|
|
2679
|
+
return escape2(text);
|
|
2679
2680
|
}
|
|
2680
2681
|
href = cleanHref;
|
|
2681
|
-
let out = `<img src="${href}" alt="${
|
|
2682
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
2682
2683
|
if (title) {
|
|
2683
2684
|
out += ` title="${escape2(title)}"`;
|
|
2684
2685
|
}
|
|
@@ -2690,29 +2691,29 @@ ${text2}</tr>
|
|
|
2690
2691
|
}
|
|
2691
2692
|
};
|
|
2692
2693
|
var _TextRenderer = class {
|
|
2693
|
-
strong({ text
|
|
2694
|
-
return
|
|
2694
|
+
strong({ text }) {
|
|
2695
|
+
return text;
|
|
2695
2696
|
}
|
|
2696
|
-
em({ text
|
|
2697
|
-
return
|
|
2697
|
+
em({ text }) {
|
|
2698
|
+
return text;
|
|
2698
2699
|
}
|
|
2699
|
-
codespan({ text
|
|
2700
|
-
return
|
|
2700
|
+
codespan({ text }) {
|
|
2701
|
+
return text;
|
|
2701
2702
|
}
|
|
2702
|
-
del({ text
|
|
2703
|
-
return
|
|
2703
|
+
del({ text }) {
|
|
2704
|
+
return text;
|
|
2704
2705
|
}
|
|
2705
|
-
html({ text
|
|
2706
|
-
return
|
|
2706
|
+
html({ text }) {
|
|
2707
|
+
return text;
|
|
2707
2708
|
}
|
|
2708
|
-
text({ text
|
|
2709
|
-
return
|
|
2709
|
+
text({ text }) {
|
|
2710
|
+
return text;
|
|
2710
2711
|
}
|
|
2711
|
-
link({ text
|
|
2712
|
-
return "" +
|
|
2712
|
+
link({ text }) {
|
|
2713
|
+
return "" + text;
|
|
2713
2714
|
}
|
|
2714
|
-
image({ text
|
|
2715
|
-
return "" +
|
|
2715
|
+
image({ text }) {
|
|
2716
|
+
return "" + text;
|
|
2716
2717
|
}
|
|
2717
2718
|
br() {
|
|
2718
2719
|
return "";
|
|
@@ -2902,8 +2903,8 @@ var _Hooks = class {
|
|
|
2902
2903
|
preprocess(markdown) {
|
|
2903
2904
|
return markdown;
|
|
2904
2905
|
}
|
|
2905
|
-
postprocess(
|
|
2906
|
-
return
|
|
2906
|
+
postprocess(html2) {
|
|
2907
|
+
return html2;
|
|
2907
2908
|
}
|
|
2908
2909
|
processAllTokens(tokens) {
|
|
2909
2910
|
return tokens;
|
|
@@ -3147,7 +3148,7 @@ var Marked = class {
|
|
|
3147
3148
|
const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
|
|
3148
3149
|
const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
|
|
3149
3150
|
if (opt.async) {
|
|
3150
|
-
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((
|
|
3151
|
+
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
|
|
3151
3152
|
}
|
|
3152
3153
|
try {
|
|
3153
3154
|
if (opt.hooks) {
|
|
@@ -3160,11 +3161,11 @@ var Marked = class {
|
|
|
3160
3161
|
if (opt.walkTokens) {
|
|
3161
3162
|
this.walkTokens(tokens, opt.walkTokens);
|
|
3162
3163
|
}
|
|
3163
|
-
let
|
|
3164
|
+
let html2 = parser2(tokens, opt);
|
|
3164
3165
|
if (opt.hooks) {
|
|
3165
|
-
|
|
3166
|
+
html2 = opt.hooks.postprocess(html2);
|
|
3166
3167
|
}
|
|
3167
|
-
return
|
|
3168
|
+
return html2;
|
|
3168
3169
|
} catch (e) {
|
|
3169
3170
|
return throwError(e);
|
|
3170
3171
|
}
|
|
@@ -3273,9 +3274,9 @@ class MarkdownRenderer {
|
|
|
3273
3274
|
currentReferences = emptyChatReferences;
|
|
3274
3275
|
lastUsedIndex = 0;
|
|
3275
3276
|
DomPurity;
|
|
3276
|
-
constructor(
|
|
3277
|
-
this.marked = new Marked({ async: false, breaks: true }).use(this.createFootnoteExtension(), ...
|
|
3278
|
-
this.DomPurity = getDomPurify(
|
|
3277
|
+
constructor(options = {}) {
|
|
3278
|
+
this.marked = new Marked({ async: false, breaks: true }).use(this.createFootnoteExtension(), ...options.extensions ?? []);
|
|
3279
|
+
this.DomPurity = getDomPurify(options.window, options.newTabSrText);
|
|
3279
3280
|
}
|
|
3280
3281
|
createFootnoteExtension = () => {
|
|
3281
3282
|
const self = this;
|
|
@@ -3285,10 +3286,10 @@ class MarkdownRenderer {
|
|
|
3285
3286
|
name: "footnote",
|
|
3286
3287
|
level: "inline",
|
|
3287
3288
|
start(src) {
|
|
3288
|
-
return src.match(/\[\^(\d+)\]/)?.index;
|
|
3289
|
+
return src.match(/\[\^(\d+(?:\.\d+)?)\]/)?.index;
|
|
3289
3290
|
},
|
|
3290
3291
|
tokenizer(src) {
|
|
3291
|
-
const rule = /^\[\^(\d+)\]/;
|
|
3292
|
+
const rule = /^\[\^(\d+(?:\.\d+)?)\]/;
|
|
3292
3293
|
const match = rule.exec(src);
|
|
3293
3294
|
if (match) {
|
|
3294
3295
|
const [full, refNumber] = match;
|
|
@@ -3301,10 +3302,12 @@ class MarkdownRenderer {
|
|
|
3301
3302
|
},
|
|
3302
3303
|
renderer(token) {
|
|
3303
3304
|
if (token.type === "footnote") {
|
|
3304
|
-
const
|
|
3305
|
+
const refs = self.currentReferences.all;
|
|
3306
|
+
const hasIds = refs.some((reference) => reference.citationId !== undefined);
|
|
3307
|
+
const refIndex = hasIds ? refs.findIndex((reference) => reference.citationId === token.refNumber) : /^\d+$/.test(token.refNumber) ? Number(token.refNumber) - 1 : -1;
|
|
3305
3308
|
const currentReference = self.currentReferences.all[refIndex];
|
|
3306
3309
|
if (!currentReference) {
|
|
3307
|
-
console.error("Could not find ref
|
|
3310
|
+
console.error("Could not find ref for citation:", token.refNumber);
|
|
3308
3311
|
return "";
|
|
3309
3312
|
}
|
|
3310
3313
|
let usedIndex;
|
|
@@ -3332,9 +3335,9 @@ class MarkdownRenderer {
|
|
|
3332
3335
|
}
|
|
3333
3336
|
toHTML(markdown, references) {
|
|
3334
3337
|
this.currentReferences = references;
|
|
3335
|
-
const
|
|
3338
|
+
const html = this.parse(markdown);
|
|
3336
3339
|
this.currentReferences = emptyChatReferences;
|
|
3337
|
-
return
|
|
3340
|
+
return html;
|
|
3338
3341
|
}
|
|
3339
3342
|
}
|
|
3340
3343
|
// node_modules/.bun/esm-env@1.2.2/node_modules/esm-env/true.js
|
|
@@ -3431,7 +3434,7 @@ var subscriber_queue = [];
|
|
|
3431
3434
|
function writable(value, start = noop) {
|
|
3432
3435
|
let stop = null;
|
|
3433
3436
|
const subscribers = new Set;
|
|
3434
|
-
function
|
|
3437
|
+
function set(new_value) {
|
|
3435
3438
|
if (safe_not_equal(value, new_value)) {
|
|
3436
3439
|
value = new_value;
|
|
3437
3440
|
if (stop) {
|
|
@@ -3450,13 +3453,13 @@ function writable(value, start = noop) {
|
|
|
3450
3453
|
}
|
|
3451
3454
|
}
|
|
3452
3455
|
function update(fn) {
|
|
3453
|
-
|
|
3456
|
+
set(fn(value));
|
|
3454
3457
|
}
|
|
3455
3458
|
function subscribe(run, invalidate = noop) {
|
|
3456
3459
|
const subscriber = [run, invalidate];
|
|
3457
3460
|
subscribers.add(subscriber);
|
|
3458
3461
|
if (subscribers.size === 1) {
|
|
3459
|
-
stop = start(
|
|
3462
|
+
stop = start(set, update) || noop;
|
|
3460
3463
|
}
|
|
3461
3464
|
run(value);
|
|
3462
3465
|
return () => {
|
|
@@ -3467,7 +3470,7 @@ function writable(value, start = noop) {
|
|
|
3467
3470
|
}
|
|
3468
3471
|
};
|
|
3469
3472
|
}
|
|
3470
|
-
return { set
|
|
3473
|
+
return { set, update, subscribe };
|
|
3471
3474
|
}
|
|
3472
3475
|
|
|
3473
3476
|
// node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/store.js
|
|
@@ -3568,13 +3571,14 @@ var getDomainName = (url) => {
|
|
|
3568
3571
|
};
|
|
3569
3572
|
|
|
3570
3573
|
// src/lib/client/utils/html-to-text.ts
|
|
3571
|
-
function htmlToText(
|
|
3572
|
-
const
|
|
3573
|
-
return
|
|
3574
|
+
function htmlToText(html) {
|
|
3575
|
+
const text = html.replace(/<[^>]*>/g, "").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"');
|
|
3576
|
+
return text;
|
|
3574
3577
|
}
|
|
3575
3578
|
|
|
3576
3579
|
// src/lib/client/chat-result-builder.ts
|
|
3577
3580
|
var mapSseReference = ({
|
|
3581
|
+
citationId,
|
|
3578
3582
|
url,
|
|
3579
3583
|
considered,
|
|
3580
3584
|
title,
|
|
@@ -3584,6 +3588,7 @@ var mapSseReference = ({
|
|
|
3584
3588
|
const domainName = getDomainName(url);
|
|
3585
3589
|
const desc = description || summary;
|
|
3586
3590
|
return {
|
|
3591
|
+
...citationId ? { citationId } : {},
|
|
3587
3592
|
url,
|
|
3588
3593
|
considered,
|
|
3589
3594
|
referenceIndex: {},
|
|
@@ -3608,17 +3613,17 @@ class ChatResultBuilder {
|
|
|
3608
3613
|
store;
|
|
3609
3614
|
content = new FutureValue;
|
|
3610
3615
|
backendSendsMappedRefs = false;
|
|
3611
|
-
constructor(
|
|
3612
|
-
this.options =
|
|
3616
|
+
constructor(options) {
|
|
3617
|
+
this.options = options;
|
|
3613
3618
|
this.store = writable({
|
|
3614
|
-
id:
|
|
3619
|
+
id: options.id,
|
|
3615
3620
|
state: "loading",
|
|
3616
3621
|
errors: [],
|
|
3617
3622
|
type: "bot",
|
|
3618
3623
|
time: new Date().toISOString(),
|
|
3619
3624
|
message: { markdown: "", html: "", text: "" },
|
|
3620
3625
|
references: { all: [], used: [], unused: [] },
|
|
3621
|
-
retrievalQuestion:
|
|
3626
|
+
retrievalQuestion: options.userQuestion
|
|
3622
3627
|
});
|
|
3623
3628
|
}
|
|
3624
3629
|
pushError(error) {
|
|
@@ -3631,14 +3636,14 @@ class ChatResultBuilder {
|
|
|
3631
3636
|
id
|
|
3632
3637
|
}));
|
|
3633
3638
|
}
|
|
3634
|
-
updateText(
|
|
3639
|
+
updateText(text) {
|
|
3635
3640
|
this.store.update((current) => {
|
|
3636
|
-
const nextMarkdown = current.message.markdown +
|
|
3637
|
-
const
|
|
3641
|
+
const nextMarkdown = current.message.markdown + text;
|
|
3642
|
+
const html = this.options.markdownRenderer.toHTML(nextMarkdown, current.references);
|
|
3638
3643
|
return {
|
|
3639
3644
|
...current,
|
|
3640
3645
|
state: "streaming",
|
|
3641
|
-
message: { markdown: nextMarkdown, html
|
|
3646
|
+
message: { markdown: nextMarkdown, html, text: "" }
|
|
3642
3647
|
};
|
|
3643
3648
|
});
|
|
3644
3649
|
}
|
|
@@ -3773,8 +3778,8 @@ class Conversation {
|
|
|
3773
3778
|
subscribe(callback) {
|
|
3774
3779
|
return this.state.subscribe(callback);
|
|
3775
3780
|
}
|
|
3776
|
-
chat(question,
|
|
3777
|
-
const chatResponse = this.clientPrimitive.chat(this.id, question,
|
|
3781
|
+
chat(question, options = {}) {
|
|
3782
|
+
const chatResponse = this.clientPrimitive.chat(this.id, question, options);
|
|
3778
3783
|
this.history.push(chatResponse);
|
|
3779
3784
|
this.latestRequest.setValue({ question, response: chatResponse });
|
|
3780
3785
|
return chatResponse;
|
|
@@ -4096,6 +4101,7 @@ var chatMessageUserSchema = import_mini4.z.object({
|
|
|
4096
4101
|
var conversationStateSchema = import_mini4.z.enum(["idle", "searching", "answering"]);
|
|
4097
4102
|
var metadataValueSchema2 = import_mini4.z.union([import_mini4.z.string(), import_mini4.z.number(), import_mini4.z.boolean(), import_mini4.z.array(import_mini4.z.string()), import_mini4.z.array(import_mini4.z.number()), import_mini4.z.array(import_mini4.z.boolean())]);
|
|
4098
4103
|
var chatReferenceSchema = import_mini4.z.object({
|
|
4104
|
+
citationId: import_mini4.z.optional(import_mini4.z.string()),
|
|
4099
4105
|
url: import_mini4.z.string(),
|
|
4100
4106
|
score: import_mini4.z.number(),
|
|
4101
4107
|
metadata: import_mini4.z.record(import_mini4.z.string(), metadataValueSchema2),
|
|
@@ -4552,10 +4558,10 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
4552
4558
|
|
|
4553
4559
|
// node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/v7.js
|
|
4554
4560
|
var _state = {};
|
|
4555
|
-
function v7(
|
|
4561
|
+
function v7(options, buf, offset) {
|
|
4556
4562
|
let bytes;
|
|
4557
|
-
if (
|
|
4558
|
-
bytes = v7Bytes(
|
|
4563
|
+
if (options) {
|
|
4564
|
+
bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
|
|
4559
4565
|
} else {
|
|
4560
4566
|
const now = Date.now();
|
|
4561
4567
|
const rnds = rng();
|
|
@@ -4564,19 +4570,19 @@ function v7(options2, buf, offset) {
|
|
|
4564
4570
|
}
|
|
4565
4571
|
return buf ?? unsafeStringify(bytes);
|
|
4566
4572
|
}
|
|
4567
|
-
function updateV7State(
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
if (now >
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
+
function updateV7State(state, now, rnds) {
|
|
4574
|
+
state.msecs ??= -Infinity;
|
|
4575
|
+
state.seq ??= 0;
|
|
4576
|
+
if (now > state.msecs) {
|
|
4577
|
+
state.seq = rnds[6] << 23 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
4578
|
+
state.msecs = now;
|
|
4573
4579
|
} else {
|
|
4574
|
-
|
|
4575
|
-
if (
|
|
4576
|
-
|
|
4580
|
+
state.seq = state.seq + 1 | 0;
|
|
4581
|
+
if (state.seq === 0) {
|
|
4582
|
+
state.msecs++;
|
|
4577
4583
|
}
|
|
4578
4584
|
}
|
|
4579
|
-
return
|
|
4585
|
+
return state;
|
|
4580
4586
|
}
|
|
4581
4587
|
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
|
4582
4588
|
if (rnds.length < 16) {
|
|
@@ -4674,23 +4680,23 @@ var getUserData = async (restClient, startParameters) => {
|
|
|
4674
4680
|
};
|
|
4675
4681
|
|
|
4676
4682
|
// node_modules/.bun/sse.js@2.8.0/node_modules/sse.js/lib/sse.js
|
|
4677
|
-
var SSE = function(url,
|
|
4683
|
+
var SSE = function(url, options) {
|
|
4678
4684
|
if (!(this instanceof SSE)) {
|
|
4679
|
-
return new SSE(url,
|
|
4685
|
+
return new SSE(url, options);
|
|
4680
4686
|
}
|
|
4681
4687
|
this.url = url;
|
|
4682
|
-
|
|
4683
|
-
this.headers =
|
|
4684
|
-
this.payload =
|
|
4685
|
-
this.method =
|
|
4686
|
-
this.withCredentials = !!
|
|
4687
|
-
this.debug = !!
|
|
4688
|
-
this.autoReconnect =
|
|
4689
|
-
this.reconnectDelay =
|
|
4690
|
-
this.maxRetries =
|
|
4688
|
+
options = options || {};
|
|
4689
|
+
this.headers = options.headers || {};
|
|
4690
|
+
this.payload = options.payload !== undefined ? options.payload : "";
|
|
4691
|
+
this.method = options.method || this.payload && "POST" || "GET";
|
|
4692
|
+
this.withCredentials = !!options.withCredentials;
|
|
4693
|
+
this.debug = !!options.debug;
|
|
4694
|
+
this.autoReconnect = options.autoReconnect !== undefined ? options.autoReconnect : false;
|
|
4695
|
+
this.reconnectDelay = options.reconnectDelay !== undefined ? options.reconnectDelay : 3000;
|
|
4696
|
+
this.maxRetries = options.maxRetries !== undefined ? options.maxRetries : null;
|
|
4691
4697
|
this.retryCount = 0;
|
|
4692
4698
|
this.reconnectTimer = null;
|
|
4693
|
-
this.useLastEventId =
|
|
4699
|
+
this.useLastEventId = options.useLastEventId !== undefined ? options.useLastEventId : true;
|
|
4694
4700
|
this.FIELD_SEPARATOR = ":";
|
|
4695
4701
|
this.listeners = {};
|
|
4696
4702
|
this.xhr = null;
|
|
@@ -4773,10 +4779,10 @@ var SSE = function(url, options2) {
|
|
|
4773
4779
|
}, this.reconnectDelay);
|
|
4774
4780
|
}
|
|
4775
4781
|
};
|
|
4776
|
-
this._setReadyState = function(
|
|
4782
|
+
this._setReadyState = function(state) {
|
|
4777
4783
|
const event = new CustomEvent("readystatechange");
|
|
4778
|
-
event.readyState =
|
|
4779
|
-
this.readyState =
|
|
4784
|
+
event.readyState = state;
|
|
4785
|
+
this.readyState = state;
|
|
4780
4786
|
this.dispatchEvent(event);
|
|
4781
4787
|
};
|
|
4782
4788
|
this._onStreamFailure = function(e) {
|
|
@@ -4920,7 +4926,7 @@ var SSE = function(url, options2) {
|
|
|
4920
4926
|
this.xhr.abort();
|
|
4921
4927
|
}
|
|
4922
4928
|
};
|
|
4923
|
-
if (
|
|
4929
|
+
if (options.start === undefined || options.start) {
|
|
4924
4930
|
this.stream();
|
|
4925
4931
|
}
|
|
4926
4932
|
};
|
|
@@ -4935,27 +4941,27 @@ class SseSubscription {
|
|
|
4935
4941
|
payload;
|
|
4936
4942
|
eventSource;
|
|
4937
4943
|
triggeredOnClose = false;
|
|
4938
|
-
constructor(url,
|
|
4939
|
-
this.options =
|
|
4944
|
+
constructor(url, options, payload) {
|
|
4945
|
+
this.options = options;
|
|
4940
4946
|
this.payload = payload;
|
|
4941
4947
|
const sseoptions = { headers: { "content-type": "application/json" } };
|
|
4942
4948
|
if (payload) {
|
|
4943
4949
|
sseoptions.payload = JSON.stringify(payload);
|
|
4944
4950
|
}
|
|
4945
|
-
if (
|
|
4946
|
-
sseoptions.headers["api-key"] =
|
|
4951
|
+
if (options.apiKey) {
|
|
4952
|
+
sseoptions.headers["api-key"] = options.apiKey;
|
|
4947
4953
|
}
|
|
4948
|
-
this.eventSource = new (
|
|
4954
|
+
this.eventSource = new (options.EventSource ?? SSE)(url, sseoptions);
|
|
4949
4955
|
this.eventSource.onmessage = (event) => {
|
|
4950
4956
|
try {
|
|
4951
4957
|
const data = JSON.parse(event.data);
|
|
4952
|
-
|
|
4958
|
+
options.onMessage(data);
|
|
4953
4959
|
} catch (error) {
|
|
4954
|
-
|
|
4960
|
+
options.onError(new CustomEvent("parse-error", { detail: error }));
|
|
4955
4961
|
}
|
|
4956
4962
|
};
|
|
4957
4963
|
this.eventSource.onerror = (event) => {
|
|
4958
|
-
|
|
4964
|
+
options.onError(event);
|
|
4959
4965
|
if (this.isClosed()) {
|
|
4960
4966
|
this.close();
|
|
4961
4967
|
}
|
|
@@ -4980,8 +4986,8 @@ var removeUndefinedValues = (obj) => Object.fromEntries(Object.entries(obj).filt
|
|
|
4980
4986
|
// src/lib/client/api/rest-client.ts
|
|
4981
4987
|
class RestClient {
|
|
4982
4988
|
options;
|
|
4983
|
-
constructor(
|
|
4984
|
-
this.options =
|
|
4989
|
+
constructor(options) {
|
|
4990
|
+
this.options = options;
|
|
4985
4991
|
}
|
|
4986
4992
|
getDefaultHeaders(additional = {}) {
|
|
4987
4993
|
const headers = {
|
|
@@ -4995,17 +5001,17 @@ class RestClient {
|
|
|
4995
5001
|
get speechRecognitionApiKey() {
|
|
4996
5002
|
return this.options.speechRecognitionApiKey;
|
|
4997
5003
|
}
|
|
4998
|
-
async subscribeSse(path, params = {},
|
|
5004
|
+
async subscribeSse(path, params = {}, options) {
|
|
4999
5005
|
const payload = removeUndefinedValues(params);
|
|
5000
5006
|
if (this.options.apiKey)
|
|
5001
|
-
|
|
5002
|
-
return new SseSubscription(`${this.options.apiUrl}${path}`,
|
|
5007
|
+
options.apiKey = this.options.apiKey;
|
|
5008
|
+
return new SseSubscription(`${this.options.apiUrl}${path}`, options, payload);
|
|
5003
5009
|
}
|
|
5004
|
-
async fetchData(path, validator, params = {},
|
|
5010
|
+
async fetchData(path, validator, params = {}, options = {}) {
|
|
5005
5011
|
const url = `${this.options.apiUrl}${path}?${new URLSearchParams(removeUndefinedValues(params)).toString()}`;
|
|
5006
5012
|
const opts = {
|
|
5007
|
-
...
|
|
5008
|
-
headers: this.getDefaultHeaders(
|
|
5013
|
+
...options,
|
|
5014
|
+
headers: this.getDefaultHeaders(options?.headers)
|
|
5009
5015
|
};
|
|
5010
5016
|
const response = await fetch(url, opts);
|
|
5011
5017
|
if (!response.ok) {
|
|
@@ -5078,30 +5084,30 @@ var linkSchema = import_mini8.z.union([linkLegacySchema, searchReferenceSchema])
|
|
|
5078
5084
|
var searchEndpointSchema = import_mini8.z.object({
|
|
5079
5085
|
links: import_mini8.z.array(linkSchema)
|
|
5080
5086
|
});
|
|
5081
|
-
var mapLinkToSearchReference = (
|
|
5082
|
-
if ("metadata" in
|
|
5083
|
-
return
|
|
5087
|
+
var mapLinkToSearchReference = (link) => {
|
|
5088
|
+
if ("metadata" in link)
|
|
5089
|
+
return link;
|
|
5084
5090
|
console.warn("Please upgrade your backend you are currently using an old api feature.");
|
|
5085
|
-
const metadata =
|
|
5086
|
-
if (
|
|
5087
|
-
metadata.fromFullTextSearch =
|
|
5088
|
-
if (
|
|
5089
|
-
metadata.rerank =
|
|
5091
|
+
const metadata = link.orgMetadata ?? {};
|
|
5092
|
+
if (link?.fromFullTextSearch)
|
|
5093
|
+
metadata.fromFullTextSearch = link?.fromFullTextSearch;
|
|
5094
|
+
if (link?.rerank)
|
|
5095
|
+
metadata.rerank = link?.rerank;
|
|
5090
5096
|
let breadcrumbs = [];
|
|
5091
|
-
let title =
|
|
5092
|
-
if (
|
|
5093
|
-
const all =
|
|
5097
|
+
let title = link.title ?? "";
|
|
5098
|
+
if (link.title && link.title.includes(" > ")) {
|
|
5099
|
+
const all = link.title.split(" > ");
|
|
5094
5100
|
title = all.pop() ?? "";
|
|
5095
5101
|
breadcrumbs = all;
|
|
5096
5102
|
}
|
|
5097
5103
|
return {
|
|
5098
|
-
url:
|
|
5104
|
+
url: link.url ?? "",
|
|
5099
5105
|
title,
|
|
5100
|
-
score:
|
|
5106
|
+
score: link.similarity || 0,
|
|
5101
5107
|
breadcrumbs,
|
|
5102
5108
|
metadata,
|
|
5103
|
-
description:
|
|
5104
|
-
date:
|
|
5109
|
+
description: link.content,
|
|
5110
|
+
date: link.date
|
|
5105
5111
|
};
|
|
5106
5112
|
};
|
|
5107
5113
|
|
|
@@ -5146,37 +5152,37 @@ var MS_PER_CHAR = 7;
|
|
|
5146
5152
|
var MIN_DELAY_MS = 8;
|
|
5147
5153
|
var MAX_DELAY_MS = 160;
|
|
5148
5154
|
var START_DELAY_MS = 750;
|
|
5149
|
-
var tokenize = (
|
|
5155
|
+
var tokenize = (text) => {
|
|
5150
5156
|
const tokens = [];
|
|
5151
5157
|
let i = 0;
|
|
5152
|
-
while (i <
|
|
5153
|
-
const ch =
|
|
5158
|
+
while (i < text.length) {
|
|
5159
|
+
const ch = text[i];
|
|
5154
5160
|
if (ch === "<") {
|
|
5155
|
-
const end =
|
|
5161
|
+
const end = text.indexOf(">", i);
|
|
5156
5162
|
if (end !== -1) {
|
|
5157
|
-
tokens.push({ type: "tag", value:
|
|
5163
|
+
tokens.push({ type: "tag", value: text.slice(i, end + 1) });
|
|
5158
5164
|
i = end + 1;
|
|
5159
5165
|
continue;
|
|
5160
5166
|
}
|
|
5161
5167
|
}
|
|
5162
5168
|
if (/\s/.test(ch)) {
|
|
5163
|
-
let
|
|
5164
|
-
while (
|
|
5165
|
-
|
|
5166
|
-
tokens.push({ type: "space", value:
|
|
5167
|
-
i =
|
|
5169
|
+
let j = i;
|
|
5170
|
+
while (j < text.length && /\s/.test(text[j]))
|
|
5171
|
+
j++;
|
|
5172
|
+
tokens.push({ type: "space", value: text.slice(i, j) });
|
|
5173
|
+
i = j;
|
|
5168
5174
|
continue;
|
|
5169
5175
|
}
|
|
5170
5176
|
let j = i;
|
|
5171
|
-
while (j <
|
|
5177
|
+
while (j < text.length && !/\s/.test(text[j]) && text[j] !== "<")
|
|
5172
5178
|
j++;
|
|
5173
|
-
tokens.push({ type: "word", value:
|
|
5179
|
+
tokens.push({ type: "word", value: text.slice(i, j) });
|
|
5174
5180
|
i = j;
|
|
5175
5181
|
}
|
|
5176
5182
|
return tokens;
|
|
5177
5183
|
};
|
|
5178
|
-
var splitForTyping = (
|
|
5179
|
-
const tokens = tokenize(
|
|
5184
|
+
var splitForTyping = (text) => {
|
|
5185
|
+
const tokens = tokenize(text);
|
|
5180
5186
|
const emissions = [];
|
|
5181
5187
|
let current = "";
|
|
5182
5188
|
let hasWord = false;
|
|
@@ -5205,8 +5211,8 @@ class FakeTypingQueue {
|
|
|
5205
5211
|
constructor(onText) {
|
|
5206
5212
|
this.onText = onText;
|
|
5207
5213
|
}
|
|
5208
|
-
ingestText(
|
|
5209
|
-
const chunks = splitForTyping(
|
|
5214
|
+
ingestText(text) {
|
|
5215
|
+
const chunks = splitForTyping(text);
|
|
5210
5216
|
if (chunks.length >= TYPING_MIN_CHUNKS) {
|
|
5211
5217
|
for (const chunk of chunks) {
|
|
5212
5218
|
this.queue.push({ kind: "text", chunk, delayMs: delayForChunk(chunk) });
|
|
@@ -5214,7 +5220,7 @@ class FakeTypingQueue {
|
|
|
5214
5220
|
this.kickoff();
|
|
5215
5221
|
return;
|
|
5216
5222
|
}
|
|
5217
|
-
this.runAfterTyping(() => this.onText(
|
|
5223
|
+
this.runAfterTyping(() => this.onText(text));
|
|
5218
5224
|
}
|
|
5219
5225
|
runAfterTyping(fn) {
|
|
5220
5226
|
if (this.queue.length === 0 && !this.isProcessing) {
|
|
@@ -5281,19 +5287,19 @@ class LiipGPTClientPrimitive {
|
|
|
5281
5287
|
markedExtensions = [];
|
|
5282
5288
|
_newTabSrText;
|
|
5283
5289
|
chatTimeout;
|
|
5284
|
-
constructor(
|
|
5285
|
-
this.chatTimeout =
|
|
5290
|
+
constructor(options) {
|
|
5291
|
+
this.chatTimeout = options.chatTimeout ?? DEFAULT_CHAT_TIMEOUT;
|
|
5286
5292
|
const restOptions = {
|
|
5287
|
-
apiUrl:
|
|
5288
|
-
apiKey:
|
|
5289
|
-
speechRecognitionApiKey:
|
|
5290
|
-
strict:
|
|
5291
|
-
EventSource:
|
|
5293
|
+
apiUrl: options.apiUrl,
|
|
5294
|
+
apiKey: options.apiKey,
|
|
5295
|
+
speechRecognitionApiKey: options.speechRecognitionApiKey,
|
|
5296
|
+
strict: options.strict ?? false,
|
|
5297
|
+
EventSource: options.EventSource ?? EventSource
|
|
5292
5298
|
};
|
|
5293
5299
|
const restClient = new RestClient(restOptions);
|
|
5294
5300
|
this.internalData = {
|
|
5295
5301
|
restClient,
|
|
5296
|
-
metadata: getUserData(restClient,
|
|
5302
|
+
metadata: getUserData(restClient, options.startParameters),
|
|
5297
5303
|
searchResponseMap: new Map,
|
|
5298
5304
|
chatResponseMap: new Map,
|
|
5299
5305
|
conversationMap: new Map
|
|
@@ -5302,8 +5308,8 @@ class LiipGPTClientPrimitive {
|
|
|
5302
5308
|
setMarkedExtensions(...extensions) {
|
|
5303
5309
|
this.markedExtensions = extensions;
|
|
5304
5310
|
}
|
|
5305
|
-
setNewTabSrText(
|
|
5306
|
-
this._newTabSrText =
|
|
5311
|
+
setNewTabSrText(text) {
|
|
5312
|
+
this._newTabSrText = text;
|
|
5307
5313
|
}
|
|
5308
5314
|
getMetadata() {
|
|
5309
5315
|
return this.internalData.metadata;
|
|
@@ -5313,7 +5319,7 @@ class LiipGPTClientPrimitive {
|
|
|
5313
5319
|
this.renderers.set(conversationId, new MarkdownRenderer({ extensions: this.markedExtensions, newTabSrText: this._newTabSrText }));
|
|
5314
5320
|
return conversationId;
|
|
5315
5321
|
}
|
|
5316
|
-
chat(conversationId, question,
|
|
5322
|
+
chat(conversationId, question, options = {}) {
|
|
5317
5323
|
const content = new FutureValue;
|
|
5318
5324
|
const requestId = v7_default();
|
|
5319
5325
|
const readyForFeedback = new Flag;
|
|
@@ -5321,7 +5327,7 @@ class LiipGPTClientPrimitive {
|
|
|
5321
5327
|
const chatResultBuilder = new ChatResultBuilder({
|
|
5322
5328
|
id: requestId,
|
|
5323
5329
|
onError: (error) => {
|
|
5324
|
-
|
|
5330
|
+
options.onError?.(error);
|
|
5325
5331
|
},
|
|
5326
5332
|
onFinish: (message) => {
|
|
5327
5333
|
content.setValue(message);
|
|
@@ -5337,7 +5343,7 @@ class LiipGPTClientPrimitive {
|
|
|
5337
5343
|
};
|
|
5338
5344
|
const subscription = new FutureValue;
|
|
5339
5345
|
const typingQueue = new FakeTypingQueue((chunk) => chatResultBuilder.updateText(chunk));
|
|
5340
|
-
const timeout =
|
|
5346
|
+
const timeout = options.timeout ?? this.chatTimeout;
|
|
5341
5347
|
let timeoutId;
|
|
5342
5348
|
let timedOut = false;
|
|
5343
5349
|
const stopWatchdog = () => {
|
|
@@ -5375,15 +5381,15 @@ class LiipGPTClientPrimitive {
|
|
|
5375
5381
|
uID: metadata.userId,
|
|
5376
5382
|
cID: conversationId,
|
|
5377
5383
|
rID: requestId,
|
|
5378
|
-
lang:
|
|
5379
|
-
feature:
|
|
5380
|
-
referrer:
|
|
5381
|
-
source:
|
|
5382
|
-
...
|
|
5383
|
-
...
|
|
5384
|
-
...
|
|
5385
|
-
...
|
|
5386
|
-
...
|
|
5384
|
+
lang: options.lang,
|
|
5385
|
+
feature: options.features?.join(","),
|
|
5386
|
+
referrer: options.referrer,
|
|
5387
|
+
source: options.source,
|
|
5388
|
+
...options.selectorValues ?? {},
|
|
5389
|
+
...options.mode ? { mode: options.mode } : {},
|
|
5390
|
+
...options.cache ? { cache: true } : {},
|
|
5391
|
+
...options.predefinedQuestionId ? { predefinedQuestionId: options.predefinedQuestionId } : {},
|
|
5392
|
+
...options.switchQuestionId ? { switchQuestionId: options.switchQuestionId } : {},
|
|
5387
5393
|
chat: "true",
|
|
5388
5394
|
version: "2"
|
|
5389
5395
|
}, {
|
|
@@ -5425,7 +5431,7 @@ class LiipGPTClientPrimitive {
|
|
|
5425
5431
|
typingQueue.runAfterTyping(() => {
|
|
5426
5432
|
chatResultBuilder.finishMessage();
|
|
5427
5433
|
readyForFeedback.resolve();
|
|
5428
|
-
subscription.then((
|
|
5434
|
+
subscription.then((s) => s.close());
|
|
5429
5435
|
});
|
|
5430
5436
|
break;
|
|
5431
5437
|
case "unexpected-call":
|
|
@@ -5448,10 +5454,10 @@ class LiipGPTClientPrimitive {
|
|
|
5448
5454
|
typingQueue.runAfterTyping(() => chatResultBuilder.setNoFeedback());
|
|
5449
5455
|
break;
|
|
5450
5456
|
case "component":
|
|
5451
|
-
typingQueue.runWithWarmup(() =>
|
|
5457
|
+
typingQueue.runWithWarmup(() => options.onEmbed?.(data));
|
|
5452
5458
|
break;
|
|
5453
5459
|
}
|
|
5454
|
-
typingQueue.runAfterTyping(() =>
|
|
5460
|
+
typingQueue.runAfterTyping(() => options.onMessage?.(data));
|
|
5455
5461
|
},
|
|
5456
5462
|
onError: (event) => {
|
|
5457
5463
|
console.error(" sse-error:", event);
|
|
@@ -5531,24 +5537,24 @@ class LiipGPTClientPrimitive {
|
|
|
5531
5537
|
};
|
|
5532
5538
|
await this.internalData.restClient.postData("/customform", answerFormRequest);
|
|
5533
5539
|
}
|
|
5534
|
-
async userAction(userAction,
|
|
5540
|
+
async userAction(userAction, options = {}) {
|
|
5535
5541
|
const metadata = await this.internalData.metadata;
|
|
5536
5542
|
if (metadata.mode !== "ready")
|
|
5537
5543
|
throw new Error("Can not post user action unless we are in ready mode");
|
|
5538
5544
|
const request = {
|
|
5539
5545
|
uID: metadata.userId,
|
|
5540
|
-
cID:
|
|
5541
|
-
lang:
|
|
5546
|
+
cID: options.conversationId,
|
|
5547
|
+
lang: options.lang,
|
|
5542
5548
|
userAction
|
|
5543
5549
|
};
|
|
5544
5550
|
await this.internalData.restClient.postData("/assistant/userAction", request);
|
|
5545
5551
|
}
|
|
5546
|
-
async search(query,
|
|
5552
|
+
async search(query, options = {}) {
|
|
5547
5553
|
const metadata = await this.internalData.metadata;
|
|
5548
5554
|
const uID = metadata.mode === "ready" ? metadata.userId : undefined;
|
|
5549
5555
|
const { links } = await this.internalData.restClient.fetchData("/assistant/search", searchEndpointSchema, {
|
|
5550
|
-
modelId:
|
|
5551
|
-
lang:
|
|
5556
|
+
modelId: options.model,
|
|
5557
|
+
lang: options.language,
|
|
5552
5558
|
query,
|
|
5553
5559
|
mapResults: "true",
|
|
5554
5560
|
uID
|
|
@@ -5573,9 +5579,9 @@ class LiipGPTClientPrimitive {
|
|
|
5573
5579
|
const data = await this.internalData.restClient.fetchData("/topics/questions", predefinedQuestionsResponseSchema, params);
|
|
5574
5580
|
return data.predefinedQuestions;
|
|
5575
5581
|
}
|
|
5576
|
-
async transcribeAudio(audioBlob,
|
|
5582
|
+
async transcribeAudio(audioBlob, options = {}) {
|
|
5577
5583
|
const metadata = await this.internalData.metadata;
|
|
5578
|
-
const language =
|
|
5584
|
+
const language = options.lang || "de-CH";
|
|
5579
5585
|
if (metadata.mode === "maintenance") {
|
|
5580
5586
|
throw new Error("Can not transcribe audio in maintenance mode");
|
|
5581
5587
|
}
|
|
@@ -5613,8 +5619,8 @@ class LiipGPTClientPrimitive {
|
|
|
5613
5619
|
// src/lib/client/liipgpt-client.ts
|
|
5614
5620
|
class LiipGPTClient {
|
|
5615
5621
|
clientPrimitive;
|
|
5616
|
-
constructor(
|
|
5617
|
-
this.clientPrimitive = new LiipGPTClientPrimitive(
|
|
5622
|
+
constructor(options) {
|
|
5623
|
+
this.clientPrimitive = new LiipGPTClientPrimitive(options);
|
|
5618
5624
|
}
|
|
5619
5625
|
getMetadata() {
|
|
5620
5626
|
return this.clientPrimitive.getMetadata();
|
|
@@ -5622,8 +5628,8 @@ class LiipGPTClient {
|
|
|
5622
5628
|
createConversation() {
|
|
5623
5629
|
return new Conversation(this.clientPrimitive);
|
|
5624
5630
|
}
|
|
5625
|
-
search(query,
|
|
5626
|
-
return this.clientPrimitive.search(query,
|
|
5631
|
+
search(query, options = {}) {
|
|
5632
|
+
return this.clientPrimitive.search(query, options);
|
|
5627
5633
|
}
|
|
5628
5634
|
getChatConfig() {
|
|
5629
5635
|
return this.clientPrimitive.getChatConfig();
|