@symbo.ls/scratch 2.11.450 → 2.11.464

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,6 +648,7 @@ 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,
@@ -794,10 +804,10 @@ var require_object = __commonJS({
794
804
  return o;
795
805
  };
796
806
  var deepStringify = (obj, stringified = {}) => {
797
- var _a;
807
+ var _a, _b;
798
808
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
799
- console.warn("Trying to clone element or state at", obj);
800
- obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
809
+ (obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn("Trying to clone element or state at", obj);
810
+ obj = (_b = obj.parse) == null ? void 0 : _b.call(obj);
801
811
  }
802
812
  for (const prop in obj) {
803
813
  const objProp = obj[prop];
@@ -867,7 +877,7 @@ var require_object = __commonJS({
867
877
  if ((0, import_types.isArray)(value)) {
868
878
  str += "[\n";
869
879
  for (const element of value) {
870
- if ((0, import_types.isObject)(element) && element !== null) {
880
+ if ((0, import_types.isObjectLike)(element) && element !== null) {
871
881
  str += `${spaces} ${objectToString(element, indent + 2)},
872
882
  `;
873
883
  } else if ((0, import_types.isString)(element)) {
@@ -966,7 +976,7 @@ var require_object = __commonJS({
966
976
  };
967
977
  var stringToObject = (str, opts = { verbose: true }) => {
968
978
  try {
969
- return import_globals2.window.eval("(" + str + ")");
979
+ return str ? import_globals2.window.eval("(" + str + ")") : {};
970
980
  } catch (e) {
971
981
  if (opts.verbose)
972
982
  console.warn(e);
@@ -1046,20 +1056,27 @@ var require_object = __commonJS({
1046
1056
  return acc;
1047
1057
  }, deletedValues);
1048
1058
  };
1049
- var overwrite = (element, params, excludeFrom = []) => {
1050
- const { ref } = element;
1051
- 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;
1052
1064
  for (const e in params) {
1053
- if (excludeFrom.includes(e) || e.startsWith("__"))
1065
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
1054
1066
  continue;
1055
1067
  const elementProp = element[e];
1056
1068
  const paramsProp = params[e];
1057
- if (paramsProp) {
1058
- ref.__cache[e] = changes[e] = elementProp;
1059
- 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
+ }
1060
1077
  }
1061
1078
  }
1062
- return changes;
1079
+ return element;
1063
1080
  };
1064
1081
  var overwriteShallow = (obj, params, excludeFrom = []) => {
1065
1082
  for (const e in params) {
@@ -1069,23 +1086,26 @@ var require_object = __commonJS({
1069
1086
  }
1070
1087
  return obj;
1071
1088
  };
1072
- 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"];
1073
1092
  if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
1074
1093
  return params;
1075
1094
  }
1076
- if (visited.has(obj)) {
1095
+ if (visited.has(obj))
1077
1096
  return visited.get(obj);
1078
- }
1079
1097
  visited.set(obj, obj);
1080
1098
  for (const e in params) {
1081
- 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("__"))
1082
1102
  continue;
1083
1103
  const objProp = obj[e];
1084
1104
  const paramsProp = params[e];
1085
1105
  if ((0, import_node.isDOMNode)(paramsProp)) {
1086
1106
  obj[e] = paramsProp;
1087
1107
  } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
1088
- obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
1108
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
1089
1109
  } else if (paramsProp !== void 0) {
1090
1110
  obj[e] = paramsProp;
1091
1111
  }
@@ -1267,6 +1287,11 @@ var require_object = __commonJS({
1267
1287
  }
1268
1288
  return detect(obj);
1269
1289
  };
1290
+ var excludeKeysFromObject = (obj, excludedKeys) => {
1291
+ const result = { ...obj };
1292
+ excludedKeys.forEach((key) => delete result[key]);
1293
+ return result;
1294
+ };
1270
1295
  }
1271
1296
  });
1272
1297
 
@@ -1422,9 +1447,11 @@ var require_cookie = __commonJS({
1422
1447
  var cookie_exports = {};
1423
1448
  __export2(cookie_exports, {
1424
1449
  getCookie: () => getCookie,
1450
+ getLocalStorage: () => getLocalStorage,
1425
1451
  isMobile: () => isMobile,
1426
1452
  removeCookie: () => removeCookie,
1427
- setCookie: () => setCookie
1453
+ setCookie: () => setCookie,
1454
+ setLocalStorage: () => setLocalStorage
1428
1455
  });
1429
1456
  module2.exports = __toCommonJS2(cookie_exports);
1430
1457
  var import_types = require_types();
@@ -1458,6 +1485,27 @@ var require_cookie = __commonJS({
1458
1485
  return;
1459
1486
  import_utils2.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1460
1487
  };
1488
+ function getLocalStorage(key) {
1489
+ let savedJSON;
1490
+ if (window.localStorage) {
1491
+ try {
1492
+ savedJSON = JSON.parse(window.localStorage.getItem(key));
1493
+ } catch (e) {
1494
+ }
1495
+ }
1496
+ if (typeof savedJSON !== "undefined") {
1497
+ return savedJSON;
1498
+ }
1499
+ }
1500
+ function setLocalStorage(key, data) {
1501
+ if (data && window.localStorage) {
1502
+ if (typeof data === "object") {
1503
+ window.localStorage.setItem(key, JSON.stringify(data));
1504
+ } else {
1505
+ window.localStorage.setItem(key, data);
1506
+ }
1507
+ }
1508
+ }
1461
1509
  }
1462
1510
  });
1463
1511
 
@@ -1661,7 +1709,9 @@ var require_component = __commonJS({
1661
1709
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1662
1710
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
1663
1711
  checkIfKeyIsProperty: () => checkIfKeyIsProperty,
1712
+ checkIfSugar: () => checkIfSugar,
1664
1713
  extendizeByKey: () => extendizeByKey,
1714
+ getCapitalCaseKeys: () => getCapitalCaseKeys,
1665
1715
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1666
1716
  getExtendsInElement: () => getExtendsInElement,
1667
1717
  hasVariantProp: () => hasVariantProp,
@@ -1686,6 +1736,8 @@ var require_component = __commonJS({
1686
1736
  return /^[a-z]*$/.test(firstCharKey);
1687
1737
  };
1688
1738
  var addAdditionalExtend = (newExtend, element) => {
1739
+ if (!newExtend)
1740
+ return element;
1689
1741
  const { extend: elementExtend } = element;
1690
1742
  const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
1691
1743
  const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
@@ -1693,26 +1745,44 @@ var require_component = __commonJS({
1693
1745
  return { ...element, extend };
1694
1746
  };
1695
1747
  var checkIfSugar = (element, parent, key) => {
1696
- const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1748
+ var _a;
1749
+ const {
1750
+ extend,
1751
+ props,
1752
+ childExtend,
1753
+ extends: extendProps,
1754
+ childExtends,
1755
+ childProps,
1756
+ children,
1757
+ on,
1758
+ $collection,
1759
+ $stateCollection,
1760
+ $propsCollection
1761
+ } = element;
1697
1762
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1698
- return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1763
+ if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
1764
+ const logErr = (_a = parent || element) == null ? void 0 : _a.error;
1765
+ if (logErr)
1766
+ logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
1767
+ }
1768
+ return !hasComponentAttrs || childProps || extendProps || children || childExtends;
1699
1769
  };
1700
1770
  var extendizeByKey = (element, parent, key) => {
1701
1771
  const { context } = parent;
1702
- const { tag, extend, childrenExtends } = element;
1703
- const isSugar = checkIfSugar(element);
1772
+ const { tag, extend, childExtends } = element;
1773
+ const isSugar = checkIfSugar(element, parent, key);
1704
1774
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1705
1775
  const isExtendKeyComponent = context && context.components[extendFromKey];
1706
1776
  if (element === isExtendKeyComponent)
1707
1777
  return element;
1708
1778
  else if (isSugar) {
1709
- const newElem = {
1779
+ const newElem = addAdditionalExtend(element.extends, {
1710
1780
  extend: extendFromKey,
1711
1781
  tag,
1712
1782
  props: { ...element }
1713
- };
1714
- if (childrenExtends)
1715
- newElem.childExtend = childrenExtends;
1783
+ });
1784
+ if (childExtends)
1785
+ newElem.childExtend = childExtends;
1716
1786
  return newElem;
1717
1787
  } else if (!extend || extend === true) {
1718
1788
  return {
@@ -1741,23 +1811,24 @@ var require_component = __commonJS({
1741
1811
  const childKey = childElems[i];
1742
1812
  const childElem = element[childKey];
1743
1813
  const newChild = element.props[childKey];
1814
+ const assignChild = (val) => {
1815
+ element[childKey] = val;
1816
+ delete element.props[childKey];
1817
+ };
1744
1818
  if (newChild == null ? void 0 : newChild.ignoreExtend)
1745
1819
  continue;
1746
- if (!childElem)
1747
- element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
1820
+ if (newChild === null)
1821
+ assignChild(null);
1822
+ else if (!childElem)
1823
+ assignChild((0, import__.deepCloneWithExtend)(newChild));
1748
1824
  else {
1749
- const isSugar = checkIfSugar(childElem);
1750
- if (!isSugar)
1825
+ const isSugarChildElem = checkIfSugar(childElem, parent, key);
1826
+ if (isSugarChildElem)
1751
1827
  continue;
1752
- const inheritedChildElem = element[childKey].props;
1753
- if ((0, import__.isObjectLike)(newChild)) {
1754
- (0, import__.overwriteDeep)(inheritedChildElem, newChild);
1755
- } else if ((0, import__.isFunction)(newChild)) {
1756
- element[childKey] = {
1757
- extend: element[childKey],
1758
- props: newChild
1759
- };
1760
- }
1828
+ assignChild({
1829
+ extend: element[childKey],
1830
+ props: newChild
1831
+ });
1761
1832
  }
1762
1833
  }
1763
1834
  };