@mujian/js-sdk 0.0.6-beta.38 → 0.0.6-beta.39
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/dist/index.js +10 -2
- package/dist/react.js +140 -132
- package/dist/umd/index.js +10 -2
- package/dist/umd/react.js +146 -138
- package/dist/utils/log.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -143,6 +143,14 @@ const generate = async function() {
|
|
|
143
143
|
};
|
|
144
144
|
const saveGame = async function() {};
|
|
145
145
|
const loadGame = async function() {};
|
|
146
|
+
const Log = {
|
|
147
|
+
i (...msg) {
|
|
148
|
+
console.log('[MujianSDK] ', ...msg);
|
|
149
|
+
},
|
|
150
|
+
e (...msg) {
|
|
151
|
+
console.error('[MujianSDK] ', ...msg);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
146
154
|
class MujianSdk {
|
|
147
155
|
constructor(){}
|
|
148
156
|
static getInstance() {
|
|
@@ -177,10 +185,10 @@ class MujianSdk {
|
|
|
177
185
|
const parent = await handshake;
|
|
178
186
|
this.ready = true;
|
|
179
187
|
this.parent = parent;
|
|
180
|
-
|
|
188
|
+
Log.i('mujian sdk client init');
|
|
181
189
|
await this.call(events_EVENT.MUJIAN_INIT);
|
|
182
190
|
} catch (error) {
|
|
183
|
-
|
|
191
|
+
Log.e('init error', error);
|
|
184
192
|
}
|
|
185
193
|
}
|
|
186
194
|
emit(event, data) {
|
package/dist/react.js
CHANGED
|
@@ -7,6 +7,140 @@ import showdown from "showdown";
|
|
|
7
7
|
import { v4 } from "uuid";
|
|
8
8
|
import postmate from "postmate";
|
|
9
9
|
import { Virtualizer } from "virtua";
|
|
10
|
+
function adjustIframeHeight(iframe) {
|
|
11
|
+
if (!iframe.contentWindow) return;
|
|
12
|
+
const document1 = iframe.contentWindow.document;
|
|
13
|
+
const height = Math.max(document1.body.offsetHeight, document1.documentElement.offsetHeight);
|
|
14
|
+
if (!Number.isFinite(height) || height <= 0) return;
|
|
15
|
+
iframe.style.height = `${height}px`;
|
|
16
|
+
}
|
|
17
|
+
const observed_elements = new Map();
|
|
18
|
+
const observer = new ResizeObserver((entries)=>{
|
|
19
|
+
for (const entry of entries){
|
|
20
|
+
const element = entry.target;
|
|
21
|
+
const iframe = observed_elements.get(element);
|
|
22
|
+
if (iframe) adjustIframeHeight(iframe);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
function useHeightObserver() {
|
|
26
|
+
return {
|
|
27
|
+
observe: (iframe)=>{
|
|
28
|
+
if (!iframe?.contentWindow?.document?.body) return;
|
|
29
|
+
const body = iframe.contentWindow.document.body;
|
|
30
|
+
observed_elements.set(body, iframe);
|
|
31
|
+
observer.observe(body);
|
|
32
|
+
adjustIframeHeight(iframe);
|
|
33
|
+
},
|
|
34
|
+
unobserve: (iframe)=>{
|
|
35
|
+
if (!iframe.contentWindow?.document?.body) return;
|
|
36
|
+
const body = iframe.contentWindow.document.body;
|
|
37
|
+
observed_elements.delete(body);
|
|
38
|
+
observer.unobserve(body);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const init = `
|
|
43
|
+
(async function () {
|
|
44
|
+
window.$mj_engine = window.parent.$mj_engine;
|
|
45
|
+
})();
|
|
46
|
+
`;
|
|
47
|
+
const thirdParty = `
|
|
48
|
+
<script src="https://cdn.jsdmirror.com/npm/@fortawesome/fontawesome-free/js/all.min.js"></script>
|
|
49
|
+
<script src="https://cdn.jsdmirror.com/npm/@tailwindcss/browser/dist/index.global.min.js"></script>
|
|
50
|
+
<script src="https://cdn.jsdmirror.com/npm/jquery/dist/jquery.min.js"></script>
|
|
51
|
+
<script src="https://cdn.jsdmirror.com/npm/jquery-ui/dist/jquery-ui.min.js"></script>
|
|
52
|
+
<link rel="stylesheet" href="https://cdn.jsdmirror.com/npm/jquery-ui/themes/base/theme.min.css" />
|
|
53
|
+
<script src="https://cdn.jsdmirror.com/npm/jquery-ui-touch-punch"></script>
|
|
54
|
+
`;
|
|
55
|
+
const unescapeHTML = (str)=>{
|
|
56
|
+
const named = {
|
|
57
|
+
amp: "&",
|
|
58
|
+
lt: "<",
|
|
59
|
+
gt: ">",
|
|
60
|
+
quot: '"',
|
|
61
|
+
apos: "'",
|
|
62
|
+
nbsp: "\u00A0"
|
|
63
|
+
};
|
|
64
|
+
return str.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (_m, body)=>{
|
|
65
|
+
if ("#" === body[0]) {
|
|
66
|
+
const isHex = body[1]?.toLowerCase() === "x";
|
|
67
|
+
const numStr = isHex ? body.slice(2) : body.slice(1);
|
|
68
|
+
const codePoint = parseInt(numStr, isHex ? 16 : 10);
|
|
69
|
+
if (Number.isFinite(codePoint)) try {
|
|
70
|
+
return String.fromCodePoint(codePoint);
|
|
71
|
+
} catch {}
|
|
72
|
+
return _m;
|
|
73
|
+
}
|
|
74
|
+
const lower = body.toLowerCase();
|
|
75
|
+
return Object.hasOwn(named, lower) ? named[lower] : _m;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const replaceVhInContent = (content)=>{
|
|
79
|
+
const has_css_min_vh = /min-height\s*:\s*[^;{}]*\d+(?:\.\d+)?vh/gi.test(content);
|
|
80
|
+
const has_inline_style_vh = /style\s*=\s*(["'])[\s\S]*?min-height\s*:\s*[^;]*?\d+(?:\.\d+)?vh[\s\S]*?\1/gi.test(content);
|
|
81
|
+
const has_js_vh = /(\.style\.minHeight\s*=\s*(["']))([\s\S]*?vh)(\2)/gi.test(content) || /(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?vh)(\3\s*\))/gi.test(content);
|
|
82
|
+
if (!has_css_min_vh && !has_inline_style_vh && !has_js_vh) return content;
|
|
83
|
+
const convertVhToVariable = (value)=>value.replace(/(\d+(?:\.\d+)?)vh\b/gi, (match, value)=>{
|
|
84
|
+
const parsed = parseFloat(value);
|
|
85
|
+
if (!isFinite(parsed)) return match;
|
|
86
|
+
const VARIABLE_EXPRESSION = "var(--MJ-iframe-height)";
|
|
87
|
+
if (100 === parsed) return VARIABLE_EXPRESSION;
|
|
88
|
+
return `calc(${VARIABLE_EXPRESSION} * ${parsed / 100})`;
|
|
89
|
+
});
|
|
90
|
+
content = content.replace(/(min-height\s*:\s*)([^;{}]*?\d+(?:\.\d+)?vh)(?=\s*[;}])/gi, (_m, prefix, value)=>`${prefix}${convertVhToVariable(value)}`);
|
|
91
|
+
content = content.replace(/(style\s*=\s*(["']))([^"'"]*?)(\2)/gi, (match, prefix, _quote, styleContent, suffix)=>{
|
|
92
|
+
if (!/min-height\s*:\s*[^;]*vh/i.test(styleContent)) return match;
|
|
93
|
+
const replaced = styleContent.replace(/(min-height\s*:\s*)([^;]*?\d+(?:\.\d+)?vh)/gi, (_m, p1, p2)=>`${p1}${convertVhToVariable(p2)}`);
|
|
94
|
+
return `${prefix}${replaced}${suffix}`;
|
|
95
|
+
});
|
|
96
|
+
content = content.replace(/(\.style\.minHeight\s*=\s*(["']))([\s\S]*?)(\2)/gi, (match, prefix, _q, val, suffix)=>{
|
|
97
|
+
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
98
|
+
const converted = convertVhToVariable(val);
|
|
99
|
+
return `${prefix}${converted}${suffix}`;
|
|
100
|
+
});
|
|
101
|
+
content = content.replace(/(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?)(\3\s*\))/gi, (match, prefix, _q1, _q2, val, suffix)=>{
|
|
102
|
+
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
103
|
+
const converted = convertVhToVariable(val);
|
|
104
|
+
return `${prefix}${converted}${suffix}`;
|
|
105
|
+
});
|
|
106
|
+
return content;
|
|
107
|
+
};
|
|
108
|
+
function escapeHtmlAttribute(value) {
|
|
109
|
+
return value.replace(/"/g, """).replace(/'/g, "'");
|
|
110
|
+
}
|
|
111
|
+
function createSrcContent(content) {
|
|
112
|
+
content = replaceVhInContent(content);
|
|
113
|
+
const getUserAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
114
|
+
const getCharAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
115
|
+
return `
|
|
116
|
+
<html>
|
|
117
|
+
<head>
|
|
118
|
+
<style>
|
|
119
|
+
|
|
120
|
+
html,body{margin:0;padding:0;overflow:hidden!important;max-width:100%!important;box-sizing:border-box}
|
|
121
|
+
.user_avatar,.user-avatar{background-image:url('${getUserAvatarPath()}')}
|
|
122
|
+
.char_avatar,.char-avatar{background-image:url('${getCharAvatarPath()}')}
|
|
123
|
+
|
|
124
|
+
</style>
|
|
125
|
+
${thirdParty}
|
|
126
|
+
<script>
|
|
127
|
+
${init}
|
|
128
|
+
</script>
|
|
129
|
+
</head>
|
|
130
|
+
<body>
|
|
131
|
+
${content}
|
|
132
|
+
</body>
|
|
133
|
+
</html>
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
const Log = {
|
|
137
|
+
i (...msg) {
|
|
138
|
+
console.log('[MujianSDK] ', ...msg);
|
|
139
|
+
},
|
|
140
|
+
e (...msg) {
|
|
141
|
+
console.error('[MujianSDK] ', ...msg);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
10
144
|
addDOMPurifyHooks();
|
|
11
145
|
function canUseNegativeLookbehind() {
|
|
12
146
|
try {
|
|
@@ -160,7 +294,7 @@ function addDOMPurifyHooks() {
|
|
|
160
294
|
const markdownUnderscoreExt = ()=>{
|
|
161
295
|
try {
|
|
162
296
|
if (!canUseNegativeLookbehind()) {
|
|
163
|
-
|
|
297
|
+
Log.i('Showdown-underscore extension: Negative lookbehind not supported. Skipping.');
|
|
164
298
|
return [];
|
|
165
299
|
}
|
|
166
300
|
return [
|
|
@@ -235,132 +369,6 @@ function messageFormatting(mes, sanitizerOverrides = {}) {
|
|
|
235
369
|
});
|
|
236
370
|
return mes;
|
|
237
371
|
}
|
|
238
|
-
const init = `
|
|
239
|
-
(async function () {
|
|
240
|
-
window.$mj_engine = window.parent.$mj_engine;
|
|
241
|
-
})();
|
|
242
|
-
`;
|
|
243
|
-
const thirdParty = `
|
|
244
|
-
<script src="https://cdn.jsdmirror.com/npm/@fortawesome/fontawesome-free/js/all.min.js"></script>
|
|
245
|
-
<script src="https://cdn.jsdmirror.com/npm/@tailwindcss/browser/dist/index.global.min.js"></script>
|
|
246
|
-
<script src="https://cdn.jsdmirror.com/npm/jquery/dist/jquery.min.js"></script>
|
|
247
|
-
<script src="https://cdn.jsdmirror.com/npm/jquery-ui/dist/jquery-ui.min.js"></script>
|
|
248
|
-
<link rel="stylesheet" href="https://cdn.jsdmirror.com/npm/jquery-ui/themes/base/theme.min.css" />
|
|
249
|
-
<script src="https://cdn.jsdmirror.com/npm/jquery-ui-touch-punch"></script>
|
|
250
|
-
`;
|
|
251
|
-
const unescapeHTML = (str)=>{
|
|
252
|
-
const named = {
|
|
253
|
-
amp: "&",
|
|
254
|
-
lt: "<",
|
|
255
|
-
gt: ">",
|
|
256
|
-
quot: '"',
|
|
257
|
-
apos: "'",
|
|
258
|
-
nbsp: "\u00A0"
|
|
259
|
-
};
|
|
260
|
-
return str.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (_m, body)=>{
|
|
261
|
-
if ("#" === body[0]) {
|
|
262
|
-
const isHex = body[1]?.toLowerCase() === "x";
|
|
263
|
-
const numStr = isHex ? body.slice(2) : body.slice(1);
|
|
264
|
-
const codePoint = parseInt(numStr, isHex ? 16 : 10);
|
|
265
|
-
if (Number.isFinite(codePoint)) try {
|
|
266
|
-
return String.fromCodePoint(codePoint);
|
|
267
|
-
} catch {}
|
|
268
|
-
return _m;
|
|
269
|
-
}
|
|
270
|
-
const lower = body.toLowerCase();
|
|
271
|
-
return Object.hasOwn(named, lower) ? named[lower] : _m;
|
|
272
|
-
});
|
|
273
|
-
};
|
|
274
|
-
const replaceVhInContent = (content)=>{
|
|
275
|
-
const has_css_min_vh = /min-height\s*:\s*[^;{}]*\d+(?:\.\d+)?vh/gi.test(content);
|
|
276
|
-
const has_inline_style_vh = /style\s*=\s*(["'])[\s\S]*?min-height\s*:\s*[^;]*?\d+(?:\.\d+)?vh[\s\S]*?\1/gi.test(content);
|
|
277
|
-
const has_js_vh = /(\.style\.minHeight\s*=\s*(["']))([\s\S]*?vh)(\2)/gi.test(content) || /(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?vh)(\3\s*\))/gi.test(content);
|
|
278
|
-
if (!has_css_min_vh && !has_inline_style_vh && !has_js_vh) return content;
|
|
279
|
-
const convertVhToVariable = (value)=>value.replace(/(\d+(?:\.\d+)?)vh\b/gi, (match, value)=>{
|
|
280
|
-
const parsed = parseFloat(value);
|
|
281
|
-
if (!isFinite(parsed)) return match;
|
|
282
|
-
const VARIABLE_EXPRESSION = "var(--MJ-iframe-height)";
|
|
283
|
-
if (100 === parsed) return VARIABLE_EXPRESSION;
|
|
284
|
-
return `calc(${VARIABLE_EXPRESSION} * ${parsed / 100})`;
|
|
285
|
-
});
|
|
286
|
-
content = content.replace(/(min-height\s*:\s*)([^;{}]*?\d+(?:\.\d+)?vh)(?=\s*[;}])/gi, (_m, prefix, value)=>`${prefix}${convertVhToVariable(value)}`);
|
|
287
|
-
content = content.replace(/(style\s*=\s*(["']))([^"'"]*?)(\2)/gi, (match, prefix, _quote, styleContent, suffix)=>{
|
|
288
|
-
if (!/min-height\s*:\s*[^;]*vh/i.test(styleContent)) return match;
|
|
289
|
-
const replaced = styleContent.replace(/(min-height\s*:\s*)([^;]*?\d+(?:\.\d+)?vh)/gi, (_m, p1, p2)=>`${p1}${convertVhToVariable(p2)}`);
|
|
290
|
-
return `${prefix}${replaced}${suffix}`;
|
|
291
|
-
});
|
|
292
|
-
content = content.replace(/(\.style\.minHeight\s*=\s*(["']))([\s\S]*?)(\2)/gi, (match, prefix, _q, val, suffix)=>{
|
|
293
|
-
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
294
|
-
const converted = convertVhToVariable(val);
|
|
295
|
-
return `${prefix}${converted}${suffix}`;
|
|
296
|
-
});
|
|
297
|
-
content = content.replace(/(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?)(\3\s*\))/gi, (match, prefix, _q1, _q2, val, suffix)=>{
|
|
298
|
-
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
299
|
-
const converted = convertVhToVariable(val);
|
|
300
|
-
return `${prefix}${converted}${suffix}`;
|
|
301
|
-
});
|
|
302
|
-
return content;
|
|
303
|
-
};
|
|
304
|
-
function escapeHtmlAttribute(value) {
|
|
305
|
-
return value.replace(/"/g, """).replace(/'/g, "'");
|
|
306
|
-
}
|
|
307
|
-
function createSrcContent(content) {
|
|
308
|
-
content = replaceVhInContent(content);
|
|
309
|
-
const getUserAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
310
|
-
const getCharAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
311
|
-
return `
|
|
312
|
-
<html>
|
|
313
|
-
<head>
|
|
314
|
-
<style>
|
|
315
|
-
|
|
316
|
-
html,body{margin:0;padding:0;overflow:hidden!important;max-width:100%!important;box-sizing:border-box}
|
|
317
|
-
.user_avatar,.user-avatar{background-image:url('${getUserAvatarPath()}')}
|
|
318
|
-
.char_avatar,.char-avatar{background-image:url('${getCharAvatarPath()}')}
|
|
319
|
-
|
|
320
|
-
</style>
|
|
321
|
-
${thirdParty}
|
|
322
|
-
<script>
|
|
323
|
-
${init}
|
|
324
|
-
</script>
|
|
325
|
-
</head>
|
|
326
|
-
<body>
|
|
327
|
-
${content}
|
|
328
|
-
</body>
|
|
329
|
-
</html>
|
|
330
|
-
`;
|
|
331
|
-
}
|
|
332
|
-
function adjustIframeHeight(iframe) {
|
|
333
|
-
if (!iframe.contentWindow) return;
|
|
334
|
-
const document1 = iframe.contentWindow.document;
|
|
335
|
-
const height = Math.max(document1.body.offsetHeight, document1.documentElement.offsetHeight);
|
|
336
|
-
if (!Number.isFinite(height) || height <= 0) return;
|
|
337
|
-
iframe.style.height = `${height}px`;
|
|
338
|
-
}
|
|
339
|
-
const observed_elements = new Map();
|
|
340
|
-
const observer = new ResizeObserver((entries)=>{
|
|
341
|
-
for (const entry of entries){
|
|
342
|
-
const element = entry.target;
|
|
343
|
-
const iframe = observed_elements.get(element);
|
|
344
|
-
if (iframe) adjustIframeHeight(iframe);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
function useHeightObserver() {
|
|
348
|
-
return {
|
|
349
|
-
observe: (iframe)=>{
|
|
350
|
-
if (!iframe?.contentWindow?.document?.body) return;
|
|
351
|
-
const body = iframe.contentWindow.document.body;
|
|
352
|
-
observed_elements.set(body, iframe);
|
|
353
|
-
observer.observe(body);
|
|
354
|
-
adjustIframeHeight(iframe);
|
|
355
|
-
},
|
|
356
|
-
unobserve: (iframe)=>{
|
|
357
|
-
if (!iframe.contentWindow?.document?.body) return;
|
|
358
|
-
const body = iframe.contentWindow.document.body;
|
|
359
|
-
observed_elements.delete(body);
|
|
360
|
-
observer.unobserve(body);
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
372
|
const MdRendererBase = ({ content })=>{
|
|
365
373
|
const containerRef = useRef(null);
|
|
366
374
|
const [iframeIdList, setIframeIdList] = useState([]);
|
|
@@ -415,7 +423,7 @@ const MdRendererBase = ({ content })=>{
|
|
|
415
423
|
const spinElement = iframe.parentElement?.querySelector("#MJ-spin-" + iframe.id);
|
|
416
424
|
if (spinElement) spinElement.remove();
|
|
417
425
|
iframe.removeEventListener("load", ()=>{
|
|
418
|
-
|
|
426
|
+
Log.i("iframe loaded", iframe.id);
|
|
419
427
|
});
|
|
420
428
|
});
|
|
421
429
|
};
|
|
@@ -591,10 +599,10 @@ class MujianSdk {
|
|
|
591
599
|
const parent = await handshake;
|
|
592
600
|
this.ready = true;
|
|
593
601
|
this.parent = parent;
|
|
594
|
-
|
|
602
|
+
Log.i('mujian sdk client init');
|
|
595
603
|
await this.call("mujian:init");
|
|
596
604
|
} catch (error) {
|
|
597
|
-
|
|
605
|
+
Log.e('init error', error);
|
|
598
606
|
}
|
|
599
607
|
}
|
|
600
608
|
emit(event, data) {
|
|
@@ -975,10 +983,10 @@ const useChatStreaming = ({ common, setError, setMessages, mujian })=>{
|
|
|
975
983
|
}
|
|
976
984
|
}
|
|
977
985
|
} catch (error) {
|
|
978
|
-
|
|
986
|
+
Log.e('Stream error', error);
|
|
979
987
|
'object' == typeof error && error && 'message' in error && 'string' == typeof error.message ? setError(new SendMessageError(error.message)) : setError(error);
|
|
980
988
|
} finally{
|
|
981
|
-
|
|
989
|
+
Log.i('stream end finally');
|
|
982
990
|
setMessages((prev)=>{
|
|
983
991
|
const newMessages = [
|
|
984
992
|
...prev
|
package/dist/umd/index.js
CHANGED
|
@@ -401,6 +401,14 @@
|
|
|
401
401
|
};
|
|
402
402
|
const saveGame = async function() {};
|
|
403
403
|
const loadGame = async function() {};
|
|
404
|
+
const Log = {
|
|
405
|
+
i (...msg) {
|
|
406
|
+
console.log('[MujianSDK] ', ...msg);
|
|
407
|
+
},
|
|
408
|
+
e (...msg) {
|
|
409
|
+
console.error('[MujianSDK] ', ...msg);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
404
412
|
class MujianSdk {
|
|
405
413
|
constructor(){}
|
|
406
414
|
static getInstance() {
|
|
@@ -435,10 +443,10 @@
|
|
|
435
443
|
const parent = await handshake;
|
|
436
444
|
this.ready = true;
|
|
437
445
|
this.parent = parent;
|
|
438
|
-
|
|
446
|
+
Log.i('mujian sdk client init');
|
|
439
447
|
await this.call(events_EVENT.MUJIAN_INIT);
|
|
440
448
|
} catch (error) {
|
|
441
|
-
|
|
449
|
+
Log.e('init error', error);
|
|
442
450
|
}
|
|
443
451
|
}
|
|
444
452
|
emit(event, data) {
|
package/dist/umd/react.js
CHANGED
|
@@ -3594,6 +3594,132 @@
|
|
|
3594
3594
|
};
|
|
3595
3595
|
const useUpdateEffect = createUpdateEffect(external_React_.useEffect);
|
|
3596
3596
|
var jsx_runtime = __webpack_require__("../../common/temp/node_modules/.pnpm/react@19.1.1/node_modules/react/jsx-runtime.js");
|
|
3597
|
+
function adjustIframeHeight(iframe) {
|
|
3598
|
+
if (!iframe.contentWindow) return;
|
|
3599
|
+
const document1 = iframe.contentWindow.document;
|
|
3600
|
+
const height = Math.max(document1.body.offsetHeight, document1.documentElement.offsetHeight);
|
|
3601
|
+
if (!Number.isFinite(height) || height <= 0) return;
|
|
3602
|
+
iframe.style.height = `${height}px`;
|
|
3603
|
+
}
|
|
3604
|
+
const observed_elements = new Map();
|
|
3605
|
+
const observer = new ResizeObserver((entries)=>{
|
|
3606
|
+
for (const entry of entries){
|
|
3607
|
+
const element = entry.target;
|
|
3608
|
+
const iframe = observed_elements.get(element);
|
|
3609
|
+
if (iframe) adjustIframeHeight(iframe);
|
|
3610
|
+
}
|
|
3611
|
+
});
|
|
3612
|
+
function useHeightObserver() {
|
|
3613
|
+
return {
|
|
3614
|
+
observe: (iframe)=>{
|
|
3615
|
+
if (!iframe?.contentWindow?.document?.body) return;
|
|
3616
|
+
const body = iframe.contentWindow.document.body;
|
|
3617
|
+
observed_elements.set(body, iframe);
|
|
3618
|
+
observer.observe(body);
|
|
3619
|
+
adjustIframeHeight(iframe);
|
|
3620
|
+
},
|
|
3621
|
+
unobserve: (iframe)=>{
|
|
3622
|
+
if (!iframe.contentWindow?.document?.body) return;
|
|
3623
|
+
const body = iframe.contentWindow.document.body;
|
|
3624
|
+
observed_elements.delete(body);
|
|
3625
|
+
observer.unobserve(body);
|
|
3626
|
+
}
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
const init = `
|
|
3630
|
+
(async function () {
|
|
3631
|
+
window.$mj_engine = window.parent.$mj_engine;
|
|
3632
|
+
})();
|
|
3633
|
+
`;
|
|
3634
|
+
const thirdParty = `
|
|
3635
|
+
<script src="https://cdn.jsdmirror.com/npm/@fortawesome/fontawesome-free/js/all.min.js"></script>
|
|
3636
|
+
<script src="https://cdn.jsdmirror.com/npm/@tailwindcss/browser/dist/index.global.min.js"></script>
|
|
3637
|
+
<script src="https://cdn.jsdmirror.com/npm/jquery/dist/jquery.min.js"></script>
|
|
3638
|
+
<script src="https://cdn.jsdmirror.com/npm/jquery-ui/dist/jquery-ui.min.js"></script>
|
|
3639
|
+
<link rel="stylesheet" href="https://cdn.jsdmirror.com/npm/jquery-ui/themes/base/theme.min.css" />
|
|
3640
|
+
<script src="https://cdn.jsdmirror.com/npm/jquery-ui-touch-punch"></script>
|
|
3641
|
+
`;
|
|
3642
|
+
const unescapeHTML = (str)=>{
|
|
3643
|
+
const named = {
|
|
3644
|
+
amp: "&",
|
|
3645
|
+
lt: "<",
|
|
3646
|
+
gt: ">",
|
|
3647
|
+
quot: '"',
|
|
3648
|
+
apos: "'",
|
|
3649
|
+
nbsp: "\u00A0"
|
|
3650
|
+
};
|
|
3651
|
+
return str.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (_m, body)=>{
|
|
3652
|
+
if ("#" === body[0]) {
|
|
3653
|
+
const isHex = body[1]?.toLowerCase() === "x";
|
|
3654
|
+
const numStr = isHex ? body.slice(2) : body.slice(1);
|
|
3655
|
+
const codePoint = parseInt(numStr, isHex ? 16 : 10);
|
|
3656
|
+
if (Number.isFinite(codePoint)) try {
|
|
3657
|
+
return String.fromCodePoint(codePoint);
|
|
3658
|
+
} catch {}
|
|
3659
|
+
return _m;
|
|
3660
|
+
}
|
|
3661
|
+
const lower = body.toLowerCase();
|
|
3662
|
+
return Object.hasOwn(named, lower) ? named[lower] : _m;
|
|
3663
|
+
});
|
|
3664
|
+
};
|
|
3665
|
+
const replaceVhInContent = (content)=>{
|
|
3666
|
+
const has_css_min_vh = /min-height\s*:\s*[^;{}]*\d+(?:\.\d+)?vh/gi.test(content);
|
|
3667
|
+
const has_inline_style_vh = /style\s*=\s*(["'])[\s\S]*?min-height\s*:\s*[^;]*?\d+(?:\.\d+)?vh[\s\S]*?\1/gi.test(content);
|
|
3668
|
+
const has_js_vh = /(\.style\.minHeight\s*=\s*(["']))([\s\S]*?vh)(\2)/gi.test(content) || /(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?vh)(\3\s*\))/gi.test(content);
|
|
3669
|
+
if (!has_css_min_vh && !has_inline_style_vh && !has_js_vh) return content;
|
|
3670
|
+
const convertVhToVariable = (value)=>value.replace(/(\d+(?:\.\d+)?)vh\b/gi, (match, value)=>{
|
|
3671
|
+
const parsed = parseFloat(value);
|
|
3672
|
+
if (!isFinite(parsed)) return match;
|
|
3673
|
+
const VARIABLE_EXPRESSION = "var(--MJ-iframe-height)";
|
|
3674
|
+
if (100 === parsed) return VARIABLE_EXPRESSION;
|
|
3675
|
+
return `calc(${VARIABLE_EXPRESSION} * ${parsed / 100})`;
|
|
3676
|
+
});
|
|
3677
|
+
content = content.replace(/(min-height\s*:\s*)([^;{}]*?\d+(?:\.\d+)?vh)(?=\s*[;}])/gi, (_m, prefix, value)=>`${prefix}${convertVhToVariable(value)}`);
|
|
3678
|
+
content = content.replace(/(style\s*=\s*(["']))([^"'"]*?)(\2)/gi, (match, prefix, _quote, styleContent, suffix)=>{
|
|
3679
|
+
if (!/min-height\s*:\s*[^;]*vh/i.test(styleContent)) return match;
|
|
3680
|
+
const replaced = styleContent.replace(/(min-height\s*:\s*)([^;]*?\d+(?:\.\d+)?vh)/gi, (_m, p1, p2)=>`${p1}${convertVhToVariable(p2)}`);
|
|
3681
|
+
return `${prefix}${replaced}${suffix}`;
|
|
3682
|
+
});
|
|
3683
|
+
content = content.replace(/(\.style\.minHeight\s*=\s*(["']))([\s\S]*?)(\2)/gi, (match, prefix, _q, val, suffix)=>{
|
|
3684
|
+
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
3685
|
+
const converted = convertVhToVariable(val);
|
|
3686
|
+
return `${prefix}${converted}${suffix}`;
|
|
3687
|
+
});
|
|
3688
|
+
content = content.replace(/(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?)(\3\s*\))/gi, (match, prefix, _q1, _q2, val, suffix)=>{
|
|
3689
|
+
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
3690
|
+
const converted = convertVhToVariable(val);
|
|
3691
|
+
return `${prefix}${converted}${suffix}`;
|
|
3692
|
+
});
|
|
3693
|
+
return content;
|
|
3694
|
+
};
|
|
3695
|
+
function escapeHtmlAttribute(value) {
|
|
3696
|
+
return value.replace(/"/g, """).replace(/'/g, "'");
|
|
3697
|
+
}
|
|
3698
|
+
function createSrcContent(content) {
|
|
3699
|
+
content = replaceVhInContent(content);
|
|
3700
|
+
const getUserAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
3701
|
+
const getCharAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
3702
|
+
return `
|
|
3703
|
+
<html>
|
|
3704
|
+
<head>
|
|
3705
|
+
<style>
|
|
3706
|
+
|
|
3707
|
+
html,body{margin:0;padding:0;overflow:hidden!important;max-width:100%!important;box-sizing:border-box}
|
|
3708
|
+
.user_avatar,.user-avatar{background-image:url('${getUserAvatarPath()}')}
|
|
3709
|
+
.char_avatar,.char-avatar{background-image:url('${getCharAvatarPath()}')}
|
|
3710
|
+
|
|
3711
|
+
</style>
|
|
3712
|
+
${thirdParty}
|
|
3713
|
+
<script>
|
|
3714
|
+
${init}
|
|
3715
|
+
</script>
|
|
3716
|
+
</head>
|
|
3717
|
+
<body>
|
|
3718
|
+
${content}
|
|
3719
|
+
</body>
|
|
3720
|
+
</html>
|
|
3721
|
+
`;
|
|
3722
|
+
}
|
|
3597
3723
|
class adobe_css_tools_t extends Error {
|
|
3598
3724
|
reason;
|
|
3599
3725
|
filename;
|
|
@@ -5583,6 +5709,14 @@
|
|
|
5583
5709
|
var purify = createDOMPurify();
|
|
5584
5710
|
var showdown = __webpack_require__("../../common/temp/node_modules/.pnpm/showdown@2.1.0/node_modules/showdown/dist/showdown.js");
|
|
5585
5711
|
var showdown_default = /*#__PURE__*/ __webpack_require__.n(showdown);
|
|
5712
|
+
const Log = {
|
|
5713
|
+
i (...msg) {
|
|
5714
|
+
console.log('[MujianSDK] ', ...msg);
|
|
5715
|
+
},
|
|
5716
|
+
e (...msg) {
|
|
5717
|
+
console.error('[MujianSDK] ', ...msg);
|
|
5718
|
+
}
|
|
5719
|
+
};
|
|
5586
5720
|
addDOMPurifyHooks();
|
|
5587
5721
|
function canUseNegativeLookbehind() {
|
|
5588
5722
|
try {
|
|
@@ -5736,7 +5870,7 @@
|
|
|
5736
5870
|
const markdownUnderscoreExt = ()=>{
|
|
5737
5871
|
try {
|
|
5738
5872
|
if (!canUseNegativeLookbehind()) {
|
|
5739
|
-
|
|
5873
|
+
Log.i('Showdown-underscore extension: Negative lookbehind not supported. Skipping.');
|
|
5740
5874
|
return [];
|
|
5741
5875
|
}
|
|
5742
5876
|
return [
|
|
@@ -5811,132 +5945,6 @@
|
|
|
5811
5945
|
});
|
|
5812
5946
|
return mes;
|
|
5813
5947
|
}
|
|
5814
|
-
const init = `
|
|
5815
|
-
(async function () {
|
|
5816
|
-
window.$mj_engine = window.parent.$mj_engine;
|
|
5817
|
-
})();
|
|
5818
|
-
`;
|
|
5819
|
-
const thirdParty = `
|
|
5820
|
-
<script src="https://cdn.jsdmirror.com/npm/@fortawesome/fontawesome-free/js/all.min.js"></script>
|
|
5821
|
-
<script src="https://cdn.jsdmirror.com/npm/@tailwindcss/browser/dist/index.global.min.js"></script>
|
|
5822
|
-
<script src="https://cdn.jsdmirror.com/npm/jquery/dist/jquery.min.js"></script>
|
|
5823
|
-
<script src="https://cdn.jsdmirror.com/npm/jquery-ui/dist/jquery-ui.min.js"></script>
|
|
5824
|
-
<link rel="stylesheet" href="https://cdn.jsdmirror.com/npm/jquery-ui/themes/base/theme.min.css" />
|
|
5825
|
-
<script src="https://cdn.jsdmirror.com/npm/jquery-ui-touch-punch"></script>
|
|
5826
|
-
`;
|
|
5827
|
-
const unescapeHTML = (str)=>{
|
|
5828
|
-
const named = {
|
|
5829
|
-
amp: "&",
|
|
5830
|
-
lt: "<",
|
|
5831
|
-
gt: ">",
|
|
5832
|
-
quot: '"',
|
|
5833
|
-
apos: "'",
|
|
5834
|
-
nbsp: "\u00A0"
|
|
5835
|
-
};
|
|
5836
|
-
return str.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (_m, body)=>{
|
|
5837
|
-
if ("#" === body[0]) {
|
|
5838
|
-
const isHex = body[1]?.toLowerCase() === "x";
|
|
5839
|
-
const numStr = isHex ? body.slice(2) : body.slice(1);
|
|
5840
|
-
const codePoint = parseInt(numStr, isHex ? 16 : 10);
|
|
5841
|
-
if (Number.isFinite(codePoint)) try {
|
|
5842
|
-
return String.fromCodePoint(codePoint);
|
|
5843
|
-
} catch {}
|
|
5844
|
-
return _m;
|
|
5845
|
-
}
|
|
5846
|
-
const lower = body.toLowerCase();
|
|
5847
|
-
return Object.hasOwn(named, lower) ? named[lower] : _m;
|
|
5848
|
-
});
|
|
5849
|
-
};
|
|
5850
|
-
const replaceVhInContent = (content)=>{
|
|
5851
|
-
const has_css_min_vh = /min-height\s*:\s*[^;{}]*\d+(?:\.\d+)?vh/gi.test(content);
|
|
5852
|
-
const has_inline_style_vh = /style\s*=\s*(["'])[\s\S]*?min-height\s*:\s*[^;]*?\d+(?:\.\d+)?vh[\s\S]*?\1/gi.test(content);
|
|
5853
|
-
const has_js_vh = /(\.style\.minHeight\s*=\s*(["']))([\s\S]*?vh)(\2)/gi.test(content) || /(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?vh)(\3\s*\))/gi.test(content);
|
|
5854
|
-
if (!has_css_min_vh && !has_inline_style_vh && !has_js_vh) return content;
|
|
5855
|
-
const convertVhToVariable = (value)=>value.replace(/(\d+(?:\.\d+)?)vh\b/gi, (match, value)=>{
|
|
5856
|
-
const parsed = parseFloat(value);
|
|
5857
|
-
if (!isFinite(parsed)) return match;
|
|
5858
|
-
const VARIABLE_EXPRESSION = "var(--MJ-iframe-height)";
|
|
5859
|
-
if (100 === parsed) return VARIABLE_EXPRESSION;
|
|
5860
|
-
return `calc(${VARIABLE_EXPRESSION} * ${parsed / 100})`;
|
|
5861
|
-
});
|
|
5862
|
-
content = content.replace(/(min-height\s*:\s*)([^;{}]*?\d+(?:\.\d+)?vh)(?=\s*[;}])/gi, (_m, prefix, value)=>`${prefix}${convertVhToVariable(value)}`);
|
|
5863
|
-
content = content.replace(/(style\s*=\s*(["']))([^"'"]*?)(\2)/gi, (match, prefix, _quote, styleContent, suffix)=>{
|
|
5864
|
-
if (!/min-height\s*:\s*[^;]*vh/i.test(styleContent)) return match;
|
|
5865
|
-
const replaced = styleContent.replace(/(min-height\s*:\s*)([^;]*?\d+(?:\.\d+)?vh)/gi, (_m, p1, p2)=>`${p1}${convertVhToVariable(p2)}`);
|
|
5866
|
-
return `${prefix}${replaced}${suffix}`;
|
|
5867
|
-
});
|
|
5868
|
-
content = content.replace(/(\.style\.minHeight\s*=\s*(["']))([\s\S]*?)(\2)/gi, (match, prefix, _q, val, suffix)=>{
|
|
5869
|
-
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
5870
|
-
const converted = convertVhToVariable(val);
|
|
5871
|
-
return `${prefix}${converted}${suffix}`;
|
|
5872
|
-
});
|
|
5873
|
-
content = content.replace(/(setProperty\s*\(\s*(["'])min-height\2\s*,\s*(["']))([\s\S]*?)(\3\s*\))/gi, (match, prefix, _q1, _q2, val, suffix)=>{
|
|
5874
|
-
if (!/\b\d+(?:\.\d+)?vh\b/i.test(val)) return match;
|
|
5875
|
-
const converted = convertVhToVariable(val);
|
|
5876
|
-
return `${prefix}${converted}${suffix}`;
|
|
5877
|
-
});
|
|
5878
|
-
return content;
|
|
5879
|
-
};
|
|
5880
|
-
function escapeHtmlAttribute(value) {
|
|
5881
|
-
return value.replace(/"/g, """).replace(/'/g, "'");
|
|
5882
|
-
}
|
|
5883
|
-
function createSrcContent(content) {
|
|
5884
|
-
content = replaceVhInContent(content);
|
|
5885
|
-
const getUserAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
5886
|
-
const getCharAvatarPath = ()=>"https://www.mujian.com/avatar.png";
|
|
5887
|
-
return `
|
|
5888
|
-
<html>
|
|
5889
|
-
<head>
|
|
5890
|
-
<style>
|
|
5891
|
-
|
|
5892
|
-
html,body{margin:0;padding:0;overflow:hidden!important;max-width:100%!important;box-sizing:border-box}
|
|
5893
|
-
.user_avatar,.user-avatar{background-image:url('${getUserAvatarPath()}')}
|
|
5894
|
-
.char_avatar,.char-avatar{background-image:url('${getCharAvatarPath()}')}
|
|
5895
|
-
|
|
5896
|
-
</style>
|
|
5897
|
-
${thirdParty}
|
|
5898
|
-
<script>
|
|
5899
|
-
${init}
|
|
5900
|
-
</script>
|
|
5901
|
-
</head>
|
|
5902
|
-
<body>
|
|
5903
|
-
${content}
|
|
5904
|
-
</body>
|
|
5905
|
-
</html>
|
|
5906
|
-
`;
|
|
5907
|
-
}
|
|
5908
|
-
function adjustIframeHeight(iframe) {
|
|
5909
|
-
if (!iframe.contentWindow) return;
|
|
5910
|
-
const document1 = iframe.contentWindow.document;
|
|
5911
|
-
const height = Math.max(document1.body.offsetHeight, document1.documentElement.offsetHeight);
|
|
5912
|
-
if (!Number.isFinite(height) || height <= 0) return;
|
|
5913
|
-
iframe.style.height = `${height}px`;
|
|
5914
|
-
}
|
|
5915
|
-
const observed_elements = new Map();
|
|
5916
|
-
const observer = new ResizeObserver((entries)=>{
|
|
5917
|
-
for (const entry of entries){
|
|
5918
|
-
const element = entry.target;
|
|
5919
|
-
const iframe = observed_elements.get(element);
|
|
5920
|
-
if (iframe) adjustIframeHeight(iframe);
|
|
5921
|
-
}
|
|
5922
|
-
});
|
|
5923
|
-
function useHeightObserver() {
|
|
5924
|
-
return {
|
|
5925
|
-
observe: (iframe)=>{
|
|
5926
|
-
if (!iframe?.contentWindow?.document?.body) return;
|
|
5927
|
-
const body = iframe.contentWindow.document.body;
|
|
5928
|
-
observed_elements.set(body, iframe);
|
|
5929
|
-
observer.observe(body);
|
|
5930
|
-
adjustIframeHeight(iframe);
|
|
5931
|
-
},
|
|
5932
|
-
unobserve: (iframe)=>{
|
|
5933
|
-
if (!iframe.contentWindow?.document?.body) return;
|
|
5934
|
-
const body = iframe.contentWindow.document.body;
|
|
5935
|
-
observed_elements.delete(body);
|
|
5936
|
-
observer.unobserve(body);
|
|
5937
|
-
}
|
|
5938
|
-
};
|
|
5939
|
-
}
|
|
5940
5948
|
const randomUUID = 'undefined' != typeof crypto && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
5941
5949
|
const dist_native = {
|
|
5942
5950
|
randomUUID
|
|
@@ -5969,11 +5977,11 @@ ${content}
|
|
|
5969
5977
|
}
|
|
5970
5978
|
return unsafeStringify(rnds);
|
|
5971
5979
|
}
|
|
5972
|
-
function
|
|
5980
|
+
function v4_v4(options, buf, offset) {
|
|
5973
5981
|
if (dist_native.randomUUID && !buf && !options) return dist_native.randomUUID();
|
|
5974
5982
|
return _v4(options, buf, offset);
|
|
5975
5983
|
}
|
|
5976
|
-
const
|
|
5984
|
+
const v4 = v4_v4;
|
|
5977
5985
|
const MdRendererBase = ({ content })=>{
|
|
5978
5986
|
const containerRef = (0, external_React_.useRef)(null);
|
|
5979
5987
|
const [iframeIdList, setIframeIdList] = (0, external_React_.useState)([]);
|
|
@@ -5984,7 +5992,7 @@ ${content}
|
|
|
5984
5992
|
if (!match.includes("<body>") && !match.includes("</body>")) return match;
|
|
5985
5993
|
const code = match.replace(/<pre><code(.*?)>/g, "").replace(/<\/code><\/pre>/g, "");
|
|
5986
5994
|
const srcdoc = createSrcContent(unescapeHTML(code));
|
|
5987
|
-
const id =
|
|
5995
|
+
const id = v4();
|
|
5988
5996
|
setIframeIdList((prev)=>[
|
|
5989
5997
|
...prev,
|
|
5990
5998
|
id
|
|
@@ -6028,7 +6036,7 @@ ${content}
|
|
|
6028
6036
|
const spinElement = iframe.parentElement?.querySelector("#MJ-spin-" + iframe.id);
|
|
6029
6037
|
if (spinElement) spinElement.remove();
|
|
6030
6038
|
iframe.removeEventListener("load", ()=>{
|
|
6031
|
-
|
|
6039
|
+
Log.i("iframe loaded", iframe.id);
|
|
6032
6040
|
});
|
|
6033
6041
|
});
|
|
6034
6042
|
};
|
|
@@ -6427,10 +6435,10 @@ ${content}
|
|
|
6427
6435
|
const parent = await handshake;
|
|
6428
6436
|
this.ready = true;
|
|
6429
6437
|
this.parent = parent;
|
|
6430
|
-
|
|
6438
|
+
Log.i('mujian sdk client init');
|
|
6431
6439
|
await this.call("mujian:init");
|
|
6432
6440
|
} catch (error) {
|
|
6433
|
-
|
|
6441
|
+
Log.e('init error', error);
|
|
6434
6442
|
}
|
|
6435
6443
|
}
|
|
6436
6444
|
emit(event, data) {
|
|
@@ -7143,7 +7151,7 @@ ${content}
|
|
|
7143
7151
|
window.addEventListener('focus', subscribeFocus_revalidate, false);
|
|
7144
7152
|
}
|
|
7145
7153
|
const subscribeFocus = subscribeFocus_subscribe;
|
|
7146
|
-
var
|
|
7154
|
+
var useRefreshOnWindowFocusPlugin_useRefreshOnWindowFocusPlugin = function(fetchInstance, _a) {
|
|
7147
7155
|
var refreshOnWindowFocus = _a.refreshOnWindowFocus, _b = _a.focusTimespan, focusTimespan = void 0 === _b ? 5000 : _b;
|
|
7148
7156
|
var unsubscribeRef = (0, external_React_.useRef)(void 0);
|
|
7149
7157
|
var stopSubscribe = function() {
|
|
@@ -7169,7 +7177,7 @@ ${content}
|
|
|
7169
7177
|
});
|
|
7170
7178
|
return {};
|
|
7171
7179
|
};
|
|
7172
|
-
const
|
|
7180
|
+
const useRefreshOnWindowFocusPlugin = useRefreshOnWindowFocusPlugin_useRefreshOnWindowFocusPlugin;
|
|
7173
7181
|
var useRetryPlugin_useRetryPlugin = function(fetchInstance, _a) {
|
|
7174
7182
|
var retryInterval = _a.retryInterval, retryCount = _a.retryCount;
|
|
7175
7183
|
var timerRef = (0, external_React_.useRef)(void 0);
|
|
@@ -7481,7 +7489,7 @@ ${content}
|
|
|
7481
7489
|
plugins_useDebouncePlugin,
|
|
7482
7490
|
useLoadingDelayPlugin,
|
|
7483
7491
|
usePollingPlugin,
|
|
7484
|
-
|
|
7492
|
+
useRefreshOnWindowFocusPlugin,
|
|
7485
7493
|
useThrottlePlugin,
|
|
7486
7494
|
plugins_useAutoRunPlugin,
|
|
7487
7495
|
plugins_useCachePlugin,
|
|
@@ -8205,10 +8213,10 @@ ${content}
|
|
|
8205
8213
|
}
|
|
8206
8214
|
}
|
|
8207
8215
|
} catch (error) {
|
|
8208
|
-
|
|
8216
|
+
Log.e('Stream error', error);
|
|
8209
8217
|
'object' == typeof error && error && 'message' in error && 'string' == typeof error.message ? setError(new SendMessageError(error.message)) : setError(error);
|
|
8210
8218
|
} finally{
|
|
8211
|
-
|
|
8219
|
+
Log.i('stream end finally');
|
|
8212
8220
|
setMessages((prev)=>{
|
|
8213
8221
|
const newMessages = [
|
|
8214
8222
|
...prev
|