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.
@@ -2845,10 +2845,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2845
2845
  __nested_webpack_require_993__.r(__webpack_exports__);
2846
2846
  /* harmony export */
2847
2847
  __nested_webpack_require_993__.d(__webpack_exports__, {
2848
- /* harmony export */"fixAndParseJSON": function fixAndParseJSON() {
2849
- return (/* binding */_fixAndParseJSON
2850
- );
2851
- },
2852
2848
  /* harmony export */"isEmail": function isEmail() {
2853
2849
  return (/* binding */_isEmail
2854
2850
  );
@@ -2894,63 +2890,82 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2894
2890
  }
2895
2891
  /**
2896
2892
  * Fix And Parse JSON (Support for handling complex escape JSON strings)
2893
+ * @desc recursively fix top-level key/value (recursively handles when encountering top-level values that are objects/arrays)
2897
2894
  * @private
2898
2895
  */
2899
2896
  /*
2900
- - Always try JSON.parse first;
2901
- - If parsing fails, unescape \" → ";
2902
- - Then process the outermost object or array key-by-key, value-by-value;
2903
- - If a top-level value is an unquoted object or array (e.g. messages: [ {...} ]),
2904
- recursively treat that value as a new root to repair;
2905
- - For values wrapped in quotes ('...' or "..."), extract the inner text and
2906
- re-encode it using JSON.stringify (ensures internal single/double quotes
2907
- are not corrupted);
2897
+ - Still prioritize JSON.parse first;
2898
+ - After parse fails, do unescaping (\\" → ");
2899
+ - Then process the outermost layer (object or array) key by key, value by value;
2900
+ - 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;
2901
+ - 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);
2908
2902
  - Set MAX_DEPTH to prevent infinite recursion.
2909
2903
  */
2910
- // fixAndParseJSON - recursively repairs top-level key/value
2911
- // (when encountering outermost values that are objects/arrays, it recurses)
2912
-
2913
2904
  /*
2914
- DEMO:
2905
+ @Examples:
2915
2906
 
2916
- // ✅ Valid JSON (contains svg and single-quote content)
2907
+ // ✅ Valid JSON (contains svg and single quote content)
2917
2908
  const okJson = `{
2918
- "label":"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> New Session",
2909
+ "label":"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> 新建会话",
2919
2910
  "value":"new",
2920
2911
  "onClick":"method.setVal(''); method.clearData();"
2921
2912
  }`;
2922
2913
 
2923
- // Single-quote JSON
2914
+ const okJson2 = `{
2915
+ label:"<svg width='16' height='16'><path fill='currentColor' d='M19 13h-6'/></svg> 新建会话",
2916
+ value:"new",
2917
+ onClick:"method.setVal(''); method.clearData();"
2918
+ }`;
2919
+
2920
+ // ⚠️ Single quote JSON
2924
2921
  const badJson = "{'model':'{model}','messages':[{'role':'user','content':'{message}'}],'stream': true}";
2925
2922
 
2926
- // Escaped JSON
2927
- 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();\\\"}";
2923
+ // ⚠️ Escaped JSON
2924
+ 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();\\\"}";
2925
+
2926
+ 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();\"}";
2927
+
2928
+ 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}]";
2929
+
2928
2930
 
2929
- 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();\"}";
2931
+ // Invalid JSON with missing } or ]
2932
+ 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}'";
2930
2933
 
2931
- 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}]";
2934
+ 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}'}";
2932
2935
 
2936
+ // ❌ Invalid JSON with missing quotes
2937
+ 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}'}";
2938
+
2939
+
2940
+
2941
+ console.log('okJson =>', fixAndParseJSON(okJson)); // Can parse normally success = true
2942
+ console.log('okJson =>', fixAndParseJSON(okJson2)); // Can parse normally success = true
2943
+ console.log('badJson =>', fixAndParseJSON(badJson)); // Can parse after fixing success = true
2944
+ console.log('badJson =>', fixAndParseJSON(badJson2)); // Can parse after fixing success = true
2945
+ console.log('badJson =>', fixAndParseJSON(badJson3)); // Can parse after fixing success = true
2946
+ console.log('badJson =>', fixAndParseJSON(badJson4)); // Can parse after fixing success = true
2947
+ console.log('errorJson =>', fixAndParseJSON(errorJson001)); // {success: false, error: 'Invalid JSON format', details: 'Invalid object: mismatched braces'}
2948
+ 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)"}
2949
+ console.log('errorJson =>', fixAndParseJSON(errorJson003)); // {success: false, error: 'Invalid JSON format', details: 'Invalid object: mismatched braces'}
2933
2950
 
2934
- console.log('okJson =>', fixAndParseJSON(okJson)); // parses correctly
2935
- console.log('badJson =>', fixAndParseJSON(badJson)); // repaired and parsed
2936
- console.log('badJson2 =>', fixAndParseJSON(badJson2)); // repaired and parsed
2937
- console.log('badJson3 =>', fixAndParseJSON(badJson3)); // repaired and parsed
2938
- console.log('badJson4 =>', fixAndParseJSON(badJson4)); // repaired and parsed
2939
2951
  */
2940
- function _fixAndParseJSON(input) {
2952
+
2953
+ // Type definitions
2954
+
2955
+ function fixAndParseJSON(input) {
2941
2956
  var MAX_DEPTH = 6;
2942
2957
 
2943
- // 1. Fast attempt
2958
+ // 1. Quick attempt
2944
2959
  try {
2945
2960
  return {
2946
2961
  success: true,
2947
2962
  data: JSON.parse(input)
2948
2963
  };
2949
2964
  } catch (e) {
2950
- // continue to repair
2965
+ // Continue with fixing
2951
2966
  }
2952
2967
 
2953
- // 2. Simple unescape of \" (common when copied from JS literals)
2968
+ // 2. Simple unescaping of escaped \" (common case from pasted JS literals)
2954
2969
  var s = input;
2955
2970
  if (s.includes('\\"')) s = s.replace(/\\"/g, '"');
2956
2971
  s = s.trim();
@@ -2967,24 +2982,54 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2967
2982
  data: JSON.parse(s)
2968
2983
  };
2969
2984
  } catch (err) {
2985
+ var error = err instanceof Error ? err : new Error('Unknown error');
2970
2986
  return {
2971
2987
  success: false,
2972
2988
  error: 'Invalid JSON format',
2973
- details: err instanceof Error ? err.message : String(err)
2989
+ details: error.message
2974
2990
  };
2975
2991
  }
2976
2992
  }
2977
2993
 
2978
- /* ---------- Helper (recursive) functions ---------- */
2994
+ /* ---------- Helper (Recursive) Functions ---------- */
2979
2995
 
2980
2996
  function processTopObject(str, depth, MAX_DEPTH) {
2981
2997
  if (depth > MAX_DEPTH) return str;
2982
2998
  str = str.trim();
2983
- // Ensure it is wrapped in { ... }
2999
+
3000
+ // First check if braces match
3001
+ var braceCount = 0;
3002
+ var inString = false;
3003
+ var escapeNext = false;
3004
+ for (var i = 0; i < str.length; i++) {
3005
+ var ch = str[i];
3006
+ if (escapeNext) {
3007
+ escapeNext = false;
3008
+ continue;
3009
+ }
3010
+ if (ch === '\\') {
3011
+ escapeNext = true;
3012
+ continue;
3013
+ }
3014
+ if ((ch === '"' || ch === "'") && !escapeNext) {
3015
+ inString = !inString;
3016
+ continue;
3017
+ }
3018
+ if (!inString) {
3019
+ if (ch === '{') braceCount++;else if (ch === '}') braceCount--;
3020
+ }
3021
+ }
3022
+ if (braceCount !== 0) {
3023
+ throw new Error('Invalid object: mismatched braces');
3024
+ }
3025
+
3026
+ // Ensure both ends are { ... }
2984
3027
  if (!(str.startsWith('{') && str.endsWith('}'))) {
2985
- var f = str.indexOf('{');
2986
- var l = str.lastIndexOf('}');
2987
- if (f === -1 || l === -1 || l <= f) return str;
3028
+ var f = str.indexOf('{'),
3029
+ l = str.lastIndexOf('}');
3030
+ if (f === -1 || l === -1 || l <= f) {
3031
+ throw new Error('Invalid object format: missing or mismatched braces');
3032
+ }
2988
3033
  str = str.slice(f, l + 1);
2989
3034
  }
2990
3035
  var inner = str.slice(1, -1);
@@ -3009,8 +3054,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3009
3054
  if (depth > MAX_DEPTH) return str;
3010
3055
  str = str.trim();
3011
3056
  if (!(str.startsWith('[') && str.endsWith(']'))) {
3012
- var f = str.indexOf('[');
3013
- var l = str.lastIndexOf(']');
3057
+ var f = str.indexOf('['),
3058
+ l = str.lastIndexOf(']');
3014
3059
  if (f === -1 || l === -1 || l <= f) return str;
3015
3060
  str = str.slice(f, l + 1);
3016
3061
  }
@@ -3026,21 +3071,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3026
3071
  return '[' + processed.join(',') + ']';
3027
3072
  }
3028
3073
 
3029
- // If value is quoted, extract inside and JSON.stringify again (safe escaping)
3030
- // If value is unquoted object/array literal, recurse treating it as new root
3031
- // Otherwise return as is (numbers, booleans, null, or raw expressions)
3074
+ // If it's a string wrapped in quotes, extract the inner content and JSON.stringify (safe escaping)
3075
+ // If it's an object/array literal (not wrapped in quotes), recursively process (treat as new outermost layer)
3076
+ // Otherwise return the original fragment directly (numbers/true/false/null or JS expressions)
3032
3077
  function repairPossiblyQuotedValue(rawVal, depth, MAX_DEPTH) {
3033
3078
  var v = rawVal.trim();
3034
3079
  if (v === '') return v;
3035
3080
  if (v[0] === '"' || v[0] === "'") {
3036
3081
  var quote = v[0];
3037
- // Find the last unescaped matching quote
3082
+ // Find the last unescaped same quote
3038
3083
  var lastPos = -1;
3039
3084
  for (var i = v.length - 1; i >= 0; i--) {
3040
3085
  if (v[i] === quote) {
3041
- // check if escaped
3042
- var bs = 0;
3043
- var k = i - 1;
3086
+ // check escaped
3087
+ var bs = 0,
3088
+ k = i - 1;
3044
3089
  while (k >= 0 && v[k] === '\\') {
3045
3090
  bs++;
3046
3091
  k--;
@@ -3052,10 +3097,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3052
3097
  }
3053
3098
  }
3054
3099
  var inner = lastPos > 0 ? v.slice(1, lastPos) : v.slice(1);
3055
- return JSON.stringify(inner); // Generate valid JSON string (auto escape)
3100
+ return JSON.stringify(inner); // Use JSON.stringify to generate valid JSON string (automatically escape internal quotes, etc.)
3056
3101
  }
3057
3102
 
3058
- // If unquoted object/array literal -> recurse
3103
+ // If it's an object or array literal (not wrapped in quotes) -> recursively treat as new outermost layer
3059
3104
  if (v.startsWith('{')) {
3060
3105
  return processTopObject(v, depth, MAX_DEPTH);
3061
3106
  }
@@ -3063,22 +3108,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3063
3108
  return processTopArray(v, depth, MAX_DEPTH);
3064
3109
  }
3065
3110
 
3066
- // Other (number, boolean, null, raw expression): return as is
3111
+ // Others (numbers, boolean, null, or JS expressions): return as-is
3067
3112
  return v;
3068
3113
  }
3069
3114
 
3070
- /* --------- Utils: split by top-level commas, find colon, extract key --------- */
3115
+ /* --------- Utilities: Split by top-level commas, find top-level colon, extract key --------- */
3071
3116
 
3072
- // Split string by top-level commas (ignores commas inside strings/objects/arrays/parentheses)
3117
+ // Split by top-level commas (ignore strings, sub-objects, sub-arrays, commas inside parentheses)
3073
3118
  function splitTopLevel(str) {
3074
3119
  var parts = [];
3075
3120
  var buf = '';
3076
- var depthCurly = 0;
3077
- var depthSquare = 0;
3078
- var depthParen = 0;
3079
- var inSingle = false;
3080
- var inDouble = false;
3081
- var esc = false;
3121
+ var depthCurly = 0,
3122
+ depthSquare = 0,
3123
+ depthParen = 0;
3124
+ var inSingle = false,
3125
+ inDouble = false,
3126
+ esc = false;
3082
3127
  for (var i = 0; i < str.length; i++) {
3083
3128
  var ch = str[i];
3084
3129
  if (esc) {
@@ -3140,18 +3185,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3140
3185
  }
3141
3186
  buf += ch;
3142
3187
  }
3188
+
3189
+ // Check for unclosed brackets or quotes
3190
+ if (depthCurly !== 0 || depthSquare !== 0 || depthParen !== 0 || inSingle || inDouble) {
3191
+ throw new Error('Invalid JSON: unclosed brackets or quotes');
3192
+ }
3143
3193
  if (buf.trim() !== '') parts.push(buf);
3144
3194
  return parts;
3145
3195
  }
3146
3196
 
3147
- // Find the first top-level colon (ignores strings and nested structures)
3197
+ // Find the first "top-level" colon index (ignore inside strings & sub-levels)
3148
3198
  function findTopLevelColon(str) {
3149
- var inSingle = false;
3150
- var inDouble = false;
3151
- var esc = false;
3152
- var depthCurly = 0;
3153
- var depthSquare = 0;
3154
- var depthParen = 0;
3199
+ var inSingle = false,
3200
+ inDouble = false,
3201
+ esc = false;
3202
+ var depthCurly = 0,
3203
+ depthSquare = 0,
3204
+ depthParen = 0;
3155
3205
  for (var i = 0; i < str.length; i++) {
3156
3206
  var ch = str[i];
3157
3207
  if (esc) {
@@ -3203,7 +3253,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3203
3253
  return -1;
3204
3254
  }
3205
3255
 
3206
- // Extract key content (supports "key", 'key', key) returns pure string key
3256
+ // Extract key content (supports "key", 'key', key), returns pure key string
3207
3257
  function extractKeyContent(rawKey) {
3208
3258
  var r = rawKey.trim();
3209
3259
  if (r.startsWith('"') && r.endsWith('"') || r.startsWith("'") && r.endsWith("'")) {
@@ -3219,7 +3269,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3219
3269
  */
3220
3270
  function _isJSON(input) {
3221
3271
  if (typeof input === 'string' && input.length > 0) {
3222
- return _fixAndParseJSON(input).success;
3272
+ return fixAndParseJSON(input).success;
3223
3273
  } else {
3224
3274
  if (_typeof(input) === 'object' && Object.prototype.toString.call(input) === '[object Object]' && !input.length) {
3225
3275
  return true;