@symbo.ls/utils 2.11.446 → 2.11.469
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.
- package/dist/cjs/index.js +143 -44
- package/dist/cjs/scaling.js +143 -44
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -302,6 +302,8 @@ var require_array = __commonJS({
|
|
|
302
302
|
arraysEqual: () => arraysEqual,
|
|
303
303
|
cutArrayAfterValue: () => cutArrayAfterValue,
|
|
304
304
|
cutArrayBeforeValue: () => cutArrayBeforeValue,
|
|
305
|
+
filterArrays: () => filterArrays,
|
|
306
|
+
filterArraysFast: () => filterArraysFast,
|
|
305
307
|
getFrequencyInArray: () => getFrequencyInArray,
|
|
306
308
|
joinArrays: () => joinArrays,
|
|
307
309
|
mergeAndCloneIfArray: () => mergeAndCloneIfArray,
|
|
@@ -410,6 +412,13 @@ var require_array = __commonJS({
|
|
|
410
412
|
}
|
|
411
413
|
return true;
|
|
412
414
|
};
|
|
415
|
+
var filterArrays = (sourceArr, excludeArr) => {
|
|
416
|
+
return sourceArr.filter((item) => !excludeArr.includes(item));
|
|
417
|
+
};
|
|
418
|
+
var filterArraysFast = (sourceArr, excludeArr) => {
|
|
419
|
+
const excludeSet = new Set(excludeArr);
|
|
420
|
+
return sourceArr.filter((item) => !excludeSet.has(item));
|
|
421
|
+
};
|
|
413
422
|
}
|
|
414
423
|
});
|
|
415
424
|
|
|
@@ -603,9 +612,11 @@ var require_object = __commonJS({
|
|
|
603
612
|
diff: () => diff,
|
|
604
613
|
diffArrays: () => diffArrays,
|
|
605
614
|
diffObjects: () => diffObjects,
|
|
615
|
+
excludeKeysFromObject: () => excludeKeysFromObject,
|
|
606
616
|
exec: () => exec,
|
|
607
617
|
flattenRecursive: () => flattenRecursive,
|
|
608
618
|
hasOwnProperty: () => hasOwnProperty,
|
|
619
|
+
isCyclic: () => isCyclic,
|
|
609
620
|
isEmpty: () => isEmpty,
|
|
610
621
|
isEmptyObject: () => isEmptyObject,
|
|
611
622
|
isEqualDeep: () => isEqualDeep,
|
|
@@ -731,28 +742,36 @@ var require_object = __commonJS({
|
|
|
731
742
|
}
|
|
732
743
|
return clone2;
|
|
733
744
|
};
|
|
734
|
-
var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
|
|
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;
|
|
749
|
+
}
|
|
750
|
+
visited.add(obj);
|
|
751
|
+
}
|
|
735
752
|
const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
|
|
736
753
|
for (const prop in obj) {
|
|
737
754
|
if (!Object.prototype.hasOwnProperty.call(obj, prop))
|
|
738
755
|
continue;
|
|
739
756
|
const objProp = obj[prop];
|
|
740
|
-
if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
|
|
757
|
+
if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
|
|
741
758
|
continue;
|
|
759
|
+
}
|
|
742
760
|
if ((0, import_types.isObjectLike)(objProp)) {
|
|
743
|
-
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
|
|
761
|
+
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
|
|
744
762
|
} else if ((0, import_types.isFunction)(objProp) && options.window) {
|
|
745
763
|
o[prop] = (options.window || import_globals.window).eval("(" + objProp.toString() + ")");
|
|
746
|
-
} else
|
|
764
|
+
} else {
|
|
747
765
|
o[prop] = objProp;
|
|
766
|
+
}
|
|
748
767
|
}
|
|
749
768
|
return o;
|
|
750
769
|
};
|
|
751
770
|
var deepStringify = (obj, stringified = {}) => {
|
|
752
|
-
var _a;
|
|
771
|
+
var _a, _b;
|
|
753
772
|
if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
|
|
754
|
-
|
|
755
|
-
obj = (
|
|
773
|
+
(obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn("Trying to clone element or state at", obj);
|
|
774
|
+
obj = (_b = obj.parse) == null ? void 0 : _b.call(obj);
|
|
756
775
|
}
|
|
757
776
|
for (const prop in obj) {
|
|
758
777
|
const objProp = obj[prop];
|
|
@@ -822,7 +841,7 @@ var require_object = __commonJS({
|
|
|
822
841
|
if ((0, import_types.isArray)(value)) {
|
|
823
842
|
str += "[\n";
|
|
824
843
|
for (const element of value) {
|
|
825
|
-
if ((0, import_types.
|
|
844
|
+
if ((0, import_types.isObjectLike)(element) && element !== null) {
|
|
826
845
|
str += `${spaces} ${objectToString(element, indent + 2)},
|
|
827
846
|
`;
|
|
828
847
|
} else if ((0, import_types.isString)(element)) {
|
|
@@ -921,7 +940,7 @@ var require_object = __commonJS({
|
|
|
921
940
|
};
|
|
922
941
|
var stringToObject = (str, opts = { verbose: true }) => {
|
|
923
942
|
try {
|
|
924
|
-
return import_globals.window.eval("(" + str + ")");
|
|
943
|
+
return str ? import_globals.window.eval("(" + str + ")") : {};
|
|
925
944
|
} catch (e) {
|
|
926
945
|
if (opts.verbose)
|
|
927
946
|
console.warn(e);
|
|
@@ -1001,20 +1020,27 @@ var require_object = __commonJS({
|
|
|
1001
1020
|
return acc;
|
|
1002
1021
|
}, deletedValues);
|
|
1003
1022
|
};
|
|
1004
|
-
var overwrite = (element, params,
|
|
1005
|
-
const { ref } = element;
|
|
1006
|
-
const
|
|
1023
|
+
var overwrite = (element, params, opts = {}) => {
|
|
1024
|
+
const { __ref: ref } = element;
|
|
1025
|
+
const excl = opts.exclude || [];
|
|
1026
|
+
const allowUnderscore = opts.preventUnderscore;
|
|
1027
|
+
const preventCaching = opts.preventCaching;
|
|
1007
1028
|
for (const e in params) {
|
|
1008
|
-
if (
|
|
1029
|
+
if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
|
|
1009
1030
|
continue;
|
|
1010
1031
|
const elementProp = element[e];
|
|
1011
1032
|
const paramsProp = params[e];
|
|
1012
|
-
if (paramsProp) {
|
|
1013
|
-
|
|
1014
|
-
ref
|
|
1033
|
+
if (paramsProp !== void 0) {
|
|
1034
|
+
element[e] = paramsProp;
|
|
1035
|
+
if (ref && !preventCaching) {
|
|
1036
|
+
ref.__cache[e] = elementProp;
|
|
1037
|
+
}
|
|
1038
|
+
if ((0, import_types.isObject)(opts.diff)) {
|
|
1039
|
+
diff[e] = elementProp;
|
|
1040
|
+
}
|
|
1015
1041
|
}
|
|
1016
1042
|
}
|
|
1017
|
-
return
|
|
1043
|
+
return element;
|
|
1018
1044
|
};
|
|
1019
1045
|
var overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
1020
1046
|
for (const e in params) {
|
|
@@ -1024,23 +1050,26 @@ var require_object = __commonJS({
|
|
|
1024
1050
|
}
|
|
1025
1051
|
return obj;
|
|
1026
1052
|
};
|
|
1027
|
-
var overwriteDeep = (obj, params,
|
|
1053
|
+
var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
|
|
1054
|
+
const excl = opts.exclude || [];
|
|
1055
|
+
const forcedExclude = opts.preventForce ? [] : ["node", "window"];
|
|
1028
1056
|
if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
|
|
1029
1057
|
return params;
|
|
1030
1058
|
}
|
|
1031
|
-
if (visited.has(obj))
|
|
1059
|
+
if (visited.has(obj))
|
|
1032
1060
|
return visited.get(obj);
|
|
1033
|
-
}
|
|
1034
1061
|
visited.set(obj, obj);
|
|
1035
1062
|
for (const e in params) {
|
|
1036
|
-
if (
|
|
1063
|
+
if (!Object.hasOwnProperty.call(params, e))
|
|
1064
|
+
continue;
|
|
1065
|
+
if (excl.includes(e) || forcedExclude && e.startsWith("__"))
|
|
1037
1066
|
continue;
|
|
1038
1067
|
const objProp = obj[e];
|
|
1039
1068
|
const paramsProp = params[e];
|
|
1040
1069
|
if ((0, import_node.isDOMNode)(paramsProp)) {
|
|
1041
1070
|
obj[e] = paramsProp;
|
|
1042
1071
|
} else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
|
|
1043
|
-
obj[e] = overwriteDeep(objProp, paramsProp,
|
|
1072
|
+
obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
|
|
1044
1073
|
} else if (paramsProp !== void 0) {
|
|
1045
1074
|
obj[e] = paramsProp;
|
|
1046
1075
|
}
|
|
@@ -1203,6 +1232,30 @@ var require_object = __commonJS({
|
|
|
1203
1232
|
}
|
|
1204
1233
|
}
|
|
1205
1234
|
};
|
|
1235
|
+
var isCyclic = (obj) => {
|
|
1236
|
+
const seenObjects = [];
|
|
1237
|
+
function detect(obj2) {
|
|
1238
|
+
if (obj2 && typeof obj2 === "object") {
|
|
1239
|
+
if (seenObjects.indexOf(obj2) !== -1) {
|
|
1240
|
+
return true;
|
|
1241
|
+
}
|
|
1242
|
+
seenObjects.push(obj2);
|
|
1243
|
+
for (const key in obj2) {
|
|
1244
|
+
if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
|
|
1245
|
+
console.log(obj2, "cycle at " + key);
|
|
1246
|
+
return true;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return false;
|
|
1251
|
+
}
|
|
1252
|
+
return detect(obj);
|
|
1253
|
+
};
|
|
1254
|
+
var excludeKeysFromObject = (obj, excludedKeys) => {
|
|
1255
|
+
const result = { ...obj };
|
|
1256
|
+
excludedKeys.forEach((key) => delete result[key]);
|
|
1257
|
+
return result;
|
|
1258
|
+
};
|
|
1206
1259
|
}
|
|
1207
1260
|
});
|
|
1208
1261
|
|
|
@@ -1358,9 +1411,11 @@ var require_cookie = __commonJS({
|
|
|
1358
1411
|
var cookie_exports = {};
|
|
1359
1412
|
__export2(cookie_exports, {
|
|
1360
1413
|
getCookie: () => getCookie,
|
|
1414
|
+
getLocalStorage: () => getLocalStorage,
|
|
1361
1415
|
isMobile: () => isMobile,
|
|
1362
1416
|
removeCookie: () => removeCookie,
|
|
1363
|
-
setCookie: () => setCookie
|
|
1417
|
+
setCookie: () => setCookie,
|
|
1418
|
+
setLocalStorage: () => setLocalStorage
|
|
1364
1419
|
});
|
|
1365
1420
|
module2.exports = __toCommonJS2(cookie_exports);
|
|
1366
1421
|
var import_types = require_types();
|
|
@@ -1394,6 +1449,27 @@ var require_cookie = __commonJS({
|
|
|
1394
1449
|
return;
|
|
1395
1450
|
import_utils3.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
1396
1451
|
};
|
|
1452
|
+
function getLocalStorage(key) {
|
|
1453
|
+
let savedJSON;
|
|
1454
|
+
if (window.localStorage) {
|
|
1455
|
+
try {
|
|
1456
|
+
savedJSON = JSON.parse(window.localStorage.getItem(key));
|
|
1457
|
+
} catch (e) {
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (typeof savedJSON !== "undefined") {
|
|
1461
|
+
return savedJSON;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
function setLocalStorage(key, data) {
|
|
1465
|
+
if (data && window.localStorage) {
|
|
1466
|
+
if (typeof data === "object") {
|
|
1467
|
+
window.localStorage.setItem(key, JSON.stringify(data));
|
|
1468
|
+
} else {
|
|
1469
|
+
window.localStorage.setItem(key, data);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1397
1473
|
}
|
|
1398
1474
|
});
|
|
1399
1475
|
|
|
@@ -1597,7 +1673,9 @@ var require_component = __commonJS({
|
|
|
1597
1673
|
applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
|
|
1598
1674
|
checkIfKeyIsComponent: () => checkIfKeyIsComponent,
|
|
1599
1675
|
checkIfKeyIsProperty: () => checkIfKeyIsProperty,
|
|
1676
|
+
checkIfSugar: () => checkIfSugar,
|
|
1600
1677
|
extendizeByKey: () => extendizeByKey,
|
|
1678
|
+
getCapitalCaseKeys: () => getCapitalCaseKeys,
|
|
1601
1679
|
getChildrenComponentsByKey: () => getChildrenComponentsByKey,
|
|
1602
1680
|
getExtendsInElement: () => getExtendsInElement,
|
|
1603
1681
|
hasVariantProp: () => hasVariantProp,
|
|
@@ -1622,6 +1700,8 @@ var require_component = __commonJS({
|
|
|
1622
1700
|
return /^[a-z]*$/.test(firstCharKey);
|
|
1623
1701
|
};
|
|
1624
1702
|
var addAdditionalExtend = (newExtend, element) => {
|
|
1703
|
+
if (!newExtend)
|
|
1704
|
+
return element;
|
|
1625
1705
|
const { extend: elementExtend } = element;
|
|
1626
1706
|
const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
1627
1707
|
const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
|
|
@@ -1629,26 +1709,44 @@ var require_component = __commonJS({
|
|
|
1629
1709
|
return { ...element, extend };
|
|
1630
1710
|
};
|
|
1631
1711
|
var checkIfSugar = (element, parent, key) => {
|
|
1632
|
-
|
|
1712
|
+
var _a;
|
|
1713
|
+
const {
|
|
1714
|
+
extend,
|
|
1715
|
+
props,
|
|
1716
|
+
childExtend,
|
|
1717
|
+
extends: extendProps,
|
|
1718
|
+
childExtends,
|
|
1719
|
+
childProps,
|
|
1720
|
+
children,
|
|
1721
|
+
on,
|
|
1722
|
+
$collection,
|
|
1723
|
+
$stateCollection,
|
|
1724
|
+
$propsCollection
|
|
1725
|
+
} = element;
|
|
1633
1726
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
|
|
1634
|
-
|
|
1727
|
+
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
1728
|
+
const logErr = (_a = parent || element) == null ? void 0 : _a.error;
|
|
1729
|
+
if (logErr)
|
|
1730
|
+
logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
|
|
1731
|
+
}
|
|
1732
|
+
return !hasComponentAttrs || childProps || extendProps || children || childExtends;
|
|
1635
1733
|
};
|
|
1636
1734
|
var extendizeByKey = (element, parent, key) => {
|
|
1637
1735
|
const { context } = parent;
|
|
1638
|
-
const { tag, extend,
|
|
1639
|
-
const isSugar = checkIfSugar(element);
|
|
1736
|
+
const { tag, extend, childExtends } = element;
|
|
1737
|
+
const isSugar = checkIfSugar(element, parent, key);
|
|
1640
1738
|
const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
|
|
1641
1739
|
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
1642
1740
|
if (element === isExtendKeyComponent)
|
|
1643
1741
|
return element;
|
|
1644
1742
|
else if (isSugar) {
|
|
1645
|
-
const newElem = {
|
|
1743
|
+
const newElem = addAdditionalExtend(element.extends, {
|
|
1646
1744
|
extend: extendFromKey,
|
|
1647
1745
|
tag,
|
|
1648
1746
|
props: { ...element }
|
|
1649
|
-
};
|
|
1650
|
-
if (
|
|
1651
|
-
newElem.childExtend =
|
|
1747
|
+
});
|
|
1748
|
+
if (childExtends)
|
|
1749
|
+
newElem.childExtend = childExtends;
|
|
1652
1750
|
return newElem;
|
|
1653
1751
|
} else if (!extend || extend === true) {
|
|
1654
1752
|
return {
|
|
@@ -1677,23 +1775,24 @@ var require_component = __commonJS({
|
|
|
1677
1775
|
const childKey = childElems[i];
|
|
1678
1776
|
const childElem = element[childKey];
|
|
1679
1777
|
const newChild = element.props[childKey];
|
|
1778
|
+
const assignChild = (val) => {
|
|
1779
|
+
element[childKey] = val;
|
|
1780
|
+
delete element.props[childKey];
|
|
1781
|
+
};
|
|
1680
1782
|
if (newChild == null ? void 0 : newChild.ignoreExtend)
|
|
1681
1783
|
continue;
|
|
1682
|
-
if (
|
|
1683
|
-
|
|
1784
|
+
if (newChild === null)
|
|
1785
|
+
assignChild(null);
|
|
1786
|
+
else if (!childElem)
|
|
1787
|
+
assignChild((0, import__.deepCloneWithExtend)(newChild));
|
|
1684
1788
|
else {
|
|
1685
|
-
const
|
|
1686
|
-
if (
|
|
1789
|
+
const isSugarChildElem = checkIfSugar(childElem, parent, key);
|
|
1790
|
+
if (isSugarChildElem)
|
|
1687
1791
|
continue;
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
}
|
|
1692
|
-
element[childKey] = {
|
|
1693
|
-
extend: element[childKey],
|
|
1694
|
-
props: newChild
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1792
|
+
assignChild({
|
|
1793
|
+
extend: element[childKey],
|
|
1794
|
+
props: newChild
|
|
1795
|
+
});
|
|
1697
1796
|
}
|
|
1698
1797
|
}
|
|
1699
1798
|
};
|
package/dist/cjs/scaling.js
CHANGED
|
@@ -302,6 +302,8 @@ var require_array = __commonJS({
|
|
|
302
302
|
arraysEqual: () => arraysEqual,
|
|
303
303
|
cutArrayAfterValue: () => cutArrayAfterValue,
|
|
304
304
|
cutArrayBeforeValue: () => cutArrayBeforeValue,
|
|
305
|
+
filterArrays: () => filterArrays,
|
|
306
|
+
filterArraysFast: () => filterArraysFast,
|
|
305
307
|
getFrequencyInArray: () => getFrequencyInArray,
|
|
306
308
|
joinArrays: () => joinArrays,
|
|
307
309
|
mergeAndCloneIfArray: () => mergeAndCloneIfArray,
|
|
@@ -410,6 +412,13 @@ var require_array = __commonJS({
|
|
|
410
412
|
}
|
|
411
413
|
return true;
|
|
412
414
|
};
|
|
415
|
+
var filterArrays = (sourceArr, excludeArr) => {
|
|
416
|
+
return sourceArr.filter((item) => !excludeArr.includes(item));
|
|
417
|
+
};
|
|
418
|
+
var filterArraysFast = (sourceArr, excludeArr) => {
|
|
419
|
+
const excludeSet = new Set(excludeArr);
|
|
420
|
+
return sourceArr.filter((item) => !excludeSet.has(item));
|
|
421
|
+
};
|
|
413
422
|
}
|
|
414
423
|
});
|
|
415
424
|
|
|
@@ -603,9 +612,11 @@ var require_object = __commonJS({
|
|
|
603
612
|
diff: () => diff,
|
|
604
613
|
diffArrays: () => diffArrays,
|
|
605
614
|
diffObjects: () => diffObjects,
|
|
615
|
+
excludeKeysFromObject: () => excludeKeysFromObject,
|
|
606
616
|
exec: () => exec,
|
|
607
617
|
flattenRecursive: () => flattenRecursive,
|
|
608
618
|
hasOwnProperty: () => hasOwnProperty,
|
|
619
|
+
isCyclic: () => isCyclic,
|
|
609
620
|
isEmpty: () => isEmpty,
|
|
610
621
|
isEmptyObject: () => isEmptyObject,
|
|
611
622
|
isEqualDeep: () => isEqualDeep,
|
|
@@ -731,28 +742,36 @@ var require_object = __commonJS({
|
|
|
731
742
|
}
|
|
732
743
|
return clone2;
|
|
733
744
|
};
|
|
734
|
-
var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
|
|
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;
|
|
749
|
+
}
|
|
750
|
+
visited.add(obj);
|
|
751
|
+
}
|
|
735
752
|
const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
|
|
736
753
|
for (const prop in obj) {
|
|
737
754
|
if (!Object.prototype.hasOwnProperty.call(obj, prop))
|
|
738
755
|
continue;
|
|
739
756
|
const objProp = obj[prop];
|
|
740
|
-
if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
|
|
757
|
+
if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
|
|
741
758
|
continue;
|
|
759
|
+
}
|
|
742
760
|
if ((0, import_types.isObjectLike)(objProp)) {
|
|
743
|
-
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
|
|
761
|
+
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
|
|
744
762
|
} else if ((0, import_types.isFunction)(objProp) && options.window) {
|
|
745
763
|
o[prop] = (options.window || import_globals.window).eval("(" + objProp.toString() + ")");
|
|
746
|
-
} else
|
|
764
|
+
} else {
|
|
747
765
|
o[prop] = objProp;
|
|
766
|
+
}
|
|
748
767
|
}
|
|
749
768
|
return o;
|
|
750
769
|
};
|
|
751
770
|
var deepStringify = (obj, stringified = {}) => {
|
|
752
|
-
var _a;
|
|
771
|
+
var _a, _b;
|
|
753
772
|
if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
|
|
754
|
-
|
|
755
|
-
obj = (
|
|
773
|
+
(obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn("Trying to clone element or state at", obj);
|
|
774
|
+
obj = (_b = obj.parse) == null ? void 0 : _b.call(obj);
|
|
756
775
|
}
|
|
757
776
|
for (const prop in obj) {
|
|
758
777
|
const objProp = obj[prop];
|
|
@@ -822,7 +841,7 @@ var require_object = __commonJS({
|
|
|
822
841
|
if ((0, import_types.isArray)(value)) {
|
|
823
842
|
str += "[\n";
|
|
824
843
|
for (const element of value) {
|
|
825
|
-
if ((0, import_types.
|
|
844
|
+
if ((0, import_types.isObjectLike)(element) && element !== null) {
|
|
826
845
|
str += `${spaces} ${objectToString(element, indent + 2)},
|
|
827
846
|
`;
|
|
828
847
|
} else if ((0, import_types.isString)(element)) {
|
|
@@ -921,7 +940,7 @@ var require_object = __commonJS({
|
|
|
921
940
|
};
|
|
922
941
|
var stringToObject = (str, opts = { verbose: true }) => {
|
|
923
942
|
try {
|
|
924
|
-
return import_globals.window.eval("(" + str + ")");
|
|
943
|
+
return str ? import_globals.window.eval("(" + str + ")") : {};
|
|
925
944
|
} catch (e) {
|
|
926
945
|
if (opts.verbose)
|
|
927
946
|
console.warn(e);
|
|
@@ -1001,20 +1020,27 @@ var require_object = __commonJS({
|
|
|
1001
1020
|
return acc;
|
|
1002
1021
|
}, deletedValues);
|
|
1003
1022
|
};
|
|
1004
|
-
var overwrite = (element, params,
|
|
1005
|
-
const { ref } = element;
|
|
1006
|
-
const
|
|
1023
|
+
var overwrite = (element, params, opts = {}) => {
|
|
1024
|
+
const { __ref: ref } = element;
|
|
1025
|
+
const excl = opts.exclude || [];
|
|
1026
|
+
const allowUnderscore = opts.preventUnderscore;
|
|
1027
|
+
const preventCaching = opts.preventCaching;
|
|
1007
1028
|
for (const e in params) {
|
|
1008
|
-
if (
|
|
1029
|
+
if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
|
|
1009
1030
|
continue;
|
|
1010
1031
|
const elementProp = element[e];
|
|
1011
1032
|
const paramsProp = params[e];
|
|
1012
|
-
if (paramsProp) {
|
|
1013
|
-
|
|
1014
|
-
ref
|
|
1033
|
+
if (paramsProp !== void 0) {
|
|
1034
|
+
element[e] = paramsProp;
|
|
1035
|
+
if (ref && !preventCaching) {
|
|
1036
|
+
ref.__cache[e] = elementProp;
|
|
1037
|
+
}
|
|
1038
|
+
if ((0, import_types.isObject)(opts.diff)) {
|
|
1039
|
+
diff[e] = elementProp;
|
|
1040
|
+
}
|
|
1015
1041
|
}
|
|
1016
1042
|
}
|
|
1017
|
-
return
|
|
1043
|
+
return element;
|
|
1018
1044
|
};
|
|
1019
1045
|
var overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
1020
1046
|
for (const e in params) {
|
|
@@ -1024,23 +1050,26 @@ var require_object = __commonJS({
|
|
|
1024
1050
|
}
|
|
1025
1051
|
return obj;
|
|
1026
1052
|
};
|
|
1027
|
-
var overwriteDeep = (obj, params,
|
|
1053
|
+
var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
|
|
1054
|
+
const excl = opts.exclude || [];
|
|
1055
|
+
const forcedExclude = opts.preventForce ? [] : ["node", "window"];
|
|
1028
1056
|
if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
|
|
1029
1057
|
return params;
|
|
1030
1058
|
}
|
|
1031
|
-
if (visited.has(obj))
|
|
1059
|
+
if (visited.has(obj))
|
|
1032
1060
|
return visited.get(obj);
|
|
1033
|
-
}
|
|
1034
1061
|
visited.set(obj, obj);
|
|
1035
1062
|
for (const e in params) {
|
|
1036
|
-
if (
|
|
1063
|
+
if (!Object.hasOwnProperty.call(params, e))
|
|
1064
|
+
continue;
|
|
1065
|
+
if (excl.includes(e) || forcedExclude && e.startsWith("__"))
|
|
1037
1066
|
continue;
|
|
1038
1067
|
const objProp = obj[e];
|
|
1039
1068
|
const paramsProp = params[e];
|
|
1040
1069
|
if ((0, import_node.isDOMNode)(paramsProp)) {
|
|
1041
1070
|
obj[e] = paramsProp;
|
|
1042
1071
|
} else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
|
|
1043
|
-
obj[e] = overwriteDeep(objProp, paramsProp,
|
|
1072
|
+
obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
|
|
1044
1073
|
} else if (paramsProp !== void 0) {
|
|
1045
1074
|
obj[e] = paramsProp;
|
|
1046
1075
|
}
|
|
@@ -1203,6 +1232,30 @@ var require_object = __commonJS({
|
|
|
1203
1232
|
}
|
|
1204
1233
|
}
|
|
1205
1234
|
};
|
|
1235
|
+
var isCyclic = (obj) => {
|
|
1236
|
+
const seenObjects = [];
|
|
1237
|
+
function detect(obj2) {
|
|
1238
|
+
if (obj2 && typeof obj2 === "object") {
|
|
1239
|
+
if (seenObjects.indexOf(obj2) !== -1) {
|
|
1240
|
+
return true;
|
|
1241
|
+
}
|
|
1242
|
+
seenObjects.push(obj2);
|
|
1243
|
+
for (const key in obj2) {
|
|
1244
|
+
if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
|
|
1245
|
+
console.log(obj2, "cycle at " + key);
|
|
1246
|
+
return true;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return false;
|
|
1251
|
+
}
|
|
1252
|
+
return detect(obj);
|
|
1253
|
+
};
|
|
1254
|
+
var excludeKeysFromObject = (obj, excludedKeys) => {
|
|
1255
|
+
const result = { ...obj };
|
|
1256
|
+
excludedKeys.forEach((key) => delete result[key]);
|
|
1257
|
+
return result;
|
|
1258
|
+
};
|
|
1206
1259
|
}
|
|
1207
1260
|
});
|
|
1208
1261
|
|
|
@@ -1358,9 +1411,11 @@ var require_cookie = __commonJS({
|
|
|
1358
1411
|
var cookie_exports = {};
|
|
1359
1412
|
__export2(cookie_exports, {
|
|
1360
1413
|
getCookie: () => getCookie,
|
|
1414
|
+
getLocalStorage: () => getLocalStorage,
|
|
1361
1415
|
isMobile: () => isMobile,
|
|
1362
1416
|
removeCookie: () => removeCookie,
|
|
1363
|
-
setCookie: () => setCookie
|
|
1417
|
+
setCookie: () => setCookie,
|
|
1418
|
+
setLocalStorage: () => setLocalStorage
|
|
1364
1419
|
});
|
|
1365
1420
|
module2.exports = __toCommonJS2(cookie_exports);
|
|
1366
1421
|
var import_types = require_types();
|
|
@@ -1394,6 +1449,27 @@ var require_cookie = __commonJS({
|
|
|
1394
1449
|
return;
|
|
1395
1450
|
import_utils2.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
1396
1451
|
};
|
|
1452
|
+
function getLocalStorage(key) {
|
|
1453
|
+
let savedJSON;
|
|
1454
|
+
if (window.localStorage) {
|
|
1455
|
+
try {
|
|
1456
|
+
savedJSON = JSON.parse(window.localStorage.getItem(key));
|
|
1457
|
+
} catch (e) {
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (typeof savedJSON !== "undefined") {
|
|
1461
|
+
return savedJSON;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
function setLocalStorage(key, data) {
|
|
1465
|
+
if (data && window.localStorage) {
|
|
1466
|
+
if (typeof data === "object") {
|
|
1467
|
+
window.localStorage.setItem(key, JSON.stringify(data));
|
|
1468
|
+
} else {
|
|
1469
|
+
window.localStorage.setItem(key, data);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1397
1473
|
}
|
|
1398
1474
|
});
|
|
1399
1475
|
|
|
@@ -1597,7 +1673,9 @@ var require_component = __commonJS({
|
|
|
1597
1673
|
applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
|
|
1598
1674
|
checkIfKeyIsComponent: () => checkIfKeyIsComponent,
|
|
1599
1675
|
checkIfKeyIsProperty: () => checkIfKeyIsProperty,
|
|
1676
|
+
checkIfSugar: () => checkIfSugar,
|
|
1600
1677
|
extendizeByKey: () => extendizeByKey,
|
|
1678
|
+
getCapitalCaseKeys: () => getCapitalCaseKeys,
|
|
1601
1679
|
getChildrenComponentsByKey: () => getChildrenComponentsByKey,
|
|
1602
1680
|
getExtendsInElement: () => getExtendsInElement,
|
|
1603
1681
|
hasVariantProp: () => hasVariantProp,
|
|
@@ -1622,6 +1700,8 @@ var require_component = __commonJS({
|
|
|
1622
1700
|
return /^[a-z]*$/.test(firstCharKey);
|
|
1623
1701
|
};
|
|
1624
1702
|
var addAdditionalExtend = (newExtend, element) => {
|
|
1703
|
+
if (!newExtend)
|
|
1704
|
+
return element;
|
|
1625
1705
|
const { extend: elementExtend } = element;
|
|
1626
1706
|
const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
1627
1707
|
const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
|
|
@@ -1629,26 +1709,44 @@ var require_component = __commonJS({
|
|
|
1629
1709
|
return { ...element, extend };
|
|
1630
1710
|
};
|
|
1631
1711
|
var checkIfSugar = (element, parent, key) => {
|
|
1632
|
-
|
|
1712
|
+
var _a;
|
|
1713
|
+
const {
|
|
1714
|
+
extend,
|
|
1715
|
+
props,
|
|
1716
|
+
childExtend,
|
|
1717
|
+
extends: extendProps,
|
|
1718
|
+
childExtends,
|
|
1719
|
+
childProps,
|
|
1720
|
+
children,
|
|
1721
|
+
on,
|
|
1722
|
+
$collection,
|
|
1723
|
+
$stateCollection,
|
|
1724
|
+
$propsCollection
|
|
1725
|
+
} = element;
|
|
1633
1726
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
|
|
1634
|
-
|
|
1727
|
+
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
1728
|
+
const logErr = (_a = parent || element) == null ? void 0 : _a.error;
|
|
1729
|
+
if (logErr)
|
|
1730
|
+
logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
|
|
1731
|
+
}
|
|
1732
|
+
return !hasComponentAttrs || childProps || extendProps || children || childExtends;
|
|
1635
1733
|
};
|
|
1636
1734
|
var extendizeByKey = (element, parent, key) => {
|
|
1637
1735
|
const { context } = parent;
|
|
1638
|
-
const { tag, extend,
|
|
1639
|
-
const isSugar = checkIfSugar(element);
|
|
1736
|
+
const { tag, extend, childExtends } = element;
|
|
1737
|
+
const isSugar = checkIfSugar(element, parent, key);
|
|
1640
1738
|
const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
|
|
1641
1739
|
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
1642
1740
|
if (element === isExtendKeyComponent)
|
|
1643
1741
|
return element;
|
|
1644
1742
|
else if (isSugar) {
|
|
1645
|
-
const newElem = {
|
|
1743
|
+
const newElem = addAdditionalExtend(element.extends, {
|
|
1646
1744
|
extend: extendFromKey,
|
|
1647
1745
|
tag,
|
|
1648
1746
|
props: { ...element }
|
|
1649
|
-
};
|
|
1650
|
-
if (
|
|
1651
|
-
newElem.childExtend =
|
|
1747
|
+
});
|
|
1748
|
+
if (childExtends)
|
|
1749
|
+
newElem.childExtend = childExtends;
|
|
1652
1750
|
return newElem;
|
|
1653
1751
|
} else if (!extend || extend === true) {
|
|
1654
1752
|
return {
|
|
@@ -1677,23 +1775,24 @@ var require_component = __commonJS({
|
|
|
1677
1775
|
const childKey = childElems[i];
|
|
1678
1776
|
const childElem = element[childKey];
|
|
1679
1777
|
const newChild = element.props[childKey];
|
|
1778
|
+
const assignChild = (val) => {
|
|
1779
|
+
element[childKey] = val;
|
|
1780
|
+
delete element.props[childKey];
|
|
1781
|
+
};
|
|
1680
1782
|
if (newChild == null ? void 0 : newChild.ignoreExtend)
|
|
1681
1783
|
continue;
|
|
1682
|
-
if (
|
|
1683
|
-
|
|
1784
|
+
if (newChild === null)
|
|
1785
|
+
assignChild(null);
|
|
1786
|
+
else if (!childElem)
|
|
1787
|
+
assignChild((0, import__.deepCloneWithExtend)(newChild));
|
|
1684
1788
|
else {
|
|
1685
|
-
const
|
|
1686
|
-
if (
|
|
1789
|
+
const isSugarChildElem = checkIfSugar(childElem, parent, key);
|
|
1790
|
+
if (isSugarChildElem)
|
|
1687
1791
|
continue;
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
}
|
|
1692
|
-
element[childKey] = {
|
|
1693
|
-
extend: element[childKey],
|
|
1694
|
-
props: newChild
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1792
|
+
assignChild({
|
|
1793
|
+
extend: element[childKey],
|
|
1794
|
+
props: newChild
|
|
1795
|
+
});
|
|
1697
1796
|
}
|
|
1698
1797
|
}
|
|
1699
1798
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/utils",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.469",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@domql/utils": "^2.5.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "711b668d5e97cf07bdc3ecec069a89c4eddee826"
|
|
30
30
|
}
|