@domql/utils 2.5.203 → 2.25.2
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/component.js +1 -1
- package/dist/cjs/array.js +3 -6
- package/dist/cjs/component.js +19 -38
- package/dist/cjs/cookie.js +5 -10
- package/dist/cjs/env.js +2 -2
- package/dist/cjs/function.js +2 -4
- package/dist/cjs/index.js +15 -15
- package/dist/cjs/key.js +1 -1
- package/dist/cjs/log.js +1 -2
- package/dist/cjs/object.js +35 -70
- package/dist/cjs/string.js +1 -2
- package/dist/cjs/types.js +2 -4
- package/dist/esm/array.js +3 -6
- package/dist/esm/component.js +19 -38
- package/dist/esm/cookie.js +5 -10
- package/dist/esm/env.js +2 -2
- package/dist/esm/function.js +2 -4
- package/dist/esm/key.js +1 -1
- package/dist/esm/log.js +1 -2
- package/dist/esm/object.js +35 -70
- package/dist/esm/string.js +1 -2
- package/dist/esm/types.js +2 -4
- package/env.js +3 -3
- package/package.json +2 -2
package/component.js
CHANGED
|
@@ -46,7 +46,7 @@ export const checkIfSugar = (element, parent, key) => {
|
|
|
46
46
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection
|
|
47
47
|
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
48
48
|
const logErr = (parent || element)?.error
|
|
49
|
-
if (logErr) logErr.call(element, 'Sugar component includes params for builtin components', { verbose: true })
|
|
49
|
+
if (logErr) logErr.call(parent, element, 'Sugar component includes params for builtin components', { verbose: true })
|
|
50
50
|
}
|
|
51
51
|
return !hasComponentAttrs || childProps || extendProps || children || childExtends
|
|
52
52
|
}
|
package/dist/cjs/array.js
CHANGED
|
@@ -48,8 +48,7 @@ const getFrequencyInArray = (arr, value) => {
|
|
|
48
48
|
}, 0);
|
|
49
49
|
};
|
|
50
50
|
const removeFromArray = (arr, index) => {
|
|
51
|
-
if ((0, import_types.isString)(index))
|
|
52
|
-
index = parseInt(index);
|
|
51
|
+
if ((0, import_types.isString)(index)) index = parseInt(index);
|
|
53
52
|
if ((0, import_types.isNumber)(index)) {
|
|
54
53
|
if (index < 0 || index >= arr.length || isNaN(index)) {
|
|
55
54
|
throw new Error("Invalid index");
|
|
@@ -82,8 +81,7 @@ const cutArrayBeforeValue = (arr, value) => {
|
|
|
82
81
|
return arr;
|
|
83
82
|
};
|
|
84
83
|
const cutArrayAfterValue = (arr, value) => {
|
|
85
|
-
if (!(0, import_types.isArray)(arr))
|
|
86
|
-
return;
|
|
84
|
+
if (!(0, import_types.isArray)(arr)) return;
|
|
87
85
|
const index = arr.indexOf(value);
|
|
88
86
|
if (index !== -1) {
|
|
89
87
|
return arr.slice(index + 1);
|
|
@@ -142,7 +140,6 @@ const filterArraysFast = (sourceArr, excludeArr) => {
|
|
|
142
140
|
return sourceArr.filter((item) => !excludeSet.has(item));
|
|
143
141
|
};
|
|
144
142
|
const checkIfStringIsInArray = (string, arr) => {
|
|
145
|
-
if (!string)
|
|
146
|
-
return;
|
|
143
|
+
if (!string) return;
|
|
147
144
|
return arr.filter((v) => string.includes(v)).length;
|
|
148
145
|
};
|
package/dist/cjs/component.js
CHANGED
|
@@ -41,21 +41,18 @@ var import_types = require("./types.js");
|
|
|
41
41
|
const ENV = "development";
|
|
42
42
|
const checkIfKeyIsComponent = (key) => {
|
|
43
43
|
const isFirstKeyString = (0, import_types.isString)(key);
|
|
44
|
-
if (!isFirstKeyString)
|
|
45
|
-
return;
|
|
44
|
+
if (!isFirstKeyString) return;
|
|
46
45
|
const firstCharKey = key.slice(0, 1);
|
|
47
46
|
return /^[A-Z]*$/.test(firstCharKey);
|
|
48
47
|
};
|
|
49
48
|
const checkIfKeyIsProperty = (key) => {
|
|
50
49
|
const isFirstKeyString = (0, import_types.isString)(key);
|
|
51
|
-
if (!isFirstKeyString)
|
|
52
|
-
return;
|
|
50
|
+
if (!isFirstKeyString) return;
|
|
53
51
|
const firstCharKey = key.slice(0, 1);
|
|
54
52
|
return /^[a-z]*$/.test(firstCharKey);
|
|
55
53
|
};
|
|
56
54
|
const addAdditionalExtend = (newExtend, element) => {
|
|
57
|
-
if (!newExtend)
|
|
58
|
-
return element;
|
|
55
|
+
if (!newExtend) return element;
|
|
59
56
|
const { extend: elementExtend } = element;
|
|
60
57
|
const originalArray = (0, import_types.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
61
58
|
const receivedArray = (0, import_types.isArray)(newExtend) ? newExtend : [newExtend];
|
|
@@ -80,8 +77,7 @@ const checkIfSugar = (element, parent, key) => {
|
|
|
80
77
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
|
|
81
78
|
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
82
79
|
const logErr = (_a = parent || element) == null ? void 0 : _a.error;
|
|
83
|
-
if (logErr)
|
|
84
|
-
logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
|
|
80
|
+
if (logErr) logErr.call(parent, element, "Sugar component includes params for builtin components", { verbose: true });
|
|
85
81
|
}
|
|
86
82
|
return !hasComponentAttrs || childProps || extendProps || children || childExtends;
|
|
87
83
|
};
|
|
@@ -94,8 +90,7 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
94
90
|
const isSugar = checkIfSugar(element, parent, key);
|
|
95
91
|
const extendFromKey = extractComponentKeyFromKey(key);
|
|
96
92
|
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
97
|
-
if (element === isExtendKeyComponent)
|
|
98
|
-
return element;
|
|
93
|
+
if (element === isExtendKeyComponent) return element;
|
|
99
94
|
else if (isSugar) {
|
|
100
95
|
const newElem = addAdditionalExtend(element.extends, {
|
|
101
96
|
extend: extendFromKey,
|
|
@@ -118,8 +113,7 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
118
113
|
newElem.if = newElem.props.if;
|
|
119
114
|
delete newElem.props.if;
|
|
120
115
|
}
|
|
121
|
-
if (childExtends)
|
|
122
|
-
newElem.childExtend = childExtends;
|
|
116
|
+
if (childExtends) newElem.childExtend = childExtends;
|
|
123
117
|
return newElem;
|
|
124
118
|
} else if (!extend || extend === true) {
|
|
125
119
|
return {
|
|
@@ -142,8 +136,7 @@ function getCapitalCaseKeys(obj) {
|
|
|
142
136
|
}
|
|
143
137
|
const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
144
138
|
const childElems = getCapitalCaseKeys(element.props);
|
|
145
|
-
if (!childElems.length)
|
|
146
|
-
return element;
|
|
139
|
+
if (!childElems.length) return element;
|
|
147
140
|
for (const i in childElems) {
|
|
148
141
|
const childKey = childElems[i];
|
|
149
142
|
const childElem = element[childKey];
|
|
@@ -152,16 +145,12 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
152
145
|
element[childKey] = val;
|
|
153
146
|
delete element.props[childKey];
|
|
154
147
|
};
|
|
155
|
-
if (newChild == null ? void 0 : newChild.ignoreExtend)
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
assignChild(null);
|
|
159
|
-
else if (!childElem)
|
|
160
|
-
assignChild((0, import_object.deepClone)(newChild));
|
|
148
|
+
if (newChild == null ? void 0 : newChild.ignoreExtend) continue;
|
|
149
|
+
if (newChild === null) assignChild(null);
|
|
150
|
+
else if (!childElem) assignChild((0, import_object.deepClone)(newChild));
|
|
161
151
|
else {
|
|
162
152
|
const isSugarChildElem = checkIfSugar(childElem, parent, key);
|
|
163
|
-
if (isSugarChildElem)
|
|
164
|
-
continue;
|
|
153
|
+
if (isSugarChildElem) continue;
|
|
165
154
|
assignChild({
|
|
166
155
|
extend: element[childKey],
|
|
167
156
|
props: newChild
|
|
@@ -174,15 +163,13 @@ const applyKeyComponentAsExtend = (element, parent, key) => {
|
|
|
174
163
|
};
|
|
175
164
|
const applyComponentFromContext = (element, parent, options) => {
|
|
176
165
|
const { context } = element;
|
|
177
|
-
if (!context || !context.components)
|
|
178
|
-
return;
|
|
166
|
+
if (!context || !context.components) return;
|
|
179
167
|
const { components } = context;
|
|
180
168
|
const { extend } = element;
|
|
181
169
|
const execExtend = (0, import_object.exec)(extend, element);
|
|
182
170
|
if ((0, import_types.isString)(execExtend)) {
|
|
183
171
|
const componentExists = components[execExtend] || components["smbls." + execExtend];
|
|
184
|
-
if (componentExists)
|
|
185
|
-
element.extend = componentExists;
|
|
172
|
+
if (componentExists) element.extend = componentExists;
|
|
186
173
|
else {
|
|
187
174
|
if ((ENV === "testing" || ENV === "development") && options.verbose) {
|
|
188
175
|
console.warn(execExtend, "is not in library", components, element);
|
|
@@ -193,15 +180,13 @@ const applyComponentFromContext = (element, parent, options) => {
|
|
|
193
180
|
}
|
|
194
181
|
};
|
|
195
182
|
const isVariant = (param) => {
|
|
196
|
-
if (!(0, import_types.isString)(param))
|
|
197
|
-
return;
|
|
183
|
+
if (!(0, import_types.isString)(param)) return;
|
|
198
184
|
const firstCharKey = param.slice(0, 1);
|
|
199
185
|
return firstCharKey === ".";
|
|
200
186
|
};
|
|
201
187
|
const hasVariantProp = (element) => {
|
|
202
188
|
const { props } = element;
|
|
203
|
-
if ((0, import_types.isObject)(props) && (0, import_types.isString)(props.variant))
|
|
204
|
-
return true;
|
|
189
|
+
if ((0, import_types.isObject)(props) && (0, import_types.isString)(props.variant)) return true;
|
|
205
190
|
};
|
|
206
191
|
const getChildrenComponentsByKey = (key, el) => {
|
|
207
192
|
if (key === el.key || el.__ref.__componentKey === key) {
|
|
@@ -210,14 +195,12 @@ const getChildrenComponentsByKey = (key, el) => {
|
|
|
210
195
|
if (el.extend) {
|
|
211
196
|
const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
|
|
212
197
|
const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
|
|
213
|
-
if (foundString || foundInArray)
|
|
214
|
-
return el;
|
|
198
|
+
if (foundString || foundInArray) return el;
|
|
215
199
|
}
|
|
216
200
|
if (el.parent && el.parent.childExtend) {
|
|
217
201
|
const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
|
|
218
202
|
const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
|
|
219
|
-
if (foundString || foundInArray)
|
|
220
|
-
return el;
|
|
203
|
+
if (foundString || foundInArray) return el;
|
|
221
204
|
}
|
|
222
205
|
};
|
|
223
206
|
const getExtendsInElement = (obj) => {
|
|
@@ -249,9 +232,7 @@ const setContentKey = (el, opts = {}) => {
|
|
|
249
232
|
const contentElementKey = opts.contentElementKey;
|
|
250
233
|
if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
|
|
251
234
|
ref.contentElementKey = contentElementKey || "content";
|
|
252
|
-
} else
|
|
253
|
-
|
|
254
|
-
if (contentElementKey !== "content")
|
|
255
|
-
opts.contentElementKey = "content";
|
|
235
|
+
} else ref.contentElementKey = "content";
|
|
236
|
+
if (contentElementKey !== "content") opts.contentElementKey = "content";
|
|
256
237
|
return ref.contentElementKey;
|
|
257
238
|
};
|
package/dist/cjs/cookie.js
CHANGED
|
@@ -30,31 +30,26 @@ var import_types = require("./types.js");
|
|
|
30
30
|
var import_globals = require("./globals.js");
|
|
31
31
|
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
32
32
|
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
33
|
-
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
|
|
34
|
-
return;
|
|
33
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
|
|
35
34
|
const d = /* @__PURE__ */ new Date();
|
|
36
35
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
37
36
|
const expires = `expires=${d.toUTCString()}`;
|
|
38
37
|
import_globals.document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
39
38
|
};
|
|
40
39
|
const getCookie = (cname) => {
|
|
41
|
-
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
|
|
42
|
-
return;
|
|
40
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
|
|
43
41
|
const name = `${cname}=`;
|
|
44
42
|
const decodedCookie = decodeURIComponent(import_globals.document.cookie);
|
|
45
43
|
const ca = decodedCookie.split(";");
|
|
46
44
|
for (let i = 0; i < ca.length; i++) {
|
|
47
45
|
let c = ca[i];
|
|
48
|
-
while (c.charAt(0) === " ")
|
|
49
|
-
|
|
50
|
-
if (c.indexOf(name) === 0)
|
|
51
|
-
return c.substring(name.length, c.length);
|
|
46
|
+
while (c.charAt(0) === " ") c = c.substring(1);
|
|
47
|
+
if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
|
|
52
48
|
}
|
|
53
49
|
return "";
|
|
54
50
|
};
|
|
55
51
|
const removeCookie = (cname) => {
|
|
56
|
-
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
|
|
57
|
-
return;
|
|
52
|
+
if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
|
|
58
53
|
import_globals.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
59
54
|
};
|
|
60
55
|
function getLocalStorage(key) {
|
package/dist/cjs/env.js
CHANGED
|
@@ -26,7 +26,7 @@ __export(env_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(env_exports);
|
|
28
28
|
const NODE_ENV = "development";
|
|
29
|
-
const isProduction = (env = NODE_ENV) => env === "production" || env
|
|
30
|
-
const isTest = (env = NODE_ENV) => env === "
|
|
29
|
+
const isProduction = (env = NODE_ENV) => env === "production" || env !== "development" && env !== "dev" && env !== "testing";
|
|
30
|
+
const isTest = (env = NODE_ENV) => env === "testing";
|
|
31
31
|
const isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev";
|
|
32
32
|
const getNev = (key, env = NODE_ENV) => env[key];
|
package/dist/cjs/function.js
CHANGED
|
@@ -32,14 +32,12 @@ function debounce(func, wait, immediate) {
|
|
|
32
32
|
const args = arguments;
|
|
33
33
|
const later = function() {
|
|
34
34
|
timeout = null;
|
|
35
|
-
if (!immediate)
|
|
36
|
-
func.apply(context, args);
|
|
35
|
+
if (!immediate) func.apply(context, args);
|
|
37
36
|
};
|
|
38
37
|
const callNow = immediate && !timeout;
|
|
39
38
|
clearTimeout(timeout);
|
|
40
39
|
timeout = setTimeout(later, wait);
|
|
41
|
-
if (callNow)
|
|
42
|
-
func.apply(context, args);
|
|
40
|
+
if (callNow) func.apply(context, args);
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
43
|
const debounceOnContext = (element, func, timeout = 300) => {
|
package/dist/cjs/index.js
CHANGED
|
@@ -13,18 +13,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
};
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var
|
|
17
|
-
module.exports = __toCommonJS(
|
|
18
|
-
__reExport(
|
|
19
|
-
__reExport(
|
|
20
|
-
__reExport(
|
|
21
|
-
__reExport(
|
|
22
|
-
__reExport(
|
|
23
|
-
__reExport(
|
|
24
|
-
__reExport(
|
|
25
|
-
__reExport(
|
|
26
|
-
__reExport(
|
|
27
|
-
__reExport(
|
|
28
|
-
__reExport(
|
|
29
|
-
__reExport(
|
|
30
|
-
__reExport(
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./key.js"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./env.js"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./types.js"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./object.js"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./function.js"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./array.js"), module.exports);
|
|
24
|
+
__reExport(index_exports, require("./node.js"), module.exports);
|
|
25
|
+
__reExport(index_exports, require("./log.js"), module.exports);
|
|
26
|
+
__reExport(index_exports, require("./string.js"), module.exports);
|
|
27
|
+
__reExport(index_exports, require("./globals.js"), module.exports);
|
|
28
|
+
__reExport(index_exports, require("./cookie.js"), module.exports);
|
|
29
|
+
__reExport(index_exports, require("./tags.js"), module.exports);
|
|
30
|
+
__reExport(index_exports, require("./component.js"), module.exports);
|
package/dist/cjs/key.js
CHANGED
package/dist/cjs/log.js
CHANGED
|
@@ -23,8 +23,7 @@ __export(log_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(log_exports);
|
|
25
25
|
const logIf = (bool, ...arg) => {
|
|
26
|
-
if (bool)
|
|
27
|
-
arg.map((v) => console.log(v));
|
|
26
|
+
if (bool) arg.map((v) => console.log(v));
|
|
28
27
|
};
|
|
29
28
|
const logGroupIf = (bool, key, ...arg) => {
|
|
30
29
|
if (bool) {
|
package/dist/cjs/object.js
CHANGED
|
@@ -83,8 +83,7 @@ const map = (obj, extention, element) => {
|
|
|
83
83
|
const merge = (element, obj, excludeFrom = []) => {
|
|
84
84
|
for (const e in obj) {
|
|
85
85
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
|
|
86
|
-
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
|
|
87
|
-
continue;
|
|
86
|
+
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
|
|
88
87
|
const elementProp = element[e];
|
|
89
88
|
const objProp = obj[e];
|
|
90
89
|
if (elementProp === void 0) {
|
|
@@ -96,8 +95,7 @@ const merge = (element, obj, excludeFrom = []) => {
|
|
|
96
95
|
const deepMerge = (element, extend, excludeFrom = []) => {
|
|
97
96
|
for (const e in extend) {
|
|
98
97
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
|
|
99
|
-
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
|
|
100
|
-
continue;
|
|
98
|
+
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
|
|
101
99
|
const elementProp = element[e];
|
|
102
100
|
const extendProp = extend[e];
|
|
103
101
|
if ((0, import_types.isObjectLike)(elementProp) && (0, import_types.isObjectLike)(extendProp)) {
|
|
@@ -112,8 +110,7 @@ const clone = (obj, excludeFrom = []) => {
|
|
|
112
110
|
const o = {};
|
|
113
111
|
for (const prop in obj) {
|
|
114
112
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
115
|
-
if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__"))
|
|
116
|
-
continue;
|
|
113
|
+
if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__")) continue;
|
|
117
114
|
o[prop] = obj[prop];
|
|
118
115
|
}
|
|
119
116
|
return o;
|
|
@@ -139,13 +136,10 @@ const deepClone = (obj, options = {}) => {
|
|
|
139
136
|
const clone2 = targetWindow ? (0, import_types.isArray)(obj) ? new targetWindow.Array() : new targetWindow.Object() : (0, import_types.isArray)(obj) ? [] : {};
|
|
140
137
|
visited.set(obj, clone2);
|
|
141
138
|
for (const key in obj) {
|
|
142
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
143
|
-
|
|
144
|
-
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
145
|
-
continue;
|
|
139
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
140
|
+
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") continue;
|
|
146
141
|
const value = obj[key];
|
|
147
|
-
if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value))
|
|
148
|
-
continue;
|
|
142
|
+
if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value)) continue;
|
|
149
143
|
if ((0, import_node.isDOMNode)(value)) {
|
|
150
144
|
clone2[key] = value;
|
|
151
145
|
continue;
|
|
@@ -276,16 +270,14 @@ const objectToString = (obj = {}, indent = 0) => {
|
|
|
276
270
|
const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
277
271
|
for (const prop in obj) {
|
|
278
272
|
const objProp = obj[prop];
|
|
279
|
-
if ((0, import_types.isFunction)(objProp))
|
|
280
|
-
continue;
|
|
273
|
+
if ((0, import_types.isFunction)(objProp)) continue;
|
|
281
274
|
else if ((0, import_types.isObject)(objProp)) {
|
|
282
275
|
detached[prop] = {};
|
|
283
276
|
deepStringify(objProp, detached[prop]);
|
|
284
277
|
} else if ((0, import_types.isArray)(objProp)) {
|
|
285
278
|
detached[prop] = [];
|
|
286
279
|
objProp.forEach((v, i) => {
|
|
287
|
-
if ((0, import_types.isFunction)(v))
|
|
288
|
-
return;
|
|
280
|
+
if ((0, import_types.isFunction)(v)) return;
|
|
289
281
|
if ((0, import_types.isObject)(v)) {
|
|
290
282
|
detached[prop][i] = {};
|
|
291
283
|
detachFunctionsFromObject(v, detached[prop][i]);
|
|
@@ -300,15 +292,11 @@ const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
|
300
292
|
return detached;
|
|
301
293
|
};
|
|
302
294
|
const hasFunction = (str) => {
|
|
303
|
-
if (!str)
|
|
304
|
-
return false;
|
|
295
|
+
if (!str) return false;
|
|
305
296
|
const trimmed = str.trim().replace(/\n\s*/g, " ").trim();
|
|
306
|
-
if (trimmed === "")
|
|
307
|
-
|
|
308
|
-
if (trimmed === "
|
|
309
|
-
return false;
|
|
310
|
-
if (trimmed === "[]")
|
|
311
|
-
return false;
|
|
297
|
+
if (trimmed === "") return false;
|
|
298
|
+
if (trimmed === "{}") return false;
|
|
299
|
+
if (trimmed === "[]") return false;
|
|
312
300
|
const patterns = [
|
|
313
301
|
/^\(\s*\{[^}]*\}\s*\)\s*=>/,
|
|
314
302
|
/^(\([^)]*\)|[^=]*)\s*=>/,
|
|
@@ -326,8 +314,7 @@ const hasFunction = (str) => {
|
|
|
326
314
|
const deepDestringify = (obj, destringified = {}) => {
|
|
327
315
|
for (const prop in obj) {
|
|
328
316
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
329
|
-
if (!hasOwnProperty2)
|
|
330
|
-
continue;
|
|
317
|
+
if (!hasOwnProperty2) continue;
|
|
331
318
|
const objProp = obj[prop];
|
|
332
319
|
if ((0, import_types.isString)(objProp)) {
|
|
333
320
|
if (hasFunction(objProp)) {
|
|
@@ -335,8 +322,7 @@ const deepDestringify = (obj, destringified = {}) => {
|
|
|
335
322
|
const evalProp = import_globals.window.eval(`(${objProp})`);
|
|
336
323
|
destringified[prop] = evalProp;
|
|
337
324
|
} catch (e) {
|
|
338
|
-
if (e)
|
|
339
|
-
destringified[prop] = objProp;
|
|
325
|
+
if (e) destringified[prop] = objProp;
|
|
340
326
|
}
|
|
341
327
|
} else {
|
|
342
328
|
destringified[prop] = objProp;
|
|
@@ -350,8 +336,7 @@ const deepDestringify = (obj, destringified = {}) => {
|
|
|
350
336
|
const evalProp = import_globals.window.eval(`(${arrProp})`);
|
|
351
337
|
destringified[prop].push(evalProp);
|
|
352
338
|
} catch (e) {
|
|
353
|
-
if (e)
|
|
354
|
-
destringified[prop].push(arrProp);
|
|
339
|
+
if (e) destringified[prop].push(arrProp);
|
|
355
340
|
}
|
|
356
341
|
} else {
|
|
357
342
|
destringified[prop].push(arrProp);
|
|
@@ -374,14 +359,12 @@ const stringToObject = (str, opts = { verbose: true }) => {
|
|
|
374
359
|
try {
|
|
375
360
|
return str ? import_globals.window.eval("(" + str + ")") : {};
|
|
376
361
|
} catch (e) {
|
|
377
|
-
if (opts.verbose)
|
|
378
|
-
console.warn(e);
|
|
362
|
+
if (opts.verbose) console.warn(e);
|
|
379
363
|
}
|
|
380
364
|
};
|
|
381
365
|
const diffObjects = (original, objToDiff, cache) => {
|
|
382
366
|
for (const e in objToDiff) {
|
|
383
|
-
if (e === "ref")
|
|
384
|
-
continue;
|
|
367
|
+
if (e === "ref") continue;
|
|
385
368
|
const originalProp = original[e];
|
|
386
369
|
const objToDiffProp = objToDiff[e];
|
|
387
370
|
if ((0, import_types.isObject)(originalProp) && (0, import_types.isObject)(objToDiffProp)) {
|
|
@@ -424,10 +407,8 @@ const isEmpty = (o) => Object.keys(o).length === 0;
|
|
|
424
407
|
const isEmptyObject = (o) => (0, import_types.isObject)(o) && isEmpty(o);
|
|
425
408
|
const makeObjectWithoutPrototype = () => /* @__PURE__ */ Object.create(null);
|
|
426
409
|
const deepDiff = (lhs, rhs) => {
|
|
427
|
-
if (lhs === rhs)
|
|
428
|
-
|
|
429
|
-
if (!(0, import_types.isObjectLike)(lhs) || !(0, import_types.isObjectLike)(rhs))
|
|
430
|
-
return rhs;
|
|
410
|
+
if (lhs === rhs) return {};
|
|
411
|
+
if (!(0, import_types.isObjectLike)(lhs) || !(0, import_types.isObjectLike)(rhs)) return rhs;
|
|
431
412
|
const deletedValues = Object.keys(lhs).reduce((acc, key) => {
|
|
432
413
|
if (!hasOwnProperty(rhs, key)) {
|
|
433
414
|
acc[key] = void 0;
|
|
@@ -435,8 +416,7 @@ const deepDiff = (lhs, rhs) => {
|
|
|
435
416
|
return acc;
|
|
436
417
|
}, makeObjectWithoutPrototype());
|
|
437
418
|
if ((0, import_types.isDate)(lhs) || (0, import_types.isDate)(rhs)) {
|
|
438
|
-
if (lhs.valueOf() === rhs.valueOf())
|
|
439
|
-
return {};
|
|
419
|
+
if (lhs.valueOf() === rhs.valueOf()) return {};
|
|
440
420
|
return rhs;
|
|
441
421
|
}
|
|
442
422
|
return Object.keys(rhs).reduce((acc, key) => {
|
|
@@ -458,8 +438,7 @@ const overwrite = (element, params, opts = {}) => {
|
|
|
458
438
|
const allowUnderscore = opts.preventUnderscore;
|
|
459
439
|
const preventCaching = opts.preventCaching;
|
|
460
440
|
for (const e in params) {
|
|
461
|
-
if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
|
|
462
|
-
continue;
|
|
441
|
+
if (excl.includes(e) || !allowUnderscore && e.startsWith("__")) continue;
|
|
463
442
|
const elementProp = element[e];
|
|
464
443
|
const paramsProp = params[e];
|
|
465
444
|
if (paramsProp !== void 0) {
|
|
@@ -476,8 +455,7 @@ const overwrite = (element, params, opts = {}) => {
|
|
|
476
455
|
};
|
|
477
456
|
const overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
478
457
|
for (const e in params) {
|
|
479
|
-
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
480
|
-
continue;
|
|
458
|
+
if (excludeFrom.includes(e) || e.startsWith("__")) continue;
|
|
481
459
|
obj[e] = params[e];
|
|
482
460
|
}
|
|
483
461
|
return obj;
|
|
@@ -488,14 +466,11 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
|
|
|
488
466
|
if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
|
|
489
467
|
return params;
|
|
490
468
|
}
|
|
491
|
-
if (visited.has(obj))
|
|
492
|
-
return visited.get(obj);
|
|
469
|
+
if (visited.has(obj)) return visited.get(obj);
|
|
493
470
|
visited.set(obj, obj);
|
|
494
471
|
for (const e in params) {
|
|
495
|
-
if (!Object.hasOwnProperty.call(params, e))
|
|
496
|
-
|
|
497
|
-
if (excl.includes(e) || forcedExclude && e.startsWith("__"))
|
|
498
|
-
continue;
|
|
472
|
+
if (!Object.hasOwnProperty.call(params, e)) continue;
|
|
473
|
+
if (excl.includes(e) || forcedExclude && e.startsWith("__")) continue;
|
|
499
474
|
const objProp = obj[e];
|
|
500
475
|
const paramsProp = params[e];
|
|
501
476
|
if ((0, import_node.isDOMNode)(paramsProp)) {
|
|
@@ -509,16 +484,14 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
|
|
|
509
484
|
return obj;
|
|
510
485
|
};
|
|
511
486
|
const mergeIfExisted = (a, b) => {
|
|
512
|
-
if ((0, import_types.isObjectLike)(a) && (0, import_types.isObjectLike)(b))
|
|
513
|
-
return deepMerge(a, b);
|
|
487
|
+
if ((0, import_types.isObjectLike)(a) && (0, import_types.isObjectLike)(b)) return deepMerge(a, b);
|
|
514
488
|
return a || b;
|
|
515
489
|
};
|
|
516
490
|
const flattenRecursive = (param, prop, stack = []) => {
|
|
517
491
|
const objectized = (0, import_array.mergeAndCloneIfArray)(param);
|
|
518
492
|
stack.push(objectized);
|
|
519
493
|
const extendOfExtend = objectized[prop];
|
|
520
|
-
if (extendOfExtend)
|
|
521
|
-
flattenRecursive(extendOfExtend, prop, stack);
|
|
494
|
+
if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack);
|
|
522
495
|
delete objectized[prop];
|
|
523
496
|
return stack;
|
|
524
497
|
};
|
|
@@ -549,31 +522,24 @@ const isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
|
|
|
549
522
|
return true;
|
|
550
523
|
};
|
|
551
524
|
const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
|
|
552
|
-
if (obj1 === obj2)
|
|
553
|
-
|
|
554
|
-
if (
|
|
555
|
-
return false;
|
|
556
|
-
if ((0, import_node.isDOMNode)(obj1) || (0, import_node.isDOMNode)(obj2))
|
|
557
|
-
return obj1 === obj2;
|
|
525
|
+
if (obj1 === obj2) return true;
|
|
526
|
+
if (!(0, import_types.isObjectLike)(obj1) || !(0, import_types.isObjectLike)(obj2)) return false;
|
|
527
|
+
if ((0, import_node.isDOMNode)(obj1) || (0, import_node.isDOMNode)(obj2)) return obj1 === obj2;
|
|
558
528
|
const stack = [[obj1, obj2]];
|
|
559
529
|
const visited = /* @__PURE__ */ new WeakSet();
|
|
560
530
|
while (stack.length > 0) {
|
|
561
531
|
const [current1, current2] = stack.pop();
|
|
562
|
-
if (visited.has(current1))
|
|
563
|
-
continue;
|
|
532
|
+
if (visited.has(current1)) continue;
|
|
564
533
|
visited.add(current1);
|
|
565
534
|
const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key));
|
|
566
535
|
const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key));
|
|
567
|
-
if (keys1.length !== keys2.length)
|
|
568
|
-
return false;
|
|
536
|
+
if (keys1.length !== keys2.length) return false;
|
|
569
537
|
for (const key of keys1) {
|
|
570
|
-
if (!Object.prototype.hasOwnProperty.call(current2, key))
|
|
571
|
-
return false;
|
|
538
|
+
if (!Object.prototype.hasOwnProperty.call(current2, key)) return false;
|
|
572
539
|
const value1 = current1[key];
|
|
573
540
|
const value2 = current2[key];
|
|
574
541
|
if ((0, import_node.isDOMNode)(value1) || (0, import_node.isDOMNode)(value2)) {
|
|
575
|
-
if (value1 !== value2)
|
|
576
|
-
return false;
|
|
542
|
+
if (value1 !== value2) return false;
|
|
577
543
|
} else if ((0, import_types.isObjectLike)(value1) && (0, import_types.isObjectLike)(value2)) {
|
|
578
544
|
if (value1 !== value2) {
|
|
579
545
|
stack.push([value1, value2]);
|
|
@@ -586,8 +552,7 @@ const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
|
|
|
586
552
|
return true;
|
|
587
553
|
};
|
|
588
554
|
const removeFromObject = (obj, props) => {
|
|
589
|
-
if (props === void 0 || props === null)
|
|
590
|
-
return obj;
|
|
555
|
+
if (props === void 0 || props === null) return obj;
|
|
591
556
|
if ((0, import_types.is)(props)("string", "number")) {
|
|
592
557
|
delete obj[props];
|
|
593
558
|
} else if ((0, import_types.isArray)(props)) {
|
package/dist/cjs/string.js
CHANGED
|
@@ -47,8 +47,7 @@ const brackRegex = {
|
|
|
47
47
|
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
48
48
|
};
|
|
49
49
|
function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
|
|
50
|
-
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
|
|
51
|
-
return str;
|
|
50
|
+
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{")) return str;
|
|
52
51
|
const reg = brackRegex[options.bracketsLength || 2];
|
|
53
52
|
const obj = forcedState || (this == null ? void 0 : this.state) || {};
|
|
54
53
|
return str.replace(reg, (_, parentPath, variable) => {
|
package/dist/cjs/types.js
CHANGED
|
@@ -36,8 +36,7 @@ __export(types_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(types_exports);
|
|
37
37
|
var import_node = require("./node.js");
|
|
38
38
|
const isObject = (arg) => {
|
|
39
|
-
if (arg === null)
|
|
40
|
-
return false;
|
|
39
|
+
if (arg === null) return false;
|
|
41
40
|
return typeof arg === "object" && arg.constructor === Object;
|
|
42
41
|
};
|
|
43
42
|
const isString = (arg) => typeof arg === "string";
|
|
@@ -48,8 +47,7 @@ const isNull = (arg) => arg === null;
|
|
|
48
47
|
const isArray = (arg) => Array.isArray(arg);
|
|
49
48
|
const isDate = (d) => d instanceof Date;
|
|
50
49
|
const isObjectLike = (arg) => {
|
|
51
|
-
if (arg === null)
|
|
52
|
-
return false;
|
|
50
|
+
if (arg === null) return false;
|
|
53
51
|
return typeof arg === "object";
|
|
54
52
|
};
|
|
55
53
|
const isDefined = (arg) => {
|
package/dist/esm/array.js
CHANGED
|
@@ -9,8 +9,7 @@ const getFrequencyInArray = (arr, value) => {
|
|
|
9
9
|
}, 0);
|
|
10
10
|
};
|
|
11
11
|
const removeFromArray = (arr, index) => {
|
|
12
|
-
if (isString(index))
|
|
13
|
-
index = parseInt(index);
|
|
12
|
+
if (isString(index)) index = parseInt(index);
|
|
14
13
|
if (isNumber(index)) {
|
|
15
14
|
if (index < 0 || index >= arr.length || isNaN(index)) {
|
|
16
15
|
throw new Error("Invalid index");
|
|
@@ -43,8 +42,7 @@ const cutArrayBeforeValue = (arr, value) => {
|
|
|
43
42
|
return arr;
|
|
44
43
|
};
|
|
45
44
|
const cutArrayAfterValue = (arr, value) => {
|
|
46
|
-
if (!isArray(arr))
|
|
47
|
-
return;
|
|
45
|
+
if (!isArray(arr)) return;
|
|
48
46
|
const index = arr.indexOf(value);
|
|
49
47
|
if (index !== -1) {
|
|
50
48
|
return arr.slice(index + 1);
|
|
@@ -103,8 +101,7 @@ const filterArraysFast = (sourceArr, excludeArr) => {
|
|
|
103
101
|
return sourceArr.filter((item) => !excludeSet.has(item));
|
|
104
102
|
};
|
|
105
103
|
const checkIfStringIsInArray = (string, arr) => {
|
|
106
|
-
if (!string)
|
|
107
|
-
return;
|
|
104
|
+
if (!string) return;
|
|
108
105
|
return arr.filter((v) => string.includes(v)).length;
|
|
109
106
|
};
|
|
110
107
|
export {
|
package/dist/esm/component.js
CHANGED
|
@@ -23,21 +23,18 @@ import { isArray, isFunction, isObject, isString } from "./types.js";
|
|
|
23
23
|
const ENV = "development";
|
|
24
24
|
const checkIfKeyIsComponent = (key) => {
|
|
25
25
|
const isFirstKeyString = isString(key);
|
|
26
|
-
if (!isFirstKeyString)
|
|
27
|
-
return;
|
|
26
|
+
if (!isFirstKeyString) return;
|
|
28
27
|
const firstCharKey = key.slice(0, 1);
|
|
29
28
|
return /^[A-Z]*$/.test(firstCharKey);
|
|
30
29
|
};
|
|
31
30
|
const checkIfKeyIsProperty = (key) => {
|
|
32
31
|
const isFirstKeyString = isString(key);
|
|
33
|
-
if (!isFirstKeyString)
|
|
34
|
-
return;
|
|
32
|
+
if (!isFirstKeyString) return;
|
|
35
33
|
const firstCharKey = key.slice(0, 1);
|
|
36
34
|
return /^[a-z]*$/.test(firstCharKey);
|
|
37
35
|
};
|
|
38
36
|
const addAdditionalExtend = (newExtend, element) => {
|
|
39
|
-
if (!newExtend)
|
|
40
|
-
return element;
|
|
37
|
+
if (!newExtend) return element;
|
|
41
38
|
const { extend: elementExtend } = element;
|
|
42
39
|
const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend];
|
|
43
40
|
const receivedArray = isArray(newExtend) ? newExtend : [newExtend];
|
|
@@ -62,8 +59,7 @@ const checkIfSugar = (element, parent, key) => {
|
|
|
62
59
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
|
|
63
60
|
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
64
61
|
const logErr = (_a = parent || element) == null ? void 0 : _a.error;
|
|
65
|
-
if (logErr)
|
|
66
|
-
logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
|
|
62
|
+
if (logErr) logErr.call(parent, element, "Sugar component includes params for builtin components", { verbose: true });
|
|
67
63
|
}
|
|
68
64
|
return !hasComponentAttrs || childProps || extendProps || children || childExtends;
|
|
69
65
|
};
|
|
@@ -76,8 +72,7 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
76
72
|
const isSugar = checkIfSugar(element, parent, key);
|
|
77
73
|
const extendFromKey = extractComponentKeyFromKey(key);
|
|
78
74
|
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
79
|
-
if (element === isExtendKeyComponent)
|
|
80
|
-
return element;
|
|
75
|
+
if (element === isExtendKeyComponent) return element;
|
|
81
76
|
else if (isSugar) {
|
|
82
77
|
const newElem = addAdditionalExtend(element.extends, {
|
|
83
78
|
extend: extendFromKey,
|
|
@@ -100,8 +95,7 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
100
95
|
newElem.if = newElem.props.if;
|
|
101
96
|
delete newElem.props.if;
|
|
102
97
|
}
|
|
103
|
-
if (childExtends)
|
|
104
|
-
newElem.childExtend = childExtends;
|
|
98
|
+
if (childExtends) newElem.childExtend = childExtends;
|
|
105
99
|
return newElem;
|
|
106
100
|
} else if (!extend || extend === true) {
|
|
107
101
|
return __spreadProps(__spreadValues({}, element), {
|
|
@@ -123,8 +117,7 @@ function getCapitalCaseKeys(obj) {
|
|
|
123
117
|
}
|
|
124
118
|
const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
125
119
|
const childElems = getCapitalCaseKeys(element.props);
|
|
126
|
-
if (!childElems.length)
|
|
127
|
-
return element;
|
|
120
|
+
if (!childElems.length) return element;
|
|
128
121
|
for (const i in childElems) {
|
|
129
122
|
const childKey = childElems[i];
|
|
130
123
|
const childElem = element[childKey];
|
|
@@ -133,16 +126,12 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
133
126
|
element[childKey] = val;
|
|
134
127
|
delete element.props[childKey];
|
|
135
128
|
};
|
|
136
|
-
if (newChild == null ? void 0 : newChild.ignoreExtend)
|
|
137
|
-
|
|
138
|
-
if (newChild
|
|
139
|
-
assignChild(null);
|
|
140
|
-
else if (!childElem)
|
|
141
|
-
assignChild(deepClone(newChild));
|
|
129
|
+
if (newChild == null ? void 0 : newChild.ignoreExtend) continue;
|
|
130
|
+
if (newChild === null) assignChild(null);
|
|
131
|
+
else if (!childElem) assignChild(deepClone(newChild));
|
|
142
132
|
else {
|
|
143
133
|
const isSugarChildElem = checkIfSugar(childElem, parent, key);
|
|
144
|
-
if (isSugarChildElem)
|
|
145
|
-
continue;
|
|
134
|
+
if (isSugarChildElem) continue;
|
|
146
135
|
assignChild({
|
|
147
136
|
extend: element[childKey],
|
|
148
137
|
props: newChild
|
|
@@ -155,15 +144,13 @@ const applyKeyComponentAsExtend = (element, parent, key) => {
|
|
|
155
144
|
};
|
|
156
145
|
const applyComponentFromContext = (element, parent, options) => {
|
|
157
146
|
const { context } = element;
|
|
158
|
-
if (!context || !context.components)
|
|
159
|
-
return;
|
|
147
|
+
if (!context || !context.components) return;
|
|
160
148
|
const { components } = context;
|
|
161
149
|
const { extend } = element;
|
|
162
150
|
const execExtend = exec(extend, element);
|
|
163
151
|
if (isString(execExtend)) {
|
|
164
152
|
const componentExists = components[execExtend] || components["smbls." + execExtend];
|
|
165
|
-
if (componentExists)
|
|
166
|
-
element.extend = componentExists;
|
|
153
|
+
if (componentExists) element.extend = componentExists;
|
|
167
154
|
else {
|
|
168
155
|
if ((ENV === "testing" || ENV === "development") && options.verbose) {
|
|
169
156
|
console.warn(execExtend, "is not in library", components, element);
|
|
@@ -174,15 +161,13 @@ const applyComponentFromContext = (element, parent, options) => {
|
|
|
174
161
|
}
|
|
175
162
|
};
|
|
176
163
|
const isVariant = (param) => {
|
|
177
|
-
if (!isString(param))
|
|
178
|
-
return;
|
|
164
|
+
if (!isString(param)) return;
|
|
179
165
|
const firstCharKey = param.slice(0, 1);
|
|
180
166
|
return firstCharKey === ".";
|
|
181
167
|
};
|
|
182
168
|
const hasVariantProp = (element) => {
|
|
183
169
|
const { props } = element;
|
|
184
|
-
if (isObject(props) && isString(props.variant))
|
|
185
|
-
return true;
|
|
170
|
+
if (isObject(props) && isString(props.variant)) return true;
|
|
186
171
|
};
|
|
187
172
|
const getChildrenComponentsByKey = (key, el) => {
|
|
188
173
|
if (key === el.key || el.__ref.__componentKey === key) {
|
|
@@ -191,14 +176,12 @@ const getChildrenComponentsByKey = (key, el) => {
|
|
|
191
176
|
if (el.extend) {
|
|
192
177
|
const foundString = isString(el.extend) && el.extend === key;
|
|
193
178
|
const foundInArray = isArray(el.extend) && el.extend.filter((v) => v === key).length;
|
|
194
|
-
if (foundString || foundInArray)
|
|
195
|
-
return el;
|
|
179
|
+
if (foundString || foundInArray) return el;
|
|
196
180
|
}
|
|
197
181
|
if (el.parent && el.parent.childExtend) {
|
|
198
182
|
const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key;
|
|
199
183
|
const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
|
|
200
|
-
if (foundString || foundInArray)
|
|
201
|
-
return el;
|
|
184
|
+
if (foundString || foundInArray) return el;
|
|
202
185
|
}
|
|
203
186
|
};
|
|
204
187
|
const getExtendsInElement = (obj) => {
|
|
@@ -230,10 +213,8 @@ const setContentKey = (el, opts = {}) => {
|
|
|
230
213
|
const contentElementKey = opts.contentElementKey;
|
|
231
214
|
if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
|
|
232
215
|
ref.contentElementKey = contentElementKey || "content";
|
|
233
|
-
} else
|
|
234
|
-
|
|
235
|
-
if (contentElementKey !== "content")
|
|
236
|
-
opts.contentElementKey = "content";
|
|
216
|
+
} else ref.contentElementKey = "content";
|
|
217
|
+
if (contentElementKey !== "content") opts.contentElementKey = "content";
|
|
237
218
|
return ref.contentElementKey;
|
|
238
219
|
};
|
|
239
220
|
export {
|
package/dist/esm/cookie.js
CHANGED
|
@@ -2,31 +2,26 @@ import { isUndefined } from "./types.js";
|
|
|
2
2
|
import { document } from "./globals.js";
|
|
3
3
|
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
4
4
|
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
5
|
-
if (isUndefined(document) || isUndefined(document.cookie))
|
|
6
|
-
return;
|
|
5
|
+
if (isUndefined(document) || isUndefined(document.cookie)) return;
|
|
7
6
|
const d = /* @__PURE__ */ new Date();
|
|
8
7
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
9
8
|
const expires = `expires=${d.toUTCString()}`;
|
|
10
9
|
document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
11
10
|
};
|
|
12
11
|
const getCookie = (cname) => {
|
|
13
|
-
if (isUndefined(document) || isUndefined(document.cookie))
|
|
14
|
-
return;
|
|
12
|
+
if (isUndefined(document) || isUndefined(document.cookie)) return;
|
|
15
13
|
const name = `${cname}=`;
|
|
16
14
|
const decodedCookie = decodeURIComponent(document.cookie);
|
|
17
15
|
const ca = decodedCookie.split(";");
|
|
18
16
|
for (let i = 0; i < ca.length; i++) {
|
|
19
17
|
let c = ca[i];
|
|
20
|
-
while (c.charAt(0) === " ")
|
|
21
|
-
|
|
22
|
-
if (c.indexOf(name) === 0)
|
|
23
|
-
return c.substring(name.length, c.length);
|
|
18
|
+
while (c.charAt(0) === " ") c = c.substring(1);
|
|
19
|
+
if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
|
|
24
20
|
}
|
|
25
21
|
return "";
|
|
26
22
|
};
|
|
27
23
|
const removeCookie = (cname) => {
|
|
28
|
-
if (isUndefined(document) || isUndefined(document.cookie))
|
|
29
|
-
return;
|
|
24
|
+
if (isUndefined(document) || isUndefined(document.cookie)) return;
|
|
30
25
|
document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
31
26
|
};
|
|
32
27
|
function getLocalStorage(key) {
|
package/dist/esm/env.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const NODE_ENV = "development";
|
|
2
|
-
const isProduction = (env = NODE_ENV) => env === "production" || env
|
|
3
|
-
const isTest = (env = NODE_ENV) => env === "
|
|
2
|
+
const isProduction = (env = NODE_ENV) => env === "production" || env !== "development" && env !== "dev" && env !== "testing";
|
|
3
|
+
const isTest = (env = NODE_ENV) => env === "testing";
|
|
4
4
|
const isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev";
|
|
5
5
|
const getNev = (key, env = NODE_ENV) => env[key];
|
|
6
6
|
export {
|
package/dist/esm/function.js
CHANGED
|
@@ -5,14 +5,12 @@ function debounce(func, wait, immediate) {
|
|
|
5
5
|
const args = arguments;
|
|
6
6
|
const later = function() {
|
|
7
7
|
timeout = null;
|
|
8
|
-
if (!immediate)
|
|
9
|
-
func.apply(context, args);
|
|
8
|
+
if (!immediate) func.apply(context, args);
|
|
10
9
|
};
|
|
11
10
|
const callNow = immediate && !timeout;
|
|
12
11
|
clearTimeout(timeout);
|
|
13
12
|
timeout = setTimeout(later, wait);
|
|
14
|
-
if (callNow)
|
|
15
|
-
func.apply(context, args);
|
|
13
|
+
if (callNow) func.apply(context, args);
|
|
16
14
|
};
|
|
17
15
|
}
|
|
18
16
|
const debounceOnContext = (element, func, timeout = 300) => {
|
package/dist/esm/key.js
CHANGED
package/dist/esm/log.js
CHANGED
package/dist/esm/object.js
CHANGED
|
@@ -52,8 +52,7 @@ const map = (obj, extention, element) => {
|
|
|
52
52
|
const merge = (element, obj, excludeFrom = []) => {
|
|
53
53
|
for (const e in obj) {
|
|
54
54
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
|
|
55
|
-
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
|
|
56
|
-
continue;
|
|
55
|
+
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
|
|
57
56
|
const elementProp = element[e];
|
|
58
57
|
const objProp = obj[e];
|
|
59
58
|
if (elementProp === void 0) {
|
|
@@ -65,8 +64,7 @@ const merge = (element, obj, excludeFrom = []) => {
|
|
|
65
64
|
const deepMerge = (element, extend, excludeFrom = []) => {
|
|
66
65
|
for (const e in extend) {
|
|
67
66
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
|
|
68
|
-
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
|
|
69
|
-
continue;
|
|
67
|
+
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
|
|
70
68
|
const elementProp = element[e];
|
|
71
69
|
const extendProp = extend[e];
|
|
72
70
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -81,8 +79,7 @@ const clone = (obj, excludeFrom = []) => {
|
|
|
81
79
|
const o = {};
|
|
82
80
|
for (const prop in obj) {
|
|
83
81
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
84
|
-
if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__"))
|
|
85
|
-
continue;
|
|
82
|
+
if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__")) continue;
|
|
86
83
|
o[prop] = obj[prop];
|
|
87
84
|
}
|
|
88
85
|
return o;
|
|
@@ -108,13 +105,10 @@ const deepClone = (obj, options = {}) => {
|
|
|
108
105
|
const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
109
106
|
visited.set(obj, clone2);
|
|
110
107
|
for (const key in obj) {
|
|
111
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
112
|
-
|
|
113
|
-
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
114
|
-
continue;
|
|
108
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
109
|
+
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") continue;
|
|
115
110
|
const value = obj[key];
|
|
116
|
-
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
|
|
117
|
-
continue;
|
|
111
|
+
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) continue;
|
|
118
112
|
if (isDOMNode(value)) {
|
|
119
113
|
clone2[key] = value;
|
|
120
114
|
continue;
|
|
@@ -244,16 +238,14 @@ const objectToString = (obj = {}, indent = 0) => {
|
|
|
244
238
|
const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
245
239
|
for (const prop in obj) {
|
|
246
240
|
const objProp = obj[prop];
|
|
247
|
-
if (isFunction(objProp))
|
|
248
|
-
continue;
|
|
241
|
+
if (isFunction(objProp)) continue;
|
|
249
242
|
else if (isObject(objProp)) {
|
|
250
243
|
detached[prop] = {};
|
|
251
244
|
deepStringify(objProp, detached[prop]);
|
|
252
245
|
} else if (isArray(objProp)) {
|
|
253
246
|
detached[prop] = [];
|
|
254
247
|
objProp.forEach((v, i) => {
|
|
255
|
-
if (isFunction(v))
|
|
256
|
-
return;
|
|
248
|
+
if (isFunction(v)) return;
|
|
257
249
|
if (isObject(v)) {
|
|
258
250
|
detached[prop][i] = {};
|
|
259
251
|
detachFunctionsFromObject(v, detached[prop][i]);
|
|
@@ -268,15 +260,11 @@ const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
|
268
260
|
return detached;
|
|
269
261
|
};
|
|
270
262
|
const hasFunction = (str) => {
|
|
271
|
-
if (!str)
|
|
272
|
-
return false;
|
|
263
|
+
if (!str) return false;
|
|
273
264
|
const trimmed = str.trim().replace(/\n\s*/g, " ").trim();
|
|
274
|
-
if (trimmed === "")
|
|
275
|
-
|
|
276
|
-
if (trimmed === "
|
|
277
|
-
return false;
|
|
278
|
-
if (trimmed === "[]")
|
|
279
|
-
return false;
|
|
265
|
+
if (trimmed === "") return false;
|
|
266
|
+
if (trimmed === "{}") return false;
|
|
267
|
+
if (trimmed === "[]") return false;
|
|
280
268
|
const patterns = [
|
|
281
269
|
/^\(\s*\{[^}]*\}\s*\)\s*=>/,
|
|
282
270
|
/^(\([^)]*\)|[^=]*)\s*=>/,
|
|
@@ -294,8 +282,7 @@ const hasFunction = (str) => {
|
|
|
294
282
|
const deepDestringify = (obj, destringified = {}) => {
|
|
295
283
|
for (const prop in obj) {
|
|
296
284
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
297
|
-
if (!hasOwnProperty2)
|
|
298
|
-
continue;
|
|
285
|
+
if (!hasOwnProperty2) continue;
|
|
299
286
|
const objProp = obj[prop];
|
|
300
287
|
if (isString(objProp)) {
|
|
301
288
|
if (hasFunction(objProp)) {
|
|
@@ -303,8 +290,7 @@ const deepDestringify = (obj, destringified = {}) => {
|
|
|
303
290
|
const evalProp = window.eval(`(${objProp})`);
|
|
304
291
|
destringified[prop] = evalProp;
|
|
305
292
|
} catch (e) {
|
|
306
|
-
if (e)
|
|
307
|
-
destringified[prop] = objProp;
|
|
293
|
+
if (e) destringified[prop] = objProp;
|
|
308
294
|
}
|
|
309
295
|
} else {
|
|
310
296
|
destringified[prop] = objProp;
|
|
@@ -318,8 +304,7 @@ const deepDestringify = (obj, destringified = {}) => {
|
|
|
318
304
|
const evalProp = window.eval(`(${arrProp})`);
|
|
319
305
|
destringified[prop].push(evalProp);
|
|
320
306
|
} catch (e) {
|
|
321
|
-
if (e)
|
|
322
|
-
destringified[prop].push(arrProp);
|
|
307
|
+
if (e) destringified[prop].push(arrProp);
|
|
323
308
|
}
|
|
324
309
|
} else {
|
|
325
310
|
destringified[prop].push(arrProp);
|
|
@@ -342,14 +327,12 @@ const stringToObject = (str, opts = { verbose: true }) => {
|
|
|
342
327
|
try {
|
|
343
328
|
return str ? window.eval("(" + str + ")") : {};
|
|
344
329
|
} catch (e) {
|
|
345
|
-
if (opts.verbose)
|
|
346
|
-
console.warn(e);
|
|
330
|
+
if (opts.verbose) console.warn(e);
|
|
347
331
|
}
|
|
348
332
|
};
|
|
349
333
|
const diffObjects = (original, objToDiff, cache) => {
|
|
350
334
|
for (const e in objToDiff) {
|
|
351
|
-
if (e === "ref")
|
|
352
|
-
continue;
|
|
335
|
+
if (e === "ref") continue;
|
|
353
336
|
const originalProp = original[e];
|
|
354
337
|
const objToDiffProp = objToDiff[e];
|
|
355
338
|
if (isObject(originalProp) && isObject(objToDiffProp)) {
|
|
@@ -392,10 +375,8 @@ const isEmpty = (o) => Object.keys(o).length === 0;
|
|
|
392
375
|
const isEmptyObject = (o) => isObject(o) && isEmpty(o);
|
|
393
376
|
const makeObjectWithoutPrototype = () => /* @__PURE__ */ Object.create(null);
|
|
394
377
|
const deepDiff = (lhs, rhs) => {
|
|
395
|
-
if (lhs === rhs)
|
|
396
|
-
|
|
397
|
-
if (!isObjectLike(lhs) || !isObjectLike(rhs))
|
|
398
|
-
return rhs;
|
|
378
|
+
if (lhs === rhs) return {};
|
|
379
|
+
if (!isObjectLike(lhs) || !isObjectLike(rhs)) return rhs;
|
|
399
380
|
const deletedValues = Object.keys(lhs).reduce((acc, key) => {
|
|
400
381
|
if (!hasOwnProperty(rhs, key)) {
|
|
401
382
|
acc[key] = void 0;
|
|
@@ -403,8 +384,7 @@ const deepDiff = (lhs, rhs) => {
|
|
|
403
384
|
return acc;
|
|
404
385
|
}, makeObjectWithoutPrototype());
|
|
405
386
|
if (isDate(lhs) || isDate(rhs)) {
|
|
406
|
-
if (lhs.valueOf() === rhs.valueOf())
|
|
407
|
-
return {};
|
|
387
|
+
if (lhs.valueOf() === rhs.valueOf()) return {};
|
|
408
388
|
return rhs;
|
|
409
389
|
}
|
|
410
390
|
return Object.keys(rhs).reduce((acc, key) => {
|
|
@@ -426,8 +406,7 @@ const overwrite = (element, params, opts = {}) => {
|
|
|
426
406
|
const allowUnderscore = opts.preventUnderscore;
|
|
427
407
|
const preventCaching = opts.preventCaching;
|
|
428
408
|
for (const e in params) {
|
|
429
|
-
if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
|
|
430
|
-
continue;
|
|
409
|
+
if (excl.includes(e) || !allowUnderscore && e.startsWith("__")) continue;
|
|
431
410
|
const elementProp = element[e];
|
|
432
411
|
const paramsProp = params[e];
|
|
433
412
|
if (paramsProp !== void 0) {
|
|
@@ -444,8 +423,7 @@ const overwrite = (element, params, opts = {}) => {
|
|
|
444
423
|
};
|
|
445
424
|
const overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
446
425
|
for (const e in params) {
|
|
447
|
-
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
448
|
-
continue;
|
|
426
|
+
if (excludeFrom.includes(e) || e.startsWith("__")) continue;
|
|
449
427
|
obj[e] = params[e];
|
|
450
428
|
}
|
|
451
429
|
return obj;
|
|
@@ -456,14 +434,11 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
|
|
|
456
434
|
if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
|
|
457
435
|
return params;
|
|
458
436
|
}
|
|
459
|
-
if (visited.has(obj))
|
|
460
|
-
return visited.get(obj);
|
|
437
|
+
if (visited.has(obj)) return visited.get(obj);
|
|
461
438
|
visited.set(obj, obj);
|
|
462
439
|
for (const e in params) {
|
|
463
|
-
if (!Object.hasOwnProperty.call(params, e))
|
|
464
|
-
|
|
465
|
-
if (excl.includes(e) || forcedExclude && e.startsWith("__"))
|
|
466
|
-
continue;
|
|
440
|
+
if (!Object.hasOwnProperty.call(params, e)) continue;
|
|
441
|
+
if (excl.includes(e) || forcedExclude && e.startsWith("__")) continue;
|
|
467
442
|
const objProp = obj[e];
|
|
468
443
|
const paramsProp = params[e];
|
|
469
444
|
if (isDOMNode(paramsProp)) {
|
|
@@ -477,16 +452,14 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
|
|
|
477
452
|
return obj;
|
|
478
453
|
};
|
|
479
454
|
const mergeIfExisted = (a, b) => {
|
|
480
|
-
if (isObjectLike(a) && isObjectLike(b))
|
|
481
|
-
return deepMerge(a, b);
|
|
455
|
+
if (isObjectLike(a) && isObjectLike(b)) return deepMerge(a, b);
|
|
482
456
|
return a || b;
|
|
483
457
|
};
|
|
484
458
|
const flattenRecursive = (param, prop, stack = []) => {
|
|
485
459
|
const objectized = mergeAndCloneIfArray(param);
|
|
486
460
|
stack.push(objectized);
|
|
487
461
|
const extendOfExtend = objectized[prop];
|
|
488
|
-
if (extendOfExtend)
|
|
489
|
-
flattenRecursive(extendOfExtend, prop, stack);
|
|
462
|
+
if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack);
|
|
490
463
|
delete objectized[prop];
|
|
491
464
|
return stack;
|
|
492
465
|
};
|
|
@@ -517,31 +490,24 @@ const isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
|
|
|
517
490
|
return true;
|
|
518
491
|
};
|
|
519
492
|
const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
|
|
520
|
-
if (obj1 === obj2)
|
|
521
|
-
|
|
522
|
-
if (
|
|
523
|
-
return false;
|
|
524
|
-
if (isDOMNode(obj1) || isDOMNode(obj2))
|
|
525
|
-
return obj1 === obj2;
|
|
493
|
+
if (obj1 === obj2) return true;
|
|
494
|
+
if (!isObjectLike(obj1) || !isObjectLike(obj2)) return false;
|
|
495
|
+
if (isDOMNode(obj1) || isDOMNode(obj2)) return obj1 === obj2;
|
|
526
496
|
const stack = [[obj1, obj2]];
|
|
527
497
|
const visited = /* @__PURE__ */ new WeakSet();
|
|
528
498
|
while (stack.length > 0) {
|
|
529
499
|
const [current1, current2] = stack.pop();
|
|
530
|
-
if (visited.has(current1))
|
|
531
|
-
continue;
|
|
500
|
+
if (visited.has(current1)) continue;
|
|
532
501
|
visited.add(current1);
|
|
533
502
|
const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key));
|
|
534
503
|
const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key));
|
|
535
|
-
if (keys1.length !== keys2.length)
|
|
536
|
-
return false;
|
|
504
|
+
if (keys1.length !== keys2.length) return false;
|
|
537
505
|
for (const key of keys1) {
|
|
538
|
-
if (!Object.prototype.hasOwnProperty.call(current2, key))
|
|
539
|
-
return false;
|
|
506
|
+
if (!Object.prototype.hasOwnProperty.call(current2, key)) return false;
|
|
540
507
|
const value1 = current1[key];
|
|
541
508
|
const value2 = current2[key];
|
|
542
509
|
if (isDOMNode(value1) || isDOMNode(value2)) {
|
|
543
|
-
if (value1 !== value2)
|
|
544
|
-
return false;
|
|
510
|
+
if (value1 !== value2) return false;
|
|
545
511
|
} else if (isObjectLike(value1) && isObjectLike(value2)) {
|
|
546
512
|
if (value1 !== value2) {
|
|
547
513
|
stack.push([value1, value2]);
|
|
@@ -554,8 +520,7 @@ const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
|
|
|
554
520
|
return true;
|
|
555
521
|
};
|
|
556
522
|
const removeFromObject = (obj, props) => {
|
|
557
|
-
if (props === void 0 || props === null)
|
|
558
|
-
return obj;
|
|
523
|
+
if (props === void 0 || props === null) return obj;
|
|
559
524
|
if (is(props)("string", "number")) {
|
|
560
525
|
delete obj[props];
|
|
561
526
|
} else if (isArray(props)) {
|
package/dist/esm/string.js
CHANGED
|
@@ -15,8 +15,7 @@ const brackRegex = {
|
|
|
15
15
|
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
16
16
|
};
|
|
17
17
|
function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
|
|
18
|
-
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
|
|
19
|
-
return str;
|
|
18
|
+
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{")) return str;
|
|
20
19
|
const reg = brackRegex[options.bracketsLength || 2];
|
|
21
20
|
const obj = forcedState || (this == null ? void 0 : this.state) || {};
|
|
22
21
|
return str.replace(reg, (_, parentPath, variable) => {
|
package/dist/esm/types.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isHtmlElement, isNode } from "./node.js";
|
|
2
2
|
const isObject = (arg) => {
|
|
3
|
-
if (arg === null)
|
|
4
|
-
return false;
|
|
3
|
+
if (arg === null) return false;
|
|
5
4
|
return typeof arg === "object" && arg.constructor === Object;
|
|
6
5
|
};
|
|
7
6
|
const isString = (arg) => typeof arg === "string";
|
|
@@ -12,8 +11,7 @@ const isNull = (arg) => arg === null;
|
|
|
12
11
|
const isArray = (arg) => Array.isArray(arg);
|
|
13
12
|
const isDate = (d) => d instanceof Date;
|
|
14
13
|
const isObjectLike = (arg) => {
|
|
15
|
-
if (arg === null)
|
|
16
|
-
return false;
|
|
14
|
+
if (arg === null) return false;
|
|
17
15
|
return typeof arg === "object";
|
|
18
16
|
};
|
|
19
17
|
const isDefined = (arg) => {
|
package/env.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
export const NODE_ENV = process.env.NODE_ENV
|
|
4
4
|
|
|
5
|
-
export const isProduction = (env = NODE_ENV) => (env === 'production'
|
|
6
|
-
(env !== 'development' && env !== 'dev' && env !== '
|
|
7
|
-
export const isTest = (env = NODE_ENV) => env === '
|
|
5
|
+
export const isProduction = (env = NODE_ENV) => (env === 'production') ||
|
|
6
|
+
(env !== 'development' && env !== 'dev' && env !== 'testing')
|
|
7
|
+
export const isTest = (env = NODE_ENV) => env === 'testing'
|
|
8
8
|
export const isDevelopment = (env = NODE_ENV) => env === 'development' || env === 'dev'
|
|
9
9
|
|
|
10
10
|
export const getNev = (key, env = NODE_ENV) => env[key]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
25
25
|
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "b226cec424e82cebf1af9844254c6a1e7058b270",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/core": "^7.12.0"
|
|
30
30
|
}
|