@symbo.ls/scratch 2.11.446 → 2.11.453

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.
@@ -338,6 +338,8 @@ var require_array = __commonJS({
338
338
  arraysEqual: () => arraysEqual,
339
339
  cutArrayAfterValue: () => cutArrayAfterValue,
340
340
  cutArrayBeforeValue: () => cutArrayBeforeValue,
341
+ filterArrays: () => filterArrays,
342
+ filterArraysFast: () => filterArraysFast,
341
343
  getFrequencyInArray: () => getFrequencyInArray,
342
344
  joinArrays: () => joinArrays,
343
345
  mergeAndCloneIfArray: () => mergeAndCloneIfArray,
@@ -446,6 +448,13 @@ var require_array = __commonJS({
446
448
  }
447
449
  return true;
448
450
  };
451
+ var filterArrays = (sourceArr, excludeArr) => {
452
+ return sourceArr.filter((item) => !excludeArr.includes(item));
453
+ };
454
+ var filterArraysFast = (sourceArr, excludeArr) => {
455
+ const excludeSet = new Set(excludeArr);
456
+ return sourceArr.filter((item) => !excludeSet.has(item));
457
+ };
449
458
  }
450
459
  });
451
460
 
@@ -639,9 +648,11 @@ var require_object = __commonJS({
639
648
  diff: () => diff,
640
649
  diffArrays: () => diffArrays,
641
650
  diffObjects: () => diffObjects,
651
+ excludeKeysFromObject: () => excludeKeysFromObject,
642
652
  exec: () => exec,
643
653
  flattenRecursive: () => flattenRecursive,
644
654
  hasOwnProperty: () => hasOwnProperty,
655
+ isCyclic: () => isCyclic,
645
656
  isEmpty: () => isEmpty,
646
657
  isEmptyObject: () => isEmptyObject,
647
658
  isEqualDeep: () => isEqualDeep,
@@ -767,20 +778,28 @@ var require_object = __commonJS({
767
778
  }
768
779
  return clone2;
769
780
  };
770
- var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
781
+ var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
782
+ if ((0, import_types.isObjectLike)(obj)) {
783
+ if (visited.has(obj)) {
784
+ return obj;
785
+ }
786
+ visited.add(obj);
787
+ }
771
788
  const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
772
789
  for (const prop in obj) {
773
790
  if (!Object.prototype.hasOwnProperty.call(obj, prop))
774
791
  continue;
775
792
  const objProp = obj[prop];
776
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
793
+ if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
777
794
  continue;
795
+ }
778
796
  if ((0, import_types.isObjectLike)(objProp)) {
779
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
797
+ o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
780
798
  } else if ((0, import_types.isFunction)(objProp) && options.window) {
781
799
  o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
782
- } else
800
+ } else {
783
801
  o[prop] = objProp;
802
+ }
784
803
  }
785
804
  return o;
786
805
  };
