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