@symbo.ls/scratch 2.11.470 → 2.11.497

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.
@@ -336,6 +336,7 @@ var require_array = __commonJS({
336
336
  addItemAfterEveryElement: () => addItemAfterEveryElement,
337
337
  arrayContainsOtherArray: () => arrayContainsOtherArray,
338
338
  arraysEqual: () => arraysEqual,
339
+ checkIfStringIsInArray: () => checkIfStringIsInArray,
339
340
  cutArrayAfterValue: () => cutArrayAfterValue,
340
341
  cutArrayBeforeValue: () => cutArrayBeforeValue,
341
342
  filterArrays: () => filterArrays,
@@ -382,11 +383,11 @@ var require_array = __commonJS({
382
383
  var joinArrays = (...arrays) => {
383
384
  return [].concat(...arrays);
384
385
  };
385
- var mergeArray = (arr, excludeFrom = []) => {
386
- return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepCloneWithExtend)(c, excludeFrom), excludeFrom), {});
386
+ var mergeArray = (arr, exclude = []) => {
387
+ return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepClone)(c, { exclude }), exclude), {});
387
388
  };
388
389
  var mergeAndCloneIfArray = (obj) => {
389
- return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepCloneWithExtend)(obj);
390
+ return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepClone)(obj);
390
391
  };
391
392
  var cutArrayBeforeValue = (arr, value) => {
392
393
  const index = arr.indexOf(value);
@@ -455,6 +456,11 @@ var require_array = __commonJS({
455
456
  const excludeSet = new Set(excludeArr);
456
457
  return sourceArr.filter((item) => !excludeSet.has(item));
457
458
  };
459
+ var checkIfStringIsInArray = (string, arr) => {
460
+ if (!string)
461
+ return;
462
+ return arr.filter((v) => string.includes(v)).length;
463
+ };
458
464
  }
459
465
  });
460
466
 