@@ -957,7 +976,7 @@ var require_object = __commonJS({
957
976
  };
958
977
  var stringToObject = (str, opts = { verbose: true }) => {
959
978
  try {
960
- return import_globals2.window.eval("(" + str + ")");
979
+ return str ? import_globals2.window.eval("(" + str + ")") : {};
961
980
  } catch (e) {
962
981
  if (opts.verbose)
963
982
  console.warn(e);
@@ -1037,20 +1056,27 @@ var require_object = __commonJS({
1037
1056
  return acc;
1038
1057
  }, deletedValues);
1039
1058
  };
1040
- var overwrite = (element, params, excludeFrom = []) => {
1041
- const { ref } = element;
1042
- const changes = {};
1059
+ var overwrite = (element, params, opts = {}) => {
1060
+ const { __ref: ref } = element;
1061
+ const excl = opts.exclude || [];
1062
+ const allowUnderscore = opts.preventUnderscore;
1063
+ const preventCaching = opts.preventCaching;
1043
1064
  for (const e in params) {
1044
- if (excludeFrom.includes(e) || e.startsWith("__"))
1065
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
1045
1066
  continue;
1046
1067
  const elementProp = element[e];
1047
1068
  const paramsProp = params[e];
1048
- if (paramsProp) {
1049
- ref.__cache[e] = changes[e] = elementProp;
1050
- ref[e] = paramsProp;
1069
+ if (paramsProp !== void 0) {
1070
+ element[e] = paramsProp;
1071
+ if (ref && !preventCaching) {
1072
+ ref.__cache[e] = elementProp;
1073
+ }
1074
+ if ((0, import_types.isObject)(opts.diff)) {
1075
+ diff[e] = elementProp;
1076
+ }
1051
1077
  }
1052
1078
  }
1053
- return changes;
1079
+ return element;
1054
1080
  };
1055
1081
  var overwriteShallow = (obj, params, excludeFrom = []) => {
1056
1082
  for (const e in params) {
@@ -1060,23 +1086,26 @@ var require_object = __commonJS({
1060
1086
  }
1061
1087
  return obj;
1062
1088
  };
1063
- var overwriteDeep = (obj, params, excludeFrom = [], visited = /* @__PURE__ */ new WeakMap()) => {
1089
+ var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
1090
+ const excl = opts.exclude || [];
1091
+ const forcedExclude = opts.preventForce ? [] : ["node", "window"];
1064
1092
  if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
1065
1093
  return params;
1066
1094
  }
1067
- if (visited.has(obj)) {
1095
+ if (visited.has(obj))
1068
1096
  return visited.get(obj);
1069
- }
1070
1097
  visited.set(obj, obj);
1071
1098
  for (const e in params) {
1072
- if (e === "__ref" || excludeFrom.includes(e) || e.startsWith("__"))
1099
+ if (!Object.hasOwnProperty.call(params, e))
1100
+ continue;
1101
+ if (excl.includes(e) || forcedExclude && e.startsWith("__"))
1073
1102
  continue;
1074
1103
  const objProp = obj[e];
1075
1104
  const paramsProp = params[e];
1076
1105
  if ((0, import_node.isDOMNode)(paramsProp)) {
1077
1106
  obj[e] = paramsProp;
1078
1107
  } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
1079
- obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
1108
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
1080
1109
  } else if (paramsProp !== void 0) {
1081
1110
  obj[e] = paramsProp;
1082
1111
  }
@@ -1239,6 +1268,30 @@ var require_object = __commonJS({
1239
1268
  }
1240
1269
  }
1241
1270
  };
1271
+ var isCyclic = (obj) => {
1272
+ const seenObjects = [];
1273
+ function detect(obj2) {
1274
+ if (obj2 && typeof obj2 === "object") {
1275
+ if (seenObjects.indexOf(obj2) !== -1) {
1276
+ return true;
1277
+ }
1278
+ seenObjects.push(obj2);
1279
+ for (const key in obj2) {
1280
+ if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
1281
+ console.log(obj2, "cycle at " + key);
1282
+ return true;
1283
+ }
1284
+ }
1285
+ }
1286
+ return false;
1287
+ }
1288
+ return detect(obj);
1289
+ };
1290
+ var excludeKeysFromObject = (obj, excludedKeys) => {
1291
+ const result = { ...obj };
1292
+ excludedKeys.forEach((key) => delete result[key]);
1293
+ return result;
1294
+ };
1242
1295
  }
1243
1296
  });
1244
1297
 
@@ -1658,6 +1711,8 @@ var require_component = __commonJS({
1658
1711
  return /^[a-z]*$/.test(firstCharKey);
1659
1712
  };
1660
1713
  var addAdditionalExtend = (newExtend, element) => {
1714
+ if (!newExtend)
1715
+ return element;
1661
1716
  const { extend: elementExtend } = element;
1662
1717
  const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
1663
1718
  const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
@@ -1665,8 +1720,23 @@ var require_component = __commonJS({
1665
1720
  return { ...element, extend };
1666
1721
  };
1667
1722
  var checkIfSugar = (element, parent, key) => {
1668
- const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1723
+ const {
1724
+ extend,
1725
+ props,
1726
+ childExtend,
1727
+ extends: extendProps,
1728
+ childrenExtends,
1729
+ childProps,
1730
+ children,
1731
+ on,
1732
+ $collection,
1733
+ $stateCollection,
1734
+ $propsCollection
1735
+ } = element;
1669
1736
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1737
+ if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
1738
+ element.error("Sugar component includes params for builtin components");
1739
+ }
1670
1740
  return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1671
1741
  };
1672
1742
  var extendizeByKey = (element, parent, key) => {
@@ -1678,11 +1748,11 @@ var require_component = __commonJS({
1678
1748
  if (element === isExtendKeyComponent)
1679
1749
  return element;
1680
1750
  else if (isSugar) {
1681
- const newElem = {
1751
+ const newElem = addAdditionalExtend(element.extends, {
1682
1752
  extend: extendFromKey,
1683
1753
  tag,
1684
1754
  props: { ...element }
1685
- };
1755
+ });
1686
1756
  if (childrenExtends)
1687
1757
  newElem.childExtend = childrenExtends;
1688
1758
  return newElem;
@@ -2153,6 +2223,8 @@ var require_cjs3 = __commonJS({
2153
2223
  arraysEqual: () => arraysEqual,
2154
2224
  cutArrayAfterValue: () => cutArrayAfterValue,
2155
2225
  cutArrayBeforeValue: () => cutArrayBeforeValue,
2226
+ filterArrays: () => filterArrays,
2227
+ filterArraysFast: () => filterArraysFast,
2156
2228
  getFrequencyInArray: () => getFrequencyInArray,
2157
2229
  joinArrays: () => joinArrays,
2158
2230
  mergeAndCloneIfArray: () => mergeAndCloneIfArray,
@@ -2261,6 +2333,13 @@ var require_cjs3 = __commonJS({
2261
2333
  }
2262
2334
  return true;
2263
2335
  };
2336
+ var filterArrays = (sourceArr, excludeArr) => {
2337
+ return sourceArr.filter((item) => !excludeArr.includes(item));
2338
+ };
2339
+ var filterArraysFast = (sourceArr, excludeArr) => {
2340
+ const excludeSet = new Set(excludeArr);
2341
+ return sourceArr.filter((item) => !excludeSet.has(item));
2342
+ };
2264
2343
  }
2265
2344
  });
2266
2345
  var require_string2 = __commonJS2({
@@ -2450,9 +2529,11 @@ var require_cjs3 = __commonJS({
2450
2529
  diff: () => diff,
2451
2530
  diffArrays: () => diffArrays,
2452
2531
  diffObjects: () => diffObjects,
2532
+ excludeKeysFromObject: () => excludeKeysFromObject,
2453
2533
  exec: () => exec,
2454
2534
  flattenRecursive: () => flattenRecursive,
2455
2535
  hasOwnProperty: () => hasOwnProperty,
2536
+ isCyclic: () => isCyclic,
2456
2537
  isEmpty: () => isEmpty,
2457
2538
  isEmptyObject: () => isEmptyObject,
2458
2539
  isEqualDeep: () => isEqualDeep,
@@ -2578,20 +2659,28 @@ var require_cjs3 = __commonJS({
2578
2659
  }
2579
2660
  return clone2;
2580
2661
  };
2581
- var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
2662
+ var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
2663
+ if ((0, import_types.isObjectLike)(obj)) {
2664
+ if (visited.has(obj)) {
2665
+ return obj;
2666
+ }
2667
+ visited.add(obj);
2668
+ }
2582
2669
  const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
2583
2670
  for (const prop in obj) {
2584
2671
  if (!Object.prototype.hasOwnProperty.call(obj, prop))
2585
2672
  continue;
2586
2673
  const objProp = obj[prop];
2587
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
2674
+ if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
2588
2675
  continue;
2676
+ }
2589
2677
  if ((0, import_types.isObjectLike)(objProp)) {
2590
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
2678
+ o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
2591
2679
  } else if ((0, import_types.isFunction)(objProp) && options.window) {
2592
2680
  o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
2593
- } else
2681
+ } else {
2594
2682
  o[prop] = objProp;
2683
+ }
2595
2684
  }
2596
2685
  return o;
2597
2686
  };
@@ -2768,7 +2857,7 @@ var require_cjs3 = __commonJS({
2768
2857
  };
2769
2858
  var stringToObject = (str, opts = { verbose: true }) => {
2770
2859
  try {
2771
- return import_globals2.window.eval("(" + str + ")");
2860
+ return str ? import_globals2.window.eval("(" + str + ")") : {};
2772
2861
  } catch (e) {
2773
2862
  if (opts.verbose)
2774
2863
  console.warn(e);
@@ -2848,20 +2937,27 @@ var require_cjs3 = __commonJS({
2848
2937
  return acc;
2849
2938
  }, deletedValues);
2850
2939
  };
2851
- var overwrite = (element, params, excludeFrom = []) => {
2852
- const { ref } = element;
2853
- const changes = {};
2940
+ var overwrite = (element, params, opts = {}) => {
2941
+ const { __ref: ref } = element;
2942
+ const excl = opts.exclude || [];
2943
+ const allowUnderscore = opts.preventUnderscore;
2944
+ const preventCaching = opts.preventCaching;
2854
2945
  for (const e in params) {
2855
- if (excludeFrom.includes(e) || e.startsWith("__"))
2946
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
2856
2947
  continue;
2857
2948
  const elementProp = element[e];
2858
2949
  const paramsProp = params[e];
2859
- if (paramsProp) {
2860
- ref.__cache[e] = changes[e] = elementProp;
2861
- ref[e] = paramsProp;
2950
+ if (paramsProp !== void 0) {
2951
+ element[e] = paramsProp;
2952
+ if (ref && !preventCaching) {
2953
+ ref.__cache[e] = elementProp;
2954
+ }
2955
+ if ((0, import_types.isObject)(opts.diff)) {
2956
+ diff[e] = elementProp;
2957
+ }
2862
2958
  }
2863
2959
  }
2864
- return changes;
2960
+ return element;
2865
2961
  };
2866
2962
  var overwriteShallow = (obj, params, excludeFrom = []) => {
2867
2963
  for (const e in params) {
@@ -2871,23 +2967,26 @@ var require_cjs3 = __commonJS({
2871
2967
  }
2872
2968
  return obj;
2873
2969
  };
2874
- var overwriteDeep = (obj, params, excludeFrom = [], visited = /* @__PURE__ */ new WeakMap()) => {
2970
+ var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
2971
+ const excl = opts.exclude || [];
2972
+ const forcedExclude = opts.preventForce ? [] : ["node", "window"];
2875
2973
  if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
2876
2974
  return params;
2877
2975
  }
2878
- if (visited.has(obj)) {
2976
+ if (visited.has(obj))
2879
2977
  return visited.get(obj);
2880
- }
2881
2978
  visited.set(obj, obj);
2882
2979
  for (const e in params) {
2883
- if (e === "__ref" || excludeFrom.includes(e) || e.startsWith("__"))
2980
+ if (!Object.hasOwnProperty.call(params, e))
2981
+ continue;
2982
+ if (excl.includes(e) || forcedExclude && e.startsWith("__"))
2884
2983
  continue;
2885
2984
  const objProp = obj[e];
2886
2985
  const paramsProp = params[e];
2887
2986
  if ((0, import_node.isDOMNode)(paramsProp)) {
2888
2987
  obj[e] = paramsProp;
2889
2988
  } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
2890
- obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
2989
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
2891
2990
  } else if (paramsProp !== void 0) {
2892
2991
  obj[e] = paramsProp;
2893
2992
  }
@@ -3050,6 +3149,30 @@ var require_cjs3 = __commonJS({
3050
3149
  }
3051
3150
  }
3052
3151
  };
3152
+ var isCyclic = (obj) => {
3153
+ const seenObjects = [];
3154
+ function detect(obj2) {
3155
+ if (obj2 && typeof obj2 === "object") {
3156
+ if (seenObjects.indexOf(obj2) !== -1) {
3157
+ return true;
3158
+ }
3159
+ seenObjects.push(obj2);
3160
+ for (const key in obj2) {
3161
+ if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
3162
+ console.log(obj2, "cycle at " + key);
3163
+ return true;
3164
+ }
3165
+ }
3166
+ }
3167
+ return false;
3168
+ }
3169
+ return detect(obj);
3170
+ };
3171
+ var excludeKeysFromObject = (obj, excludedKeys) => {
3172
+ const result = { ...obj };
3173
+ excludedKeys.forEach((key) => delete result[key]);
3174
+ return result;
3175
+ };
3053
3176
  }
3054
3177
  });
3055
3178
  var require_function2 = __commonJS2({
@@ -3459,6 +3582,8 @@ var require_cjs3 = __commonJS({
3459
3582
  return /^[a-z]*$/.test(firstCharKey);
3460
3583
  };
3461
3584
  var addAdditionalExtend = (newExtend, element) => {
3585
+ if (!newExtend)
3586
+ return element;
3462
3587
  const { extend: elementExtend } = element;
3463
3588
  const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
3464
3589
  const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
@@ -3466,8 +3591,23 @@ var require_cjs3 = __commonJS({
3466
3591
  return { ...element, extend };
3467
3592
  };
3468
3593
  var checkIfSugar = (element, parent, key) => {
3469
- const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
3594
+ const {
3595
+ extend,
3596
+ props,
3597
+ childExtend,
3598
+ extends: extendProps,
3599
+ childrenExtends,
3600
+ childProps,
3601
+ children,
3602
+ on,
3603
+ $collection,
3604
+ $stateCollection,
3605
+ $propsCollection
3606
+ } = element;
3470
3607
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
3608
+ if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
3609
+ element.error("Sugar component includes params for builtin components");
3610
+ }
3471
3611
  return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3472
3612
  };
3473
3613
  var extendizeByKey = (element, parent, key) => {
@@ -3479,11 +3619,11 @@ var require_cjs3 = __commonJS({
3479
3619
  if (element === isExtendKeyComponent)
3480
3620
  return element;
3481
3621
  else if (isSugar) {
3482
- const newElem = {
3622
+ const newElem = addAdditionalExtend(element.extends, {
3483
3623
  extend: extendFromKey,
3484
3624
  tag,
3485
3625
  props: { ...element }
3486
- };
3626
+ });
3487
3627
  if (childrenExtends)
3488
3628
  newElem.childExtend = childrenExtends;
3489
3629
  return newElem;