@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.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/*! @liip/liipgpt | Copyright 2025-2026 Liip AG | Apache-2.0 | see LICENSE and NOTICE */
|
|
2
|
+
|
|
1
3
|
// node_modules/.bun/dompurify@3.3.3/node_modules/dompurify/dist/purify.es.mjs
|
|
2
4
|
/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
|
|
3
5
|
var {
|
|
@@ -17,17 +19,17 @@ var {
|
|
|
17
19
|
construct
|
|
18
20
|
} = typeof Reflect !== "undefined" && Reflect;
|
|
19
21
|
if (!freeze) {
|
|
20
|
-
freeze = function
|
|
22
|
+
freeze = function freeze(x) {
|
|
21
23
|
return x;
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
if (!seal) {
|
|
25
|
-
seal = function
|
|
27
|
+
seal = function seal(x) {
|
|
26
28
|
return x;
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
31
|
if (!apply) {
|
|
30
|
-
apply = function
|
|
32
|
+
apply = function apply(func, thisArg) {
|
|
31
33
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2;_key < _len; _key++) {
|
|
32
34
|
args[_key - 2] = arguments[_key];
|
|
33
35
|
}
|
|
@@ -35,7 +37,7 @@ if (!apply) {
|
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
if (!construct) {
|
|
38
|
-
construct = function
|
|
40
|
+
construct = function construct(Func) {
|
|
39
41
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++) {
|
|
40
42
|
args[_key2 - 1] = arguments[_key2];
|
|
41
43
|
}
|
|
@@ -187,10 +189,10 @@ var NODE_TYPE = {
|
|
|
187
189
|
documentFragment: 11,
|
|
188
190
|
notation: 12
|
|
189
191
|
};
|
|
190
|
-
var getGlobal = function
|
|
192
|
+
var getGlobal = function getGlobal() {
|
|
191
193
|
return typeof window === "undefined" ? null : window;
|
|
192
194
|
};
|
|
193
|
-
var _createTrustedTypesPolicy = function
|
|
195
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
194
196
|
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
|
|
195
197
|
return null;
|
|
196
198
|
}
|
|
@@ -202,8 +204,8 @@ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes
|
|
|
202
204
|
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
203
205
|
try {
|
|
204
206
|
return trustedTypes.createPolicy(policyName, {
|
|
205
|
-
createHTML(
|
|
206
|
-
return
|
|
207
|
+
createHTML(html) {
|
|
208
|
+
return html;
|
|
207
209
|
},
|
|
208
210
|
createScriptURL(scriptUrl) {
|
|
209
211
|
return scriptUrl;
|
|
@@ -214,7 +216,7 @@ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes
|
|
|
214
216
|
return null;
|
|
215
217
|
}
|
|
216
218
|
};
|
|
217
|
-
var _createHooksMap = function
|
|
219
|
+
var _createHooksMap = function _createHooksMap() {
|
|
218
220
|
return {
|
|
219
221
|
afterSanitizeAttributes: [],
|
|
220
222
|
afterSanitizeElements: [],
|
|
@@ -278,14 +280,14 @@ function createDOMPurify() {
|
|
|
278
280
|
let hooks = _createHooksMap();
|
|
279
281
|
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== undefined;
|
|
280
282
|
const {
|
|
281
|
-
MUSTACHE_EXPR
|
|
282
|
-
ERB_EXPR
|
|
283
|
-
TMPLIT_EXPR
|
|
284
|
-
DATA_ATTR
|
|
285
|
-
ARIA_ATTR
|
|
286
|
-
IS_SCRIPT_OR_DATA
|
|
287
|
-
ATTR_WHITESPACE
|
|
288
|
-
CUSTOM_ELEMENT
|
|
283
|
+
MUSTACHE_EXPR,
|
|
284
|
+
ERB_EXPR,
|
|
285
|
+
TMPLIT_EXPR,
|
|
286
|
+
DATA_ATTR,
|
|
287
|
+
ARIA_ATTR,
|
|
288
|
+
IS_SCRIPT_OR_DATA,
|
|
289
|
+
ATTR_WHITESPACE,
|
|
290
|
+
CUSTOM_ELEMENT
|
|
289
291
|
} = EXPRESSIONS;
|
|
290
292
|
let {
|
|
291
293
|
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
@@ -370,10 +372,10 @@ function createDOMPurify() {
|
|
|
370
372
|
let transformCaseFunc = null;
|
|
371
373
|
let CONFIG = null;
|
|
372
374
|
const formElement = document2.createElement("form");
|
|
373
|
-
const isRegexOrFunction = function
|
|
375
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
374
376
|
return testValue instanceof RegExp || testValue instanceof Function;
|
|
375
377
|
};
|
|
376
|
-
const _parseConfig = function
|
|
378
|
+
const _parseConfig = function _parseConfig() {
|
|
377
379
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
378
380
|
if (CONFIG && CONFIG === cfg) {
|
|
379
381
|
return;
|
|
@@ -526,7 +528,7 @@ function createDOMPurify() {
|
|
|
526
528
|
};
|
|
527
529
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
528
530
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
529
|
-
const _checkValidNamespace = function
|
|
531
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
530
532
|
let parent = getParentNode(element);
|
|
531
533
|
if (!parent || !parent.tagName) {
|
|
532
534
|
parent = {
|
|
@@ -571,7 +573,7 @@ function createDOMPurify() {
|
|
|
571
573
|
}
|
|
572
574
|
return false;
|
|
573
575
|
};
|
|
574
|
-
const _forceRemove = function
|
|
576
|
+
const _forceRemove = function _forceRemove(node) {
|
|
575
577
|
arrayPush(DOMPurify.removed, {
|
|
576
578
|
element: node
|
|
577
579
|
});
|
|
@@ -581,7 +583,7 @@ function createDOMPurify() {
|
|
|
581
583
|
remove(node);
|
|
582
584
|
}
|
|
583
585
|
};
|
|
584
|
-
const _removeAttribute = function
|
|
586
|
+
const _removeAttribute = function _removeAttribute(name, element) {
|
|
585
587
|
try {
|
|
586
588
|
arrayPush(DOMPurify.removed, {
|
|
587
589
|
attribute: element.getAttributeNode(name),
|
|
@@ -606,7 +608,7 @@ function createDOMPurify() {
|
|
|
606
608
|
}
|
|
607
609
|
}
|
|
608
610
|
};
|
|
609
|
-
const _initDocument = function
|
|
611
|
+
const _initDocument = function _initDocument(dirty) {
|
|
610
612
|
let doc = null;
|
|
611
613
|
let leadingWhitespace = null;
|
|
612
614
|
if (FORCE_BODY) {
|
|
@@ -639,21 +641,21 @@ function createDOMPurify() {
|
|
|
639
641
|
}
|
|
640
642
|
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
641
643
|
};
|
|
642
|
-
const _createNodeIterator = function
|
|
644
|
+
const _createNodeIterator = function _createNodeIterator(root) {
|
|
643
645
|
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);
|
|
644
646
|
};
|
|
645
|
-
const _isClobbered = function
|
|
647
|
+
const _isClobbered = function _isClobbered(element) {
|
|
646
648
|
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");
|
|
647
649
|
};
|
|
648
|
-
const _isNode = function
|
|
650
|
+
const _isNode = function _isNode(value) {
|
|
649
651
|
return typeof Node2 === "function" && value instanceof Node2;
|
|
650
652
|
};
|
|
651
|
-
function _executeHooks(
|
|
652
|
-
arrayForEach(
|
|
653
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
654
|
+
arrayForEach(hooks, (hook) => {
|
|
653
655
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
654
656
|
});
|
|
655
657
|
}
|
|
656
|
-
const _sanitizeElements = function
|
|
658
|
+
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
657
659
|
let content = null;
|
|
658
660
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
659
661
|
if (_isClobbered(currentNode)) {
|
|
@@ -711,7 +713,7 @@ function createDOMPurify() {
|
|
|
711
713
|
}
|
|
712
714
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
713
715
|
content = currentNode.textContent;
|
|
714
|
-
arrayForEach([
|
|
716
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {
|
|
715
717
|
content = stringReplace(content, expr, " ");
|
|
716
718
|
});
|
|
717
719
|
if (currentNode.textContent !== content) {
|
|
@@ -724,16 +726,16 @@ function createDOMPurify() {
|
|
|
724
726
|
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
725
727
|
return false;
|
|
726
728
|
};
|
|
727
|
-
const _isValidAttribute = function
|
|
729
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
728
730
|
if (FORBID_ATTR[lcName]) {
|
|
729
731
|
return false;
|
|
730
732
|
}
|
|
731
733
|
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && ((value in document2) || (value in formElement))) {
|
|
732
734
|
return false;
|
|
733
735
|
}
|
|
734
|
-
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(
|
|
736
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName))
|
|
735
737
|
;
|
|
736
|
-
else if (ALLOW_ARIA_ATTR && regExpTest(
|
|
738
|
+
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName))
|
|
737
739
|
;
|
|
738
740
|
else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag))
|
|
739
741
|
;
|
|
@@ -745,21 +747,21 @@ function createDOMPurify() {
|
|
|
745
747
|
}
|
|
746
748
|
} else if (URI_SAFE_ATTRIBUTES[lcName])
|
|
747
749
|
;
|
|
748
|
-
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value,
|
|
750
|
+
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, "")))
|
|
749
751
|
;
|
|
750
752
|
else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag])
|
|
751
753
|
;
|
|
752
|
-
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(
|
|
754
|
+
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, "")))
|
|
753
755
|
;
|
|
754
756
|
else if (value) {
|
|
755
757
|
return false;
|
|
756
758
|
}
|
|
757
759
|
return true;
|
|
758
760
|
};
|
|
759
|
-
const _isBasicCustomElement = function
|
|
760
|
-
return tagName !== "annotation-xml" && stringMatch(tagName,
|
|
761
|
+
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
762
|
+
return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT);
|
|
761
763
|
};
|
|
762
|
-
const _sanitizeAttributes = function
|
|
764
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
763
765
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
764
766
|
const {
|
|
765
767
|
attributes
|
|
@@ -815,7 +817,7 @@ function createDOMPurify() {
|
|
|
815
817
|
continue;
|
|
816
818
|
}
|
|
817
819
|
if (SAFE_FOR_TEMPLATES) {
|
|
818
|
-
arrayForEach([
|
|
820
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {
|
|
819
821
|
value = stringReplace(value, expr, " ");
|
|
820
822
|
});
|
|
821
823
|
}
|
|
@@ -859,7 +861,7 @@ function createDOMPurify() {
|
|
|
859
861
|
}
|
|
860
862
|
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
861
863
|
};
|
|
862
|
-
const _sanitizeShadowDOM = function
|
|
864
|
+
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
863
865
|
let shadowNode = null;
|
|
864
866
|
const shadowIterator = _createNodeIterator(fragment);
|
|
865
867
|
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
@@ -868,7 +870,7 @@ function createDOMPurify() {
|
|
|
868
870
|
_sanitizeElements(shadowNode);
|
|
869
871
|
_sanitizeAttributes(shadowNode);
|
|
870
872
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
871
|
-
|
|
873
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
872
874
|
}
|
|
873
875
|
}
|
|
874
876
|
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
@@ -963,7 +965,7 @@ function createDOMPurify() {
|
|
|
963
965
|
` + serializedHTML;
|
|
964
966
|
}
|
|
965
967
|
if (SAFE_FOR_TEMPLATES) {
|
|
966
|
-
arrayForEach([
|
|
968
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {
|
|
967
969
|
serializedHTML = stringReplace(serializedHTML, expr, " ");
|
|
968
970
|
});
|
|
969
971
|
}
|
|
@@ -1240,17 +1242,17 @@ var escapeReplacements = {
|
|
|
1240
1242
|
"'": "'"
|
|
1241
1243
|
};
|
|
1242
1244
|
var getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
1243
|
-
function escape2(
|
|
1245
|
+
function escape2(html2, encode) {
|
|
1244
1246
|
if (encode) {
|
|
1245
|
-
if (other.escapeTest.test(
|
|
1246
|
-
return
|
|
1247
|
+
if (other.escapeTest.test(html2)) {
|
|
1248
|
+
return html2.replace(other.escapeReplace, getEscapeReplacement);
|
|
1247
1249
|
}
|
|
1248
1250
|
} else {
|
|
1249
|
-
if (other.escapeTestNoEncode.test(
|
|
1250
|
-
return
|
|
1251
|
+
if (other.escapeTestNoEncode.test(html2)) {
|
|
1252
|
+
return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
|
|
1251
1253
|
}
|
|
1252
1254
|
}
|
|
1253
|
-
return
|
|
1255
|
+
return html2;
|
|
1254
1256
|
}
|
|
1255
1257
|
function cleanUrl(href) {
|
|
1256
1258
|
try {
|
|
@@ -1335,26 +1337,26 @@ function findClosingBracket(str, b) {
|
|
|
1335
1337
|
function outputLink(cap, link2, raw, lexer2, rules) {
|
|
1336
1338
|
const href = link2.href;
|
|
1337
1339
|
const title = link2.title || null;
|
|
1338
|
-
const
|
|
1340
|
+
const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
|
|
1339
1341
|
lexer2.state.inLink = true;
|
|
1340
1342
|
const token = {
|
|
1341
1343
|
type: cap[0].charAt(0) === "!" ? "image" : "link",
|
|
1342
1344
|
raw,
|
|
1343
1345
|
href,
|
|
1344
1346
|
title,
|
|
1345
|
-
text
|
|
1346
|
-
tokens: lexer2.inlineTokens(
|
|
1347
|
+
text,
|
|
1348
|
+
tokens: lexer2.inlineTokens(text)
|
|
1347
1349
|
};
|
|
1348
1350
|
lexer2.state.inLink = false;
|
|
1349
1351
|
return token;
|
|
1350
1352
|
}
|
|
1351
|
-
function indentCodeCompensation(raw,
|
|
1353
|
+
function indentCodeCompensation(raw, text, rules) {
|
|
1352
1354
|
const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
|
|
1353
1355
|
if (matchIndentToCode === null) {
|
|
1354
|
-
return
|
|
1356
|
+
return text;
|
|
1355
1357
|
}
|
|
1356
1358
|
const indentToCode = matchIndentToCode[1];
|
|
1357
|
-
return
|
|
1359
|
+
return text.split(`
|
|
1358
1360
|
`).map((node) => {
|
|
1359
1361
|
const matchIndentInNode = node.match(rules.other.beginningSpace);
|
|
1360
1362
|
if (matchIndentInNode === null) {
|
|
@@ -1387,13 +1389,13 @@ var _Tokenizer = class {
|
|
|
1387
1389
|
code(src) {
|
|
1388
1390
|
const cap = this.rules.block.code.exec(src);
|
|
1389
1391
|
if (cap) {
|
|
1390
|
-
const
|
|
1392
|
+
const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
|
|
1391
1393
|
return {
|
|
1392
1394
|
type: "code",
|
|
1393
1395
|
raw: cap[0],
|
|
1394
1396
|
codeBlockStyle: "indented",
|
|
1395
|
-
text: !this.options.pedantic ? rtrim(
|
|
1396
|
-
`) :
|
|
1397
|
+
text: !this.options.pedantic ? rtrim(text, `
|
|
1398
|
+
`) : text
|
|
1397
1399
|
};
|
|
1398
1400
|
}
|
|
1399
1401
|
}
|
|
@@ -1401,33 +1403,33 @@ var _Tokenizer = class {
|
|
|
1401
1403
|
const cap = this.rules.block.fences.exec(src);
|
|
1402
1404
|
if (cap) {
|
|
1403
1405
|
const raw = cap[0];
|
|
1404
|
-
const
|
|
1406
|
+
const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
|
|
1405
1407
|
return {
|
|
1406
1408
|
type: "code",
|
|
1407
1409
|
raw,
|
|
1408
1410
|
lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
|
|
1409
|
-
text
|
|
1411
|
+
text
|
|
1410
1412
|
};
|
|
1411
1413
|
}
|
|
1412
1414
|
}
|
|
1413
1415
|
heading(src) {
|
|
1414
1416
|
const cap = this.rules.block.heading.exec(src);
|
|
1415
1417
|
if (cap) {
|
|
1416
|
-
let
|
|
1417
|
-
if (this.rules.other.endingHash.test(
|
|
1418
|
-
const trimmed = rtrim(
|
|
1418
|
+
let text = cap[2].trim();
|
|
1419
|
+
if (this.rules.other.endingHash.test(text)) {
|
|
1420
|
+
const trimmed = rtrim(text, "#");
|
|
1419
1421
|
if (this.options.pedantic) {
|
|
1420
|
-
|
|
1422
|
+
text = trimmed.trim();
|
|
1421
1423
|
} else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
|
|
1422
|
-
|
|
1424
|
+
text = trimmed.trim();
|
|
1423
1425
|
}
|
|
1424
1426
|
}
|
|
1425
1427
|
return {
|
|
1426
1428
|
type: "heading",
|
|
1427
1429
|
raw: cap[0],
|
|
1428
1430
|
depth: cap[1].length,
|
|
1429
|
-
text
|
|
1430
|
-
tokens: this.lexer.inline(
|
|
1431
|
+
text,
|
|
1432
|
+
tokens: this.lexer.inline(text)
|
|
1431
1433
|
};
|
|
1432
1434
|
}
|
|
1433
1435
|
}
|
|
@@ -1448,7 +1450,7 @@ var _Tokenizer = class {
|
|
|
1448
1450
|
`).split(`
|
|
1449
1451
|
`);
|
|
1450
1452
|
let raw = "";
|
|
1451
|
-
let
|
|
1453
|
+
let text = "";
|
|
1452
1454
|
const tokens = [];
|
|
1453
1455
|
while (lines.length > 0) {
|
|
1454
1456
|
let inBlockquote = false;
|
|
@@ -1471,7 +1473,7 @@ var _Tokenizer = class {
|
|
|
1471
1473
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1472
1474
|
raw = raw ? `${raw}
|
|
1473
1475
|
${currentRaw}` : currentRaw;
|
|
1474
|
-
|
|
1476
|
+
text = text ? `${text}
|
|
1475
1477
|
${currentText}` : currentText;
|
|
1476
1478
|
const top = this.lexer.state.top;
|
|
1477
1479
|
this.lexer.state.top = true;
|
|
@@ -1491,7 +1493,7 @@ ${currentText}` : currentText;
|
|
|
1491
1493
|
const newToken = this.blockquote(newText);
|
|
1492
1494
|
tokens[tokens.length - 1] = newToken;
|
|
1493
1495
|
raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
|
|
1494
|
-
|
|
1496
|
+
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
|
|
1495
1497
|
break;
|
|
1496
1498
|
} else if (lastToken?.type === "list") {
|
|
1497
1499
|
const oldToken = lastToken;
|
|
@@ -1501,7 +1503,7 @@ ${currentText}` : currentText;
|
|
|
1501
1503
|
const newToken = this.list(newText);
|
|
1502
1504
|
tokens[tokens.length - 1] = newToken;
|
|
1503
1505
|
raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
|
|
1504
|
-
|
|
1506
|
+
text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
|
|
1505
1507
|
lines = newText.substring(tokens.at(-1).raw.length).split(`
|
|
1506
1508
|
`);
|
|
1507
1509
|
continue;
|
|
@@ -1511,7 +1513,7 @@ ${currentText}` : currentText;
|
|
|
1511
1513
|
type: "blockquote",
|
|
1512
1514
|
raw,
|
|
1513
1515
|
tokens,
|
|
1514
|
-
text
|
|
1516
|
+
text
|
|
1515
1517
|
};
|
|
1516
1518
|
}
|
|
1517
1519
|
}
|
|
@@ -1780,13 +1782,13 @@ ${currentText}` : currentText;
|
|
|
1780
1782
|
paragraph(src) {
|
|
1781
1783
|
const cap = this.rules.block.paragraph.exec(src);
|
|
1782
1784
|
if (cap) {
|
|
1783
|
-
const
|
|
1785
|
+
const text = cap[1].charAt(cap[1].length - 1) === `
|
|
1784
1786
|
` ? cap[1].slice(0, -1) : cap[1];
|
|
1785
1787
|
return {
|
|
1786
1788
|
type: "paragraph",
|
|
1787
1789
|
raw: cap[0],
|
|
1788
|
-
text
|
|
1789
|
-
tokens: this.lexer.inline(
|
|
1790
|
+
text,
|
|
1791
|
+
tokens: this.lexer.inline(text)
|
|
1790
1792
|
};
|
|
1791
1793
|
}
|
|
1792
1794
|
}
|
|
@@ -1890,11 +1892,11 @@ ${currentText}` : currentText;
|
|
|
1890
1892
|
const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
|
|
1891
1893
|
const link2 = links[linkString.toLowerCase()];
|
|
1892
1894
|
if (!link2) {
|
|
1893
|
-
const
|
|
1895
|
+
const text = cap[0].charAt(0);
|
|
1894
1896
|
return {
|
|
1895
1897
|
type: "text",
|
|
1896
|
-
raw:
|
|
1897
|
-
text
|
|
1898
|
+
raw: text,
|
|
1899
|
+
text
|
|
1898
1900
|
};
|
|
1899
1901
|
}
|
|
1900
1902
|
return outputLink(cap, link2, cap[0], this.lexer, this.rules);
|
|
@@ -1934,20 +1936,20 @@ ${currentText}` : currentText;
|
|
|
1934
1936
|
const lastCharLength = [...match[0]][0].length;
|
|
1935
1937
|
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
|
|
1936
1938
|
if (Math.min(lLength, rLength) % 2) {
|
|
1937
|
-
const
|
|
1939
|
+
const text2 = raw.slice(1, -1);
|
|
1938
1940
|
return {
|
|
1939
1941
|
type: "em",
|
|
1940
1942
|
raw,
|
|
1941
|
-
text:
|
|
1942
|
-
tokens: this.lexer.inlineTokens(
|
|
1943
|
+
text: text2,
|
|
1944
|
+
tokens: this.lexer.inlineTokens(text2)
|
|
1943
1945
|
};
|
|
1944
1946
|
}
|
|
1945
|
-
const
|
|
1947
|
+
const text = raw.slice(2, -2);
|
|
1946
1948
|
return {
|
|
1947
1949
|
type: "strong",
|
|
1948
1950
|
raw,
|
|
1949
|
-
text
|
|
1950
|
-
tokens: this.lexer.inlineTokens(
|
|
1951
|
+
text,
|
|
1952
|
+
tokens: this.lexer.inlineTokens(text)
|
|
1951
1953
|
};
|
|
1952
1954
|
}
|
|
1953
1955
|
}
|
|
@@ -1955,16 +1957,16 @@ ${currentText}` : currentText;
|
|
|
1955
1957
|
codespan(src) {
|
|
1956
1958
|
const cap = this.rules.inline.code.exec(src);
|
|
1957
1959
|
if (cap) {
|
|
1958
|
-
let
|
|
1959
|
-
const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(
|
|
1960
|
-
const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(
|
|
1960
|
+
let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
|
|
1961
|
+
const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
|
|
1962
|
+
const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
|
|
1961
1963
|
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
1962
|
-
|
|
1964
|
+
text = text.substring(1, text.length - 1);
|
|
1963
1965
|
}
|
|
1964
1966
|
return {
|
|
1965
1967
|
type: "codespan",
|
|
1966
1968
|
raw: cap[0],
|
|
1967
|
-
text
|
|
1969
|
+
text
|
|
1968
1970
|
};
|
|
1969
1971
|
}
|
|
1970
1972
|
}
|
|
@@ -1991,24 +1993,24 @@ ${currentText}` : currentText;
|
|
|
1991
1993
|
autolink(src) {
|
|
1992
1994
|
const cap = this.rules.inline.autolink.exec(src);
|
|
1993
1995
|
if (cap) {
|
|
1994
|
-
let
|
|
1996
|
+
let text, href;
|
|
1995
1997
|
if (cap[2] === "@") {
|
|
1996
|
-
|
|
1997
|
-
href = "mailto:" +
|
|
1998
|
+
text = cap[1];
|
|
1999
|
+
href = "mailto:" + text;
|
|
1998
2000
|
} else {
|
|
1999
|
-
|
|
2000
|
-
href =
|
|
2001
|
+
text = cap[1];
|
|
2002
|
+
href = text;
|
|
2001
2003
|
}
|
|
2002
2004
|
return {
|
|
2003
2005
|
type: "link",
|
|
2004
2006
|
raw: cap[0],
|
|
2005
|
-
text
|
|
2007
|
+
text,
|
|
2006
2008
|
href,
|
|
2007
2009
|
tokens: [
|
|
2008
2010
|
{
|
|
2009
2011
|
type: "text",
|
|
2010
|
-
raw:
|
|
2011
|
-
text
|
|
2012
|
+
raw: text,
|
|
2013
|
+
text
|
|
2012
2014
|
}
|
|
2013
2015
|
]
|
|
2014
2016
|
};
|
|
@@ -2017,17 +2019,17 @@ ${currentText}` : currentText;
|
|
|
2017
2019
|
url(src) {
|
|
2018
2020
|
let cap;
|
|
2019
2021
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
2020
|
-
let
|
|
2022
|
+
let text, href;
|
|
2021
2023
|
if (cap[2] === "@") {
|
|
2022
|
-
|
|
2023
|
-
href = "mailto:" +
|
|
2024
|
+
text = cap[0];
|
|
2025
|
+
href = "mailto:" + text;
|
|
2024
2026
|
} else {
|
|
2025
2027
|
let prevCapZero;
|
|
2026
2028
|
do {
|
|
2027
2029
|
prevCapZero = cap[0];
|
|
2028
2030
|
cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
|
|
2029
2031
|
} while (prevCapZero !== cap[0]);
|
|
2030
|
-
|
|
2032
|
+
text = cap[0];
|
|
2031
2033
|
if (cap[1] === "www.") {
|
|
2032
2034
|
href = "http://" + cap[0];
|
|
2033
2035
|
} else {
|
|
@@ -2037,13 +2039,13 @@ ${currentText}` : currentText;
|
|
|
2037
2039
|
return {
|
|
2038
2040
|
type: "link",
|
|
2039
2041
|
raw: cap[0],
|
|
2040
|
-
text
|
|
2042
|
+
text,
|
|
2041
2043
|
href,
|
|
2042
2044
|
tokens: [
|
|
2043
2045
|
{
|
|
2044
2046
|
type: "text",
|
|
2045
|
-
raw:
|
|
2046
|
-
text
|
|
2047
|
+
raw: text,
|
|
2048
|
+
text
|
|
2047
2049
|
}
|
|
2048
2050
|
]
|
|
2049
2051
|
};
|
|
@@ -2431,9 +2433,9 @@ var _Renderer = class {
|
|
|
2431
2433
|
space(token) {
|
|
2432
2434
|
return "";
|
|
2433
2435
|
}
|
|
2434
|
-
code({ text
|
|
2436
|
+
code({ text, lang, escaped }) {
|
|
2435
2437
|
const langString = (lang || "").match(other.notSpaceStart)?.[0];
|
|
2436
|
-
const code =
|
|
2438
|
+
const code = text.replace(other.endingNewline, "") + `
|
|
2437
2439
|
`;
|
|
2438
2440
|
if (!langString) {
|
|
2439
2441
|
return "<pre><code>" + (escaped ? code : escape2(code, true)) + `</code></pre>
|
|
@@ -2448,8 +2450,8 @@ var _Renderer = class {
|
|
|
2448
2450
|
${body}</blockquote>
|
|
2449
2451
|
`;
|
|
2450
2452
|
}
|
|
2451
|
-
html({ text
|
|
2452
|
-
return
|
|
2453
|
+
html({ text }) {
|
|
2454
|
+
return text;
|
|
2453
2455
|
}
|
|
2454
2456
|
heading({ tokens, depth }) {
|
|
2455
2457
|
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
|
|
@@ -2531,9 +2533,9 @@ ${body}</blockquote>
|
|
|
2531
2533
|
` + body + `</table>
|
|
2532
2534
|
`;
|
|
2533
2535
|
}
|
|
2534
|
-
tablerow({ text
|
|
2536
|
+
tablerow({ text }) {
|
|
2535
2537
|
return `<tr>
|
|
2536
|
-
${
|
|
2538
|
+
${text}</tr>
|
|
2537
2539
|
`;
|
|
2538
2540
|
}
|
|
2539
2541
|
tablecell(token) {
|
|
@@ -2549,8 +2551,8 @@ ${text2}</tr>
|
|
|
2549
2551
|
em({ tokens }) {
|
|
2550
2552
|
return `<em>${this.parser.parseInline(tokens)}</em>`;
|
|
2551
2553
|
}
|
|
2552
|
-
codespan({ text
|
|
2553
|
-
return `<code>${escape2(
|
|
2554
|
+
codespan({ text }) {
|
|
2555
|
+
return `<code>${escape2(text, true)}</code>`;
|
|
2554
2556
|
}
|
|
2555
2557
|
br(token) {
|
|
2556
2558
|
return "<br>";
|
|
@@ -2559,29 +2561,29 @@ ${text2}</tr>
|
|
|
2559
2561
|
return `<del>${this.parser.parseInline(tokens)}</del>`;
|
|
2560
2562
|
}
|
|
2561
2563
|
link({ href, title, tokens }) {
|
|
2562
|
-
const
|
|
2564
|
+
const text = this.parser.parseInline(tokens);
|
|
2563
2565
|
const cleanHref = cleanUrl(href);
|
|
2564
2566
|
if (cleanHref === null) {
|
|
2565
|
-
return
|
|
2567
|
+
return text;
|
|
2566
2568
|
}
|
|
2567
2569
|
href = cleanHref;
|
|
2568
2570
|
let out = '<a href="' + href + '"';
|
|
2569
2571
|
if (title) {
|
|
2570
2572
|
out += ' title="' + escape2(title) + '"';
|
|
2571
2573
|
}
|
|
2572
|
-
out += ">" +
|
|
2574
|
+
out += ">" + text + "</a>";
|
|
2573
2575
|
return out;
|
|
2574
2576
|
}
|
|
2575
|
-
image({ href, title, text
|
|
2577
|
+
image({ href, title, text, tokens }) {
|
|
2576
2578
|
if (tokens) {
|
|
2577
|
-
|
|
2579
|
+
text = this.parser.parseInline(tokens, this.parser.textRenderer);
|
|
2578
2580
|
}
|
|
2579
2581
|
const cleanHref = cleanUrl(href);
|
|
2580
2582
|
if (cleanHref === null) {
|
|
2581
|
-
return escape2(
|
|
2583
|
+
return escape2(text);
|
|
2582
2584
|
}
|
|
2583
2585
|
href = cleanHref;
|
|
2584
|
-
let out = `<img src="${href}" alt="${
|
|
2586
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
2585
2587
|
if (title) {
|
|
2586
2588
|
out += ` title="${escape2(title)}"`;
|
|
2587
2589
|
}
|
|
@@ -2593,29 +2595,29 @@ ${text2}</tr>
|
|
|
2593
2595
|
}
|
|
2594
2596
|
};
|
|
2595
2597
|
var _TextRenderer = class {
|
|
2596
|
-
strong({ text
|
|
2597
|
-
return
|
|
2598
|
+
strong({ text }) {
|
|
2599
|
+
return text;
|
|
2598
2600
|
}
|
|
2599
|
-
em({ text
|
|
2600
|
-
return
|
|
2601
|
+
em({ text }) {
|
|
2602
|
+
return text;
|
|
2601
2603
|
}
|
|
2602
|
-
codespan({ text
|
|
2603
|
-
return
|
|
2604
|
+
codespan({ text }) {
|
|
2605
|
+
return text;
|
|
2604
2606
|
}
|
|
2605
|
-
del({ text
|
|
2606
|
-
return
|
|
2607
|
+
del({ text }) {
|
|
2608
|
+
return text;
|
|
2607
2609
|
}
|
|
2608
|
-
html({ text
|
|
2609
|
-
return
|
|
2610
|
+
html({ text }) {
|
|
2611
|
+
return text;
|
|
2610
2612
|
}
|
|
2611
|
-
text({ text
|
|
2612
|
-
return
|
|
2613
|
+
text({ text }) {
|
|
2614
|
+
return text;
|
|
2613
2615
|
}
|
|
2614
|
-
link({ text
|
|
2615
|
-
return "" +
|
|
2616
|
+
link({ text }) {
|
|
2617
|
+
return "" + text;
|
|
2616
2618
|
}
|
|
2617
|
-
image({ text
|
|
2618
|
-
return "" +
|
|
2619
|
+
image({ text }) {
|
|
2620
|
+
return "" + text;
|
|
2619
2621
|
}
|
|
2620
2622
|
br() {
|
|
2621
2623
|
return "";
|
|
@@ -2805,8 +2807,8 @@ var _Hooks = class {
|
|
|
2805
2807
|
preprocess(markdown) {
|
|
2806
2808
|
return markdown;
|
|
2807
2809
|
}
|
|
2808
|
-
postprocess(
|
|
2809
|
-
return
|
|
2810
|
+
postprocess(html2) {
|
|
2811
|
+
return html2;
|
|
2810
2812
|
}
|
|
2811
2813
|
processAllTokens(tokens) {
|
|
2812
2814
|
return tokens;
|
|
@@ -3050,7 +3052,7 @@ var Marked = class {
|
|
|
3050
3052
|
const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
|
|
3051
3053
|
const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
|
|
3052
3054
|
if (opt.async) {
|
|
3053
|
-
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((
|
|
3055
|
+
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);
|
|
3054
3056
|
}
|
|
3055
3057
|
try {
|
|
3056
3058
|
if (opt.hooks) {
|
|
@@ -3063,11 +3065,11 @@ var Marked = class {
|
|
|
3063
3065
|
if (opt.walkTokens) {
|
|
3064
3066
|
this.walkTokens(tokens, opt.walkTokens);
|
|
3065
3067
|
}
|
|
3066
|
-
let
|
|
3068
|
+
let html2 = parser2(tokens, opt);
|
|
3067
3069
|
if (opt.hooks) {
|
|
3068
|
-
|
|
3070
|
+
html2 = opt.hooks.postprocess(html2);
|
|
3069
3071
|
}
|
|
3070
|
-
return
|
|
3072
|
+
return html2;
|
|
3071
3073
|
} catch (e) {
|
|
3072
3074
|
return throwError(e);
|
|
3073
3075
|
}
|
|
@@ -3176,9 +3178,9 @@ class MarkdownRenderer {
|
|
|
3176
3178
|
currentReferences = emptyChatReferences;
|
|
3177
3179
|
lastUsedIndex = 0;
|
|
3178
3180
|
DomPurity;
|
|
3179
|
-
constructor(
|
|
3180
|
-
this.marked = new Marked({ async: false, breaks: true }).use(this.createFootnoteExtension(), ...
|
|
3181
|
-
this.DomPurity = getDomPurify(
|
|
3181
|
+
constructor(options = {}) {
|
|
3182
|
+
this.marked = new Marked({ async: false, breaks: true }).use(this.createFootnoteExtension(), ...options.extensions ?? []);
|
|
3183
|
+
this.DomPurity = getDomPurify(options.window, options.newTabSrText);
|
|
3182
3184
|
}
|
|
3183
3185
|
createFootnoteExtension = () => {
|
|
3184
3186
|
const self = this;
|
|
@@ -3188,10 +3190,10 @@ class MarkdownRenderer {
|
|
|
3188
3190
|
name: "footnote",
|
|
3189
3191
|
level: "inline",
|
|
3190
3192
|
start(src) {
|
|
3191
|
-
return src.match(/\[\^(\d+)\]/)?.index;
|
|
3193
|
+
return src.match(/\[\^(\d+(?:\.\d+)?)\]/)?.index;
|
|
3192
3194
|
},
|
|
3193
3195
|
tokenizer(src) {
|
|
3194
|
-
const rule = /^\[\^(\d+)\]/;
|
|
3196
|
+
const rule = /^\[\^(\d+(?:\.\d+)?)\]/;
|
|
3195
3197
|
const match = rule.exec(src);
|
|
3196
3198
|
if (match) {
|
|
3197
3199
|
const [full, refNumber] = match;
|
|
@@ -3204,10 +3206,12 @@ class MarkdownRenderer {
|
|
|
3204
3206
|
},
|
|
3205
3207
|
renderer(token) {
|
|
3206
3208
|
if (token.type === "footnote") {
|
|
3207
|
-
const
|
|
3209
|
+
const refs = self.currentReferences.all;
|
|
3210
|
+
const hasIds = refs.some((reference) => reference.citationId !== undefined);
|
|
3211
|
+
const refIndex = hasIds ? refs.findIndex((reference) => reference.citationId === token.refNumber) : /^\d+$/.test(token.refNumber) ? Number(token.refNumber) - 1 : -1;
|
|
3208
3212
|
const currentReference = self.currentReferences.all[refIndex];
|
|
3209
3213
|
if (!currentReference) {
|
|
3210
|
-
console.error("Could not find ref
|
|
3214
|
+
console.error("Could not find ref for citation:", token.refNumber);
|
|
3211
3215
|
return "";
|
|
3212
3216
|
}
|
|
3213
3217
|
let usedIndex;
|
|
@@ -3235,9 +3239,9 @@ class MarkdownRenderer {
|
|
|
3235
3239
|
}
|
|
3236
3240
|
toHTML(markdown, references) {
|
|
3237
3241
|
this.currentReferences = references;
|
|
3238
|
-
const
|
|
3242
|
+
const html = this.parse(markdown);
|
|
3239
3243
|
this.currentReferences = emptyChatReferences;
|
|
3240
|
-
return
|
|
3244
|
+
return html;
|
|
3241
3245
|
}
|
|
3242
3246
|
}
|
|
3243
3247
|
// node_modules/.bun/esm-env@1.2.2/node_modules/esm-env/true.js
|
|
@@ -3334,7 +3338,7 @@ var subscriber_queue = [];
|
|
|
3334
3338
|
function writable(value, start = noop) {
|
|
3335
3339
|
let stop = null;
|
|
3336
3340
|
const subscribers = new Set;
|
|
3337
|
-
function
|
|
3341
|
+
function set(new_value) {
|
|
3338
3342
|
if (safe_not_equal(value, new_value)) {
|
|
3339
3343
|
value = new_value;
|
|
3340
3344
|
if (stop) {
|
|
@@ -3353,13 +3357,13 @@ function writable(value, start = noop) {
|
|
|
3353
3357
|
}
|
|
3354
3358
|
}
|
|
3355
3359
|
function update(fn) {
|
|
3356
|
-
|
|
3360
|
+
set(fn(value));
|
|
3357
3361
|
}
|
|
3358
3362
|
function subscribe(run, invalidate = noop) {
|
|
3359
3363
|
const subscriber = [run, invalidate];
|
|
3360
3364
|
subscribers.add(subscriber);
|
|
3361
3365
|
if (subscribers.size === 1) {
|
|
3362
|
-
stop = start(
|
|
3366
|
+
stop = start(set, update) || noop;
|
|
3363
3367
|
}
|
|
3364
3368
|
run(value);
|
|
3365
3369
|
return () => {
|
|
@@ -3370,7 +3374,7 @@ function writable(value, start = noop) {
|
|
|
3370
3374
|
}
|
|
3371
3375
|
};
|
|
3372
3376
|
}
|
|
3373
|
-
return { set
|
|
3377
|
+
return { set, update, subscribe };
|
|
3374
3378
|
}
|
|
3375
3379
|
|
|
3376
3380
|
// node_modules/.bun/svelte@5.54.0/node_modules/svelte/src/internal/client/reactivity/store.js
|
|
@@ -3471,13 +3475,14 @@ var getDomainName = (url) => {
|
|
|
3471
3475
|
};
|
|
3472
3476
|
|
|
3473
3477
|
// src/lib/client/utils/html-to-text.ts
|
|
3474
|
-
function htmlToText(
|
|
3475
|
-
const
|
|
3476
|
-
return
|
|
3478
|
+
function htmlToText(html) {
|
|
3479
|
+
const text = html.replace(/<[^>]*>/g, "").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"');
|
|
3480
|
+
return text;
|
|
3477
3481
|
}
|
|
3478
3482
|
|
|
3479
3483
|
// src/lib/client/chat-result-builder.ts
|
|
3480
3484
|
var mapSseReference = ({
|
|
3485
|
+
citationId,
|
|
3481
3486
|
url,
|
|
3482
3487
|
considered,
|
|
3483
3488
|
title,
|
|
@@ -3487,6 +3492,7 @@ var mapSseReference = ({
|
|
|
3487
3492
|
const domainName = getDomainName(url);
|
|
3488
3493
|
const desc = description || summary;
|
|
3489
3494
|
return {
|
|
3495
|
+
...citationId ? { citationId } : {},
|
|
3490
3496
|
url,
|
|
3491
3497
|
considered,
|
|
3492
3498
|
referenceIndex: {},
|
|
@@ -3511,17 +3517,17 @@ class ChatResultBuilder {
|
|
|
3511
3517
|
store;
|
|
3512
3518
|
content = new FutureValue;
|
|
3513
3519
|
backendSendsMappedRefs = false;
|
|
3514
|
-
constructor(
|
|
3515
|
-
this.options =
|
|
3520
|
+
constructor(options) {
|
|
3521
|
+
this.options = options;
|
|
3516
3522
|
this.store = writable({
|
|
3517
|
-
id:
|
|
3523
|
+
id: options.id,
|
|
3518
3524
|
state: "loading",
|
|
3519
3525
|
errors: [],
|
|
3520
3526
|
type: "bot",
|
|
3521
3527
|
time: new Date().toISOString(),
|
|
3522
3528
|
message: { markdown: "", html: "", text: "" },
|
|
3523
3529
|
references: { all: [], used: [], unused: [] },
|
|
3524
|
-
retrievalQuestion:
|
|
3530
|
+
retrievalQuestion: options.userQuestion
|
|
3525
3531
|
});
|
|
3526
3532
|
}
|
|
3527
3533
|
pushError(error) {
|
|
@@ -3534,14 +3540,14 @@ class ChatResultBuilder {
|
|
|
3534
3540
|
id
|
|
3535
3541
|
}));
|
|
3536
3542
|
}
|
|
3537
|
-
updateText(
|
|
3543
|
+
updateText(text) {
|
|
3538
3544
|
this.store.update((current) => {
|
|
3539
|
-
const nextMarkdown = current.message.markdown +
|
|
3540
|
-
const
|
|
3545
|
+
const nextMarkdown = current.message.markdown + text;
|
|
3546
|
+
const html = this.options.markdownRenderer.toHTML(nextMarkdown, current.references);
|
|
3541
3547
|
return {
|
|
3542
3548
|
...current,
|
|
3543
3549
|
state: "streaming",
|
|
3544
|
-
message: { markdown: nextMarkdown, html
|
|
3550
|
+
message: { markdown: nextMarkdown, html, text: "" }
|
|
3545
3551
|
};
|
|
3546
3552
|
});
|
|
3547
3553
|
}
|
|
@@ -3676,8 +3682,8 @@ class Conversation {
|
|
|
3676
3682
|
subscribe(callback) {
|
|
3677
3683
|
return this.state.subscribe(callback);
|
|
3678
3684
|
}
|
|
3679
|
-
chat(question,
|
|
3680
|
-
const chatResponse = this.clientPrimitive.chat(this.id, question,
|
|
3685
|
+
chat(question, options = {}) {
|
|
3686
|
+
const chatResponse = this.clientPrimitive.chat(this.id, question, options);
|
|
3681
3687
|
this.history.push(chatResponse);
|
|
3682
3688
|
this.latestRequest.setValue({ question, response: chatResponse });
|
|
3683
3689
|
return chatResponse;
|
|
@@ -3999,6 +4005,7 @@ var chatMessageUserSchema = z4.object({
|
|
|
3999
4005
|
var conversationStateSchema = z4.enum(["idle", "searching", "answering"]);
|
|
4000
4006
|
var metadataValueSchema2 = z4.union([z4.string(), z4.number(), z4.boolean(), z4.array(z4.string()), z4.array(z4.number()), z4.array(z4.boolean())]);
|
|
4001
4007
|
var chatReferenceSchema = z4.object({
|
|
4008
|
+
citationId: z4.optional(z4.string()),
|
|
4002
4009
|
url: z4.string(),
|
|
4003
4010
|
score: z4.number(),
|
|
4004
4011
|
metadata: z4.record(z4.string(), metadataValueSchema2),
|
|
@@ -4455,10 +4462,10 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
4455
4462
|
|
|
4456
4463
|
// node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/v7.js
|
|
4457
4464
|
var _state = {};
|
|
4458
|
-
function v7(
|
|
4465
|
+
function v7(options, buf, offset) {
|
|
4459
4466
|
let bytes;
|
|
4460
|
-
if (
|
|
4461
|
-
bytes = v7Bytes(
|
|
4467
|
+
if (options) {
|
|
4468
|
+
bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
|
|
4462
4469
|
} else {
|
|
4463
4470
|
const now = Date.now();
|
|
4464
4471
|
const rnds = rng();
|
|
@@ -4467,19 +4474,19 @@ function v7(options2, buf, offset) {
|
|
|
4467
4474
|
}
|
|
4468
4475
|
return buf ?? unsafeStringify(bytes);
|
|
4469
4476
|
}
|
|
4470
|
-
function updateV7State(
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
if (now >
|
|
4474
|
-
|
|
4475
|
-
|
|
4477
|
+
function updateV7State(state, now, rnds) {
|
|
4478
|
+
state.msecs ??= -Infinity;
|
|
4479
|
+
state.seq ??= 0;
|
|
4480
|
+
if (now > state.msecs) {
|
|
4481
|
+
state.seq = rnds[6] << 23 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
4482
|
+
state.msecs = now;
|
|
4476
4483
|
} else {
|
|
4477
|
-
|
|
4478
|
-
if (
|
|
4479
|
-
|
|
4484
|
+
state.seq = state.seq + 1 | 0;
|
|
4485
|
+
if (state.seq === 0) {
|
|
4486
|
+
state.msecs++;
|
|
4480
4487
|
}
|
|
4481
4488
|
}
|
|
4482
|
-
return
|
|
4489
|
+
return state;
|
|
4483
4490
|
}
|
|
4484
4491
|
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
|
4485
4492
|
if (rnds.length < 16) {
|
|
@@ -4577,23 +4584,23 @@ var getUserData = async (restClient, startParameters) => {
|
|
|
4577
4584
|
};
|
|
4578
4585
|
|
|
4579
4586
|
// node_modules/.bun/sse.js@2.8.0/node_modules/sse.js/lib/sse.js
|
|
4580
|
-
var SSE = function(url,
|
|
4587
|
+
var SSE = function(url, options) {
|
|
4581
4588
|
if (!(this instanceof SSE)) {
|
|
4582
|
-
return new SSE(url,
|
|
4589
|
+
return new SSE(url, options);
|
|
4583
4590
|
}
|
|
4584
4591
|
this.url = url;
|
|
4585
|
-
|
|
4586
|
-
this.headers =
|
|
4587
|
-
this.payload =
|
|
4588
|
-
this.method =
|
|
4589
|
-
this.withCredentials = !!
|
|
4590
|
-
this.debug = !!
|
|
4591
|
-
this.autoReconnect =
|
|
4592
|
-
this.reconnectDelay =
|
|
4593
|
-
this.maxRetries =
|
|
4592
|
+
options = options || {};
|
|
4593
|
+
this.headers = options.headers || {};
|
|
4594
|
+
this.payload = options.payload !== undefined ? options.payload : "";
|
|
4595
|
+
this.method = options.method || this.payload && "POST" || "GET";
|
|
4596
|
+
this.withCredentials = !!options.withCredentials;
|
|
4597
|
+
this.debug = !!options.debug;
|
|
4598
|
+
this.autoReconnect = options.autoReconnect !== undefined ? options.autoReconnect : false;
|
|
4599
|
+
this.reconnectDelay = options.reconnectDelay !== undefined ? options.reconnectDelay : 3000;
|
|
4600
|
+
this.maxRetries = options.maxRetries !== undefined ? options.maxRetries : null;
|
|
4594
4601
|
this.retryCount = 0;
|
|
4595
4602
|
this.reconnectTimer = null;
|
|
4596
|
-
this.useLastEventId =
|
|
4603
|
+
this.useLastEventId = options.useLastEventId !== undefined ? options.useLastEventId : true;
|
|
4597
4604
|
this.FIELD_SEPARATOR = ":";
|
|
4598
4605
|
this.listeners = {};
|
|
4599
4606
|
this.xhr = null;
|
|
@@ -4676,10 +4683,10 @@ var SSE = function(url, options2) {
|
|
|
4676
4683
|
}, this.reconnectDelay);
|
|
4677
4684
|
}
|
|
4678
4685
|
};
|
|
4679
|
-
this._setReadyState = function(
|
|
4686
|
+
this._setReadyState = function(state) {
|
|
4680
4687
|
const event = new CustomEvent("readystatechange");
|
|
4681
|
-
event.readyState =
|
|
4682
|
-
this.readyState =
|
|
4688
|
+
event.readyState = state;
|
|
4689
|
+
this.readyState = state;
|
|
4683
4690
|
this.dispatchEvent(event);
|
|
4684
4691
|
};
|
|
4685
4692
|
this._onStreamFailure = function(e) {
|
|
@@ -4823,7 +4830,7 @@ var SSE = function(url, options2) {
|
|
|
4823
4830
|
this.xhr.abort();
|
|
4824
4831
|
}
|
|
4825
4832
|
};
|
|
4826
|
-
if (
|
|
4833
|
+
if (options.start === undefined || options.start) {
|
|
4827
4834
|
this.stream();
|
|
4828
4835
|
}
|
|
4829
4836
|
};
|
|
@@ -4838,27 +4845,27 @@ class SseSubscription {
|
|
|
4838
4845
|
payload;
|
|
4839
4846
|
eventSource;
|
|
4840
4847
|
triggeredOnClose = false;
|
|
4841
|
-
constructor(url,
|
|
4842
|
-
this.options =
|
|
4848
|
+
constructor(url, options, payload) {
|
|
4849
|
+
this.options = options;
|
|
4843
4850
|
this.payload = payload;
|
|
4844
4851
|
const sseoptions = { headers: { "content-type": "application/json" } };
|
|
4845
4852
|
if (payload) {
|
|
4846
4853
|
sseoptions.payload = JSON.stringify(payload);
|
|
4847
4854
|
}
|
|
4848
|
-
if (
|
|
4849
|
-
sseoptions.headers["api-key"] =
|
|
4855
|
+
if (options.apiKey) {
|
|
4856
|
+
sseoptions.headers["api-key"] = options.apiKey;
|
|
4850
4857
|
}
|
|
4851
|
-
this.eventSource = new (
|
|
4858
|
+
this.eventSource = new (options.EventSource ?? SSE)(url, sseoptions);
|
|
4852
4859
|
this.eventSource.onmessage = (event) => {
|
|
4853
4860
|
try {
|
|
4854
4861
|
const data = JSON.parse(event.data);
|
|
4855
|
-
|
|
4862
|
+
options.onMessage(data);
|
|
4856
4863
|
} catch (error) {
|
|
4857
|
-
|
|
4864
|
+
options.onError(new CustomEvent("parse-error", { detail: error }));
|
|
4858
4865
|
}
|
|
4859
4866
|
};
|
|
4860
4867
|
this.eventSource.onerror = (event) => {
|
|
4861
|
-
|
|
4868
|
+
options.onError(event);
|
|
4862
4869
|
if (this.isClosed()) {
|
|
4863
4870
|
this.close();
|
|
4864
4871
|
}
|
|
@@ -4883,8 +4890,8 @@ var removeUndefinedValues = (obj) => Object.fromEntries(Object.entries(obj).filt
|
|
|
4883
4890
|
// src/lib/client/api/rest-client.ts
|
|
4884
4891
|
class RestClient {
|
|
4885
4892
|
options;
|
|
4886
|
-
constructor(
|
|
4887
|
-
this.options =
|
|
4893
|
+
constructor(options) {
|
|
4894
|
+
this.options = options;
|
|
4888
4895
|
}
|
|
4889
4896
|
getDefaultHeaders(additional = {}) {
|
|
4890
4897
|
const headers = {
|
|
@@ -4898,17 +4905,17 @@ class RestClient {
|
|
|
4898
4905
|
get speechRecognitionApiKey() {
|
|
4899
4906
|
return this.options.speechRecognitionApiKey;
|
|
4900
4907
|
}
|
|
4901
|
-
async subscribeSse(path, params = {},
|
|
4908
|
+
async subscribeSse(path, params = {}, options) {
|
|
4902
4909
|
const payload = removeUndefinedValues(params);
|
|
4903
4910
|
if (this.options.apiKey)
|
|
4904
|
-
|
|
4905
|
-
return new SseSubscription(`${this.options.apiUrl}${path}`,
|
|
4911
|
+
options.apiKey = this.options.apiKey;
|
|
4912
|
+
return new SseSubscription(`${this.options.apiUrl}${path}`, options, payload);
|
|
4906
4913
|
}
|
|
4907
|
-
async fetchData(path, validator, params = {},
|
|
4914
|
+
async fetchData(path, validator, params = {}, options = {}) {
|
|
4908
4915
|
const url = `${this.options.apiUrl}${path}?${new URLSearchParams(removeUndefinedValues(params)).toString()}`;
|
|
4909
4916
|
const opts = {
|
|
4910
|
-
...
|
|
4911
|
-
headers: this.getDefaultHeaders(
|
|
4917
|
+
...options,
|
|
4918
|
+
headers: this.getDefaultHeaders(options?.headers)
|
|
4912
4919
|
};
|
|
4913
4920
|
const response = await fetch(url, opts);
|
|
4914
4921
|
if (!response.ok) {
|
|
@@ -4981,30 +4988,30 @@ var linkSchema = z8.union([linkLegacySchema, searchReferenceSchema]);
|
|
|
4981
4988
|
var searchEndpointSchema = z8.object({
|
|
4982
4989
|
links: z8.array(linkSchema)
|
|
4983
4990
|
});
|
|
4984
|
-
var mapLinkToSearchReference = (
|
|
4985
|
-
if ("metadata" in
|
|
4986
|
-
return
|
|
4991
|
+
var mapLinkToSearchReference = (link) => {
|
|
4992
|
+
if ("metadata" in link)
|
|
4993
|
+
return link;
|
|
4987
4994
|
console.warn("Please upgrade your backend you are currently using an old api feature.");
|
|
4988
|
-
const metadata =
|
|
4989
|
-
if (
|
|
4990
|
-
metadata.fromFullTextSearch =
|
|
4991
|
-
if (
|
|
4992
|
-
metadata.rerank =
|
|
4995
|
+
const metadata = link.orgMetadata ?? {};
|
|
4996
|
+
if (link?.fromFullTextSearch)
|
|
4997
|
+
metadata.fromFullTextSearch = link?.fromFullTextSearch;
|
|
4998
|
+
if (link?.rerank)
|
|
4999
|
+
metadata.rerank = link?.rerank;
|
|
4993
5000
|
let breadcrumbs = [];
|
|
4994
|
-
let title =
|
|
4995
|
-
if (
|
|
4996
|
-
const all =
|
|
5001
|
+
let title = link.title ?? "";
|
|
5002
|
+
if (link.title && link.title.includes(" > ")) {
|
|
5003
|
+
const all = link.title.split(" > ");
|
|
4997
5004
|
title = all.pop() ?? "";
|
|
4998
5005
|
breadcrumbs = all;
|
|
4999
5006
|
}
|
|
5000
5007
|
return {
|
|
5001
|
-
url:
|
|
5008
|
+
url: link.url ?? "",
|
|
5002
5009
|
title,
|
|
5003
|
-
score:
|
|
5010
|
+
score: link.similarity || 0,
|
|
5004
5011
|
breadcrumbs,
|
|
5005
5012
|
metadata,
|
|
5006
|
-
description:
|
|
5007
|
-
date:
|
|
5013
|
+
description: link.content,
|
|
5014
|
+
date: link.date
|
|
5008
5015
|
};
|
|
5009
5016
|
};
|
|
5010
5017
|
|
|
@@ -5049,37 +5056,37 @@ var MS_PER_CHAR = 7;
|
|
|
5049
5056
|
var MIN_DELAY_MS = 8;
|
|
5050
5057
|
var MAX_DELAY_MS = 160;
|
|
5051
5058
|
var START_DELAY_MS = 750;
|
|
5052
|
-
var tokenize = (
|
|
5059
|
+
var tokenize = (text) => {
|
|
5053
5060
|
const tokens = [];
|
|
5054
5061
|
let i = 0;
|
|
5055
|
-
while (i <
|
|
5056
|
-
const ch =
|
|
5062
|
+
while (i < text.length) {
|
|
5063
|
+
const ch = text[i];
|
|
5057
5064
|
if (ch === "<") {
|
|
5058
|
-
const end =
|
|
5065
|
+
const end = text.indexOf(">", i);
|
|
5059
5066
|
if (end !== -1) {
|
|
5060
|
-
tokens.push({ type: "tag", value:
|
|
5067
|
+
tokens.push({ type: "tag", value: text.slice(i, end + 1) });
|
|
5061
5068
|
i = end + 1;
|
|
5062
5069
|
continue;
|
|
5063
5070
|
}
|
|
5064
5071
|
}
|
|
5065
5072
|
if (/\s/.test(ch)) {
|
|
5066
|
-
let
|
|
5067
|
-
while (
|
|
5068
|
-
|
|
5069
|
-
tokens.push({ type: "space", value:
|
|
5070
|
-
i =
|
|
5073
|
+
let j = i;
|
|
5074
|
+
while (j < text.length && /\s/.test(text[j]))
|
|
5075
|
+
j++;
|
|
5076
|
+
tokens.push({ type: "space", value: text.slice(i, j) });
|
|
5077
|
+
i = j;
|
|
5071
5078
|
continue;
|
|
5072
5079
|
}
|
|
5073
5080
|
let j = i;
|
|
5074
|
-
while (j <
|
|
5081
|
+
while (j < text.length && !/\s/.test(text[j]) && text[j] !== "<")
|
|
5075
5082
|
j++;
|
|
5076
|
-
tokens.push({ type: "word", value:
|
|
5083
|
+
tokens.push({ type: "word", value: text.slice(i, j) });
|
|
5077
5084
|
i = j;
|
|
5078
5085
|
}
|
|
5079
5086
|
return tokens;
|
|
5080
5087
|
};
|
|
5081
|
-
var splitForTyping = (
|
|
5082
|
-
const tokens = tokenize(
|
|
5088
|
+
var splitForTyping = (text) => {
|
|
5089
|
+
const tokens = tokenize(text);
|
|
5083
5090
|
const emissions = [];
|
|
5084
5091
|
let current = "";
|
|
5085
5092
|
let hasWord = false;
|
|
@@ -5108,8 +5115,8 @@ class FakeTypingQueue {
|
|
|
5108
5115
|
constructor(onText) {
|
|
5109
5116
|
this.onText = onText;
|
|
5110
5117
|
}
|
|
5111
|
-
ingestText(
|
|
5112
|
-
const chunks = splitForTyping(
|
|
5118
|
+
ingestText(text) {
|
|
5119
|
+
const chunks = splitForTyping(text);
|
|
5113
5120
|
if (chunks.length >= TYPING_MIN_CHUNKS) {
|
|
5114
5121
|
for (const chunk of chunks) {
|
|
5115
5122
|
this.queue.push({ kind: "text", chunk, delayMs: delayForChunk(chunk) });
|
|
@@ -5117,7 +5124,7 @@ class FakeTypingQueue {
|
|
|
5117
5124
|
this.kickoff();
|
|
5118
5125
|
return;
|
|
5119
5126
|
}
|
|
5120
|
-
this.runAfterTyping(() => this.onText(
|
|
5127
|
+
this.runAfterTyping(() => this.onText(text));
|
|
5121
5128
|
}
|
|
5122
5129
|
runAfterTyping(fn) {
|
|
5123
5130
|
if (this.queue.length === 0 && !this.isProcessing) {
|
|
@@ -5184,19 +5191,19 @@ class LiipGPTClientPrimitive {
|
|
|
5184
5191
|
markedExtensions = [];
|
|
5185
5192
|
_newTabSrText;
|
|
5186
5193
|
chatTimeout;
|
|
5187
|
-
constructor(
|
|
5188
|
-
this.chatTimeout =
|
|
5194
|
+
constructor(options) {
|
|
5195
|
+
this.chatTimeout = options.chatTimeout ?? DEFAULT_CHAT_TIMEOUT;
|
|
5189
5196
|
const restOptions = {
|
|
5190
|
-
apiUrl:
|
|
5191
|
-
apiKey:
|
|
5192
|
-
speechRecognitionApiKey:
|
|
5193
|
-
strict:
|
|
5194
|
-
EventSource:
|
|
5197
|
+
apiUrl: options.apiUrl,
|
|
5198
|
+
apiKey: options.apiKey,
|
|
5199
|
+
speechRecognitionApiKey: options.speechRecognitionApiKey,
|
|
5200
|
+
strict: options.strict ?? false,
|
|
5201
|
+
EventSource: options.EventSource ?? EventSource
|
|
5195
5202
|
};
|
|
5196
5203
|
const restClient = new RestClient(restOptions);
|
|
5197
5204
|
this.internalData = {
|
|
5198
5205
|
restClient,
|
|
5199
|
-
metadata: getUserData(restClient,
|
|
5206
|
+
metadata: getUserData(restClient, options.startParameters),
|
|
5200
5207
|
searchResponseMap: new Map,
|
|
5201
5208
|
chatResponseMap: new Map,
|
|
5202
5209
|
conversationMap: new Map
|
|
@@ -5205,8 +5212,8 @@ class LiipGPTClientPrimitive {
|
|
|
5205
5212
|
setMarkedExtensions(...extensions) {
|
|
5206
5213
|
this.markedExtensions = extensions;
|
|
5207
5214
|
}
|
|
5208
|
-
setNewTabSrText(
|
|
5209
|
-
this._newTabSrText =
|
|
5215
|
+
setNewTabSrText(text) {
|
|
5216
|
+
this._newTabSrText = text;
|
|
5210
5217
|
}
|
|
5211
5218
|
getMetadata() {
|
|
5212
5219
|
return this.internalData.metadata;
|
|
@@ -5216,7 +5223,7 @@ class LiipGPTClientPrimitive {
|
|
|
5216
5223
|
this.renderers.set(conversationId, new MarkdownRenderer({ extensions: this.markedExtensions, newTabSrText: this._newTabSrText }));
|
|
5217
5224
|
return conversationId;
|
|
5218
5225
|
}
|
|
5219
|
-
chat(conversationId, question,
|
|
5226
|
+
chat(conversationId, question, options = {}) {
|
|
5220
5227
|
const content = new FutureValue;
|
|
5221
5228
|
const requestId = v7_default();
|
|
5222
5229
|
const readyForFeedback = new Flag;
|
|
@@ -5224,7 +5231,7 @@ class LiipGPTClientPrimitive {
|
|
|
5224
5231
|
const chatResultBuilder = new ChatResultBuilder({
|
|
5225
5232
|
id: requestId,
|
|
5226
5233
|
onError: (error) => {
|
|
5227
|
-
|
|
5234
|
+
options.onError?.(error);
|
|
5228
5235
|
},
|
|
5229
5236
|
onFinish: (message) => {
|
|
5230
5237
|
content.setValue(message);
|
|
@@ -5240,7 +5247,7 @@ class LiipGPTClientPrimitive {
|
|
|
5240
5247
|
};
|
|
5241
5248
|
const subscription = new FutureValue;
|
|
5242
5249
|
const typingQueue = new FakeTypingQueue((chunk) => chatResultBuilder.updateText(chunk));
|
|
5243
|
-
const timeout =
|
|
5250
|
+
const timeout = options.timeout ?? this.chatTimeout;
|
|
5244
5251
|
let timeoutId;
|
|
5245
5252
|
let timedOut = false;
|
|
5246
5253
|
const stopWatchdog = () => {
|
|
@@ -5278,15 +5285,15 @@ class LiipGPTClientPrimitive {
|
|
|
5278
5285
|
uID: metadata.userId,
|
|
5279
5286
|
cID: conversationId,
|
|
5280
5287
|
rID: requestId,
|
|
5281
|
-
lang:
|
|
5282
|
-
feature:
|
|
5283
|
-
referrer:
|
|
5284
|
-
source:
|
|
5285
|
-
...
|
|
5286
|
-
...
|
|
5287
|
-
...
|
|
5288
|
-
...
|
|
5289
|
-
...
|
|
5288
|
+
lang: options.lang,
|
|
5289
|
+
feature: options.features?.join(","),
|
|
5290
|
+
referrer: options.referrer,
|
|
5291
|
+
source: options.source,
|
|
5292
|
+
...options.selectorValues ?? {},
|
|
5293
|
+
...options.mode ? { mode: options.mode } : {},
|
|
5294
|
+
...options.cache ? { cache: true } : {},
|
|
5295
|
+
...options.predefinedQuestionId ? { predefinedQuestionId: options.predefinedQuestionId } : {},
|
|
5296
|
+
...options.switchQuestionId ? { switchQuestionId: options.switchQuestionId } : {},
|
|
5290
5297
|
chat: "true",
|
|
5291
5298
|
version: "2"
|
|
5292
5299
|
}, {
|
|
@@ -5328,7 +5335,7 @@ class LiipGPTClientPrimitive {
|
|
|
5328
5335
|
typingQueue.runAfterTyping(() => {
|
|
5329
5336
|
chatResultBuilder.finishMessage();
|
|
5330
5337
|
readyForFeedback.resolve();
|
|
5331
|
-
subscription.then((
|
|
5338
|
+
subscription.then((s) => s.close());
|
|
5332
5339
|
});
|
|
5333
5340
|
break;
|
|
5334
5341
|
case "unexpected-call":
|
|
@@ -5351,10 +5358,10 @@ class LiipGPTClientPrimitive {
|
|
|
5351
5358
|
typingQueue.runAfterTyping(() => chatResultBuilder.setNoFeedback());
|
|
5352
5359
|
break;
|
|
5353
5360
|
case "component":
|
|
5354
|
-
typingQueue.runWithWarmup(() =>
|
|
5361
|
+
typingQueue.runWithWarmup(() => options.onEmbed?.(data));
|
|
5355
5362
|
break;
|
|
5356
5363
|
}
|
|
5357
|
-
typingQueue.runAfterTyping(() =>
|
|
5364
|
+
typingQueue.runAfterTyping(() => options.onMessage?.(data));
|
|
5358
5365
|
},
|
|
5359
5366
|
onError: (event) => {
|
|
5360
5367
|
console.error(" sse-error:", event);
|
|
@@ -5434,24 +5441,24 @@ class LiipGPTClientPrimitive {
|
|
|
5434
5441
|
};
|
|
5435
5442
|
await this.internalData.restClient.postData("/customform", answerFormRequest);
|
|
5436
5443
|
}
|
|
5437
|
-
async userAction(userAction,
|
|
5444
|
+
async userAction(userAction, options = {}) {
|
|
5438
5445
|
const metadata = await this.internalData.metadata;
|
|
5439
5446
|
if (metadata.mode !== "ready")
|
|
5440
5447
|
throw new Error("Can not post user action unless we are in ready mode");
|
|
5441
5448
|
const request = {
|
|
5442
5449
|
uID: metadata.userId,
|
|
5443
|
-
cID:
|
|
5444
|
-
lang:
|
|
5450
|
+
cID: options.conversationId,
|
|
5451
|
+
lang: options.lang,
|
|
5445
5452
|
userAction
|
|
5446
5453
|
};
|
|
5447
5454
|
await this.internalData.restClient.postData("/assistant/userAction", request);
|
|
5448
5455
|
}
|
|
5449
|
-
async search(query,
|
|
5456
|
+
async search(query, options = {}) {
|
|
5450
5457
|
const metadata = await this.internalData.metadata;
|
|
5451
5458
|
const uID = metadata.mode === "ready" ? metadata.userId : undefined;
|
|
5452
5459
|
const { links } = await this.internalData.restClient.fetchData("/assistant/search", searchEndpointSchema, {
|
|
5453
|
-
modelId:
|
|
5454
|
-
lang:
|
|
5460
|
+
modelId: options.model,
|
|
5461
|
+
lang: options.language,
|
|
5455
5462
|
query,
|
|
5456
5463
|
mapResults: "true",
|
|
5457
5464
|
uID
|
|
@@ -5476,9 +5483,9 @@ class LiipGPTClientPrimitive {
|
|
|
5476
5483
|
const data = await this.internalData.restClient.fetchData("/topics/questions", predefinedQuestionsResponseSchema, params);
|
|
5477
5484
|
return data.predefinedQuestions;
|
|
5478
5485
|
}
|
|
5479
|
-
async transcribeAudio(audioBlob,
|
|
5486
|
+
async transcribeAudio(audioBlob, options = {}) {
|
|
5480
5487
|
const metadata = await this.internalData.metadata;
|
|
5481
|
-
const language =
|
|
5488
|
+
const language = options.lang || "de-CH";
|
|
5482
5489
|
if (metadata.mode === "maintenance") {
|
|
5483
5490
|
throw new Error("Can not transcribe audio in maintenance mode");
|
|
5484
5491
|
}
|
|
@@ -5516,8 +5523,8 @@ class LiipGPTClientPrimitive {
|
|
|
5516
5523
|
// src/lib/client/liipgpt-client.ts
|
|
5517
5524
|
class LiipGPTClient {
|
|
5518
5525
|
clientPrimitive;
|
|
5519
|
-
constructor(
|
|
5520
|
-
this.clientPrimitive = new LiipGPTClientPrimitive(
|
|
5526
|
+
constructor(options) {
|
|
5527
|
+
this.clientPrimitive = new LiipGPTClientPrimitive(options);
|
|
5521
5528
|
}
|
|
5522
5529
|
getMetadata() {
|
|
5523
5530
|
return this.clientPrimitive.getMetadata();
|
|
@@ -5525,8 +5532,8 @@ class LiipGPTClient {
|
|
|
5525
5532
|
createConversation() {
|
|
5526
5533
|
return new Conversation(this.clientPrimitive);
|
|
5527
5534
|
}
|
|
5528
|
-
search(query,
|
|
5529
|
-
return this.clientPrimitive.search(query,
|
|
5535
|
+
search(query, options = {}) {
|
|
5536
|
+
return this.clientPrimitive.search(query, options);
|
|
5530
5537
|
}
|
|
5531
5538
|
getChatConfig() {
|
|
5532
5539
|
return this.clientPrimitive.getChatConfig();
|