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.
- package/Chatbox/index.js +123 -69
- package/LiveSearch/index.js +117 -67
- package/MultipleCheckboxes/index.js +117 -67
- package/MultipleSelect/index.js +117 -67
- package/NativeSelect/index.js +117 -67
- package/Radio/index.js +117 -67
- package/Select/index.js +117 -67
- package/Utils/anim.js +116 -62
- package/Utils/initDefaultOptions.js +116 -62
- package/Utils/validate.d.ts +1 -7
- package/Utils/validate.js +115 -62
- package/lib/cjs/Chatbox/index.js +123 -69
- package/lib/cjs/LiveSearch/index.js +117 -67
- package/lib/cjs/MultipleCheckboxes/index.js +117 -67
- package/lib/cjs/MultipleSelect/index.js +117 -67
- package/lib/cjs/NativeSelect/index.js +117 -67
- package/lib/cjs/Radio/index.js +117 -67
- package/lib/cjs/Select/index.js +117 -67
- package/lib/cjs/Utils/anim.js +116 -62
- package/lib/cjs/Utils/initDefaultOptions.js +116 -62
- package/lib/cjs/Utils/validate.d.ts +1 -7
- package/lib/cjs/Utils/validate.js +115 -62
- package/lib/esm/Chatbox/index.tsx +8 -2
- package/lib/esm/Utils/libs/validate.ts +167 -194
- package/package.json +1 -1
package/lib/cjs/Select/index.js
CHANGED
|
@@ -3180,10 +3180,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3180
3180
|
__nested_webpack_require_993__.r(__webpack_exports__);
|
|
3181
3181
|
/* harmony export */
|
|
3182
3182
|
__nested_webpack_require_993__.d(__webpack_exports__, {
|
|
3183
|
-
/* harmony export */"fixAndParseJSON": function fixAndParseJSON() {
|
|
3184
|
-
return (/* binding */_fixAndParseJSON
|
|
3185
|
-
);
|
|
3186
|
-
},
|
|
3187
3183
|
/* harmony export */"isEmail": function isEmail() {
|
|
3188
3184
|
return (/* binding */_isEmail
|
|
3189
3185
|
);
|
|
@@ -3229,63 +3225,82 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3229
3225
|
}
|
|
3230
3226
|
/**
|
|
3231
3227
|
* Fix And Parse JSON (Support for handling complex escape JSON strings)
|
|
3228
|
+
* @desc recursively fix top-level key/value (recursively handles when encountering top-level values that are objects/arrays)
|
|
3232
3229
|
* @private
|
|
3233
3230
|
*/
|
|
3234
3231
|
/*
|
|
3235
|
-
-
|
|
3236
|
-
-
|
|
3237
|
-
- Then process the outermost object or array key
|
|
3238
|
-
- If a top-level value is an unquoted object or array (e.g
|
|
3239
|
-
|
|
3240
|
-
- For values wrapped in quotes ('...' or "..."), extract the inner text and
|
|
3241
|
-
re-encode it using JSON.stringify (ensures internal single/double quotes
|
|
3242
|
-
are not corrupted);
|
|
3232
|
+
- Still prioritize JSON.parse first;
|
|
3233
|
+
- After parse fails, do unescaping (\\" → ");
|
|
3234
|
+
- Then process the outermost layer (object or array) key by key, value by value;
|
|
3235
|
+
- 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;
|
|
3236
|
+
- 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);
|
|
3243
3237
|
- Set MAX_DEPTH to prevent infinite recursion.
|
|
3244
3238
|
*/
|
|
3245
|
-
// fixAndParseJSON - recursively repairs top-level key/value
|
|
3246
|
-
// (when encountering outermost values that are objects/arrays, it recurses)
|
|
3247
|
-
|
|
3248
3239
|
/*
|
|
3249
|
-
|
|
3240
|
+
@Examples:
|
|
3250
3241
|
|
|
3251
|
-
// ✅ Valid JSON (contains svg and single
|
|
3242
|
+
// ✅ Valid JSON (contains svg and single quote content)
|
|
3252
3243
|
const okJson = `{
|
|
3253
|
-
"label":"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg>
|
|
3244
|
+
"label":"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> 新建会话",
|
|
3254
3245
|
"value":"new",
|
|
3255
3246
|
"onClick":"method.setVal(''); method.clearData();"
|
|
3256
3247
|
}`;
|
|
3257
3248
|
|
|
3258
|
-
|
|
3249
|
+
const okJson2 = `{
|
|
3250
|
+
label:"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> 新建会话",
|
|
3251
|
+
value:"new",
|
|
3252
|
+
onClick:"method.setVal(''); method.clearData();"
|
|
3253
|
+
}`;
|
|
3254
|
+
|
|
3255
|
+
// ⚠️ Single quote JSON
|
|
3259
3256
|
const badJson = "{'model':'{model}','messages':[{'role':'user','content':'{message}'}],'stream': true}";
|
|
3260
3257
|
|
|
3261
|
-
//
|
|
3262
|
-
const badJson2 = "{\\\"label\\\":\\\"<svg width='16' height='16' viewBox='0 0 24 24'><path fill='currentColor' d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'/></svg>
|
|
3258
|
+
// ⚠️ Escaped JSON
|
|
3259
|
+
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();\\\"}";
|
|
3260
|
+
|
|
3261
|
+
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();\"}";
|
|
3262
|
+
|
|
3263
|
+
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}]";
|
|
3264
|
+
|
|
3263
3265
|
|
|
3264
|
-
|
|
3266
|
+
// ❌ Invalid JSON with missing } or ]
|
|
3267
|
+
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}'";
|
|
3265
3268
|
|
|
3266
|
-
const
|
|
3269
|
+
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}'}";
|
|
3267
3270
|
|
|
3271
|
+
// ❌ Invalid JSON with missing quotes
|
|
3272
|
+
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}'}";
|
|
3273
|
+
|
|
3274
|
+
|
|
3275
|
+
|
|
3276
|
+
console.log('okJson =>', fixAndParseJSON(okJson)); // Can parse normally success = true
|
|
3277
|
+
console.log('okJson =>', fixAndParseJSON(okJson2)); // Can parse normally success = true
|
|
3278
|
+
console.log('badJson =>', fixAndParseJSON(badJson)); // Can parse after fixing success = true
|
|
3279
|
+
console.log('badJson =>', fixAndParseJSON(badJson2)); // Can parse after fixing success = true
|
|
3280
|
+
console.log('badJson =>', fixAndParseJSON(badJson3)); // Can parse after fixing success = true
|
|
3281
|
+
console.log('badJson =>', fixAndParseJSON(badJson4)); // Can parse after fixing success = true
|
|
3282
|
+
console.log('errorJson =>', fixAndParseJSON(errorJson001)); // {success: false, error: 'Invalid JSON format', details: 'Invalid object: mismatched braces'}
|
|
3283
|
+
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)"}
|
|
3284
|
+
console.log('errorJson =>', fixAndParseJSON(errorJson003)); // {success: false, error: 'Invalid JSON format', details: 'Invalid object: mismatched braces'}
|
|
3268
3285
|
|
|
3269
|
-
console.log('okJson =>', fixAndParseJSON(okJson)); // parses correctly
|
|
3270
|
-
console.log('badJson =>', fixAndParseJSON(badJson)); // repaired and parsed
|
|
3271
|
-
console.log('badJson2 =>', fixAndParseJSON(badJson2)); // repaired and parsed
|
|
3272
|
-
console.log('badJson3 =>', fixAndParseJSON(badJson3)); // repaired and parsed
|
|
3273
|
-
console.log('badJson4 =>', fixAndParseJSON(badJson4)); // repaired and parsed
|
|
3274
3286
|
*/
|
|
3275
|
-
|
|
3287
|
+
|
|
3288
|
+
// Type definitions
|
|
3289
|
+
|
|
3290
|
+
function fixAndParseJSON(input) {
|
|
3276
3291
|
var MAX_DEPTH = 6;
|
|
3277
3292
|
|
|
3278
|
-
// 1.
|
|
3293
|
+
// 1. Quick attempt
|
|
3279
3294
|
try {
|
|
3280
3295
|
return {
|
|
3281
3296
|
success: true,
|
|
3282
3297
|
data: JSON.parse(input)
|
|
3283
3298
|
};
|
|
3284
3299
|
} catch (e) {
|
|
3285
|
-
//
|
|
3300
|
+
// Continue with fixing
|
|
3286
3301
|
}
|
|
3287
3302
|
|
|
3288
|
-
// 2. Simple
|
|
3303
|
+
// 2. Simple unescaping of escaped \" (common case from pasted JS literals)
|
|
3289
3304
|
var s = input;
|
|
3290
3305
|
if (s.includes('\\"')) s = s.replace(/\\"/g, '"');
|
|
3291
3306
|
s = s.trim();
|
|
@@ -3302,24 +3317,54 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3302
3317
|
data: JSON.parse(s)
|
|
3303
3318
|
};
|
|
3304
3319
|
} catch (err) {
|
|
3320
|
+
var error = err instanceof Error ? err : new Error('Unknown error');
|
|
3305
3321
|
return {
|
|
3306
3322
|
success: false,
|
|
3307
3323
|
error: 'Invalid JSON format',
|
|
3308
|
-
details:
|
|
3324
|
+
details: error.message
|
|
3309
3325
|
};
|
|
3310
3326
|
}
|
|
3311
3327
|
}
|
|
3312
3328
|
|
|
3313
|
-
/* ---------- Helper (
|
|
3329
|
+
/* ---------- Helper (Recursive) Functions ---------- */
|
|
3314
3330
|
|
|
3315
3331
|
function processTopObject(str, depth, MAX_DEPTH) {
|
|
3316
3332
|
if (depth > MAX_DEPTH) return str;
|
|
3317
3333
|
str = str.trim();
|
|
3318
|
-
|
|
3334
|
+
|
|
3335
|
+
// First check if braces match
|
|
3336
|
+
var braceCount = 0;
|
|
3337
|
+
var inString = false;
|
|
3338
|
+
var escapeNext = false;
|
|
3339
|
+
for (var i = 0; i < str.length; i++) {
|
|
3340
|
+
var ch = str[i];
|
|
3341
|
+
if (escapeNext) {
|
|
3342
|
+
escapeNext = false;
|
|
3343
|
+
continue;
|
|
3344
|
+
}
|
|
3345
|
+
if (ch === '\\') {
|
|
3346
|
+
escapeNext = true;
|
|
3347
|
+
continue;
|
|
3348
|
+
}
|
|
3349
|
+
if ((ch === '"' || ch === "'") && !escapeNext) {
|
|
3350
|
+
inString = !inString;
|
|
3351
|
+
continue;
|
|
3352
|
+
}
|
|
3353
|
+
if (!inString) {
|
|
3354
|
+
if (ch === '{') braceCount++;else if (ch === '}') braceCount--;
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
if (braceCount !== 0) {
|
|
3358
|
+
throw new Error('Invalid object: mismatched braces');
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3361
|
+
// Ensure both ends are { ... }
|
|
3319
3362
|
if (!(str.startsWith('{') && str.endsWith('}'))) {
|
|
3320
|
-
var f = str.indexOf('{')
|
|
3321
|
-
|
|
3322
|
-
if (f === -1 || l === -1 || l <= f)
|
|
3363
|
+
var f = str.indexOf('{'),
|
|
3364
|
+
l = str.lastIndexOf('}');
|
|
3365
|
+
if (f === -1 || l === -1 || l <= f) {
|
|
3366
|
+
throw new Error('Invalid object format: missing or mismatched braces');
|
|
3367
|
+
}
|
|
3323
3368
|
str = str.slice(f, l + 1);
|
|
3324
3369
|
}
|
|
3325
3370
|
var inner = str.slice(1, -1);
|
|
@@ -3344,8 +3389,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3344
3389
|
if (depth > MAX_DEPTH) return str;
|
|
3345
3390
|
str = str.trim();
|
|
3346
3391
|
if (!(str.startsWith('[') && str.endsWith(']'))) {
|
|
3347
|
-
var f = str.indexOf('[')
|
|
3348
|
-
|
|
3392
|
+
var f = str.indexOf('['),
|
|
3393
|
+
l = str.lastIndexOf(']');
|
|
3349
3394
|
if (f === -1 || l === -1 || l <= f) return str;
|
|
3350
3395
|
str = str.slice(f, l + 1);
|
|
3351
3396
|
}
|
|
@@ -3361,21 +3406,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3361
3406
|
return '[' + processed.join(',') + ']';
|
|
3362
3407
|
}
|
|
3363
3408
|
|
|
3364
|
-
// If
|
|
3365
|
-
// If
|
|
3366
|
-
// Otherwise return
|
|
3409
|
+
// If it's a string wrapped in quotes, extract the inner content and JSON.stringify (safe escaping)
|
|
3410
|
+
// If it's an object/array literal (not wrapped in quotes), recursively process (treat as new outermost layer)
|
|
3411
|
+
// Otherwise return the original fragment directly (numbers/true/false/null or JS expressions)
|
|
3367
3412
|
function repairPossiblyQuotedValue(rawVal, depth, MAX_DEPTH) {
|
|
3368
3413
|
var v = rawVal.trim();
|
|
3369
3414
|
if (v === '') return v;
|
|
3370
3415
|
if (v[0] === '"' || v[0] === "'") {
|
|
3371
3416
|
var quote = v[0];
|
|
3372
|
-
// Find the last unescaped
|
|
3417
|
+
// Find the last unescaped same quote
|
|
3373
3418
|
var lastPos = -1;
|
|
3374
3419
|
for (var i = v.length - 1; i >= 0; i--) {
|
|
3375
3420
|
if (v[i] === quote) {
|
|
3376
|
-
// check
|
|
3377
|
-
var bs = 0
|
|
3378
|
-
|
|
3421
|
+
// check escaped
|
|
3422
|
+
var bs = 0,
|
|
3423
|
+
k = i - 1;
|
|
3379
3424
|
while (k >= 0 && v[k] === '\\') {
|
|
3380
3425
|
bs++;
|
|
3381
3426
|
k--;
|
|
@@ -3387,10 +3432,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3387
3432
|
}
|
|
3388
3433
|
}
|
|
3389
3434
|
var inner = lastPos > 0 ? v.slice(1, lastPos) : v.slice(1);
|
|
3390
|
-
return JSON.stringify(inner); //
|
|
3435
|
+
return JSON.stringify(inner); // Use JSON.stringify to generate valid JSON string (automatically escape internal quotes, etc.)
|
|
3391
3436
|
}
|
|
3392
3437
|
|
|
3393
|
-
// If
|
|
3438
|
+
// If it's an object or array literal (not wrapped in quotes) -> recursively treat as new outermost layer
|
|
3394
3439
|
if (v.startsWith('{')) {
|
|
3395
3440
|
return processTopObject(v, depth, MAX_DEPTH);
|
|
3396
3441
|
}
|
|
@@ -3398,22 +3443,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3398
3443
|
return processTopArray(v, depth, MAX_DEPTH);
|
|
3399
3444
|
}
|
|
3400
3445
|
|
|
3401
|
-
//
|
|
3446
|
+
// Others (numbers, boolean, null, or JS expressions): return as-is
|
|
3402
3447
|
return v;
|
|
3403
3448
|
}
|
|
3404
3449
|
|
|
3405
|
-
/* ---------
|
|
3450
|
+
/* --------- Utilities: Split by top-level commas, find top-level colon, extract key --------- */
|
|
3406
3451
|
|
|
3407
|
-
// Split
|
|
3452
|
+
// Split by top-level commas (ignore strings, sub-objects, sub-arrays, commas inside parentheses)
|
|
3408
3453
|
function splitTopLevel(str) {
|
|
3409
3454
|
var parts = [];
|
|
3410
3455
|
var buf = '';
|
|
3411
|
-
var depthCurly = 0
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
var inSingle = false
|
|
3415
|
-
|
|
3416
|
-
|
|
3456
|
+
var depthCurly = 0,
|
|
3457
|
+
depthSquare = 0,
|
|
3458
|
+
depthParen = 0;
|
|
3459
|
+
var inSingle = false,
|
|
3460
|
+
inDouble = false,
|
|
3461
|
+
esc = false;
|
|
3417
3462
|
for (var i = 0; i < str.length; i++) {
|
|
3418
3463
|
var ch = str[i];
|
|
3419
3464
|
if (esc) {
|
|
@@ -3475,18 +3520,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3475
3520
|
}
|
|
3476
3521
|
buf += ch;
|
|
3477
3522
|
}
|
|
3523
|
+
|
|
3524
|
+
// Check for unclosed brackets or quotes
|
|
3525
|
+
if (depthCurly !== 0 || depthSquare !== 0 || depthParen !== 0 || inSingle || inDouble) {
|
|
3526
|
+
throw new Error('Invalid JSON: unclosed brackets or quotes');
|
|
3527
|
+
}
|
|
3478
3528
|
if (buf.trim() !== '') parts.push(buf);
|
|
3479
3529
|
return parts;
|
|
3480
3530
|
}
|
|
3481
3531
|
|
|
3482
|
-
// Find the first top-level colon (
|
|
3532
|
+
// Find the first "top-level" colon index (ignore inside strings & sub-levels)
|
|
3483
3533
|
function findTopLevelColon(str) {
|
|
3484
|
-
var inSingle = false
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
var depthCurly = 0
|
|
3488
|
-
|
|
3489
|
-
|
|
3534
|
+
var inSingle = false,
|
|
3535
|
+
inDouble = false,
|
|
3536
|
+
esc = false;
|
|
3537
|
+
var depthCurly = 0,
|
|
3538
|
+
depthSquare = 0,
|
|
3539
|
+
depthParen = 0;
|
|
3490
3540
|
for (var i = 0; i < str.length; i++) {
|
|
3491
3541
|
var ch = str[i];
|
|
3492
3542
|
if (esc) {
|
|
@@ -3538,7 +3588,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3538
3588
|
return -1;
|
|
3539
3589
|
}
|
|
3540
3590
|
|
|
3541
|
-
// Extract key content (supports "key", 'key', key)
|
|
3591
|
+
// Extract key content (supports "key", 'key', key), returns pure key string
|
|
3542
3592
|
function extractKeyContent(rawKey) {
|
|
3543
3593
|
var r = rawKey.trim();
|
|
3544
3594
|
if (r.startsWith('"') && r.endsWith('"') || r.startsWith("'") && r.endsWith("'")) {
|
|
@@ -3554,7 +3604,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3554
3604
|
*/
|
|
3555
3605
|
function _isJSON(input) {
|
|
3556
3606
|
if (typeof input === 'string' && input.length > 0) {
|
|
3557
|
-
return
|
|
3607
|
+
return fixAndParseJSON(input).success;
|
|
3558
3608
|
} else {
|
|
3559
3609
|
if (_typeof(input) === 'object' && Object.prototype.toString.call(input) === '[object Object]' && !input.length) {
|
|
3560
3610
|
return true;
|