@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.
@@ -300,6 +300,7 @@ var require_array = __commonJS({
300
300
  addItemAfterEveryElement: () => addItemAfterEveryElement,
301
301
  arrayContainsOtherArray: () => arrayContainsOtherArray,
302
302
  arraysEqual: () => arraysEqual,
303
+ checkIfStringIsInArray: () => checkIfStringIsInArray,
303
304
  cutArrayAfterValue: () => cutArrayAfterValue,
304
305
  cutArrayBeforeValue: () => cutArrayBeforeValue,
305
306
  filterArrays: () => filterArrays,
@@ -346,11 +347,11 @@ var require_array = __commonJS({
346
347
  var joinArrays = (...arrays) => {
347
348
  return [].concat(...arrays);
348
349
  };
349
- var mergeArray = (arr, excludeFrom = []) => {
350
- return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepCloneWithExtend)(c, excludeFrom), excludeFrom), {});
350
+ var mergeArray = (arr, exclude = []) => {
351
+ return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepClone)(c, { exclude }), exclude), {});
351
352
  };
352
353
  var mergeAndCloneIfArray = (obj) => {
353
- return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepCloneWithExtend)(obj);
354
+ return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepClone)(obj);
354
355
  };
355
356
  var cutArrayBeforeValue = (arr, value) => {
356
357
  const index = arr.indexOf(value);
@@ -419,6 +420,11 @@ var require_array = __commonJS({
419
420
  const excludeSet = new Set(excludeArr);
420
421
  return sourceArr.filter((item) => !excludeSet.has(item));
421
422
  };
423
+ var checkIfStringIsInArray = (string, arr) => {
424
+ if (!string)
425
+ return;
426
+ return arr.filter((v) => string.includes(v)).length;
427
+ };
422
428
  }
423
429
  });
424
430
 
