@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.
@@ -325,6 +325,8 @@ var require_cjs = __commonJS({
325
325
  arraysEqual: () => arraysEqual,
326
326
  cutArrayAfterValue: () => cutArrayAfterValue,
327
327
  cutArrayBeforeValue: () => cutArrayBeforeValue,
328
+ filterArrays: () => filterArrays,
329
+ filterArraysFast: () => filterArraysFast,
328
330
  getFrequencyInArray: () => getFrequencyInArray,
329
331
  joinArrays: () => joinArrays,
330
332
  mergeAndCloneIfArray: () => mergeAndCloneIfArray,
@@ -433,6 +435,13 @@ var require_cjs = __commonJS({
433
435
  }
434
436
  return true;
435
437
  };
438
+ var filterArrays = (sourceArr, excludeArr) => {
439
+ return sourceArr.filter((item) => !excludeArr.includes(item));
440
+ };
441
+ var filterArraysFast = (sourceArr, excludeArr) => {
442
+ const excludeSet = new Set(excludeArr);
443
+ return sourceArr.filter((item) => !excludeSet.has(item));
444
+ };
436
445
  }
437
446
  });
438
447
  var require_string2 = __commonJS2({
@@ -622,9 +631,11 @@ var require_cjs = __commonJS({
622
631
  diff: () => diff,
623
632
  diffArrays: () => diffArrays,
624
633
  diffObjects: () => diffObjects,
634
+ excludeKeysFromObject: () => excludeKeysFromObject,
625
635
  exec: () => exec,
626
636
  flattenRecursive: () => flattenRecursive,
627
637
  hasOwnProperty: () => hasOwnProperty,
638
+ isCyclic: () => isCyclic,
628
639
  isEmpty: () => isEmpty,
629
640
  isEmptyObject: () => isEmptyObject,
630
641
  isEqualDeep: () => isEqualDeep,
@@ -750,20 +761,28 @@ var require_cjs = __commonJS({
750
761
  }
751
762
  return clone2;
752
763
  };
753
- var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
764
+ var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
765
+ if ((0, import_types.isObjectLike)(obj)) {
766
+ if (visited.has(obj)) {
767
+ return obj;
768
+ }
769
+ visited.add(obj);
770
+ }
754
771
  const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
755
772
  for (const prop in obj) {
756
773
  if (!Object.prototype.hasOwnProperty.call(obj, prop))
757
774
  continue;
758
775
  const objProp = obj[prop];
759
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
776
+ if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
760
777
  continue;
778
+ }
761
779
  if ((0, import_types.isObjectLike)(objProp)) {
762
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
780
+ o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
763
781
  } else if ((0, import_types.isFunction)(objProp) && options.window) {
764
782
  o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
765
- } else
783
+ } else {
766
784
  o[prop] = objProp;
785
+ }
767
786
  }
768
787
  return o;
769
788
  };
@@ -940,7 +959,7 @@ var require_cjs = __commonJS({
940
959
  };
941
960
  var stringToObject = (str, opts = { verbose: true }) => {
942
961
  try {
943
- return import_globals2.window.eval("(" + str + ")");
962
+ return str ? import_globals2.window.eval("(" + str + ")") : {};
944
963
  } catch (e) {
945
964
  if (opts.verbose)
946
965
  console.warn(e);
@@ -1020,20 +1039,27 @@ var require_cjs = __commonJS({
1020
1039
  return acc;
1021
1040
  }, deletedValues);
1022
1041
  };
1023
- var overwrite = (element, params, excludeFrom = []) => {
1024
- const { ref } = element;
1025
- const changes = {};
1042
+ var overwrite = (element, params, opts = {}) => {
1043
+ const { __ref: ref } = element;
1044
+ const excl = opts.exclude || [];
1045
+ const allowUnderscore = opts.preventUnderscore;
1046
+ const preventCaching = opts.preventCaching;
1026
1047
  for (const e in params) {
1027
- if (excludeFrom.includes(e) || e.startsWith("__"))
1048
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
1028
1049
  continue;
1029
1050
  const elementProp = element[e];
1030
1051
  const paramsProp = params[e];
1031
- if (paramsProp) {
1032
- ref.__cache[e] = changes[e] = elementProp;
1033
- ref[e] = paramsProp;
1052
+ if (paramsProp !== void 0) {
1053
+ element[e] = paramsProp;
1054
+ if (ref && !preventCaching) {
1055
+ ref.__cache[e] = elementProp;
1056
+ }
1057
+ if ((0, import_types.isObject)(opts.diff)) {
1058
+ diff[e] = elementProp;
1059
+ }
1034
1060
  }
1035
1061
  }
1036
- return changes;
1062
+ return element;
1037
1063
  };
1038
1064
  var overwriteShallow = (obj, params, excludeFrom = []) => {
1039
1065
  for (const e in params) {
@@ -1043,23 +1069,26 @@ var require_cjs = __commonJS({
1043
1069
  }
1044
1070
  return obj;
1045
1071
  };
1046
- var overwriteDeep = (obj, params, excludeFrom = [], visited = /* @__PURE__ */ new WeakMap()) => {
1072
+ var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
1073
+ const excl = opts.exclude || [];
1074
+ const forcedExclude = opts.preventForce ? [] : ["node", "window"];
1047
1075
  if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
1048
1076
  return params;
1049
1077
  }
1050
- if (visited.has(obj)) {
1078
+ if (visited.has(obj))
1051
1079
  return visited.get(obj);
1052
- }
1053
1080
  visited.set(obj, obj);
1054
1081
  for (const e in params) {
1055
- if (e === "__ref" || excludeFrom.includes(e) || e.startsWith("__"))
1082
+ if (!Object.hasOwnProperty.call(params, e))
1083
+ continue;
1084
+ if (excl.includes(e) || forcedExclude && e.startsWith("__"))
1056
1085
  continue;
1057
1086
  const objProp = obj[e];
1058
1087
  const paramsProp = params[e];
1059
1088
  if ((0, import_node.isDOMNode)(paramsProp)) {
1060
1089
  obj[e] = paramsProp;
1061
1090
  } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
1062
- obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
1091
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
1063
1092
  } else if (paramsProp !== void 0) {
1064
1093
  obj[e] = paramsProp;
1065
1094
  }
@@ -1222,6 +1251,30 @@ var require_cjs = __commonJS({
1222
1251
  }
1223
1252
  }
1224
1253
  };
1254
+ var isCyclic = (obj) => {
1255
+ const seenObjects = [];
1256
+ function detect(obj2) {
1257
+ if (obj2 && typeof obj2 === "object") {
1258
+ if (seenObjects.indexOf(obj2) !== -1) {
1259
+ return true;
1260
+ }
1261
+ seenObjects.push(obj2);
1262
+ for (const key in obj2) {
1263
+ if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
1264
+ console.log(obj2, "cycle at " + key);
1265
+ return true;
1266
+ }
1267
+ }
1268
+ }
1269
+ return false;
1270
+ }
1271
+ return detect(obj);
1272
+ };
1273
+ var excludeKeysFromObject = (obj, excludedKeys) => {
1274
+ const result = { ...obj };
1275
+ excludedKeys.forEach((key) => delete result[key]);
1276
+ return result;
1277
+ };
1225
1278
  }
1226
1279
  });
1227
1280
  var require_function2 = __commonJS2({
@@ -1631,6 +1684,8 @@ var require_cjs = __commonJS({
1631
1684
  return /^[a-z]*$/.test(firstCharKey);
1632
1685
  };
1633
1686
  var addAdditionalExtend = (newExtend, element) => {
1687
+ if (!newExtend)
1688
+ return element;
1634
1689
  const { extend: elementExtend } = element;
1635
1690
  const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
1636
1691
  const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
@@ -1638,8 +1693,23 @@ var require_cjs = __commonJS({
1638
1693
  return { ...element, extend };
1639
1694
  };
1640
1695
  var checkIfSugar = (element, parent, key) => {
1641
- const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1696
+ const {
1697
+ extend,
1698
+ props,
1699
+ childExtend,
1700
+ extends: extendProps,
1701
+ childrenExtends,
1702
+ childProps,
1703
+ children,
1704
+ on,
1705
+ $collection,
1706
+ $stateCollection,
1707
+ $propsCollection
1708
+ } = element;
1642
1709
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1710
+ if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
1711
+ element.error("Sugar component includes params for builtin components");
1712
+ }
1643
1713
  return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1644
1714
  };
1645
1715
  var extendizeByKey = (element, parent, key) => {
@@ -1651,11 +1721,11 @@ var require_cjs = __commonJS({
1651
1721
  if (element === isExtendKeyComponent)
1652
1722
  return element;
1653
1723
  else if (isSugar) {
1654
- const newElem = {
1724
+ const newElem = addAdditionalExtend(element.extends, {
1655
1725
  extend: extendFromKey,
1656
1726
  tag,
1657
1727
  props: { ...element }
1658
- };
1728
+ });
1659
1729
  if (childrenExtends)
1660
1730
  newElem.childExtend = childrenExtends;
1661
1731
  return newElem;
@@ -2311,6 +2381,8 @@ var require_array = __commonJS({
2311
2381
  arraysEqual: () => arraysEqual,
2312
2382
  cutArrayAfterValue: () => cutArrayAfterValue,
2313
2383
  cutArrayBeforeValue: () => cutArrayBeforeValue,
2384
+ filterArrays: () => filterArrays,
2385
+ filterArraysFast: () => filterArraysFast,
2314
2386
  getFrequencyInArray: () => getFrequencyInArray,
2315
2387
  joinArrays: () => joinArrays,
2316
2388
  mergeAndCloneIfArray: () => mergeAndCloneIfArray,
@@ -2419,6 +2491,13 @@ var require_array = __commonJS({
2419
2491
  }
2420
2492
  return true;
2421
2493
  };
2494
+ var filterArrays = (sourceArr, excludeArr) => {
2495
+ return sourceArr.filter((item) => !excludeArr.includes(item));
2496
+ };
2497
+ var filterArraysFast = (sourceArr, excludeArr) => {
2498
+ const excludeSet = new Set(excludeArr);
2499
+ return sourceArr.filter((item) => !excludeSet.has(item));
2500
+ };
2422
2501
  }
2423
2502
  });
2424
2503
 
@@ -2612,9 +2691,11 @@ var require_object = __commonJS({
2612
2691
  diff: () => diff,
2613
2692
  diffArrays: () => diffArrays,
2614
2693
  diffObjects: () => diffObjects,
2694
+ excludeKeysFromObject: () => excludeKeysFromObject,
2615
2695
  exec: () => exec,
2616
2696
  flattenRecursive: () => flattenRecursive,
2617
2697
  hasOwnProperty: () => hasOwnProperty,
2698
+ isCyclic: () => isCyclic,
2618
2699
  isEmpty: () => isEmpty,
2619
2700
  isEmptyObject: () => isEmptyObject,
2620
2701
  isEqualDeep: () => isEqualDeep,
@@ -2740,20 +2821,28 @@ var require_object = __commonJS({
2740
2821
  }
2741
2822
  return clone2;
2742
2823
  };
2743
- var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
2824
+ var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
2825
+ if ((0, import_types.isObjectLike)(obj)) {
2826
+ if (visited.has(obj)) {
2827
+ return obj;
2828
+ }
2829
+ visited.add(obj);
2830
+ }
2744
2831
  const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
2745
2832
  for (const prop in obj) {
2746
2833
  if (!Object.prototype.hasOwnProperty.call(obj, prop))
2747
2834
  continue;
2748
2835
  const objProp = obj[prop];
2749
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
2836
+ if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
2750
2837
  continue;
2838
+ }
2751
2839
  if ((0, import_types.isObjectLike)(objProp)) {
2752
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
2840
+ o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
2753
2841
  } else if ((0, import_types.isFunction)(objProp) && options.window) {
2754
2842
  o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
2755
- } else
2843
+ } else {
2756
2844
  o[prop] = objProp;
2845
+ }
2757
2846
  }
2758
2847
  return o;
2759
2848
  };
@@ -2930,7 +3019,7 @@ var require_object = __commonJS({
2930
3019
  };
2931
3020
  var stringToObject = (str, opts = { verbose: true }) => {
2932
3021
  try {
2933
- return import_globals2.window.eval("(" + str + ")");
3022
+ return str ? import_globals2.window.eval("(" + str + ")") : {};
2934
3023
  } catch (e) {
2935
3024
  if (opts.verbose)
2936
3025
  console.warn(e);
@@ -3010,20 +3099,27 @@ var require_object = __commonJS({
3010
3099
  return acc;
3011
3100
  }, deletedValues);
3012
3101
  };
3013
- var overwrite = (element, params, excludeFrom = []) => {
3014
- const { ref } = element;
3015
- const changes = {};
3102
+ var overwrite = (element, params, opts = {}) => {
3103
+ const { __ref: ref } = element;
3104
+ const excl = opts.exclude || [];
3105
+ const allowUnderscore = opts.preventUnderscore;
3106
+ const preventCaching = opts.preventCaching;
3016
3107
  for (const e in params) {
3017
- if (excludeFrom.includes(e) || e.startsWith("__"))
3108
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
3018
3109
  continue;
3019
3110
  const elementProp = element[e];
3020
3111
  const paramsProp = params[e];
3021
- if (paramsProp) {
3022
- ref.__cache[e] = changes[e] = elementProp;
3023
- ref[e] = paramsProp;
3112
+ if (paramsProp !== void 0) {
3113
+ element[e] = paramsProp;
3114
+ if (ref && !preventCaching) {
3115
+ ref.__cache[e] = elementProp;
3116
+ }
3117
+ if ((0, import_types.isObject)(opts.diff)) {
3118
+ diff[e] = elementProp;
3119
+ }
3024
3120
  }
3025
3121
  }
3026
- return changes;
3122
+ return element;
3027
3123
  };
3028
3124
  var overwriteShallow = (obj, params, excludeFrom = []) => {
3029
3125
  for (const e in params) {
@@ -3033,23 +3129,26 @@ var require_object = __commonJS({
3033
3129
  }
3034
3130
  return obj;
3035
3131
  };
3036
- var overwriteDeep = (obj, params, excludeFrom = [], visited = /* @__PURE__ */ new WeakMap()) => {
3132
+ var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
3133
+ const excl = opts.exclude || [];
3134
+ const forcedExclude = opts.preventForce ? [] : ["node", "window"];
3037
3135
  if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
3038
3136
  return params;
3039
3137
  }
3040
- if (visited.has(obj)) {
3138
+ if (visited.has(obj))
3041
3139
  return visited.get(obj);
3042
- }
3043
3140
  visited.set(obj, obj);
3044
3141
  for (const e in params) {
3045
- if (e === "__ref" || excludeFrom.includes(e) || e.startsWith("__"))
3142
+ if (!Object.hasOwnProperty.call(params, e))
3143
+ continue;
3144
+ if (excl.includes(e) || forcedExclude && e.startsWith("__"))
3046
3145
  continue;
3047
3146
  const objProp = obj[e];
3048
3147
  const paramsProp = params[e];
3049
3148
  if ((0, import_node.isDOMNode)(paramsProp)) {
3050
3149
  obj[e] = paramsProp;
3051
3150
  } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
3052
- obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
3151
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
3053
3152
  } else if (paramsProp !== void 0) {
3054
3153
  obj[e] = paramsProp;
3055
3154
  }
@@ -3212,6 +3311,30 @@ var require_object = __commonJS({
3212
3311
  }
3213
3312
  }
3214
3313
  };
3314
+ var isCyclic = (obj) => {
3315
+ const seenObjects = [];
3316
+ function detect(obj2) {
3317
+ if (obj2 && typeof obj2 === "object") {
3318
+ if (seenObjects.indexOf(obj2) !== -1) {
3319
+ return true;
3320
+ }
3321
+ seenObjects.push(obj2);
3322
+ for (const key in obj2) {
3323
+ if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
3324
+ console.log(obj2, "cycle at " + key);
3325
+ return true;
3326
+ }
3327
+ }
3328
+ }
3329
+ return false;
3330
+ }
3331
+ return detect(obj);
3332
+ };
3333
+ var excludeKeysFromObject = (obj, excludedKeys) => {
3334
+ const result = { ...obj };
3335
+ excludedKeys.forEach((key) => delete result[key]);
3336
+ return result;
3337
+ };
3215
3338
  }
3216
3339
  });
3217
3340
 
@@ -3631,6 +3754,8 @@ var require_component = __commonJS({
3631
3754
  return /^[a-z]*$/.test(firstCharKey);
3632
3755
  };
3633
3756
  var addAdditionalExtend = (newExtend, element) => {
3757
+ if (!newExtend)
3758
+ return element;
3634
3759
  const { extend: elementExtend } = element;
3635
3760
  const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
3636
3761
  const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
@@ -3638,8 +3763,23 @@ var require_component = __commonJS({
3638
3763
  return { ...element, extend };
3639
3764
  };
3640
3765
  var checkIfSugar = (element, parent, key) => {
3641
- const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
3766
+ const {
3767
+ extend,
3768
+ props,
3769
+ childExtend,
3770
+ extends: extendProps,
3771
+ childrenExtends,
3772
+ childProps,
3773
+ children,
3774
+ on,
3775
+ $collection,
3776
+ $stateCollection,
3777
+ $propsCollection
3778
+ } = element;
3642
3779
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
3780
+ if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
3781
+ element.error("Sugar component includes params for builtin components");
3782
+ }
3643
3783
  return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3644
3784
  };
3645
3785
  var extendizeByKey = (element, parent, key) => {
@@ -3651,11 +3791,11 @@ var require_component = __commonJS({
3651
3791
  if (element === isExtendKeyComponent)
3652
3792
  return element;
3653
3793
  else if (isSugar) {
3654
- const newElem = {
3794
+ const newElem = addAdditionalExtend(element.extends, {
3655
3795
  extend: extendFromKey,
3656
3796
  tag,
3657
3797
  props: { ...element }
3658
- };
3798
+ });
3659
3799
  if (childrenExtends)
3660
3800
  newElem.childExtend = childrenExtends;
3661
3801
  return newElem;