@@ -509,14 +515,15 @@ var require_string = __commonJS({
509
515
  2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
510
516
  3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
511
517
  };
512
- var replaceLiteralsWithObjectFields = (str, state, options = {}) => {
518
+ function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
513
519
  if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
514
520
  return str;
515
521
  const reg = brackRegex[options.bracketsLength || 2];
522
+ const obj = forcedState || this.state || {};
516
523
  return str.replace(reg, (_, parentPath, variable) => {
517
524
  if (parentPath) {
518
525
  const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
519
- let parentState = state;
526
+ let parentState = obj;
520
527
  for (let i = 0; i < parentLevels; i++) {
521
528
  parentState = parentState.parent;
522
529
  if (!parentState) {
@@ -526,11 +533,11 @@ var require_string = __commonJS({
526
533
  const value = parentState[variable.trim()];
527
534
  return value !== void 0 ? `${value}` : "";
528
535
  } else {
529
- const value = state[variable.trim()];
536
+ const value = obj[variable.trim()];
530
537
  return value !== void 0 ? `${value}` : "";
531
538
  }
532
539
  });
533
- };
540
+ }
534
541
  var lowercaseFirstLetter = (inputString) => {
535
542
  return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`;
536
543
  };
@@ -635,8 +642,6 @@ var require_object = __commonJS({
635
642
  createNestedObject: () => createNestedObject,
636
643
  createObjectWithoutPrototype: () => createObjectWithoutPrototype,
637
644
  deepClone: () => deepClone,
638
- deepCloneExclude: () => deepCloneExclude,
639
- deepCloneWithExtend: () => deepCloneWithExtend,
640
645
  deepContains: () => deepContains,
641
646
  deepDestringify: () => deepDestringify,
642
647
  deepDiff: () => deepDiff,
@@ -730,78 +735,56 @@ var require_object = __commonJS({
730
735
  }
731
736
  return o;
732
737
  };
733
- var deepCloneExclude = (obj, excludeFrom = []) => {
734
- if ((0, import_types.isArray)(obj)) {
735
- return obj.map((x) => deepCloneExclude(x, excludeFrom));
736
- }
737
- const o = {};
738
- for (const k in obj) {
739
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, k);
740
- if (!hasOwnProperty2 || excludeFrom.includes(k) || k.startsWith("__"))
741
- continue;
742
- let v = obj[k];
743
- if (k === "extend" && (0, import_types.isArray)(v)) {
744
- v = mergeArrayExclude(v, excludeFrom);
745
- }
746
- if ((0, import_types.isArray)(v)) {
747
- o[k] = v.map((x) => deepCloneExclude(x, excludeFrom));
748
- } else if ((0, import_types.isObject)(v)) {
749
- o[k] = deepCloneExclude(v, excludeFrom);
750
- } else
751
- o[k] = v;
752
- }
753
- return o;
754
- };
755
- var mergeArrayExclude = (arr, excl = []) => {
756
- return arr.reduce((acc, curr) => deepMerge(acc, deepCloneExclude(curr, excl)), {});
738
+ var mergeArrayExclude = (arr, exclude = []) => {
739
+ return arr.reduce((acc, curr) => deepMerge(acc, deepClone(curr, { exclude })), {});
757
740
  };
758
- var deepClone = (obj, exclude = [], cleanUndefined = false, visited = /* @__PURE__ */ new WeakMap()) => {
759
- if (!(0, import_types.isObjectLike)(obj) || (0, import_node.isDOMNode)(obj))
741
+ var deepClone = (obj, options = {}) => {
742
+ const {
743
+ exclude = [],
744
+ cleanUndefined = false,
745
+ cleanNull = false,
746
+ window: targetWindow,
747
+ visited = /* @__PURE__ */ new WeakMap(),
748
+ handleExtend = false
749
+ } = options;
750
+ if (!(0, import_types.isObjectLike)(obj) || (0, import_node.isDOMNode)(obj)) {
760
751
  return obj;
761
- if (visited.has(obj))
752
+ }
753
+ if (visited.has(obj)) {
762
754
  return visited.get(obj);
763
- const clone2 = (0, import_types.isArray)(obj) ? [] : {};
755
+ }
756
+ const clone2 = targetWindow ? (0, import_types.isArray)(obj) ? new targetWindow.Array() : new targetWindow.Object() : (0, import_types.isArray)(obj) ? [] : {};
764
757
  visited.set(obj, clone2);
765
758
  for (const key in obj) {
766
- if (Object.prototype.hasOwnProperty.call(obj, key) && !exclude.includes(key)) {
767
- const value = obj[key];
768
- if ((0, import_node.isDOMNode)(value)) {
769
- clone2[key] = value;
770
- } else if (key === "extend" && (0, import_types.isArray)(value)) {
771
- clone2[key] = (0, import_array.mergeArray)(value, exclude);
772
- } else if ((0, import_types.isObjectLike)(value)) {
773
- clone2[key] = deepClone(value, exclude, cleanUndefined, visited);
774
- } else {
775
- clone2[key] = value;
776
- }
777
- }
778
- }
779
- return clone2;
780
- };
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;
759
+ if (!Object.prototype.hasOwnProperty.call(obj, key))
760
+ continue;
761
+ if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
762
+ continue;
763
+ const value = obj[key];
764
+ if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value))
765
+ continue;
766
+ if ((0, import_node.isDOMNode)(value)) {
767
+ clone2[key] = value;
768
+ continue;
785
769
  }
786
- visited.add(obj);
787
- }
788
- const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
789
- for (const prop in obj) {
790
- if (!Object.prototype.hasOwnProperty.call(obj, prop))
770
+ if (handleExtend && key === "extend" && (0, import_types.isArray)(value)) {
771
+ clone2[key] = (0, import_array.mergeArray)(value, exclude);
791
772
  continue;
792
- const objProp = obj[prop];
793
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
773
+ }
774
+ if ((0, import_types.isFunction)(value) && targetWindow) {
775
+ clone2[key] = targetWindow.eval("(" + value.toString() + ")");
794
776
  continue;
795
777
  }
796
- if ((0, import_types.isObjectLike)(objProp)) {
797
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
798
- } else if ((0, import_types.isFunction)(objProp) && options.window) {
799
- o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
778
+ if ((0, import_types.isObjectLike)(value)) {
779
+ clone2[key] = deepClone(value, {
780
+ ...options,
781
+ visited
782
+ });
800
783
  } else {
801
- o[prop] = objProp;
784
+ clone2[key] = value;
802
785
  }
803
786
  }
804
- return o;
787
+ return clone2;
805
788
  };
806
789
  var deepStringify = (obj, stringified = {}) => {
807
790
  var _a, _b;
@@ -1711,6 +1694,7 @@ var require_component = __commonJS({
1711
1694
  checkIfKeyIsProperty: () => checkIfKeyIsProperty,
1712
1695
  checkIfSugar: () => checkIfSugar,
1713
1696
  extendizeByKey: () => extendizeByKey,
1697
+ extractComponentKeyFromKey: () => extractComponentKeyFromKey,
1714
1698
  getCapitalCaseKeys: () => getCapitalCaseKeys,
1715
1699
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1716
1700
  getExtendsInElement: () => getExtendsInElement,
@@ -1767,11 +1751,14 @@ var require_component = __commonJS({
1767
1751
  }
1768
1752
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
1769
1753
  };
1754
+ var extractComponentKeyFromKey = (key) => {
1755
+ return key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1756
+ };
1770
1757
  var extendizeByKey = (element, parent, key) => {
1771
1758
  const { context } = parent;
1772
1759
  const { tag, extend, childExtends } = element;
1773
1760
  const isSugar = checkIfSugar(element, parent, key);
1774
- const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1761
+ const extendFromKey = extractComponentKeyFromKey(key);
1775
1762
  const isExtendKeyComponent = context && context.components[extendFromKey];
1776
1763
  if (element === isExtendKeyComponent)
1777
1764
  return element;
@@ -1820,7 +1807,7 @@ var require_component = __commonJS({
1820
1807
  if (newChild === null)
1821
1808
  assignChild(null);
1822
1809
  else if (!childElem)
1823
- assignChild((0, import__.deepCloneWithExtend)(newChild));
1810
+ assignChild((0, import__.deepClone)(newChild));
1824
1811
  else {
1825
1812
  const isSugarChildElem = checkIfSugar(childElem, parent, key);
1826
1813
  if (isSugarChildElem)
@@ -1891,7 +1878,7 @@ var require_component = __commonJS({
1891
1878
  if (checkIfKeyIsComponent(key)) {
1892
1879
  result.push(key);
1893
1880
  }
1894
- if (key === "extend") {
1881
+ if (key === "extend" || key === "extends") {
1895
1882
  if (typeof o[key] === "string") {
1896
1883
  result.push(o[key]);
1897
1884
  } else if (Array.isArray(o[key])) {