@@ -473,14 +479,15 @@ var require_string = __commonJS({
473
479
  2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
474
480
  3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
475
481
  };
476
- var replaceLiteralsWithObjectFields = (str, state, options = {}) => {
482
+ function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
477
483
  if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
478
484
  return str;
479
485
  const reg = brackRegex[options.bracketsLength || 2];
486
+ const obj = forcedState || this.state || {};
480
487
  return str.replace(reg, (_, parentPath, variable) => {
481
488
  if (parentPath) {
482
489
  const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
483
- let parentState = state;
490
+ let parentState = obj;
484
491
  for (let i = 0; i < parentLevels; i++) {
485
492
  parentState = parentState.parent;
486
493
  if (!parentState) {
@@ -490,11 +497,11 @@ var require_string = __commonJS({
490
497
  const value = parentState[variable.trim()];
491
498
  return value !== void 0 ? `${value}` : "";
492
499
  } else {
493
- const value = state[variable.trim()];
500
+ const value = obj[variable.trim()];
494
501
  return value !== void 0 ? `${value}` : "";
495
502
  }
496
503
  });
497
- };
504
+ }
498
505
  var lowercaseFirstLetter = (inputString) => {
499
506
  return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`;
500
507
  };
@@ -599,8 +606,6 @@ var require_object = __commonJS({
599
606
  createNestedObject: () => createNestedObject,
600
607
  createObjectWithoutPrototype: () => createObjectWithoutPrototype,
601
608
  deepClone: () => deepClone2,
602
- deepCloneExclude: () => deepCloneExclude,
603
- deepCloneWithExtend: () => deepCloneWithExtend,
604
609
  deepContains: () => deepContains,
605
610
  deepDestringify: () => deepDestringify,
606
611
  deepDiff: () => deepDiff,
@@ -694,78 +699,56 @@ var require_object = __commonJS({
694
699
  }
695
700
  return o;
696
701
  };
697
- var deepCloneExclude = (obj, excludeFrom = []) => {
698
- if ((0, import_types.isArray)(obj)) {
699
- return obj.map((x) => deepCloneExclude(x, excludeFrom));
700
- }
701
- const o = {};
702
- for (const k in obj) {
703
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, k);
704
- if (!hasOwnProperty2 || excludeFrom.includes(k) || k.startsWith("__"))
705
- continue;
706
- let v = obj[k];
707
- if (k === "extend" && (0, import_types.isArray)(v)) {
708
- v = mergeArrayExclude(v, excludeFrom);
709
- }
710
- if ((0, import_types.isArray)(v)) {
711
- o[k] = v.map((x) => deepCloneExclude(x, excludeFrom));
712
- } else if ((0, import_types.isObject)(v)) {
713
- o[k] = deepCloneExclude(v, excludeFrom);
714
- } else
715
- o[k] = v;
716
- }
717
- return o;
718
- };
719
- var mergeArrayExclude = (arr, excl = []) => {
720
- return arr.reduce((acc, curr) => deepMerge2(acc, deepCloneExclude(curr, excl)), {});
702
+ var mergeArrayExclude = (arr, exclude = []) => {
703
+ return arr.reduce((acc, curr) => deepMerge2(acc, deepClone2(curr, { exclude })), {});
721
704
  };
722
- var deepClone2 = (obj, exclude = [], cleanUndefined = false, visited = /* @__PURE__ */ new WeakMap()) => {
723
- if (!(0, import_types.isObjectLike)(obj) || (0, import_node.isDOMNode)(obj))
705
+ var deepClone2 = (obj, options = {}) => {
706
+ const {
707
+ exclude = [],
708
+ cleanUndefined = false,
709
+ cleanNull = false,
710
+ window: targetWindow,
711
+ visited = /* @__PURE__ */ new WeakMap(),
712
+ handleExtend = false
713
+ } = options;
714
+ if (!(0, import_types.isObjectLike)(obj) || (0, import_node.isDOMNode)(obj)) {
724
715
  return obj;
725
- if (visited.has(obj))
716
+ }
717
+ if (visited.has(obj)) {
726
718
  return visited.get(obj);
727
- const clone2 = (0, import_types.isArray)(obj) ? [] : {};
719
+ }
720
+ const clone2 = targetWindow ? (0, import_types.isArray)(obj) ? new targetWindow.Array() : new targetWindow.Object() : (0, import_types.isArray)(obj) ? [] : {};
728
721
  visited.set(obj, clone2);
729
722
  for (const key in obj) {
730
- if (Object.prototype.hasOwnProperty.call(obj, key) && !exclude.includes(key)) {
731
- const value = obj[key];
732
- if ((0, import_node.isDOMNode)(value)) {
733
- clone2[key] = value;
734
- } else if (key === "extend" && (0, import_types.isArray)(value)) {
735
- clone2[key] = (0, import_array.mergeArray)(value, exclude);
736
- } else if ((0, import_types.isObjectLike)(value)) {
737
- clone2[key] = deepClone2(value, exclude, cleanUndefined, visited);
738
- } else {
739
- clone2[key] = value;
740
- }
741
- }
742
- }
743
- return clone2;
744
- };
745
- var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
746
- if ((0, import_types.isObjectLike)(obj)) {
747
- if (visited.has(obj)) {
748
- return obj;
723
+ if (!Object.prototype.hasOwnProperty.call(obj, key))
724
+ continue;
725
+ if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
726
+ continue;
727
+ const value = obj[key];
728
+ if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value))
729
+ continue;
730
+ if ((0, import_node.isDOMNode)(value)) {
731
+ clone2[key] = value;
732
+ continue;
749
733
  }
750
- visited.add(obj);
751
- }
752
- const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
753
- for (const prop in obj) {
754
- if (!Object.prototype.hasOwnProperty.call(obj, prop))
734
+ if (handleExtend && key === "extend" && (0, import_types.isArray)(value)) {
735
+ clone2[key] = (0, import_array.mergeArray)(value, exclude);
755
736
  continue;
756
- const objProp = obj[prop];
757
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
737
+ }
738
+ if ((0, import_types.isFunction)(value) && targetWindow) {
739
+ clone2[key] = targetWindow.eval("(" + value.toString() + ")");
758
740
  continue;
759
741
  }
760
- if ((0, import_types.isObjectLike)(objProp)) {
761
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
762
- } else if ((0, import_types.isFunction)(objProp) && options.window) {
763
- o[prop] = (options.window || import_globals.window).eval("(" + objProp.toString() + ")");
742
+ if ((0, import_types.isObjectLike)(value)) {
743
+ clone2[key] = deepClone2(value, {
744
+ ...options,
745
+ visited
746
+ });
764
747
  } else {
765
- o[prop] = objProp;
748
+ clone2[key] = value;
766
749
  }
767
750
  }
768
- return o;
751
+ return clone2;
769
752
  };
770
753
  var deepStringify = (obj, stringified = {}) => {
771
754
  var _a, _b;
@@ -1675,6 +1658,7 @@ var require_component = __commonJS({
1675
1658
  checkIfKeyIsProperty: () => checkIfKeyIsProperty,
1676
1659
  checkIfSugar: () => checkIfSugar,
1677
1660
  extendizeByKey: () => extendizeByKey,
1661
+ extractComponentKeyFromKey: () => extractComponentKeyFromKey,
1678
1662
  getCapitalCaseKeys: () => getCapitalCaseKeys,
1679
1663
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1680
1664
  getExtendsInElement: () => getExtendsInElement,
@@ -1731,11 +1715,14 @@ var require_component = __commonJS({
1731
1715
  }
1732
1716
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
1733
1717
  };
1718
+ var extractComponentKeyFromKey = (key) => {
1719
+ return key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1720
+ };
1734
1721
  var extendizeByKey = (element, parent, key) => {
1735
1722
  const { context } = parent;
1736
1723
  const { tag, extend, childExtends } = element;
1737
1724
  const isSugar = checkIfSugar(element, parent, key);
1738
- const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1725
+ const extendFromKey = extractComponentKeyFromKey(key);
1739
1726
  const isExtendKeyComponent = context && context.components[extendFromKey];
1740
1727
  if (element === isExtendKeyComponent)
1741
1728
  return element;
@@ -1784,7 +1771,7 @@ var require_component = __commonJS({
1784
1771
  if (newChild === null)
1785
1772
  assignChild(null);
1786
1773
  else if (!childElem)
1787
- assignChild((0, import__.deepCloneWithExtend)(newChild));
1774
+ assignChild((0, import__.deepClone)(newChild));
1788
1775
  else {
1789
1776
  const isSugarChildElem = checkIfSugar(childElem, parent, key);
1790
1777
  if (isSugarChildElem)
@@ -1855,7 +1842,7 @@ var require_component = __commonJS({
1855
1842
  if (checkIfKeyIsComponent(key)) {
1856
1843
  result.push(key);
1857
1844
  }
1858
- if (key === "extend") {
1845
+ if (key === "extend" || key === "extends") {
1859
1846
  if (typeof o[key] === "string") {
1860
1847
  result.push(o[key]);
1861
1848
  } else if (Array.isArray(o[key])) {