@symbo.ls/scratch 2.11.450 → 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,6 +2691,7 @@ 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,
@@ -2939,7 +3019,7 @@ var require_object = __commonJS({
2939
3019
  };
2940
3020
  var stringToObject = (str, opts = { verbose: true }) => {
2941
3021
  try {
2942
- return import_globals2.window.eval("(" + str + ")");
3022
+ return str ? import_globals2.window.eval("(" + str + ")") : {};
2943
3023
  } catch (e) {
2944
3024
  if (opts.verbose)
2945
3025
  console.warn(e);
@@ -3019,20 +3099,27 @@ var require_object = __commonJS({
3019
3099
  return acc;
3020
3100
  }, deletedValues);
3021
3101
  };
3022
- var overwrite = (element, params, excludeFrom = []) => {
3023
- const { ref } = element;
3024
- 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;
3025
3107
  for (const e in params) {
3026
- if (excludeFrom.includes(e) || e.startsWith("__"))
3108
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
3027
3109
  continue;
3028
3110
  const elementProp = element[e];
3029
3111
  const paramsProp = params[e];
3030
- if (paramsProp) {
3031
- ref.__cache[e] = changes[e] = elementProp;
3032
- 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
+ }
3033
3120
  }
3034
3121
  }
3035
- return changes;
3122
+ return element;
3036
3123
  };
3037
3124
  var overwriteShallow = (obj, params, excludeFrom = []) => {
3038
3125
  for (const e in params) {
@@ -3042,23 +3129,26 @@ var require_object = __commonJS({
3042
3129
  }
3043
3130
  return obj;
3044
3131
  };
3045
- 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"];
3046
3135
  if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
3047
3136
  return params;
3048
3137
  }
3049
- if (visited.has(obj)) {
3138
+ if (visited.has(obj))
3050
3139
  return visited.get(obj);
3051
- }
3052
3140
  visited.set(obj, obj);
3053
3141
  for (const e in params) {
3054
- 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("__"))
3055
3145
  continue;
3056
3146
  const objProp = obj[e];
3057
3147
  const paramsProp = params[e];
3058
3148
  if ((0, import_node.isDOMNode)(paramsProp)) {
3059
3149
  obj[e] = paramsProp;
3060
3150
  } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
3061
- obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
3151
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
3062
3152
  } else if (paramsProp !== void 0) {
3063
3153
  obj[e] = paramsProp;
3064
3154
  }
@@ -3240,6 +3330,11 @@ var require_object = __commonJS({
3240
3330
  }
3241
3331
  return detect(obj);
3242
3332
  };
3333
+ var excludeKeysFromObject = (obj, excludedKeys) => {
3334
+ const result = { ...obj };
3335
+ excludedKeys.forEach((key) => delete result[key]);
3336
+ return result;
3337
+ };
3243
3338
  }
3244
3339
  });
3245
3340
 
@@ -3659,6 +3754,8 @@ var require_component = __commonJS({
3659
3754
  return /^[a-z]*$/.test(firstCharKey);
3660
3755
  };
3661
3756
  var addAdditionalExtend = (newExtend, element) => {
3757
+ if (!newExtend)
3758
+ return element;
3662
3759
  const { extend: elementExtend } = element;
3663
3760
  const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
3664
3761
  const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
@@ -3666,8 +3763,23 @@ var require_component = __commonJS({
3666
3763
  return { ...element, extend };
3667
3764
  };
3668
3765
  var checkIfSugar = (element, parent, key) => {
3669
- 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;
3670
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
+ }
3671
3783
  return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3672
3784
  };
3673
3785
  var extendizeByKey = (element, parent, key) => {
@@ -3679,11 +3791,11 @@ var require_component = __commonJS({
3679
3791
  if (element === isExtendKeyComponent)
3680
3792
  return element;
3681
3793
  else if (isSugar) {
3682
- const newElem = {
3794
+ const newElem = addAdditionalExtend(element.extends, {
3683
3795
  extend: extendFromKey,
3684
3796
  tag,
3685
3797
  props: { ...element }
3686
- };
3798
+ });
3687
3799
  if (childrenExtends)
3688
3800
  newElem.childExtend = childrenExtends;
3689
3801
  return newElem;