funda-ui 4.7.604 → 4.7.608

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.
@@ -46,7 +46,6 @@ return /******/ (() => { // webpackBootstrap
46
46
  var __webpack_exports__ = {};
47
47
  __webpack_require__.r(__webpack_exports__);
48
48
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
49
- /* harmony export */ "fixAndParseJSON": () => (/* binding */ fixAndParseJSON),
50
49
  /* harmony export */ "isEmail": () => (/* binding */ isEmail),
51
50
  /* harmony export */ "isEmpty": () => (/* binding */ isEmpty),
52
51
  /* harmony export */ "isInt": () => (/* binding */ isInt),
@@ -59,63 +58,82 @@ __webpack_require__.r(__webpack_exports__);
59
58
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
60
59
  /**
61
60
  * Fix And Parse JSON (Support for handling complex escape JSON strings)
61
+ * @desc recursively fix top-level key/value (recursively handles when encountering top-level values that are objects/arrays)
62
62
  * @private
63
63
  */
64
64
  /*
65
- - Always try JSON.parse first;
66
- - If parsing fails, unescape \" → ";
67
- - Then process the outermost object or array key-by-key, value-by-value;
68
- - If a top-level value is an unquoted object or array (e.g. messages: [ {...} ]),
69
- recursively treat that value as a new root to repair;
70
- - For values wrapped in quotes ('...' or "..."), extract the inner text and
71
- re-encode it using JSON.stringify (ensures internal single/double quotes
72
- are not corrupted);
65
+ - Still prioritize JSON.parse first;
66
+ - After parse fails, do unescaping (\\" → ");
67
+ - Then process the outermost layer (object or array) key by key, value by value;
68
+ - If a top-level value is an unquoted object or array (e.g., messages: [ {...} ]), recursively treat that value as a new outermost layer for fixing;
69
+ - For strings wrapped in quotes ('...' or "..."), only extract the outer layer and re-encode with JSON.stringify (ensuring internal single/double quotes won't be mistakenly changed);
73
70
  - Set MAX_DEPTH to prevent infinite recursion.
74
71
  */
75
- // fixAndParseJSON - recursively repairs top-level key/value
76
- // (when encountering outermost values that are objects/arrays, it recurses)
77
-
78
72
  /*
79
- DEMO:
73
+ @Examples:
80
74
 
81
- // ✅ Valid JSON (contains svg and single-quote content)
75
+ // ✅ Valid JSON (contains svg and single quote content)
82
76
  const okJson = `{
83
- "label":"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> New Session",
77
+ "label":"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> 新建会话",
84
78
  "value":"new",
85
79
  "onClick":"method.setVal(''); method.clearData();"
86
80
  }`;
87
81
 
88
- // Single-quote JSON
82
+ const okJson2 = `{
83
+ label:"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> 新建会话",
84
+ value:"new",
85
+ onClick:"method.setVal(''); method.clearData();"
86
+ }`;
87
+
88
+ // ⚠️ Single quote JSON
89
89
  const badJson = "{'model':'{model}','messages':[{'role':'user','content':'{message}'}],'stream': true}";
90
90
 
91
- // Escaped JSON
92
- const badJson2 = "{\\\"label\\\":\\\"<svg width='16' height='16' viewBox='0 0 24 24'><path fill='currentColor' d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'/></svg> New Session\\\",\\\"value\\\":\\\"new\\\",\\\"onClick\\\":\\\"method.setVal(''); method.clearData();\\\"}";
91
+ // ⚠️ Escaped JSON
92
+ const badJson2 = "{\\\"label\\\":\\\"<svg width='16' height='16' viewBox='0 0 24 24'><path fill='currentColor' d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'/></svg> 新建会话\\\",\\\"value\\\":\\\"new\\\",\\\"onClick\\\":\\\"method.setVal(''); method.clearData();\\\"}";
93
+
94
+ const badJson3 = "{\"label\":\"<svg width='16' height='16' viewBox='0 0 24 24'><path fill='currentColor' d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'/></svg> 新建会话\",\"value\":\"new\",\"onClick\":\"method.setVal(''); method.clearData();\"}";
95
+
96
+ const badJson4 = "[{\"label\":\"<svg fill='currentColor' width='12' height='12' viewBox='0 0 24 24'><path d='M20.5 9a3.49 3.49 0 0 0-3.45 3h-1.1a2.49 2.49 0 0 0-4.396-1.052L8.878 9.731l3.143-4.225a2.458 2.458 0 0 0 2.98-.019L17.339 8H16v1h3V6h-1v1.243l-2.336-2.512A2.473 2.473 0 0 0 16 3.5a2.5 2.5 0 0 0-5 0 2.474 2.474 0 0 0 .343 1.243L7.947 9.308 4.955 7.947a2.404 2.404 0 0 0-.161-1.438l3.704-1.385-.44 1.371.942.333L10 4 7.172 3l-.334.943 1.01.357-3.659 1.368a2.498 2.498 0 1 0-.682 4.117l2.085 2.688-2.053 2.76a2.5 2.5 0 1 0 .87 3.864l3.484 1.587-1.055.373.334.943L10 21l-1-2.828-.943.333.435 1.354-3.608-1.645A2.471 2.471 0 0 0 5 17.5a2.5 2.5 0 0 0-.058-.527l3.053-1.405 3.476 4.48a2.498 2.498 0 1 0 4.113.075L18 17.707V19h1v-3h-3v1h1.293l-2.416 2.416a2.466 2.466 0 0 0-2.667-.047l-3.283-4.23 2.554-1.176A2.494 2.494 0 0 0 15.95 13h1.1a3.493 3.493 0 1 0 3.45-4zm-7-7A1.5 1.5 0 1 1 12 3.5 1.502 1.502 0 0 1 13.5 2zm0 18a1.5 1.5 0 1 1-1.5 1.5 1.502 1.502 0 0 1 1.5-1.5zM1 7.5a1.5 1.5 0 1 1 2.457 1.145l-.144.112A1.496 1.496 0 0 1 1 7.5zm3.32 1.703a2.507 2.507 0 0 0 .264-.326l2.752 1.251-1.124 1.512zM2.5 19A1.5 1.5 0 1 1 4 17.5 1.502 1.502 0 0 1 2.5 19zm2.037-2.941a2.518 2.518 0 0 0-.193-.234l1.885-2.532 1.136 1.464zm3.76-1.731L6.849 12.46l1.42-1.908L11.1 11.84a2.29 2.29 0 0 0-.033 1.213zM13.5 14a1.5 1.5 0 1 1 1.5-1.5 1.502 1.502 0 0 1-1.5 1.5zm7 1a2.5 2.5 0 1 1 2.5-2.5 2.502 2.502 0 0 1-2.5 2.5zm1.5-2.5a1.5 1.5 0 1 1-1.5-1.5 1.502 1.502 0 0 1 1.5 1.5z'/><path fill='none' d='M0 0h24v24H0z'/></svg> 深度思考\",\"value\":\"brief\",\"onClick\":\"if(isActive){method.executeCustomMethod('changeModel', true)}else{method.executeCustomMethod('changeModel', false)}\"},{\"label\":\"<svg fill='currentColor' width='12' height='12' viewBox='0 0 24 24'><path d='M19 2H5c-1.103 0-2 .897-2 2v12c0 1.103.897 2 2 2h3.586L12 21.414 15.414 18H19c1.103 0 2-.897 2-2V4c0-1.103-.897-2-2-2zm0 14h-4.414L12 18.586 9.414 16H5V4h14v12z'/></svg> 精简回答\",\"value\":\"brief\",\"onClick\":\"if(isActive){method.setContextData({systemPrompt:'请精简回答,字数控制在150个字左右, 思考过程请简洁简短',mergedText:method.getContextData().mergedText,analyzeMetrics:method.getContextData().analyzeMetrics});}else{method.setContextData({mergedText:method.getContextData().mergedText,analyzeMetrics:method.getContextData().analyzeMetrics});}\"},{\"label\":\"<svg fill='none' width='12' height='12' viewBox='0 0 16 16'><path d='M7 0.0618896V9H15.9381C15.446 12.9463 12.0796 16 8 16C3.58172 16 0 12.4183 0 8C0 3.92038 3.05369 0.553988 7 0.0618896Z' fill='currentColor'/><path d='M9 0.0618897V7H15.9381C15.4869 3.38128 12.6187 0.513137 9 0.0618897Z' fill='currentColor'/></svg> 指标分析\",\"value\":\"lab\",\"onClick\":\"return method.executeCustomMethod('getLibList')\",\"isSelect\":true,\"dynamicOptions\":true}]";
97
+
98
+
99
+ // ❌ Invalid JSON with missing } or ]
100
+ const errorJson001 = "{'model':'qwen-plus','base_url':'https://dashscope.aliyuncs.com/compatible-mode/v1/','api_key':'sk-0989fb9baab8450682af4d000f5b7cba','message':'{message}','stream':'true','chatId': '{chatId}', 'token': '{token}'";
101
+
102
+ const errorJson002 = "[{'model':'qwen-plus','base_url':'https://dashscope.aliyuncs.com/compatible-mode/v1/','api_key':'sk-0989fb9baab8450682af4d000f5b7cba','message':'{message}','stream':'true','chatId': '{chatId}', 'token': '{token}'}";
93
103
 
94
- const badJson3 = "{\"label\":\"<svg width='16' height='16' viewBox='0 0 24 24'><path fill='currentColor' d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'/></svg> New Session\",\"value\":\"new\",\"onClick\":\"method.setVal(''); method.clearData();\"}";
104
+ // Invalid JSON with missing quotes
105
+ const errorJson003 = "{'model':'qwen-plus','base_url':'https://dashscope.aliyuncs.com/compatible-mode/v1/','api_key':'sk-0989fb9baab8450682af4d000f5b7cba','message':'{message}','stream':'true','chatId': {chatId}', 'token': '{token}'}";
95
106
 
96
- const badJson4 = "[{\"label\":\"<svg fill='currentColor' width='12' height='12' viewBox='0 0 24 24'><path d='M20.5 9a3.49 3.49 0 0 0-3.45 3h-1.1a2.49 2.49 0 0 0-4.396-1.052L8.878 9.731l3.143-4.225a2.458 2.458 0 0 0 2.98-.019L17.339 8H16v1h3V6h-1v1.243l-2.336-2.512A2.473 2.473 0 0 0 16 3.5a2.5 2.5 0 0 0-5 0 2.474 2.474 0 0 0 .343 1.243L7.947 9.308 4.955 7.947a2.404 2.404 0 0 0-.161-1.438l3.704-1.385-.44 1.371.942.333L10 4 7.172 3l-.334.943 1.01.357-3.659 1.368a2.498 2.498 0 1 0-.682 4.117l2.085 2.688-2.053 2.76a2.5 2.5 0 1 0 .87 3.864l3.484 1.587-1.055.373.334.943L10 21l-1-2.828-.943.333.435 1.354-3.608-1.645A2.471 2.471 0 0 0 5 17.5a2.5 2.5 0 0 0-.058-.527l3.053-1.405 3.476 4.48a2.498 2.498 0 1 0 4.113.075L18 17.707V19h1v-3h-3v1h1.293l-2.416 2.416a2.466 2.466 0 0 0-2.667-.047l-3.283-4.23 2.554-1.176A2.494 2.494 0 0 0 15.95 13h1.1a3.493 3.493 0 1 0 3.45-4zm-7-7A1.5 1.5 0 1 1 12 3.5 1.502 1.502 0 0 1 13.5 2zm0 18a1.5 1.5 0 1 1-1.5 1.5 1.502 1.502 0 0 1 1.5-1.5zM1 7.5a1.5 1.5 0 1 1 2.457 1.145l-.144.112A1.496 1.496 0 0 1 1 7.5zm3.32 1.703a2.507 2.507 0 0 0 .264-.326l2.752 1.251-1.124 1.512zM2.5 19A1.5 1.5 0 1 1 4 17.5 1.502 1.502 0 0 1 2.5 19zm2.037-2.941a2.518 2.518 0 0 0-.193-.234l1.885-2.532 1.136 1.464zm3.76-1.731L6.849 12.46l1.42-1.908L11.1 11.84a2.29 2.29 0 0 0-.033 1.213zM13.5 14a1.5 1.5 0 1 1 1.5-1.5 1.502 1.502 0 0 1-1.5 1.5zm7 1a2.5 2.5 0 1 1 2.5-2.5 2.502 2.502 0 0 1-2.5 2.5zm1.5-2.5a1.5 1.5 0 1 1-1.5-1.5 1.502 1.502 0 0 1 1.5 1.5z'/><path fill='none' d='M0 0h24v24H0z'/></svg> Deep Thought","value":"brief","onClick":"if(isActive){method.executeCustomMethod('changeModel', true)}else{method.executeCustomMethod('changeModel', false)}"},{"label":"<svg fill='currentColor' width='12' height='12' viewBox='0 0 24 24'><path d='M19 2H5c-1.103 0-2 .897-2 2v12c0 1.103.897 2 2 2h3.586L12 21.414 15.414 18H19c1.103 0 2-.897 2-2V4c0-1.103-.897-2-2-2zm0 14h-4.414L12 18.586 9.414 16H5V4h14v12z'/></svg> Concise Answer","value":"brief","onClick":"if(isActive){method.setContextData({systemPrompt:'Please answer concisely, around 150 words, keep reasoning brief',mergedText:method.getContextData().mergedText,analyzeMetrics:method.getContextData().analyzeMetrics});}else{method.setContextData({mergedText:method.getContextData().mergedText,analyzeMetrics:method.getContextData().analyzeMetrics});}"},{"label":"<svg fill='none' width='12' height='12' viewBox='0 0 16 16'><path d='M7 0.0618896V9H15.9381C15.446 12.9463 12.0796 16 8 16C3.58172 16 0 12.4183 0 8C0 3.92038 3.05369 0.553988 7 0.0618896Z' fill='currentColor'/><path d='M9 0.0618897V7H15.9381C15.4869 3.38128 12.6187 0.513137 9 0.0618897Z' fill='currentColor'/></svg> Metrics Analysis","value":"lab","onClick":"return method.executeCustomMethod('getLibList')","isSelect":true,"dynamicOptions":true}]";
97
107
 
98
108
 
99
- console.log('okJson =>', fixAndParseJSON(okJson)); // parses correctly
100
- console.log('badJson =>', fixAndParseJSON(badJson)); // repaired and parsed
101
- console.log('badJson2 =>', fixAndParseJSON(badJson2)); // repaired and parsed
102
- console.log('badJson3 =>', fixAndParseJSON(badJson3)); // repaired and parsed
103
- console.log('badJson4 =>', fixAndParseJSON(badJson4)); // repaired and parsed
109
+ console.log('okJson =>', fixAndParseJSON(okJson)); // Can parse normally success = true
110
+ console.log('okJson =>', fixAndParseJSON(okJson2)); // Can parse normally success = true
111
+ console.log('badJson =>', fixAndParseJSON(badJson)); // Can parse after fixing success = true
112
+ console.log('badJson =>', fixAndParseJSON(badJson2)); // Can parse after fixing success = true
113
+ console.log('badJson =>', fixAndParseJSON(badJson3)); // Can parse after fixing success = true
114
+ console.log('badJson =>', fixAndParseJSON(badJson4)); // Can parse after fixing success = true
115
+ console.log('errorJson =>', fixAndParseJSON(errorJson001)); // {success: false, error: 'Invalid JSON format', details: 'Invalid object: mismatched braces'}
116
+ console.log('errorJson =>', fixAndParseJSON(errorJson002)); // {success: false, error: 'Invalid JSON format', details: "Expected property name or '}' in JSON at position 2 (line 1 column 3)"}
117
+ console.log('errorJson =>', fixAndParseJSON(errorJson003)); // {success: false, error: 'Invalid JSON format', details: 'Invalid object: mismatched braces'}
118
+
104
119
  */
120
+
121
+ // Type definitions
122
+
105
123
  function fixAndParseJSON(input) {
106
124
  var MAX_DEPTH = 6;
107
125
 
108
- // 1. Fast attempt
126
+ // 1. Quick attempt
109
127
  try {
110
128
  return {
111
129
  success: true,
112
130
  data: JSON.parse(input)
113
131
  };
114
132
  } catch (e) {
115
- // continue to repair
133
+ // Continue with fixing
116
134
  }
117
135
 
118
- // 2. Simple unescape of \" (common when copied from JS literals)
136
+ // 2. Simple unescaping of escaped \" (common case from pasted JS literals)
119
137
  var s = input;
120
138
  if (s.includes('\\"')) s = s.replace(/\\"/g, '"');
121
139
  s = s.trim();
@@ -132,24 +150,54 @@ function fixAndParseJSON(input) {
132
150
  data: JSON.parse(s)
133
151
  };
134
152
  } catch (err) {
153
+ var error = err instanceof Error ? err : new Error('Unknown error');
135
154
  return {
136
155
  success: false,
137
156
  error: 'Invalid JSON format',
138
- details: err instanceof Error ? err.message : String(err)
157
+ details: error.message
139
158
  };
140
159
  }
141
160
  }
142
161
 
143
- /* ---------- Helper (recursive) functions ---------- */
162
+ /* ---------- Helper (Recursive) Functions ---------- */
144
163
 
145
164
  function processTopObject(str, depth, MAX_DEPTH) {
146
165
  if (depth > MAX_DEPTH) return str;
147
166
  str = str.trim();
148
- // Ensure it is wrapped in { ... }
167
+
168
+ // First check if braces match
169
+ var braceCount = 0;
170
+ var inString = false;
171
+ var escapeNext = false;
172
+ for (var i = 0; i < str.length; i++) {
173
+ var ch = str[i];
174
+ if (escapeNext) {
175
+ escapeNext = false;
176
+ continue;
177
+ }
178
+ if (ch === '\\') {
179
+ escapeNext = true;
180
+ continue;
181
+ }
182
+ if ((ch === '"' || ch === "'") && !escapeNext) {
183
+ inString = !inString;
184
+ continue;
185
+ }
186
+ if (!inString) {
187
+ if (ch === '{') braceCount++;else if (ch === '}') braceCount--;
188
+ }
189
+ }
190
+ if (braceCount !== 0) {
191
+ throw new Error('Invalid object: mismatched braces');
192
+ }
193
+
194
+ // Ensure both ends are { ... }
149
195
  if (!(str.startsWith('{') && str.endsWith('}'))) {
150
- var f = str.indexOf('{');
151
- var l = str.lastIndexOf('}');
152
- if (f === -1 || l === -1 || l <= f) return str;
196
+ var f = str.indexOf('{'),
197
+ l = str.lastIndexOf('}');
198
+ if (f === -1 || l === -1 || l <= f) {
199
+ throw new Error('Invalid object format: missing or mismatched braces');
200
+ }
153
201
  str = str.slice(f, l + 1);
154
202
  }
155
203
  var inner = str.slice(1, -1);
@@ -174,8 +222,8 @@ function processTopArray(str, depth, MAX_DEPTH) {
174
222
  if (depth > MAX_DEPTH) return str;
175
223
  str = str.trim();
176
224
  if (!(str.startsWith('[') && str.endsWith(']'))) {
177
- var f = str.indexOf('[');
178
- var l = str.lastIndexOf(']');
225
+ var f = str.indexOf('['),
226
+ l = str.lastIndexOf(']');
179
227
  if (f === -1 || l === -1 || l <= f) return str;
180
228
  str = str.slice(f, l + 1);
181
229
  }
@@ -191,21 +239,21 @@ function processTopArray(str, depth, MAX_DEPTH) {
191
239
  return '[' + processed.join(',') + ']';
192
240
  }
193
241
 
194
- // If value is quoted, extract inside and JSON.stringify again (safe escaping)
195
- // If value is unquoted object/array literal, recurse treating it as new root
196
- // Otherwise return as is (numbers, booleans, null, or raw expressions)
242
+ // If it's a string wrapped in quotes, extract the inner content and JSON.stringify (safe escaping)
243
+ // If it's an object/array literal (not wrapped in quotes), recursively process (treat as new outermost layer)
244
+ // Otherwise return the original fragment directly (numbers/true/false/null or JS expressions)
197
245
  function repairPossiblyQuotedValue(rawVal, depth, MAX_DEPTH) {
198
246
  var v = rawVal.trim();
199
247
  if (v === '') return v;
200
248
  if (v[0] === '"' || v[0] === "'") {
201
249
  var quote = v[0];
202
- // Find the last unescaped matching quote
250
+ // Find the last unescaped same quote
203
251
  var lastPos = -1;
204
252
  for (var i = v.length - 1; i >= 0; i--) {
205
253
  if (v[i] === quote) {
206
- // check if escaped
207
- var bs = 0;
208
- var k = i - 1;
254
+ // check escaped
255
+ var bs = 0,
256
+ k = i - 1;
209
257
  while (k >= 0 && v[k] === '\\') {
210
258
  bs++;
211
259
  k--;
@@ -217,10 +265,10 @@ function repairPossiblyQuotedValue(rawVal, depth, MAX_DEPTH) {
217
265
  }
218
266
  }
219
267
  var inner = lastPos > 0 ? v.slice(1, lastPos) : v.slice(1);
220
- return JSON.stringify(inner); // Generate valid JSON string (auto escape)
268
+ return JSON.stringify(inner); // Use JSON.stringify to generate valid JSON string (automatically escape internal quotes, etc.)
221
269
  }
222
270
 
223
- // If unquoted object/array literal -> recurse
271
+ // If it's an object or array literal (not wrapped in quotes) -> recursively treat as new outermost layer
224
272
  if (v.startsWith('{')) {
225
273
  return processTopObject(v, depth, MAX_DEPTH);
226
274
  }
@@ -228,22 +276,22 @@ function repairPossiblyQuotedValue(rawVal, depth, MAX_DEPTH) {
228
276
  return processTopArray(v, depth, MAX_DEPTH);
229
277
  }
230
278
 
231
- // Other (number, boolean, null, raw expression): return as is
279
+ // Others (numbers, boolean, null, or JS expressions): return as-is
232
280
  return v;
233
281
  }
234
282
 
235
- /* --------- Utils: split by top-level commas, find colon, extract key --------- */
283
+ /* --------- Utilities: Split by top-level commas, find top-level colon, extract key --------- */
236
284
 
237
- // Split string by top-level commas (ignores commas inside strings/objects/arrays/parentheses)
285
+ // Split by top-level commas (ignore strings, sub-objects, sub-arrays, commas inside parentheses)
238
286
  function splitTopLevel(str) {
239
287
  var parts = [];
240
288
  var buf = '';
241
- var depthCurly = 0;
242
- var depthSquare = 0;
243
- var depthParen = 0;
244
- var inSingle = false;
245
- var inDouble = false;
246
- var esc = false;
289
+ var depthCurly = 0,
290
+ depthSquare = 0,
291
+ depthParen = 0;
292
+ var inSingle = false,
293
+ inDouble = false,
294
+ esc = false;
247
295
  for (var i = 0; i < str.length; i++) {
248
296
  var ch = str[i];
249
297
  if (esc) {
@@ -305,18 +353,23 @@ function splitTopLevel(str) {
305
353
  }
306
354
  buf += ch;
307
355
  }
356
+
357
+ // Check for unclosed brackets or quotes
358
+ if (depthCurly !== 0 || depthSquare !== 0 || depthParen !== 0 || inSingle || inDouble) {
359
+ throw new Error('Invalid JSON: unclosed brackets or quotes');
360
+ }
308
361
  if (buf.trim() !== '') parts.push(buf);
309
362
  return parts;
310
363
  }
311
364
 
312
- // Find the first top-level colon (ignores strings and nested structures)
365
+ // Find the first "top-level" colon index (ignore inside strings & sub-levels)
313
366
  function findTopLevelColon(str) {
314
- var inSingle = false;
315
- var inDouble = false;
316
- var esc = false;
317
- var depthCurly = 0;
318
- var depthSquare = 0;
319
- var depthParen = 0;
367
+ var inSingle = false,
368
+ inDouble = false,
369
+ esc = false;
370
+ var depthCurly = 0,
371
+ depthSquare = 0,
372
+ depthParen = 0;
320
373
  for (var i = 0; i < str.length; i++) {
321
374
  var ch = str[i];
322
375
  if (esc) {
@@ -368,7 +421,7 @@ function findTopLevelColon(str) {
368
421
  return -1;
369
422
  }
370
423
 
371
- // Extract key content (supports "key", 'key', key) returns pure string key
424
+ // Extract key content (supports "key", 'key', key), returns pure key string
372
425
  function extractKeyContent(rawKey) {
373
426
  var r = rawKey.trim();
374
427
  if (r.startsWith('"') && r.endsWith('"') || r.startsWith("'") && r.endsWith("'")) {
@@ -14,6 +14,7 @@ import { htmlEncode } from 'funda-utils/dist/cjs/sanitize';
14
14
  import { isJSON } from 'funda-utils/dist/cjs/validate';
15
15
 
16
16
 
17
+
17
18
  // loader
18
19
  import PureLoader from './PureLoader';
19
20
  import TypingEffect from "./TypingEffect";
@@ -380,9 +381,14 @@ const Chatbox = (props: ChatboxProps) => {
380
381
  return {};
381
382
  } else {
382
383
 
383
- if (JSON.parse(_requestBodyTmpl).hasOwnProperty('stream')) {
384
- _isStream = toBoolean(JSON.parse(_requestBodyTmpl).stream) === true;
384
+ try {
385
+ if (JSON.parse(_requestBodyTmpl).hasOwnProperty('stream')) {
386
+ _isStream = toBoolean(JSON.parse(_requestBodyTmpl).stream) === true;
387
+ }
388
+ } catch (err) {
389
+ console.error(err);
385
390
  }
391
+
386
392
  }
387
393
 
388
394
  // Whether or not to show reasoning